/* ==========================================================================
   GravityFlow — Gravity Water Supply Network Designer
   ========================================================================== */

:root {
    --color-bg: #f4f6f8;
    --color-surface: #ffffff;
    --color-surface-alt: #f8fafc;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-primary: #0891b2;
    --color-primary-dark: #0e7490;
    --color-primary-light: #e0f7fa;
    --color-accent: #2563eb;
    --color-danger: #dc2626;
    --color-danger-bg: #fef2f2;
    --color-warning: #d97706;
    --color-warning-bg: #fffbeb;
    --color-success: #16a34a;
    --color-success-bg: #f0fdf4;

    --node-source: #0e7490;
    --node-bpt: #d97706;
    --node-junction: #334155;
    --node-prv: #9333ea;
    --node-arv: #0891b2;
    --node-scour: #78350f;

    --topbar-h: 52px;
    --statusbar-h: 28px;
    --toolbar-w: 84px;
    --sidebar-w: 340px;

    --radius: 8px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.10);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: var(--font);
    color: var(--color-text);
    background: var(--color-bg);
    font-size: 13px;
    overflow: hidden;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* ---------------------------- Top bar ---------------------------- */

#topbar {
    position: relative;
    height: var(--topbar-h);
    min-height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: linear-gradient(180deg, #0b2540 0%, #0f172a 100%);
    color: #fff;
    border-bottom: 0.25px solid rgba(143, 139, 139, 0.68);
    padding: 0 14px;
    box-shadow: var(--shadow-sm);
    z-index: 200;
}
#btnUndo{ font-size: 24px;}
#btnRedo{ font-size: 24px;}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; letter-spacing: 0.2px; flex-shrink: 0; }
.brand-icon { height: 25px; font-size: 20px; }
.brand-text { white-space: nowrap; }
.brand-text small { font-weight: 400; color: #9fc9d8; margin-left: 6px; font-size: 11px; }

/* No overflow-x/y here on purpose: it would clip the Project dropdown's absolutely-positioned
   menu, since overflow-x != visible forces the other axis non-visible too (a CSS quirk) and
   this row is only as tall as the topbar itself. Below the breakpoint the hamburger menu
   takes over instead of relying on horizontal scroll. */
.topbar-actions { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; min-width: 0; }
.topbar-actions .btn { flex-shrink: 0; }
.btn-group { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.divider { width: 1px; height: 22px; background: rgba(255,255,255,0.18); margin: 0 4px; flex-shrink: 0; }

/* Hamburger toggle — hidden on wide screens, shown once the topbar can no longer fit its
   actions in one row (see the max-width breakpoint below). */
.hamburger-btn {
    display: none;
    flex-shrink: 0;
    width: 36px;
    height: 32px;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
}
.hamburger-btn:hover { background: rgba(255,255,255,0.18); }
.hamburger-icon, .hamburger-icon::before, .hamburger-icon::after {
    display: block;
    width: 18px;
    height: 2px;
    background: #fff;
    border-radius: 1px;
    transition: transform 0.18s ease, opacity 0.18s ease;
}
.hamburger-icon { position: relative; }
.hamburger-icon::before, .hamburger-icon::after { content: ''; position: absolute; left: 0; }
.hamburger-icon::before { top: -6px; }
.hamburger-icon::after { top: 6px; }
.hamburger-btn.open .hamburger-icon { background: transparent; }
.hamburger-btn.open .hamburger-icon::before { top: 0; transform: rotate(45deg); }
.hamburger-btn.open .hamburger-icon::after { top: 0; transform: rotate(-45deg); }

@media (max-width: 1250px) {
    .hamburger-btn { display: flex; }
    .topbar-actions {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        overflow: visible;
        max-height: calc(100vh - var(--topbar-h));
        overflow-y: auto;
        background: #0f172a;
        border-bottom: 1px solid rgba(255,255,255,0.14);
        box-shadow: var(--shadow-md);
        padding: 10px 14px 14px;
        gap: 8px;
    }
    .topbar-actions.open { display: flex; }
    .topbar-actions .divider { display: none; }
    .topbar-actions > .btn, .topbar-actions > .dropdown, .topbar-actions > .btn-group {
        width: 100%;
    }
    .btn-group > .btn { flex: 1 1 0; width: auto; }
    .topbar-actions .dropdown-menu { position: static; width: 100%; box-shadow: none; margin-top: 4px; }
}

.btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.14);
    color: #e2e8f0;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, transform 0.05s;
    white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,0.18); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.35; cursor: default; pointer-events: none; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
.btn-icon { padding: 6px 10px; font-size: 15px; line-height: 1; }

.btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
    font-weight: 600;
}
.btn-primary:hover { background: var(--color-primary-dark); }

.dropdown { position: relative; }
.caret { font-size: 14px; margin-left: 6px; opacity: 0.9; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: auto;
    min-width: 180px;
    max-width: calc(100vw - 24px);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    padding: 6px;
    z-index: 1000;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    color: var(--color-text);
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12.5px;
}
.dropdown-item:hover { background: var(--color-surface-alt); }
.dropdown-sep { height: 1px; background: var(--color-border); margin: 5px 2px; }

/* ---------------------------- Main layout ---------------------------- */

#main {
    flex: 1;
    display: flex;
    min-height: 0;
}

/* ---------------------------- Left toolbar ---------------------------- */

#toolbar {
    width: var(--toolbar-w);
    min-width: var(--toolbar-w);
    background: linear-gradient(180deg, #132540 0%, #0b1526 100%);
    border-right: 1px solid rgba(203, 195, 195, 0.88);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 5px 5px;
    gap: 3px;
    overflow-y: auto;
    z-index: 20;
}

.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 4px 2px;
    cursor: pointer;
    color: #8ba3c7;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.tool-btn .icon { font-size: 15px; line-height: 1; }
.tool-icon-img { width: 25px; height: 23px; object-fit: contain; display: block; margin: 0 auto; }
.tool-icon-bpt { width: 21px; height: 17px; object-fit: contain; display: block; margin: 0 auto; }
.tool-icon-bptR{ width: 20px; height: 20px; object-fit: contain; display: block; margin: 0 auto; }
.tool-icon-bjun { width: 17px; height: 18px; object-fit: contain; display: block; margin: 0 auto; }
.tool-icon-prv { width: 23px; height: 23px; object-fit: contain; display: block; margin: 0 auto; }
.tool-btn .tlabel { font-size: 8.5px; line-height: 1.15; color: white; }
.tool-btn:hover { color: #fff; background: rgba(255,255,255,0.18); }
.tool-btn.active {
    color: #fff;
    background: linear-gradient(180deg, #0ea5c4 0%, #0891b2 100%);
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(8,145,178,0.45);
}
.tool-icon-measure{ width:34px; height:17px; }
.tool-icon-elevation{width: 32px; height: 18px;}
.icon-locate{font-size: 16px;}
.icon-fit{font-size: 18px;}
.icon-delete{font-size: 16px; color: #fdfdfd;}
.tool-btn.active .tlabel { color: #fff; font-weight: 600; }

#toolbar hr { width: 100%; border: none; border-top: 1px solid rgba(255,255,255,0.12); margin: 2px 0; }


.node-swatch { width: 14px; height: 14px; border-radius: 50%; display: inline-block; border: 2px solid #fff; box-shadow: 0 0 0 1.5px currentColor; }
.swatch-source { background: var(--node-source); color: var(--node-source); border-radius: 4px; }
.swatch-bpt { background: var(--node-bpt); color: var(--node-bpt); }
.swatch-junction { background: var(--node-junction); color: var(--node-junction); }
.swatch-prv { background: var(--node-prv); color: var(--node-prv); }

/* ---------------------------- Map area ---------------------------- */

#mapWrap {
    position: relative;
    flex: 1;
    min-width: 0;
    isolation: isolate;
}

#map {
    position: absolute;
    inset: 0;
    background: #dce3e8;
}
#map.tool-source, #map.tool-bpt, #map.tool-junction, #map.tool-pipe, #map.tool-measure, #map.tool-boxselect { cursor: crosshair; }
#map.tool-delete { cursor: not-allowed; }

.gf-node-icon.box-selected { box-shadow: 0 0 0 3px #2563eb, 0 1px 4px rgba(0,0,0,0.4); }
.gf-node-icon.gf-node-img.box-selected img { filter: drop-shadow(0 0 3px #2563eb) drop-shadow(0 0 3px #2563eb); }
.gf-pipe-line.box-selected { filter: drop-shadow(0 0 4px #2563eb) drop-shadow(0 0 4px #2563eb); }

.gf-bend-marker {
    width: 14px;
    height: 14px;
    background: #fff;
    border: 3px solid #dc2626;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
    cursor: grab;
}
.gf-bend-marker:active { cursor: grabbing; }

.gf-flow-arrow { pointer-events: none; }
.gf-flow-arrow-badge {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2563eb;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.gf-flow-arrow-glyph {
    display: inline-block;
    color: #fff;
    font-size: 11px;
    line-height: 1;
}

.gf-pump-marker { pointer-events: none; }
.gf-pump-badge {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f59e0b;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.5);
    font-size: 12px;
    line-height: 1;
}

.leaflet-container .leaflet-control-attribution {
    background: rgba(55, 65, 81, 0.85);
    color: #fff;
}
.leaflet-container .leaflet-control-attribution a { color: #7dd3fc; }
#btnFileMenu{ border:1px solid rgb(250, 242, 4); width:90px;}
#mapSearch {
    position: absolute;
    top: 12px;
    left: 55px;
    z-index: 500;
    width: 230px;
    border-radius: 8px;
    border: 1px solid rgb(3, 2, 2);
}
#searchInput {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    background: var(--color-surface);
    outline: none;
}
#searchInput:focus { border-color: var(--color-primary); }
#searchResults {
    margin-top: 4px;
    background: var(--color-surface);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    display: none;
}
#searchResults.visible { display: block; }
#searchResults div {
    padding: 7px 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border);
    font-size: 12px;
}
#searchResults div:last-child { border-bottom: none; }
#searchResults div:hover { background: var(--color-surface-alt); }

#legend {
    position: absolute;
    bottom: calc(var(--statusbar-h) + 12px);
    right: 12px;
    z-index: 500;
    background: linear-gradient(180deg, rgba(31, 77, 109, 0.97), rgba(17, 78, 149, 0.94));
    border:0.1px solid rgb(194, 184, 184);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    padding: 8px 10px;
    font-size: 12px;
    min-width: 150px;
    color: #fff;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    
}
.legend-title { font-weight: 700; margin-bottom: 4px; color: rgb(253, 253, 253); text-transform: uppercase; font-size: 12px; letter-spacing: 0.05em; }

#hoverPreview {
    display: none;
    position: absolute;
    z-index: 900;
    pointer-events: none;
    background: linear-gradient(165deg, #16233f 0%, #0a1220 100%);
    border: 1px solid rgba(148,180,221,0.3);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    padding: 8px 10px;
    font-size: 11.5px;
    color: #e8eefc;
    min-width: 140px;
    max-width: 240px;
}
#hoverPreview.visible { display: block; }
.hp-title { font-weight: 700; font-size: 12.5px; color: #fff; margin-bottom: 4px; padding-bottom: 4px; border-bottom: 1px solid rgba(148,180,221,0.25); }
.hp-row { display: flex; justify-content: space-between; gap: 10px; padding: 1.5px 0; }
.hp-row span:first-child { color: #8fa8ce; }
.hp-row span:last-child { font-weight: 600; color: #fff; }
.hp-row.ok span:last-child { color: #4ade80; }
.hp-row.warn span:last-child { color: #fbbf24; }
.hp-row.danger span:last-child { color: #f87171; }
.legend-row { display: flex; align-items: center; gap: 6px; margin: 7px 0; }
.legend-swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }
.legend-swatch.round { border-radius: 50%; }
.legend-line { width: 18px; height: 4px; border-radius: 2px; flex-shrink: 0; }

#measurePanel {
    display: none;
    position: absolute;
    top: 60px;
    left: 55px;
    width: 230px;
    z-index: 500;
    background: linear-gradient(180deg, rgba(31, 77, 109, 0.97), rgba(17, 78, 149, 0.94));
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    padding: 8px 10px;
    font-size: 12px;
    color: #fff;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}
#measurePanel.visible { display: block; }
#measureValue { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.measure-controls { display: flex; gap: 6px; align-items: center; }
.measure-controls select {
    flex: 1;
    min-width: 0;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.1);
    color: #fff;
    padding: 4px 6px;
    font-size: 11px;
}
.measure-controls select option { color: #111827; background: #fff; }
.measure-controls .btn { padding: 4px 10px; font-size: 11px; }

#statusbar {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: var(--statusbar-h);
    background: #0f172a;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    gap: 18px;
    height: 40px;
    padding: 0 12px;
    font-size: 11px;
    z-index: 500;
    overflow: hidden;
}
#statusbar span { white-space: nowrap; }
#statusCalc { color: #7dd3fc; font-weight: 600; }
#statusCalc.err { color: #fca5a5; }
#statusAuthor { margin: 0 auto; }
#statusFile { margin-left: auto; color: #86efac; }
.status-contact-btn {
    margin-left: 8px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1.6;
}
.status-contact-btn:hover { background: var(--color-primary-dark); }
.contact-intro { margin-top: 0; }

/* Progressively drop the least essential status-bar items as width shrinks, so the bar never
   overflows or squeezes #statusCalc/#statusFile — the two that actually need to stay readable
   (calculation warnings and autosave state). */
@media (max-width: 900px) {
    #statusCoords { display: none; }
}
@media (max-width: 700px) {
    #statusCounts { display: none; }
    #statusAuthor .author-text { display: none; }
}
@media (max-width: 480px) {
    #statusMode { display: none; }
    .status-contact-label { display: none; }
    #statusbar { gap: 10px; padding: 0 8px; }
}

#toastContainer {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 320px;
    pointer-events: none;
    border:1px solid white;
    border-radius: 5px;
}
.toast {
    position: relative;
    background: var(--color-text);
    color: #fff;
    padding: 10px 28px 10px 14px;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    font-size: 12.5px;
    pointer-events: auto;
    animation: toast-in 0.18s ease-out;
}
.toast-close {
    position: absolute;
    top: 4px;
    right: 6px;
    background: transparent;
    border: none;
    color: inherit;
    opacity: 0.7;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
}
.toast-close:hover { opacity: 1; }
.toast.warn { background: var(--color-warning); }
.toast.err { background: var(--color-danger); }
.toast.ok { background: var(--color-success); }
@keyframes toast-in { from { opacity:0; transform: translateY(-6px);} to {opacity:1; transform:none;} }

/* Leaflet marker label */
.gf-label {
    background: #cfe8fb;
    border: 1px solid #000;
    border-radius: 4px;
    padding: 0 4px;
    font-size: 9px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.gf-label.leaflet-tooltip-right::before { border-right-color: #000; }
.gf-label.leaflet-tooltip-left::before { border-left-color: #000; }
#map.labels-hidden .gf-label { display: none; }
.gf-node-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 11px;
    box-shadow: 0 0 0 2px #fff, 0 1px 4px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
}
.gf-node-icon:hover { transform: scale(1.2); }
.gf-node-icon.selected { box-shadow: 0 0 0 3px #facc15, 0 1px 4px rgba(0,0,0,0.4); }
.gf-node-icon.source { background: var(--node-source); border-radius: 6px; }
.gf-node-icon.bpt { background: var(--node-bpt); border-radius: 50% 50% 50% 0; }
.gf-node-icon.junction { background: var(--node-junction); border-radius: 50%; }
.gf-node-icon.prv { background: var(--node-prv); border-radius: 4px; transform: rotate(45deg); }
.gf-node-icon.arv { background: var(--node-arv); border-radius: 50%; border: 2px solid #fff; }
.gf-node-icon.scour { background: var(--node-scour); border-radius: 2px; }
.gf-node-icon.warn-neg { box-shadow: 0 0 0 3px var(--color-danger), 0 1px 4px rgba(0,0,0,0.4); }
.gf-node-icon.warn-hi { box-shadow: 0 0 0 3px var(--color-warning), 0 1px 4px rgba(0,0,0,0.4); }

.gf-node-icon.gf-node-img { background: transparent; box-shadow: none; border-radius: 0; transform: none; }
.gf-node-icon.gf-node-img img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5)); }
.gf-node-icon.gf-node-img.selected img { filter: drop-shadow(0 0 3px #facc15) drop-shadow(0 0 3px #facc15); }
.gf-node-icon.gf-node-img.warn-neg img { filter: drop-shadow(0 0 3px var(--color-danger)) drop-shadow(0 0 3px var(--color-danger)); }
.gf-node-icon.gf-node-img.warn-hi img { filter: drop-shadow(0 0 3px var(--color-warning)) drop-shadow(0 0 3px var(--color-warning)); }

.leaflet-interactive { transition: filter 0.15s ease; cursor: pointer; }

/* Give pipes a raised, cylindrical "tube" look: a light edge on top, a dark
   edge underneath, and a soft drop shadow to lift them off the basemap. */
.gf-pipe-line {
    filter:
        drop-shadow(0 -1px 0 rgba(255,255,255,0.55))
        drop-shadow(0 1px 0 rgba(0,0,0,0.4))
        drop-shadow(0 2px 2px rgba(0,0,0,0.25));
}
.gf-pipe-hover {
    filter:
        drop-shadow(0 -1px 0 rgba(255,255,255,0.55))
        drop-shadow(0 1px 0 rgba(0,0,0,0.4))
        drop-shadow(0 0 5px rgba(37,99,235,0.85))
        drop-shadow(0 0 5px rgba(37,99,235,0.85));
}

/* Animated flow overlay — a dashed line drawn on top of the pipe's own color, moving in the
   actual flow direction. Dash pattern + duration read as "dots drifting downstream" rather
   than a static striped line. */
.gf-pipe-flow {
    stroke-dasharray: 15, 16;
    stroke-linecap: round;
    animation: gf-flow-move 1.1s linear infinite;
    pointer-events: none;
}
.gf-pipe-flow-reverse { animation-direction: reverse; }
@keyframes gf-flow-move {
    to { stroke-dashoffset: -30; }
}

.gf-draft-vertex {
    background: #fff;
    border: 2px solid var(--color-accent);
    border-radius: 50%;
}

/* ---------------------------- Sidebar ---------------------------- */

#sidebar {
    display: flex;
    flex-direction: row;
    min-height: 0;
}

#sidebarPanel {
    width: 0;
    min-width: 0;
    overflow: hidden;
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    min-height: 0;
    transition: width 0.22s ease;
}
#sidebarPanel.open { width: var(--sidebar-w); min-width: var(--sidebar-w); }
#sidebarPanel > * { width: var(--sidebar-w); flex-shrink: 0; }
#sidebarPanel > .tab-panels { flex: 1 1 auto; }

.panel-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 16px;
    background: linear-gradient(180deg, #eaf7fb 0%, var(--color-surface) 100%);
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}
.panel-topbar span {
    font-weight: 700;
    font-size: 14px;
    color: var(--color-primary-dark);
    letter-spacing: 0.01em;
}
.panel-topbar .modal-close {
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
    width: 26px;
    height: 26px;
    font-size: 16px;
}
.panel-topbar .modal-close:hover { background: var(--color-border); color: var(--color-text); }

#tabRail {
    width: var(--toolbar-w);
    min-width: var(--toolbar-w);
    background: linear-gradient(180deg, #132540 0%, #0b1526 100%);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 10px 6px;
    gap: 12px;
    flex-shrink: 0;
    overflow-y: auto;
}
#tabRail .tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: transparent;
    border: none;
    border-radius: 8px;
    padding: 10px 2px;
    cursor: pointer;
    color: #fff;
    font-weight: 600;
    transition: background 0.15s ease, color 0.15s ease;
}
#tabRail .tab-btn .icon { font-size: 18px; line-height: 1; }
#tabRail .tab-btn .tlabel { font-size: 9.5px; color: inherit; }
#tabRail .tab-btn:hover { color: #fff; background: rgba(255,255,255,0.18); }
#tabRail .tab-btn.active { color: #fff; background: linear-gradient(180deg, #0ea5c4 0%, #0891b2 100%); box-shadow: 0 2px 8px rgba(8,145,178,0.45); }

.tab-panels { flex: 1; min-height: 0; position: relative; }
.tab-content {
    display: none;
    position: absolute;
    inset: 0;
    overflow-y: auto;
    padding: 14px;
    background: linear-gradient(180deg, #eaf6fa 0%, #eef1f6 45%, #eef1f6 100%);
}
.tab-content.active { display: block; }

.tab-content select, .tab-content input[type="text"], .tab-content input[type="number"] {
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 5px 8px;
    background: var(--color-surface);
    color: var(--color-text);
}
.tab-content select:focus, .tab-content input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(8,145,178,0.15);
}
.tab-content > .panel-section > label:not(.layer-toggle-row) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--color-text-muted);
}

.empty-hint {
    color: var(--color-text-muted);
    font-size: 14px;
    line-height: 1.5;
    background: var(--color-surface-alt);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius);
    padding: 14px;
}

.panel-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 12px 14px 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
}
.panel-section h3 {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin: -2px 0 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 7px;
}
.panel-section h3::before {
    content: '';
    width: 4px;
    height: 12px;
    border-radius: 2px;
    background: var(--color-primary);
    flex-shrink: 0;
}

.count-badge {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    border-radius: 10px;
    padding: 0 7px;
    font-size: 10.5px;
    font-weight: 700;
}

.layer-toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    margin: 0 -8px;
    border-radius: 6px;
    font-size: 12.5px;
    color: var(--color-text);
    cursor: pointer;
    transition: background 0.12s ease;
}
.layer-toggle-row:hover { background: var(--color-surface-alt); }
.layer-toggle-row input[type="checkbox"] { accent-color: var(--color-primary); width: 15px; height: 15px; cursor: pointer; }
.layer-toggle-row span:first-of-type { flex: 1; }

.hover-field-hint { margin-bottom: 6px; }
.hover-field-group-label { font-size: 11px; font-weight: 600; color: var(--color-text-muted); margin-bottom: 2px; }
.hover-field-group-label-spaced { margin-top: 8px; }

#hillshadeHint { display: none; font-style: italic; color: var(--color-text-muted); }
#hillshadeHint.visible { display: block; }

.gf-elev-popup .leaflet-popup-content-wrapper {
    padding: 0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.25);
}
.gf-elev-popup .leaflet-popup-content { margin: 0; }
.gf-elev-popup .leaflet-popup-tip { box-shadow: 0 4px 10px rgba(15, 23, 42, 0.2); }
.gf-elev-popup .leaflet-popup-close-button {
    color: rgba(255, 255, 255, 0.85);
    top: 6px; right: 6px;
}
.gf-elev-popup .leaflet-popup-close-button:hover { color: #ffffff; }

.gf-elev-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px 10px 12px;
    min-width: 160px;
    background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
    color: #fff;
    border: 1px solid rgb(3, 3, 3);
    
}
.gf-elev-card-error { background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%); }
.gf-elev-icon { font-size: 22px; line-height: 1; }
.gf-elev-value { font-size: 15px; font-weight: 700; line-height: 1.15; }
.gf-elev-unit { font-size: 13px; font-weight: 500; margin-left: 3px; opacity: 0.85; }
.gf-elev-coords {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    font-family: "Courier New", monospace;
    margin-top: 2px;
}
.gf-elev-card-error .gf-elev-value { font-size: 14px; }

.gf-gpx-pin {
    width: 16px;
    height: 16px;
    border-radius: 50% 50% 50% 0;
    background: #7c3aed;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.4);
    transform: rotate(-45deg);
}
.gf-gpx-popup { min-width: 150px; }
.gf-gpx-popup-name { font-weight: 700; font-size: 13px; color: #1e1b4b; }
.gf-gpx-popup-coords { font-size: 12px; font-family: "Courier New", monospace; color: #475569; margin-top: 2px; }
.gf-gpx-popup-ele { font-size: 12px; color: #475569; margin-top: 2px; }
.gf-gpx-popup-remove {
    margin-top: 8px;
    font-size: 12px;
    color: #fff;
    background: #7c3aed;
    border: none;
    border-radius: 5px;
    padding: 4px 10px;
    cursor: pointer;
}
.gf-gpx-popup-remove:hover { background: #6d28d9; }

/* Property form */
.form-row { margin-bottom: 10px; display: flex; flex-direction: column; gap: 3px; }
.form-row label { font-size: 11px; font-weight: 600; color: rgb(188, 175, 175); }
.form-row input, .form-row select, .form-row textarea {
    padding: 6px 8px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-surface);
    color: var(--color-text);
    width: 100%;
}
.form-row input:focus, .form-row select:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(8,145,178,0.15); }
.form-row input[type="range"] { accent-color: var(--color-primary); padding: 0; border: none; background: transparent; height: 20px; }
.form-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.form-title {
    font-weight: 700;
    font-size: 13.5px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.type-pill {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: #fff;
}
.type-pill.source { background: var(--node-source); }
.type-pill.bpt { background: var(--node-bpt); }
.type-pill.junction { background: var(--node-junction); }
.type-pill.prv { background: var(--node-prv); }
.type-pill.arv { background: var(--node-arv); }
.type-pill.scour { background: var(--node-scour); }

.form-actions { display: flex; gap: 8px; margin-top: 12px; }
.form-actions .btn { flex: 1; text-align: center; color: var(--color-text); background: var(--color-surface-alt); border-color: var(--color-border); }
.form-actions .btn:hover { background: var(--color-border); }
.form-actions .btn.danger { color: var(--color-danger); }
.form-actions .btn.primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.hint-text { font-size: 10.5px; color: var(--color-text-muted); margin-top: -6px; }
.hint-text code, .about-text code {
    display: inline-block;
    margin-top: 3px;
    padding: 2px 6px;
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-family: "Courier New", monospace;
    font-size: 10.5px;
    color: var(--color-text);
}

/* Tables */
.table-scroll { max-height: 260px; overflow: auto; border: 1px solid var(--color-border); border-radius: 6px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.data-table th {
    position: sticky; top: 0;
    background: #0f172a;
    text-align: left;
    padding: 6px 8px;
    color: #fff;
    font-weight: 700;
    border-bottom: 1px solid #0f172a;
}
.data-table td { padding: 5px 8px; border-bottom: 1px solid var(--color-border); }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: var(--color-surface-alt); }
.data-table tbody tr.row-selected { background: var(--color-primary-light); }
.row-del { color: var(--color-text-muted); cursor: pointer; }
.row-del:hover { color: var(--color-danger); }

/* Bill of Quantities */
.boq-table tbody tr { cursor: default; }
.boq-table tbody tr:hover { background: transparent; }
.boq-table td:nth-child(2), .boq-table td:nth-child(3) { color: var(--color-text-muted); }
.boq-table th, .boq-table td { padding: 5px 4px; font-size: 10.5px; }
.boq-table .boq-price, .boq-table .boq-qty {
    width: 56px;
    padding: 3px 4px;
    border: 1px solid var(--color-border);
    border-radius: 5px;
    font-size: 10.5px;
}
.boq-table .boq-price:focus, .boq-table .boq-qty:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(8,145,178,0.15); }
.boq-table .boq-amount { font-weight: 700; text-align: right; }
.boq-header-row { display: flex; align-items: flex-start; gap: 8px; }
.boq-header-row h3 { flex: 1 1 auto; min-width: 0; }
.boq-header-row .modal-close {
    flex-shrink: 0;
    margin-top: -2px;
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
    width: 26px;
    height: 26px;
    font-size: 14px;
}
.boq-header-row .modal-close:hover { background: var(--color-border); color: var(--color-text); }
.boq-print-row { margin-top: 10px; }
.boq-grand-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--color-primary-light);
    border: 1px solid var(--color-primary);
    border-radius: 8px;
    font-size: 13px;
    color: var(--color-primary-dark);
}
.boq-grand-total strong { font-size: 16px; }

/* Feasibility */
.feas-verdict {
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 12px;
    border: 1px solid var(--color-border);
}
.feas-verdict-label { font-size: 20px; font-weight: 800; letter-spacing: 0.03em; }
.feas-verdict-sub { font-size: 11.5px; margin-top: 4px; opacity: 0.9; }
.feas-verdict.ok { background: var(--color-success-bg); color: #166534; border-color: #bbf7d0; }
.feas-verdict.warn { background: var(--color-warning-bg); color: #92400e; border-color: #fde68a; }
.feas-verdict.danger { background: var(--color-danger-bg); color: #991b1b; border-color: #fecaca; }
#feasChart { width: 100%; height: 160px; background: var(--color-surface-alt); border: 1px solid var(--color-border); border-radius: 6px; margin-bottom: 8px; }

/* Results */
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.summary-card {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 8px 10px;
}
.summary-card .val { font-size: 17px; font-weight: 700; }
.summary-card .lbl { font-size: 10.5px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.03em; }

.warning-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.warning-item {
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 11.5px;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    background: var(--color-surface-alt);
    border-left: 3px solid var(--color-border);
}
.warning-icon { flex-shrink: 0; line-height: 1.3; }
.warning-msg { color: var(--color-text); line-height: 1.4; }
.warning-body { flex: 1; min-width: 0; }
.warning-suggestion {
    margin-top: 6px;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 6px;
    padding: 7px 9px;
    line-height: 1.5;
}
.warning-suggestion .sugg-label {
    color: #7dd3fc;
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: block;
    margin-bottom: 3px;
}
.warning-suggestion ul { margin: 0; padding-left: 16px; }
.warning-suggestion li { margin: 2px 0; }
.warning-suggestion li::marker { color: #7dd3fc; }
.warning-item.danger { border-left-color: var(--color-danger); }
.warning-item.danger .warning-icon { color: var(--color-danger); }
.warning-item.warn { border-left-color: var(--color-warning); }
.warning-item.warn .warning-icon { color: var(--color-warning); }
.warning-item.ok { border-left-color: var(--color-success); }
.warning-item.ok .warning-icon { color: var(--color-success); }
.warning-item.ok .warning-msg { color: var(--color-text-muted); }

.badge-cell { font-weight: 700; }
.badge-cell.danger { color: var(--color-danger); }
.badge-cell.warn { color: var(--color-warning); }
.badge-cell.ok { color: var(--color-success); }

/* Profile */
#profileCanvas {
    width: 100%;
    max-width: 100%;
    background: #fbfdfe;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    margin: 10px 0;
}
.profile-legend { display: flex; gap: 14px; font-size: 11px; margin-bottom: 10px; flex-wrap: wrap; }
.profile-legend .legend-row { margin: 0; }

/* Settings */
#tab-settings label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

#tab-settings input, #tab-settings select { width: 120px; padding: 5px 7px; border: 1px solid var(--color-border); border-radius: 6px; background: var(--color-surface); color: var(--color-text); }
#tab-settings input:focus, #tab-settings select:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(8,145,178,0.15); }
.about-text { font-size: 12px; line-height: 1.6; color: black; }
.about-credit {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--color-border);
    font-size: 11px;
    line-height: 1.7;
    color: black;
    text-align: center;
}
.about-credit a { color: var(--color-primary); text-decoration: none; }
.about-credit a:hover { text-decoration: underline; }

/* Scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---------------------------- Responsive ---------------------------- */

@media (max-width: 980px) {
    :root { --sidebar-w: 300px; --toolbar-w: 70px; }
    .tool-btn .tlabel { display: none; }
}

/* ---------------------------- Feasibility modal ---------------------------- */

.btn-feasibility {
    background: linear-gradient(180deg, #0ea5c4 0%, #0891b2 100%);
    border-color: #0ea5c4;
    color: #fff;
    font-weight: 700;
}
.btn-feasibility:hover { background: linear-gradient(180deg, #22c3e0 0%, #0ea5c4 100%); }
#btnNew{ background: linear-gradient(180deg, #1f74db 0%, #0974e6 100%);
    border-color: #0ea5c4;
    color: #fff;
    font-weight: 700;
}

#btnCalculate{ background: linear-gradient(180deg, #0590f2 0%, #1167f2 100%);
    border-color: #0ea5c4;
    color: #fff;
    font-weight: 700;
}
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6, 12, 24, 0.6);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    z-index: 5000;
    align-items: center;
    justify-content: center;
    padding: 30px;
    transition: padding 0.15s ease;
}
.modal-backdrop.open { display: flex; }
.modal-backdrop.maximized { padding: 12px; }
.modal-dialog {
    background: linear-gradient(165deg, #16233f 0%, #0a1220 100%);
    border-radius: 14px;
    border: 1px solid rgba(249, 246, 246, 0.8);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    width: min(880px, calc(100vw - 60px));
    max-height: min(820px, 100%);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.15s ease, height 0.15s ease;
}
.modal-dialog.sm { width: min(520px, calc(100vw - 60px)); }
.modal-dialog.maximized {
    width: 100%;
    height: 100%;
    max-height: 100%;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(180deg, #0b2540 0%, #0f172a 100%);
    color: #fff;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.modal-header h2 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-header-actions { display: flex; gap: 6px; }
.modal-close {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    width: 30px; height: 30px;
    border-radius: 50%;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.modal-close:hover { background: rgba(255,255,255,0.22); }
.modal-body { padding: 18px 20px; overflow-y: auto; color: #fafbfb; flex: 1 1 auto; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 12px 20px;
    background: rgba(255,255,255,0.03);
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}


.feas-grid { display: grid; grid-template-columns: 300px 1fr; gap: 24px; margin-top: 14px; }
.feas-inputs { min-width: 0; }
.feas-output { min-width: 0; }
@media (max-width: 760px) {
    .feas-grid { grid-template-columns: 1fr; }

    #legend {
        right: 8px;
        bottom: calc(var(--statusbar-h) + 8px);
        padding: 6px 8px;
        font-size: 10px;
        min-width: 0;
        max-width: 42vw;
    }
    .legend-swatch { width: 11px; height: 11px; }
    .legend-line { width: 14px; height: 3px; }
}

/* Feasibility modal — dark theme text/contrast overrides (scoped to this modal only) */
#feasibilityModal .empty-hint {
    background: rgba(255,255,255,0.05);
    border: 1px dashed rgba(255,255,255,0.2);
    color: #cbd5e1;
}
#feasibilityModal .panel-section {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: none;
}
#feasibilityModal .panel-section h3 { color: #7dd3fc; border-bottom-color: rgba(255,255,255,0.14); }
#feasibilityModal .panel-section h3::before { background: #7dd3fc; }
#feasibilityModal .hint-text { color: #d2d2db; font-size: 12px; margin-top:5px; border:0.25px solid white; border-radius: 5px;
padding:4px;}
#feasibilityModal .form-row label { color: #a8bedb; }
#feasibilityModal .form-row input,
#feasibilityModal .form-row select {
    background: #fff;
    color: #111827;
    border: 1px solid rgba(255,255,255,0.18);
}
#feasibilityModal .form-row input:focus,
#feasibilityModal .form-row select:focus { border-color: #7dd3fc; }

#feasibilityModal .feas-verdict { border-width: 1px; border-style: solid; }
#feasibilityModal .feas-verdict.ok { background: rgba(74,222,128,0.12); border-color: rgba(74,222,128,0.35); color: #4ade80; }
#feasibilityModal .feas-verdict.warn { background: rgba(251,191,36,0.12); border-color: rgba(251,191,36,0.35); color: #fbbf24; }
#feasibilityModal .feas-verdict.danger { background: rgba(248,113,113,0.12); border-color: rgba(248,113,113,0.35); color: #f87171; }
#feasibilityModal .feas-verdict-sub { color: #cbd5e1; }

#feasibilityModal .summary-card { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); }
#feasibilityModal .summary-card .val { color: #fff; }
#feasibilityModal .summary-card .lbl { color: #8ba3c7; }

#feasibilityModal .warning-item { background: rgba(255,255,255,0.06); border-left-width: 3px; }
#feasibilityModal .warning-msg { color: #f1f5f9; }
#feasibilityModal .warning-icon { color: #f1f5f9; }
#feasibilityModal .warning-item.danger .warning-icon { color: #f87171; }
#feasibilityModal .warning-item.warn .warning-icon { color: #fbbf24; }
#feasibilityModal .warning-suggestion { background: rgba(0,0,0,0.4); }

#feasibilityModal #feasChart { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.14); }

#feasibilityModal .table-scroll { border: 1px solid rgba(255,255,255,0.14); }
#feasibilityModal .data-table th {
    background: rgba(255,255,255,0.08);
    color: #a8bedb;
    border-bottom: 1px solid rgba(255,255,255,0.14);
}
#feasibilityModal .data-table td { color: #e2e8f0; border-bottom: 1px solid rgba(255,255,255,0.08); }
#feasibilityModal .data-table tbody tr:hover { background: rgba(255,255,255,0.05); }
#feasibilityModal .badge-cell.ok { color: #4ade80; }
#feasibilityModal .badge-cell.warn { color: #fbbf24; }
#feasibilityModal .badge-cell.danger { color: #f87171; }

/* ---------------------------- BOQ modal ---------------------------- */
/* The BOQ tab's own DOM is reparented into #boqModalBody when expanded (see js), so
   these overrides re-theme the same light-mode .panel-section markup for the dark modal. */
#boqModalHeader { cursor: grab; }
#boqModalHeader.dragging { cursor: grabbing; }
/* #tab-boq is reparented here as-is, complete with its .tab-content styling (absolute-fill,
   active-class toggle, own padding/background) — all of that only makes sense inside the
   sidebar's height:100vh-constrained layout, so override it back to plain flow here: display
   forced on regardless of which sidebar tab is selected behind the modal (switchTab() would
   otherwise strip its .active class and hide it), and position:static so it just flows inside
   #boqModalBody's own scroll area instead of needing a definite height to fill via inset:0. */
#boqModalBody #tab-boq {
    display: block !important;
    position: static !important;
    inset: auto;
    padding: 0;
    background: transparent;
}
#boqModalBody #btnExpandBOQ { display: none; }
#boqModal .panel-section {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: none;
}
#boqModal .panel-section h3 { color: #7dd3fc; border-bottom-color: rgba(255,255,255,0.14); }
#boqModal .panel-section h3::before { background: #7dd3fc; }
#boqModal .boq-header-row .modal-close { background: rgba(255,255,255,0.1); color: #fff; }
#boqModal .boq-header-row .modal-close:hover { background: rgba(255,255,255,0.22); }
#boqModal .hint-text { color: #a8bedb; }
#boqModal .form-row label { color: #a8bedb; }
#boqModal .form-row input,
#boqModal .form-row select { background: #fff; color: #111827; border: 1px solid rgba(255,255,255,0.18); }
#boqModal .form-row input:focus,
#boqModal .form-row select:focus { border-color: #7dd3fc; }
#boqModal .empty-hint {
    background: rgba(255,255,255,0.05);
    border: 1px dashed rgba(255,255,255,0.2);
    color: #cbd5e1;
}
#boqModal .table-scroll { border: 1px solid rgba(255,255,255,0.14); }
#boqModal .data-table td { color: #e2e8f0; border-bottom: 1px solid rgba(255,255,255,0.08); }
#boqModal .boq-table td:nth-child(2), #boqModal .boq-table td:nth-child(3) { color: #a8bedb; }
#boqModal .boq-grand-total { background: rgba(125,211,252,0.12); border-color: rgba(125,211,252,0.4); color: #7dd3fc; }
#boqModal .form-actions .btn { color: #fff; background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.18); }
#boqModal .form-actions .btn:hover { background: rgba(255,255,255,0.2); }

/* ---------------------------- Print report ---------------------------- */

#printReport { display: none; }

@media print {
    html, body { background: #fff; }
    body * { visibility: hidden; }
    #printReport, #printReport * { visibility: visible; }
    #printReport {
        display: block;
        position: absolute;
        left: 0; top: 0; width: 100%;
        padding: 0;
        color: #1e293b;
        font-family: var(--font);
        font-size: 11.5px;
        line-height: 1.4;
    }

    .pr-header {
        display: flex;
        align-items: flex-end;
        justify-content: space-between;
        border-bottom: 3px solid #0891b2;
        padding-bottom: 8px;
        margin-bottom: 12px;
    }
    .pr-header h1 { font-size: 19px; margin: 0; color: #0e293a; letter-spacing: 0.01em; }
    .pr-meta { font-size: 10px; color: #64748b; }

    .pr-section-title {
        font-size: 12px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: #0e7490;
        margin: 16px 0 8px;
        padding: 5px 0 5px 10px;
        border-left: 4px solid #0891b2;
        background: #f0fbfd;
    }
    .pr-header + .pr-section-title,
    #printReport > .pr-section-title:first-child { margin-top: 0; }

    .pr-verdict {
        display: inline-block;
        font-size: 15px;
        font-weight: 800;
        letter-spacing: 0.03em;
        padding: 6px 16px;
        border-radius: 4px;
        margin-bottom: 10px;
        border: 1px solid;
    }
    .pr-verdict.ok { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
    .pr-verdict.warn { background: #fffbeb; color: #92400e; border-color: #fde68a; }
    .pr-verdict.danger { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

    .pr-summary { border-collapse: collapse; margin-bottom: 10px; width: 100%; max-width: 520px; }
    .pr-summary td { padding: 4px 16px 4px 0; font-size: 11px; border-bottom: 1px solid #eef2f6; }
    .pr-summary td:first-child { color: #64748b; width: 55%; }
    .pr-summary tr:last-child td { border-bottom: none; }

    .pr-chart { width: 100%; max-width: 620px; height: auto; border: 1px solid #e2e8f0; border-radius: 4px; margin-bottom: 10px; display: block; }

    .pr-table { width: 100%; border-collapse: collapse; font-size: 10.5px; margin-bottom: 10px; }
    .pr-table th {
        background: #0f172a;
        color: #fff;
        font-weight: 600;
        text-align: left;
        padding: 6px 8px;
        border: 1px solid #0f172a;
    }
    .pr-table td { padding: 5px 8px; border: 1px solid #e2e8f0; }
    .pr-table tbody tr:nth-child(even) { background: #f8fafc; }

    .pr-badge {
        display: inline-block;
        padding: 1px 8px;
        border-radius: 9px;
        font-size: 9.5px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.02em;
    }
    .pr-badge.ok { background: #dcfce7; color: #166534; }
    .pr-badge.warn { background: #fef3c7; color: #92400e; }
    .pr-badge.danger { background: #fee2e2; color: #991b1b; }

    .pr-warnings { margin: 0 0 10px; padding-left: 0; list-style: none; font-size: 10.5px; }
    .pr-warnings li {
        margin-bottom: 5px;
        padding: 6px 10px;
        border-left: 3px solid #d97706;
        background: #fffbeb;
        border-radius: 0 3px 3px 0;
    }
    .pr-warnings em { color: #78716c; font-style: normal; display: block; margin-top: 3px; }

    .pr-summary-total {
        text-align: right;
        font-size: 13px;
        margin: 2px 0 14px;
        padding: 8px 12px;
        background: #ecfeff;
        border: 1px solid #a5f3fc;
        border-radius: 4px;
        color: #0e7490;
    }
    .pr-summary-total strong { font-size: 15px; }

    .pr-footer {
        margin-top: 18px;
        font-size: 9px;
        color: #94a3b8;
        border-top: 1px solid #e2e8f0;
        padding-top: 6px;
        text-align: center;
    }
    @page { margin: 12mm 14mm; }
}
