/* Datgel View — Application Styles
   Brand palette extracted from Datgel corporate CSS:
     Primary green  : #009048
     Hover green    : #00AE4B
     Bright accent  : #08C862
     Orange accent  : #F57E20
     Body text      : #546563
     Font           : Roboto
*/

:root {
    --brand:         #009048;
    --brand-hover:   #00AE4B;
    --brand-bright:  #08C862;
    --brand-dark:    #006633;
    --brand-orange:  #F57E20;
    --text:          #546563;
    --text-muted:    #888;
    --border:        #dee2e6;
    --bg-light:      #f4f4f4;
    --bg-white:      #ffffff;
    --sidebar-width: 260px;
    --header-height: 48px;
    --footer-height: 58px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    height: 100%;
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: var(--text);
}

main {
    padding-top: var(--header-height);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }

h2 { font-size: 24px; color: var(--brand-bright); font-family: 'Roboto', sans-serif; }
h3 { font-size: 16px; color: #555; font-family: 'Roboto', sans-serif; }

/* Access Denied / message pages */
.access-denied {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    flex: 1;
    text-align: center;
    padding: 48px 24px;
    min-height: calc(100vh - var(--header-height) - var(--footer-height));
}
.access-denied h2 { margin: 0 0 12px; font-size: 28px; color: var(--brand-orange); }
.access-denied p  { margin: 0; font-size: 15px; color: var(--text-muted); max-width: 480px; }

input[type=text]:focus,
input[type=password]:focus,
input[type=search]:focus,
textarea:focus,
select:focus,
.form-control:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(0,144,72,.15);
}

/* ── Layout ──────────────────────────────────────────── */
.app-header {
    height: var(--header-height);
    background: var(--brand);
    color: #fff;
    display: flex; align-items: center;
    padding: 0 16px; gap: 12px;
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.app-header .brand { font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.app-header .spacer { flex: 1; }
.app-header a { color: rgba(255,255,255,.9); text-decoration: none; margin-left: 8px; font-weight: 500; }
.app-header a:hover { color: #fff; }
.app-header .user-block {
    display: flex; align-items: center; gap: 8px;
    border-left: 1px solid rgba(255,255,255,.2);
    padding-left: 12px; margin-left: 4px;
}
.app-header .user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; }
.app-header .user-org  {
    font-size: 11px; color: rgba(255,255,255,.7); white-space: nowrap;
    background: rgba(0,0,0,.15); border-radius: 3px; padding: 1px 6px;
}
.app-header .logout-btn {
    font-size: 12px; font-weight: 600; margin-left: 0;
    background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.35);
    border-radius: 4px; padding: 3px 10px;
    color: #fff; text-decoration: none; white-space: nowrap;
    transition: background .15s;
}
.app-header .logout-btn:hover { background: rgba(255,255,255,.28); color: #fff; }

/* Language selector in header */
.language-selector {
    font-size: 11px; padding: 2px 4px; border-radius: 4px;
    background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.35);
    cursor: pointer; appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='4'%3E%3Cpath d='M0 0l4 4 4-4' fill='%23fff'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 4px center;
    padding-right: 14px;
}
.language-selector option { background: #333; color: #fff; }

/* Map layout is fixed — sits between header and footer */
.map-layout {
    position: fixed;
    top: var(--header-height);
    left: 0; right: 0;
    bottom: var(--footer-height);
    display: flex;
}

.map-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-light);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 8px;
    display: flex; flex-direction: column; gap: 4px;
}

.map-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* ── Properties panel ──────────────────────────────────── */
.props-panel {
    width: 360px;
    min-width: 180px;
    background: var(--bg-white);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    user-select: text;
    position: relative;
    flex-shrink: 0;
}
.props-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px 8px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-light);
    flex-shrink: 0;
}
.props-panel-header h6 { margin: 0; font-size: 12px; font-weight: 600; color: var(--text); }
.props-panel-header .props-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.props-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}
.props-field-row {
    display: flex;
    flex-direction: column;
    padding: 4px 12px;
    border-bottom: 1px solid #f0f0f0;
}
.props-field-row:last-child { border-bottom: none; }
.props-field-col {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 1px;
}
.props-field-val {
    font-size: 12px;
    color: var(--text);
    word-break: break-word;
}
.props-empty {
    padding: 24px 12px;
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar-section {
    background: var(--bg-white);
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 4px;
}
.sidebar-heading {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .5px; color: var(--brand); margin: 0 0 8px 0;
}
.layer-item {
    display: flex; align-items: center; gap: 6px;
    padding: 3px 0; font-size: 13px; color: var(--text);
}
.layer-item-indent { padding-left: 18px; }
.form-select-sm { font-size: 13px; width: 100%; padding: 4px 8px; }

/* ── Project Panel ───────────────────────────────────── */
.project-panel { display: flex; flex-direction: column; gap: 4px; }
.project-item { border-radius: 4px; padding: 4px; }
.project-item.project-hidden { opacity: .55; }
.project-header {
    display: flex; align-items: center; gap: 6px;
    font-weight: 600; font-size: 12px; color: var(--text);
}
.project-name-stack { flex: 1; overflow: hidden; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.project-name { cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-subtitle { font-size: 10px; color: #aaa; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-icon {
    background: none; border: none; cursor: pointer; padding: 2px 4px;
    font-size: 14px; color: var(--brand);
}
.btn-icon:hover { color: var(--brand-hover); }
.types-toggle-row { padding-left: 18px; margin-top: 2px; }
.btn-types-toggle { background: none; border: none; cursor: pointer; font-size: 11px; color: #999; padding: 0; }
.btn-types-toggle:hover { color: var(--brand); }
.point-types { padding-left: 18px; margin-top: 4px; display: flex; flex-direction: column; gap: 2px; }
.type-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text); }
.type-icon-svg { display: flex; align-items: center; flex-shrink: 0; line-height: 1; }

/* ── Admin Excel-style grid ──────────────────────────── */
.admin-grid { border-collapse: collapse; width: 100%; font-size: 13px; }
.admin-grid th { background: #f0f4f8; font-weight: 600; font-size: 12px; color: #555;
    border: 1px solid #d0d7de; padding: 5px 8px; text-align: left; white-space: nowrap; }
.admin-grid td { border: 1px solid #e0e6ed; padding: 2px 6px; vertical-align: middle; }
.admin-grid tr:hover td { background: #f6f9fc; }
.grid-cell-input {
    width: 100%; border: none; background: transparent;
    padding: 4px 6px; font-size: 13px; outline: none; color: inherit;
}
.grid-cell-input:focus { background: #fff; box-shadow: inset 0 0 0 2px var(--brand); border-radius: 2px; }

/* ── Icon picker ─────────────────────────────────────── */
.icon-picker-btn {
    display: flex; align-items: center; gap: 5px;
    background: none; border: 1px solid #d0d7de; border-radius: 4px;
    padding: 3px 6px; cursor: pointer; font-size: 12px; color: var(--text);
    white-space: nowrap; max-width: 190px;
}
.icon-picker-btn:hover { border-color: var(--brand); color: var(--brand); }
.icon-picker-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.icon-picker-caret { color: #999; font-size: 10px; }
.picker-backdrop { position: fixed; inset: 0; z-index: 999; }
.icon-picker-popup {
    position: fixed; z-index: 1000;
    background: #fff; border: 1px solid #ccc; border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0,0,0,.18);
    padding: 8px; display: grid;
    width: min(calc(100vw - 16px), 560px);
    grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
    gap: 4px;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
}
.icon-option {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: none; border: 1px solid transparent; border-radius: 4px;
    padding: 5px 4px; cursor: pointer; font-size: 10px; color: #444;
    line-height: 1.2;
}
.icon-option:hover { background: #f0f4f8; border-color: #c0d0e0; }
.icon-option.active { background: #e8f4f8; border-color: #2980b9; color: #2980b9; font-weight: 600; }

/* ── Map Popup ───────────────────────────────────────── */
.map-popup {
    position: absolute; z-index: 200;
    background: var(--bg-white); border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0,0,0,.2);
    min-width: 200px; max-width: 320px;
    pointer-events: none; /* hover popups — don't block mouse */
}
.dynamic-popup { transform: none; } /* positioned by JS/left+top */
.project-popup {
    /* anchor next to the sidebar */
    position: absolute; left: calc(var(--sidebar-width, 260px) + 8px); top: 60px;
    max-height: calc(100vh - 120px); overflow-y: auto;
    pointer-events: none;
}
.popup-header {
    background: var(--brand); color: #fff;
    padding: 8px 12px; border-radius: 6px 6px 0 0;
    display: flex; align-items: center;
    font-size: 13px; font-weight: 700;
}
.popup-close { background: none; border: none; color: #fff; cursor: pointer; font-size: 18px; line-height: 1; padding: 0; pointer-events: auto; }
.popup-body { padding: 8px 0; font-size: 12px; color: var(--text); max-height: 320px; overflow-y: auto; }
.popup-body .label { color: var(--text-muted); font-size: 11px; margin-right: 4px; }
/* Dynamic field table inside popup */
.popup-fields { display: table; width: 100%; border-collapse: collapse; }
.popup-field-row { display: table-row; }
.popup-field-row:nth-child(even) .popup-field-col,
.popup-field-row:nth-child(even) .popup-field-unit,
.popup-field-row:nth-child(even) .popup-field-val { background: rgba(0,0,0,.03); }
.popup-field-col {
    display: table-cell; padding: 2px 6px 2px 12px;
    font-size: 11px; color: #777; white-space: nowrap;
    width: 40%; vertical-align: top;
}
.popup-field-unit {
    display: table-cell; padding: 2px 6px;
    font-size: 10px; color: #aaa; white-space: nowrap; vertical-align: top;
}
.popup-field-val {
    display: table-cell; padding: 2px 12px 2px 4px;
    font-size: 11px; color: var(--text); word-break: break-word;
}

/* ── Mouse position control ──────────────────────────── */
.mouse-position {
    background: rgba(255,255,255,.85); padding: 2px 8px;
    font-size: 11px; font-family: monospace;
    position: absolute; bottom: 24px; right: 8px;
    border-radius: 3px; pointer-events: none;
}

/* ── Scale text + grid spacing label ─────────────────── */
.map-scale-bar {
    position: absolute; bottom: 42px; left: 8px;
    display: flex; flex-direction: column; gap: 2px;
    pointer-events: none; z-index: 10;
}
.scale-text, .grid-spacing-label {
    background: rgba(255,255,255,.85); padding: 1px 6px;
    font-size: 11px; font-family: monospace;
    border-radius: 3px; white-space: nowrap;
}

/* ── Admin pages ─────────────────────────────────────── */
.admin-layout { padding: 24px; max-width: 1100px; margin: 0 auto; }
.admin-layout h3 { color: var(--brand); margin: 0 0 4px; }

.admin-nav {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 28px;
}
.admin-nav a {
    padding: 10px 20px;
    font-size: 13px; font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color .15s, border-color .15s;
}
.admin-nav a:hover { color: var(--brand); }
.admin-nav a.active { color: var(--brand); border-bottom-color: var(--brand); }

.admin-section-header {
    display: flex; align-items: flex-start;
    justify-content: space-between; gap: 16px;
    margin-bottom: 20px;
}
.admin-section-header p.text-muted { margin: 4px 0 0; font-size: 13px; color: var(--text-muted); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
    background: var(--brand); color: #fff;
    border-bottom: 2px solid var(--brand-dark);
    padding: 8px 12px; text-align: left; font-weight: 600;
}
.table td { padding: 8px 12px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; color: var(--text); }
.table tr:hover td { background: #f0faf4; }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 6px 14px; border-radius: 4px; border: none;
    cursor: pointer; font-size: 13px; text-decoration: none;
    font-family: 'Roboto', sans-serif; font-weight: 500;
    transition: background .15s ease;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); color: #fff; }
.btn-danger { background: #dc3545; color: #fff; }
.btn-danger:hover { background: #c82333; }
.btn-sm { padding: 3px 8px; font-size: 12px; }

/* Default (outlined-ish) btn used for nav links */
.btn:not(.btn-primary):not(.btn-danger) {
    background: var(--bg-light); color: var(--brand);
    border: 1px solid var(--border);
}
.btn:not(.btn-primary):not(.btn-danger):hover {
    background: #e8f7ef; border-color: var(--brand);
}

.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-success { background: #d4edda; color: #155724; }
.badge-danger  { background: #f8d7da; color: #721c24; }

/* ── Project colour dot ──────────────────────────────── */
.project-colour-dot {
    display: inline-block; width: 16px; height: 16px; border-radius: 3px;
    cursor: pointer; flex-shrink: 0; border: 1.5px solid rgba(0,0,0,.25);
    position: relative;
}
.project-colour-dot input[type=color] {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    opacity: 0; cursor: pointer; border: none; padding: 0; z-index: 1;
}

/* ── Symbology grid icon preview ─────────────────────── */
.icon-preview { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; }

/* ── Sidebar toggle (tablet) ─────────────────────────── */
.sidebar-toggle-btn {
    display: none;
    position: absolute;
    top: 8px; left: 8px;
    z-index: 110;
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.sidebar-toggle-btn:hover { background: var(--brand-hover); }

.sidebar-backdrop {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 98;
    background: rgba(0,0,0,.35);
}

/* ── Tablet responsive (≤ 1023 px) ──────────────────── */
@media (max-width: 1023px) {
    .sidebar-toggle-btn { display: block; }

    .map-sidebar {
        position: absolute;
        top: 0; left: 0; bottom: 0;
        z-index: 99;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 2px 0 16px rgba(0,0,0,.2);
    }

    .map-layout.sidebar-open .map-sidebar {
        transform: translateX(0);
    }

    .map-layout.sidebar-open .sidebar-backdrop {
        display: block;
    }

    .props-panel {
        width: 300px;
        min-width: 220px;
    }

    .admin-layout {
        padding: 16px 12px;
    }

    .admin-nav {
        flex-wrap: wrap;
    }

    .admin-nav a {
        padding: 8px 12px;
        font-size: 12px;
    }
}

/* ── Footer ──────────────────────────────────────────── */
.app-footer {
    position: relative;
    z-index: 200;
    margin-top: auto;
    background: #2d3436;
    color: rgba(255,255,255,.7);
    font-size: 12px;
    padding: 20px 24px;
}
.footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.footer-inner a { color: var(--brand-bright); text-decoration: none; }
.footer-inner a:hover { color: #fff; text-decoration: underline; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 16px; }
.footer-nav a { font-size: 12px; }
.app-version { color: rgba(255,255,255,.4); font-size: 11px; }
.app-licensee { color: rgba(255,255,255,.5); font-size: 11px; }

/* ── Legal pages ──────────────────────────────────────── */
.legal-page {
    max-width: 860px;
    margin: 0 auto;
    padding: 32px 24px 48px;
}
.legal-page h1 { font-size: 28px; color: var(--brand); margin-bottom: 4px; }
.legal-page .effective-date { color: var(--text-muted); font-size: 13px; margin-bottom: 32px; }
.legal-page h2 { font-size: 16px; color: var(--text); margin: 28px 0 8px; border-bottom: 1px solid #eee; padding-bottom: 4px; }
.legal-page p, .legal-page li { line-height: 1.7; color: var(--text); }
.legal-page ul { padding-left: 20px; }
.legal-page table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 13px; }
.legal-page table th { background: var(--brand); color: #fff; padding: 8px 12px; text-align: left; }
.legal-page table td { padding: 8px 12px; border-bottom: 1px solid #f0f0f0; vertical-align: top; }
.legal-page table tr:hover td { background: #f0faf4; }
.legal-page code { background: #f4f4f4; padding: 1px 5px; border-radius: 3px; font-size: 12px; }
.legal-notice {
    background: #fff8e1; border-left: 4px solid var(--brand-orange);
    padding: 12px 16px; border-radius: 0 4px 4px 0;
    font-size: 13px; color: #5d4037; margin-bottom: 24px;
}

/* ── Log Viewer ──────────────────────────────────────── */
.logs-toolbar {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
    padding: 10px 16px; background: #f8f9fa; border-bottom: 1px solid #e0e0e0;
}
.logs-label { display: flex; flex-direction: column; font-size: 11px; color: #666; gap: 2px; }
.logs-select { font-size: 13px; padding: 4px 6px; border: 1px solid #ccc; border-radius: 4px; }
.logs-search-label { flex: 1; min-width: 160px; }
.btn-quick { font-size: 12px; padding: 4px 10px; border: 1px solid #ccc; border-radius: 4px; background: #f5f5f5; cursor: pointer; outline: none; }
.btn-quick:hover { background: #e8e8e8; }
.btn-quick:focus { box-shadow: none; }
.btn-quick.btn-quick-active { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-quick.btn-quick-active:hover { background: var(--brand-hover); }
.logs-search { width: 100%; font-size: 13px; padding: 4px 8px; border: 1px solid #ccc; border-radius: 4px; }
.logs-autoreload { display: flex; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.logs-count { margin-left: auto; font-size: 12px; color: #888; white-space: nowrap; }
.logs-status { padding: 24px 16px; color: #666; text-align: center; }
.logs-error  { color: #c0392b; }
.logs-pager { display: flex; align-items: center; gap: 8px; padding: 6px 16px; font-size: 13px; border-bottom: 1px solid #eee; }
.logs-pager button { padding: 2px 10px; font-size: 16px; border: 1px solid #ccc; border-radius: 4px; cursor: pointer; background: #fff; }
.logs-pager button:disabled { opacity: .4; cursor: default; }
.logs-table-wrap { overflow-x: auto; overflow-y: auto; flex: 1; }
.logs-table { width: 100%; border-collapse: collapse; font-size: 12px; font-family: 'Roboto Mono', 'Consolas', monospace; }
.logs-table th { position: sticky; top: 0; background: #f0f0f0; border-bottom: 2px solid #ddd; padding: 6px 8px; text-align: left; white-space: nowrap; font-family: Roboto, sans-serif; font-size: 12px; font-weight: 600; }
.logs-table td { padding: 4px 8px; border-bottom: 1px solid #f0f0f0; vertical-align: top; }
.logs-table tr:hover td { background: #f9f9f9; }
.col-ts   { white-space: nowrap; color: #666; min-width: 180px; }
.col-lvl  { white-space: nowrap; text-align: center; }
.col-user { white-space: nowrap; color: #555; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.col-org  { white-space: nowrap; color: #555; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.col-src  { white-space: nowrap; color: #555; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.col-msg  { word-break: break-word; }

/* Level row tinting */
.log-row-warn  td { background: #fffbec; }
.log-row-error td { background: #fff5f5; }
.log-row-fatal td { background: #ffeaea; }

/* Level badges */
.log-badge { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 10px; font-weight: 700; font-family: Roboto, sans-serif; letter-spacing: .4px; }
.log-badge-debug { background: #e8e8e8; color: #555; }
.log-badge-info  { background: #e3f2fd; color: #1565c0; }
.log-badge-warn  { background: #fff8e1; color: #e65100; }
.log-badge-error { background: #ffebee; color: #b71c1c; }
.log-badge-fatal { background: #b71c1c; color: #fff; }

/* Exception details */
.log-ex { margin-top: 4px; }
.log-ex summary { cursor: pointer; color: #c0392b; font-size: 11px; }
.log-ex pre { margin: 4px 0 0; padding: 8px; background: #fff8f8; border: 1px solid #f5c6cb; border-radius: 4px; font-size: 11px; white-space: pre-wrap; word-break: break-all; max-height: 300px; overflow-y: auto; }

/* ── Map Tools ───────────────────────────────────────── */
.map-tools-toolbar {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.map-tool-btn {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-white);
    color: var(--text);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0,0,0,.15);
    transition: background .15s, color .15s, border-color .15s;
}
.map-tool-btn:hover { background: var(--bg-light); border-color: var(--brand); }
.map-tool-btn.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand-dark);
    box-shadow: 0 1px 6px rgba(0,144,72,.35);
}

.map-tool-overlay {
    position: absolute;
    top: 90px;
    right: 10px;
    z-index: 200;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0,0,0,.15);
    min-width: 190px;
    max-width: 260px;
    font-size: 12px;
    padding: 0;
    overflow: hidden;
}
.map-tool-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 11px;
    color: var(--text);
}
.map-tool-overlay-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: #888;
    padding: 0 2px;
    line-height: 1;
}
.map-tool-overlay-close:hover { color: #333; }
.map-tool-overlay-segments {
    padding: 4px 10px 0;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 2px;
}
.map-tool-overlay-row {
    padding: 3px 10px;
    color: var(--text);
}
.map-tool-overlay-pts {
    padding: 4px 10px 2px;
    border-bottom: 1px solid #f0f0f0;
}
.map-tool-overlay-pt {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 2px 0;
}
.map-tool-pt-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--brand);
    white-space: nowrap;
    min-width: 26px;
}
.map-tool-pt-coord {
    font-size: 11px;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.map-tool-overlay-seg-arrow {
    padding: 0 0 2px 32px;
    font-size: 11px;
    color: var(--text-muted);
}
.map-tool-overlay-total {
    padding: 5px 10px 4px;
    color: var(--text);
    font-size: 12px;
}
.map-tool-overlay-actions {
    display: flex;
    gap: 6px;
    padding: 2px 10px 8px;
}
.map-tool-overlay-actions .map-tool-copy-btn {
    display: block;
    margin: 0;
    flex: 1;
}
.map-tool-overlay-hint {
    padding: 8px 10px;
    color: var(--text-muted);
    font-size: 11px;
    font-style: italic;
}
.map-tool-copy-btn {
    display: block;
    margin: 4px 10px 8px;
    padding: 3px 10px;
    font-size: 11px;
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background .15s;
}
.map-tool-copy-btn:hover { background: var(--brand-hover); }

/* ── Blazor loading ──────────────────────────────────── */
.loading-progress { position: relative; display: block; width: 8rem; height: 8rem; margin: 20vh auto 1rem; }
.loading-progress circle { fill: none; stroke: #e0e0e0; stroke-width: 0.6rem; transform-origin: 50% 50%; transform: rotate(-90deg); transition: stroke-dasharray 0.05s ease-in-out; }
.loading-progress circle:last-child { stroke: var(--brand); stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%; }
.loading-progress-text { text-align: center; }
.loading-progress-text::after { content: var(--blazor-load-percentage-text, "Loading Datgel View..."); }
#blazor-error-ui { background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none; left: 0; padding: 0.6rem 1.25rem 0.7rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* ── License status (Deployment page) ────────────────── */
.license-status-active {
    background: linear-gradient(135deg, #f0faf0, #e8f5e9);
    border: 1px solid #c8e6c9;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 20px;
}
.license-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.license-dot {
    width: 8px; height: 8px;
    background: #4caf50;
    border-radius: 50%;
    flex-shrink: 0;
}
.license-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted, #6c757d);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.license-org {
    font-size: 18px;
    font-weight: 600;
    color: var(--text, #212529);
    padding-left: 16px;
}

/* ── Database Admin ──────────────────────────────────── */
.db-admin-card { max-width: 100%; padding: 24px; border: 1px solid #dee2e6; border-radius: 6px; }
.field-group { margin-bottom: 16px; }
.field-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.field-hint { font-size: 12px; color: #6c757d; margin-top: 4px; margin-bottom: 0; }
.conn-str-input { font-family: monospace; font-size: 12px; resize: vertical; width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.db-result { margin-bottom: 16px; white-space: pre-wrap; font-size: 13px; }
.saved-notice { font-size: 12px; color: #6c757d; margin-top: 12px; margin-bottom: 0; }

/* ── Setup Wizard ─────────────────────────────────────── */
.setup-wizard { min-height: calc(100vh - var(--header-height) - var(--footer-height)); background: #f5f7fa; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; overflow: hidden; }
.setup-card { background: #fff; border-radius: 10px; box-shadow: 0 4px 24px rgba(0,0,0,.10); padding: 40px; max-width: 540px; width: 100%; }
.setup-logo { margin-bottom: 8px; }
.setup-logo .brand { font-size: 20px; font-weight: 700; color: var(--brand); }
.setup-card h2 { margin: 0 0 4px; font-size: 22px; }
.setup-intro { color: #666; margin-bottom: 28px; }
.setup-step { border: 1px solid #e0e0e0; border-radius: 8px; padding: 20px; margin-bottom: 16px; }
.setup-step.step-done { border-color: #c3e6cb; background: #f8fff9; }
.setup-step.step-disabled { opacity: .45; pointer-events: none; }
.step-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.step-number { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.step-done .step-number { background: #28a745; }
.step-title { font-weight: 600; font-size: 15px; }
.step-desc, .step-pending { color: #666; font-size: 14px; margin-bottom: 14px; }
.step-success { color: #155724; font-size: 14px; margin: 0; }
.field-group { margin-bottom: 14px; }
.field-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.conn-str-input { font-family: monospace; font-size: 12px; resize: vertical; }
.btn-row { display: flex; gap: 10px; margin-top: 4px; }
.setup-complete { text-align: center; padding: 20px 0 4px; border-top: 1px solid #e0e0e0; margin-top: 8px; }
.setup-complete p { color: #155724; font-weight: 600; margin-bottom: 16px; }
.expire-note { font-size: 12px; color: #6c757d; margin-left: 6px; }
.setup-version { margin-top: 12px; font-size: 11px; color: #999; text-align: center; }

/* ── Alert boxes (shared) ─────────────────────────────────── */
.alert-error   { background: #f8d7da; border: 1px solid #f5c6cb; color: #721c24; border-radius: 6px; padding: 10px 14px; font-size: 14px; margin-bottom: 12px; }
.alert-success { background: #d4edda; border: 1px solid #c3e6cb; color: #155724; border-radius: 6px; padding: 10px 14px; font-size: 14px; margin-bottom: 12px; }
.alert-warn    { background: #fff3cd; border: 1px solid #ffeeba; color: #856404; border-radius: 6px; padding: 10px 14px; font-size: 14px; margin-bottom: 12px; }
.alert-error strong, .alert-success strong, .alert-warn strong { display: block; margin-bottom: 4px; }
.error-detail  { font-size: 12px; color: #856404; background: #fff8e1; border: 1px solid #ffe082; border-radius: 4px; padding: 6px 10px; margin-top: 8px; white-space: pre-wrap; word-break: break-word; }
.error-entitlement { font-size: 12px; color: #6c757d; margin-top: 6px; }
.error-entitlement code { background: #f0f0f0; border-radius: 3px; padding: 1px 4px; font-size: 11px; }

/* ── Landing Page ─────────────────────────────────────────── */
.landing-shell { min-height: 100vh; display: flex; flex-direction: column; background: #fff; }

/* License error alert */
.lp-alert {
    background: #fff3cd; color: #856404; border-bottom: 1px solid #ffc107;
    padding: 14px 32px; text-align: center; font-size: 0.95rem;
}
.lp-alert a { color: #533f03; font-weight: 600; text-decoration: underline; }

/* Top bar */
.lp-topbar {
    height: 56px;
    background: var(--brand-dark);
    color: #fff;
    display: flex; align-items: center;
    padding: 0 32px; gap: 20px;
    position: sticky; top: 0; z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.lp-topbar-brand {
    font-weight: 700; font-size: 17px; letter-spacing: .3px; color: #fff;
    flex: 1;
}
.lp-topbar-nav { display: flex; align-items: center; gap: 20px; }
.lp-topbar-nav a { color: rgba(255,255,255,.8); text-decoration: none; font-size: 14px; font-weight: 500; transition: color .15s; }
.lp-topbar-nav a:hover { color: #fff; }
.lp-store-link {
    background: var(--brand-orange); color: #fff !important;
    border-radius: 4px; padding: 3px 12px; font-weight: 600;
}
.lp-store-link:hover { opacity: .88; }
.lp-topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: 8px; }

/* Shared button styles */
.lp-btn {
    display: inline-flex; align-items: center;
    border-radius: 5px; font-weight: 600; font-size: 14px;
    padding: 7px 20px; text-decoration: none; cursor: pointer;
    transition: background .15s, opacity .15s; white-space: nowrap;
}
.lp-btn-primary { background: var(--brand); color: #fff; border: none; }
.lp-btn-primary:hover { background: var(--brand-hover); color: #fff; }
.lp-btn-ghost { background: transparent; color: rgba(255,255,255,.85); border: 1px solid rgba(255,255,255,.4); }
.lp-btn-ghost:hover { background: rgba(255,255,255,.12); color: #fff; }
.lp-btn-lg { font-size: 16px; padding: 11px 28px; border-radius: 6px; }

/* Hero section */
.lp-hero {
    /* Gradient backdrop — replace with background-image once a hero.jpg is placed in wwwroot/images/ */
    background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 55%, var(--brand-bright) 100%);
    min-height: 420px;
    display: flex; align-items: center; justify-content: center;
    text-align: center; padding: 64px 32px;
    flex: 1;
}
.lp-hero-content { max-width: 640px; }
.lp-hero-title {
    font-size: clamp(32px, 5vw, 52px);
    font-weight: 800; color: #fff;
    margin: 0 0 16px;
    text-shadow: 0 2px 12px rgba(0,0,0,.25);
}
.lp-hero-tagline {
    font-size: clamp(15px, 2vw, 19px);
    color: rgba(255,255,255,.88);
    margin: 0 0 36px; line-height: 1.55;
}
.lp-hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

/* Features */
.lp-features { background: #f7f9f8; padding: 56px 32px; }
.lp-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px; max-width: 900px; margin: 0 auto;
}
.lp-feature-card {
    background: #fff; border-radius: 10px;
    padding: 32px 24px; text-align: center;
    box-shadow: 0 1px 6px rgba(0,0,0,.07);
    border: 1px solid var(--border);
}
.lp-feature-icon { font-size: 36px; margin-bottom: 14px; }
.lp-feature-card h3 {
    font-size: 16px; font-weight: 700;
    color: var(--brand-dark); margin: 0 0 10px;
}
.lp-feature-card p { font-size: 13px; color: var(--text-muted); line-height: 1.6; margin: 0; }

/* Links bar */
.lp-links-bar {
    background: #fff; border-top: 1px solid var(--border);
    padding: 18px 32px; text-align: center;
    display: flex; flex-wrap: wrap; gap: 6px 4px;
    align-items: center; justify-content: center;
}
.lp-links-bar a { font-size: 13px; color: var(--brand); text-decoration: none; }
.lp-links-bar a:hover { text-decoration: underline; }
.lp-links-sep { color: #ccc; font-size: 13px; }

/* Footer */
.lp-footer {
    background: var(--brand-dark); color: rgba(255,255,255,.65);
    text-align: center; padding: 14px 32px; font-size: 12px;
}

/* ── Branding ────────────────────────────────────────────── */
.brand-logo { height: 32px; max-width: 180px; object-fit: contain; }

.branding-admin { padding: 20px; max-width: 800px; }
.branding-section { margin-bottom: 28px; }
.branding-section h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; color: var(--brand); border-bottom: 1px solid #e0e0e0; padding-bottom: 6px; }
.branding-colour-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.branding-colour-item { display: flex; align-items: center; gap: 10px; }
.branding-colour-item input[type="color"] { width: 48px; height: 32px; padding: 2px; border: 1px solid #ccc; border-radius: 4px; cursor: pointer; }
.branding-colour-item label { font-size: 13px; font-weight: 500; }
.branding-preview { margin-top: 12px; padding: 12px; border: 1px solid #e0e0e0; border-radius: 6px; }
.branding-preview-header { padding: 8px 16px; border-radius: 4px; color: white; font-weight: 600; font-size: 14px; }
.branding-preview-btn { display: inline-block; padding: 6px 16px; border-radius: 4px; color: white; font-size: 13px; margin-top: 8px; }
.branding-image-upload { display: flex; align-items: center; gap: 16px; }
.branding-image-preview { max-height: 48px; max-width: 180px; object-fit: contain; border: 1px solid #e0e0e0; border-radius: 4px; padding: 4px; }
.branding-image-preview-favicon { max-height: 32px; max-width: 32px; }
