/* =====================================================================
   assets/css/app.css
   SINGLE global stylesheet for the entire HopeLine app — Admin, Manager,
   and Responder all link ONLY this file.

   Structure:
     1. Theme variables (dark default + [data-theme="light"] override)
     2. Base / reset
     3. Sidebar (shared shell used by all three roles)
     4. Page shell (.main, headers, alerts, cards, forms, buttons)
     5. Shared badges/pills (severity, status)
     6. Page-specific sections
     7. RESPONSIVE  <-- icon-rail sidebar + every breakpoint lives here
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. THEME VARIABLES
   --------------------------------------------------------------------- */
:root {
    --burnt-umber: #FE7743;
    --redwood: #E0632E;
    --macadamia: #EFEEEA;
    --cool-blue: #121212;
    --light-grayish: #92A5B3;
    --bg-page: #000000;

    --surface-rgb: 239, 238, 234;
    --border-rgb: 125, 147, 163;

    --critical: #b02029;
    --high: #d9752b;
    --moderate: #d4ab2b;
    --low: #3f7a5c;

    --available: var(--low);
    --enroute: var(--high);
    --onsite: var(--critical);
    --returning: var(--light-grayish);

    /* Layout: section 7 swaps --sidebar-w to --rail-w on small screens,
       so .sidebar and .main follow automatically. */
    --sidebar-w: 248px;
    --rail-w: 60px;
}

[data-theme="light"] {
    --macadamia: #273F4F;
    --cool-blue: #FFFFFF;
    --light-grayish: #5B6B78;
    --bg-page: #FFFFFF;

    --surface-rgb: 39, 63, 79;
    --border-rgb: 39, 63, 79;
}

/* ---------------------------------------------------------------------
   2. BASE / RESET
   --------------------------------------------------------------------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { height: 100%; }
html { overflow: hidden; overflow: clip; }

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-page);
  
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
}

select option { background: var(--cool-blue); color: var(--macadamia); }

/* Keep Leaflet's internal z-indexes (400-1000) from escaping the map box
   and painting over the sidebar / modals. */
.leaflet-container { z-index: 0; }

/* ---------------------------------------------------------------------
   3. SIDEBAR (shared shell — Admin, Manager, Responder)
   --------------------------------------------------------------------- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-page);
    height: 100vh;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(var(--border-rgb), 0.15);
    flex-shrink: 0;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10;
}

.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 14px; }
.sidebar-actions { display: flex; align-items: center; gap: 4px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 26px; height: 26px; border-radius: 6px; background: var(--burnt-umber); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-mark svg { width: 15px; height: 15px; }
.brand-name { color: var(--macadamia); font-weight: 700; font-size: 14.5px; letter-spacing: 0.2px; }
.brand-role { color: var(--light-grayish); font-size: 10px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase; }

.header-icon {
    width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center;
    color: var(--light-grayish); cursor: pointer; position: relative; text-decoration: none; border: none; background: none;
}
.header-icon:hover { background: rgba(var(--border-rgb), 0.14); color: var(--macadamia); }
.header-icon svg { width: 16px; height: 16px; }

.notif-dot { position: absolute; top: 5px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--redwood); border: 1.5px solid var(--bg-page); }

.search-wrap { margin: 4px 12px 14px; position: relative; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--light-grayish); pointer-events: none; }
.search-input { width: 100%; background: rgba(var(--surface-rgb), 0.08); border: 1px solid rgba(var(--border-rgb), 0.25); border-radius: 7px; color: var(--macadamia); font-size: 12.5px; outline: none; }
/* Higher specificity on purpose: the generic input[type="text"] rule used to
   reset this padding and the placeholder ran underneath the search icon. */
.sidebar .search-wrap .search-input { padding: 8px 58px 8px 32px; }
.search-input::placeholder { color: var(--light-grayish); }
.search-input:focus { border-color: var(--redwood); }

.kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); display: flex; gap: 3px; }
.kbd span { background: rgba(var(--border-rgb), 0.2); color: var(--light-grayish); font-size: 10px; padding: 1.5px 5px; border-radius: 4px; font-family: monospace; }

.nav { flex: 1; padding: 2px 10px; overflow-y: auto; }
.nav-section-label { color: var(--light-grayish); font-size: 10px; font-weight: 700; letter-spacing: 0.7px; text-transform: uppercase; padding: 14px 8px 6px; opacity: 0.8; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; color: var(--light-grayish); font-size: 13px; font-weight: 500; text-decoration: none; cursor: pointer; margin-bottom: 2px; transition: background 0.12s ease, color 0.12s ease; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item .nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { background: rgba(var(--surface-rgb), 0.08); color: var(--macadamia); }
.nav-item.active { background: var(--burnt-umber); color: #FFFFFF; }
.nav-item:focus-visible, .header-icon:focus-visible, .logout-btn:focus-visible { outline: 2px solid var(--redwood); outline-offset: 2px; }
.nav-item .badge { margin-left: auto; background: var(--redwood); color: #FFFFFF; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 20px; }

.sidebar-footer { padding: 12px; border-top: 1px solid rgba(var(--border-rgb), 0.15); display: flex; align-items: center; gap: 8px; }
.status-card { flex: 1; min-width: 0; background: rgba(var(--surface-rgb), 0.06); border: 1px solid rgba(var(--border-rgb), 0.18); border-radius: 8px; padding: 10px 12px; display: flex; align-items: center; gap: 9px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #4caf7d; box-shadow: 0 0 0 3px rgba(76, 175, 125, 0.18); flex-shrink: 0; }
.status-text { min-width: 0; }
.status-text .t1 { color: var(--macadamia); font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-text .t2 { color: var(--light-grayish); font-size: 10.5px; margin-top: 1px; }

.logout-btn { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--light-grayish); background: rgba(176, 32, 41, 0.08); border: 1px solid rgba(176, 32, 41, 0.25); text-decoration: none; transition: background 0.15s, color 0.15s; }
.logout-btn:hover { background: var(--redwood); color: #FFFFFF; }
.logout-btn svg { width: 16px; height: 16px; }

/* ---------------------------------------------------------------------
   4. PAGE SHELL
   --------------------------------------------------------------------- */
.main {
    width: auto;          /* instead of relying on flex:1 */
    min-width: 0;
    --content-max: 1280px;
    flex: 1; min-width: 0;
    margin-left: var(--sidebar-w);
    padding: 26px 32px 50px;
    color: var(--macadamia);
    max-width: 1280px;
    height: 100vh;
    overflow-y: auto;
    overflow-wrap: break-word;
}
.main-1180 { --content-max: 1180px; max-width: 1180px; padding-bottom: 60px; }
.main-1100 { --content-max: 1100px; max-width: 1100px; }
.main-1320 { --content-max: 1320px; max-width: 1320px; overflow-x: auto; }
.main-720  { --content-max: 720px;  max-width: 720px; }
.main-640  { --content-max: 640px;  max-width: 640px; }
.main-900  { --content-max: 900px;  max-width: 900px; }

.main-fullscreen { padding: 0; max-width: none; margin-left: var(--sidebar-w); display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* Big monitors: centre the content column and let the scrollbar sit at the
   window edge (before, the scroll box stopped at 1280px, mid-screen). */
@media (min-width: 1500px) {
    .main:not(.main-fullscreen) {
        max-width: none;
        padding-left: max(32px, calc((100vw - var(--sidebar-w) - var(--content-max)) / 2));
        padding-right: max(32px, calc((100vw - var(--sidebar-w) - var(--content-max)) / 2));
    }
}

.page-head { margin-bottom: 18px; }
.page-head h1 { font-size: 21px; margin-bottom: 4px; }
.page-head p { color: var(--light-grayish); font-size: 13px; }
.page-head--flex { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 10px; }

.clip-ref-preview { display: inline-block; margin-top: 8px; font-size: 11px; font-weight: 700; letter-spacing: 0.5px; color: var(--light-grayish); background: rgba(var(--border-rgb), 0.12); border: 1px solid rgba(var(--border-rgb), 0.25); padding: 4px 10px; border-radius: 20px; }

.alert-banner, .flash { padding: 12px 16px; border-radius: 6px; font-size: 13px; margin-bottom: 18px; }
.alert-success, .flash { background: rgba(63,122,92,0.18); border: 1px solid #3f7a5c; color: #b7ecd1; }
.alert-error { background: rgba(176,32,41,0.15); border: 1px solid var(--redwood); color: #ffd0d3; }
.alert-error ul { margin: 6px 0 0 18px; }

.card { background: rgba(var(--surface-rgb), 0.04); border: 1px solid rgba(var(--border-rgb), 0.18); border-radius: 10px; padding: 18px 20px; margin-bottom: 18px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-header h2 { font-size: 14.5px; font-weight: 700; }
.card-header a { font-size: 11.5px; color: var(--light-grayish); text-decoration: none; }
.card-header a:hover { color: var(--macadamia); }

.empty-state { text-align: center; padding: 50px 20px; color: var(--light-grayish); font-size: 13px; }
.empty-state svg { width: 44px; height: 44px; display: block; margin: 0 auto 12px; opacity: .5; }
.empty-state h2 { font-size: 16px; margin-bottom: 6px; }
.empty-mini { text-align: center; padding: 20px; color: var(--light-grayish); font-size: 12px; }

input[type="text"], input[type="tel"], input[type="number"], input[type="date"], input[type="email"], input[type="password"],
select, textarea {
    background: rgba(var(--surface-rgb), 0.06);
    border: 1px solid rgba(var(--border-rgb), 0.28);
    border-radius: 6px;
    padding: 9px 11px;
    color: var(--macadamia);
    font-size: 13px;
    outline: none;
    font-family: inherit;
    max-width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--light-grayish); opacity: 0.7; }
input:focus, select:focus, textarea:focus { border-color: var(--redwood); }
textarea { resize: vertical; min-height: 60px; width: 100%; }

label { display: block; font-size: 12px; font-weight: 600; color: var(--macadamia); margin-bottom: 6px; }
label .optional { color: var(--light-grayish); font-weight: 400; font-size: 10.5px; }

.btn-primary, button[type="submit"] {
    background: var(--burnt-umber); color: #FFFFFF; border: 0; padding: 10px 20px; border-radius: 50px;
    font-weight: 700; font-size: 13px; cursor: pointer; text-decoration: none;
    display: inline-flex; align-items: center; gap: 7px; transition: background 0.15s;
}
.btn-primary:hover, button[type="submit"]:hover { background: var(--redwood); }
.btn-primary:disabled, button[type="submit"]:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary svg { width: 14px; height: 14px; }

.btn-filter { background: var(--burnt-umber); color: #FFFFFF; border: 0; padding: 9px 18px; border-radius: 20px; font-weight: 700; font-size: 12px; cursor: pointer; }
.btn-filter:hover { background: var(--redwood); }

.btn-tool { display: flex; align-items: center; gap: 6px; background: rgba(var(--border-rgb), 0.14); border: 1px solid rgba(var(--border-rgb), 0.3); color: var(--macadamia); font-size: 12px; font-weight: 600; padding: 8px 12px; border-radius: 6px; cursor: pointer; transition: background 0.15s; }
.btn-tool:hover { background: rgba(var(--border-rgb), 0.24); }
.btn-tool svg { width: 14px; height: 14px; }

.btn-dispatch { border: 0; border-radius: 20px; padding: 8px 16px; font-size: 12px; font-weight: 700; cursor: pointer; background: var(--burnt-umber); color: #FFFFFF; }
.btn-dispatch:hover { background: var(--redwood); }

.btn-resolve { background: rgba(63,122,92,0.2); color: #7fd6a5; border: 1px solid #3f7a5c; border-radius: 20px; padding: 6px 13px; font-size: 11px; font-weight: 700; cursor: pointer; }
.btn-resolve:hover { background: rgba(63,122,92,0.35); }

.btn-cancel { background: transparent; border: 1px solid rgba(var(--border-rgb), 0.3); color: var(--light-grayish); border-radius: 20px; padding: 8px 16px; font-size: 12px; cursor: pointer; }

.btn-mini { border: 0; border-radius: 20px; padding: 5px 11px; font-size: 11px; font-weight: 700; cursor: pointer; }
.btn-deactivate { background: rgba(176,32,41,0.15); color: var(--redwood); }
.btn-activate { background: rgba(63,122,92,0.15); color: #3f7a5c; }
.btn-cancel-inc { background: rgba(176,32,41,0.15); color: var(--redwood); border: 0; border-radius: 20px; padding: 5px 11px; font-size: 11px; font-weight: 700; cursor: pointer; }
.btn-save { background: var(--burnt-umber); color: #FFFFFF; border: 0; padding: 12px 26px; border-radius: 50px; font-weight: 700; font-size: 13.5px; cursor: pointer; margin-top: 6px; }
.btn-save:hover { background: var(--redwood); }
.btn-submit { width: 100%; background: var(--burnt-umber); color: #FFFFFF; border: 0; padding: 13px; border-radius: 10px; font-weight: 700; font-size: 14px; cursor: pointer; }
.btn-submit:hover { background: var(--redwood); }
.btn-inline { background: var(--burnt-umber); color: #FFFFFF; border: 0; padding: 10px 20px; border-radius: 50px; font-weight: 700; font-size: 12.5px; cursor: pointer; text-decoration: none; display: inline-block; white-space: nowrap; }
.btn-inline:hover { background: var(--redwood); }
.btn-action { display: inline-flex; align-items: center; gap: 10px; border: 0; padding: 16px 36px; border-radius: 50px; background: var(--burnt-umber); color: #FFFFFF; font-weight: 700; font-size: 15px; cursor: pointer; transition: background 0.15s; }
.btn-action:hover { background: var(--redwood); }
.btn-action svg { width: 18px; height: 18px; }
.btn-secondary { display: inline-block; margin-top: 14px; font-size: 12px; color: var(--light-grayish); text-decoration: none; }

/* ---------------------------------------------------------------------
   5. SHARED BADGES / PILLS
   --------------------------------------------------------------------- */
.sev-badge, .role-badge, .tag, .status-pill, .incident-status, .status-badge {
    font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 3px 10px; border-radius: 20px; letter-spacing: 0.3px; white-space: nowrap;
}
.sev-Critical, .status-critical { background: rgba(176,32,41,0.2); color: var(--critical); }
.sev-High, .status-high { background: rgba(217,117,43,0.2); color: var(--high); }
.sev-Moderate, .status-moderate { background: rgba(212,171,43,0.2); color: var(--moderate); }
.sev-Low, .status-low { background: rgba(63,122,92,0.2); color: var(--low); }

.status-pending { background: rgba(217,117,43,0.18); color: var(--high); }
.status-dispatched, .status-en_route { background: rgba(var(--border-rgb), 0.2); color: var(--light-grayish); }
.status-on_site { background: rgba(176,32,41,0.18); color: var(--redwood); }
.status-resolved, .status-success, .status-active { background: rgba(63,122,92,0.2); color: #3f7a5c; }
.status-cancelled { background: rgba(var(--border-rgb), 0.15); color: var(--light-grayish); text-decoration: line-through; }
.status-failed { background: rgba(176,32,41,0.2); color: var(--redwood); }
.status-inactive { background: rgba(var(--border-rgb), 0.2); color: var(--light-grayish); }

.role-admin { background: rgba(176,32,41,0.2); color: var(--redwood); }
.role-manager { background: rgba(217,117,43,0.2); color: var(--high); }
.role-user { background: rgba(63,122,92,0.2); color: #3f7a5c; }

.tag-active { background: rgba(217,117,43,0.2); color: var(--high); }
.tag-resolved { background: rgba(63,122,92,0.2); color: #3f7a5c; }
.tag-manual { background: rgba(var(--border-rgb), 0.2); color: var(--light-grayish); }
.tag-auto { background: rgba(var(--border-rgb), 0.1); color: var(--light-grayish); }

/* =====================================================================
   6. PAGE-SPECIFIC SECTIONS
   ===================================================================== */

/* ---------- Dashboards (Admin + Manager + Responder) ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: rgba(var(--surface-rgb), 0.04); border: 1px solid rgba(var(--border-rgb), 0.18); border-radius: 10px; padding: 16px 18px; min-width: 0; }
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.stat-icon { width: 30px; height: 30px; border-radius: 7px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 15px; height: 15px; color: #FFFFFF; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--macadamia); }
.stat-label { font-size: 11.5px; color: var(--light-grayish); margin-top: 2px; }
.stat-sub { font-size: 10.5px; margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.stat-sub.warn { color: var(--high); }
.stat-sub.ok { color: var(--low); }

.dash-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }

.incident-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid rgba(var(--border-rgb), 0.1); }
.incident-row:last-child { border-bottom: none; }
.sev-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.incident-main { flex: 1; min-width: 0; }
.incident-title { font-size: 13px; font-weight: 600; color: var(--macadamia); margin-bottom: 2px; }
.incident-meta { font-size: 11px; color: var(--light-grayish); }
.incident-time { font-size: 11px; color: var(--light-grayish); text-align: right; min-width: 55px; }

.breakdown-row, .unit-status-row, .bar-row { margin-bottom: 14px; }
.breakdown-row:last-child, .unit-status-row:last-child, .bar-row:last-child { margin-bottom: 0; }
.breakdown-label, .unit-status-label, .bar-label { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 12px; margin-bottom: 6px; }
.breakdown-label .n, .unit-status-label .n, .bar-label .n { font-weight: 700; color: var(--macadamia); }
.bar-track { height: 7px; background: rgba(var(--border-rgb), 0.15); border-radius: 20px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 20px; }

.audit-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(var(--border-rgb), 0.1); font-size: 12px; }
.audit-row:last-child { border-bottom: none; }
.audit-action { font-weight: 600; }
.audit-meta { color: var(--light-grayish); font-size: 10.5px; }
.audit-status { font-size: 9.5px; font-weight: 700; text-transform: uppercase; padding: 2px 8px; border-radius: 20px; }

.delay-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid rgba(var(--border-rgb), 0.1); }
.delay-item:last-child { border-bottom: none; }
.delay-item svg { width: 15px; height: 15px; color: var(--high); flex-shrink: 0; margin-top: 1px; }
.delay-item .t { font-size: 12.5px; color: var(--macadamia); font-weight: 600; }
.delay-item .s { font-size: 11px; color: var(--light-grayish); }

/* ---------- Toolbars / filter bars (used across list pages) ---------- */
.toolbar, .filter-bar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: flex-end; }
.filter-bar { background: rgba(var(--surface-rgb), 0.04); border: 1px solid rgba(var(--border-rgb), 0.18); border-radius: 10px; padding: 14px 16px; }
.filter-field label { display: block; font-size: 10.5px; color: var(--light-grayish); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.4px; }

/* ---------- Data tables (Incidents, Audit Trail, History, Delay Reports) ---------- */
table { width: 100%; border-collapse: collapse; background: rgba(var(--surface-rgb), 0.04); border: 1px solid rgba(var(--border-rgb), 0.18); border-radius: 10px; overflow: hidden; }
thead th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--light-grayish); padding: 12px 14px; border-bottom: 1px solid rgba(var(--border-rgb), 0.18); white-space: nowrap; }
tbody td { padding: 11px 14px; font-size: 12.5px; border-bottom: 1px solid rgba(var(--border-rgb), 0.08); vertical-align: middle; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(var(--surface-rgb), 0.03); }

.clip-ref-cell { font-family: monospace; font-size: 11px; color: var(--light-grayish); }
.delay-flag { color: var(--high); font-weight: 700; }
.no-delay { color: var(--light-grayish); }

.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 18px; }
.pagination a { display: inline-block; padding: 7px 12px; border-radius: 6px; font-size: 12px; color: var(--light-grayish); text-decoration: none; border: 1px solid rgba(var(--border-rgb), 0.2); }
.pagination a.active { background: var(--burnt-umber); color: #FFFFFF; border-color: var(--burnt-umber); }
.pagination a:hover:not(.active) { border-color: var(--light-grayish); }

/* ---------- Modal (User Create, Add Unit, Manual Delay, Case Details) ---------- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 1000; align-items: center; justify-content: center; padding: 14px; }
.modal-overlay.show { display: flex; }
.modal { background: var(--cool-blue); border: 1px solid rgba(var(--border-rgb), 0.3); border-radius: 10px; padding: 22px; width: 100%; max-width: 420px; max-height: calc(100vh - 28px); max-height: calc(100dvh - 28px); overflow-y: auto; }
.modal h3 { font-size: 15px; margin-bottom: 14px; }
.modal .field { margin-bottom: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- Active Incidents ---------- */
.incident-card { background: rgba(var(--surface-rgb), 0.04); border: 1px solid rgba(var(--border-rgb), 0.18); border-radius: 10px; padding: 16px 18px; margin-bottom: 12px; }
.incident-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.incident-title-wrap { display: flex; align-items: center; gap: 10px; }
.clip-ref { font-size: 10.5px; color: var(--light-grayish); font-family: monospace; }
.incident-body { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.info-block .label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--light-grayish); margin-bottom: 3px; }
.info-block .value { font-size: 12.5px; color: var(--macadamia); font-weight: 600; }
.info-block.full { grid-column: 1 / -1; }
.incident-actions { display: flex; align-items: center; gap: 10px; padding-top: 12px; border-top: 1px dashed rgba(var(--border-rgb), 0.2); flex-wrap: wrap; }
.dispatch-form { display: flex; gap: 8px; align-items: center; flex: 1; }
.dispatch-form select { flex: 1; max-width: 220px; padding: 7px 10px; font-size: 12px; }
.assigned-unit-tag { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--macadamia); font-weight: 600; }
.assigned-unit-tag svg { width: 14px; height: 14px; color: var(--light-grayish); }

/* ---------- CLIP Report ---------- */
.card-title { display: flex; align-items: center; gap: 9px; margin-bottom: 4px; }
.step-num { width: 22px; height: 22px; border-radius: 50%; background: var(--burnt-umber); color: #FFFFFF; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.card-title h2 { font-size: 14.5px; font-weight: 700; }
.card-sub { color: var(--light-grayish); font-size: 11.5px; margin: 2px 0 16px 31px; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.loc-tools { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
#map { height: 220px; border-radius: 8px; margin-bottom: 12px; border: 1px solid rgba(var(--border-rgb), 0.3); }
.coords-readout { font-size: 11.5px; color: var(--light-grayish); margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.coords-readout strong { color: var(--macadamia); font-family: monospace; }

.incident-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 4px; }
.incident-option { position: relative; }
.incident-option input { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.incident-option label { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px; border: 1px solid rgba(var(--border-rgb), 0.28); border-radius: 8px; text-align: center; font-size: 11.5px; font-weight: 600; cursor: pointer; margin: 0; color: var(--macadamia); transition: border-color 0.15s, background 0.15s; }
.incident-option label svg { width: 20px; height: 20px; }
.incident-option input:checked + label { border-color: var(--burnt-umber); background: rgba(254, 119, 67, 0.28); }
.incident-option input:focus-visible + label { outline: 2px solid var(--redwood); outline-offset: 2px; }

.severity-wrap { margin-top: 16px; padding-top: 16px; border-top: 1px dashed rgba(var(--border-rgb), 0.25); display: none; }
.severity-wrap.show { display: block; }
.severity-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.col-main, .col-side { min-width: 0; }
.col-side { align-self: stretch; }


.main { position: relative; }

.sev-option { position: relative; }
.sev-option input {
    position: absolute; opacity: 0;
    width: 1px; height: 1px; margin: 0; pointer-events: none;
}
.sev-option input:focus-visible + label { outline: 2px solid var(--redwood); outline-offset: 2px; }
.sev-option label { display: block; text-align: center; padding: 10px 6px; border-radius: 7px; font-size: 12px; font-weight: 700; cursor: pointer; border: 1.5px solid transparent; opacity: 0.55; transition: opacity 0.15s, border-color 0.15s; }
.sev-option input:checked + label { opacity: 1; border-color: currentColor; }
.sev-critical label { background: rgba(176,32,41,0.18); color: var(--critical); }
.sev-high label { background: rgba(217,117,43,0.18); color: var(--high); }
.sev-moderate label { background: rgba(212,171,43,0.18); color: var(--moderate); }
.sev-low label { background: rgba(63,122,92,0.18); color: var(--low); }
.status-assigned, .status-returning { background: rgba(var(--border-rgb),0.2); color: var(--light-grayish); }
/* Resource picker ("Problem" card) */
.resource-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.resource-option { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid rgba(var(--border-rgb), 0.28); border-radius: 8px; padding: 10px 12px; color: var(--macadamia); transition: border-color .15s, background-color .15s; }
.resource-option.suggested { border-color: var(--redwood); background: rgba(224, 99, 46, 0.12); }
.resource-option.has-qty { border-color: #3f7a5c; }
.resource-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.resource-name { font-weight: 600; font-size: 13px; line-height: 1.25; }
.resource-available { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--light-grayish); }
.resource-available::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #3f7a5c; flex-shrink: 0; }
.resource-option.unavailable .resource-available { color: #e0705a; }
.resource-option.unavailable .resource-available::before { background: var(--critical); }
.suggest-tag { font-size: 9.5px; font-weight: 700; color: var(--redwood); text-transform: uppercase; letter-spacing: 0.4px; }
.qty-control { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.qty-btn { width: 30px; height: 30px; border: 1px solid rgba(var(--border-rgb), 0.3); border-radius: 6px; background: #fff; color: #111827; font-size: 16px; line-height: 1; cursor: pointer; }
.qty-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.qty-input { width: 34px; height: 30px; text-align: center; font-weight: 700; padding: 0; -moz-appearance: textfield; }

.submit-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* Sticky wrapper: summary + Log button travel together */
.side-sticky {
    position: sticky;
    top: 0;
    max-height: calc(100vh - 20px);
    overflow-y: auto;
}
.summary-card { position: static; margin-bottom: 14px; background: rgba(var(--surface-rgb), 0.04); border: 1px solid rgba(var(--border-rgb), 0.18); border-radius: 10px; padding: 18px; }
.summary-card h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--light-grayish); margin-bottom: 14px; }
.summary-row { margin-bottom: 12px; }
.summary-row .label { font-size: 10.5px; color: var(--light-grayish); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 2px; }
.summary-row .value { font-size: 13px; font-weight: 600; color: var(--macadamia); }
.summary-row .value.empty { color: var(--light-grayish); opacity: 0.6; font-weight: 400; font-style: italic; }
.summary-severity { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }

.checklist { list-style: none; margin-top: 16px; padding-top: 16px; border-top: 1px dashed rgba(var(--border-rgb), 0.25); }
.checklist li { font-size: 11.5px; color: var(--light-grayish); display: flex; align-items: center; gap: 7px; margin-bottom: 7px; }
.checklist li svg { width: 13px; height: 13px; flex-shrink: 0; }
.checklist li.done { color: #b7ecd1; }
.checklist li.done svg { color: #3f7a5c; }

.leaflet-routing-container { display: none !important; }

/* ---------- CLIP Report: PTV ETA panel ---------- */
.eta-panel {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 14px;
    margin-bottom: 12px;
    border-radius: 8px;
    border: 1px solid rgba(var(--border-rgb), 0.25);
    background: rgba(var(--surface-rgb), 0.06);
}
.eta-panel.eta-pending { opacity: 0.65; }

.eta-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(217,117,43,0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.eta-icon svg { width: 18px; height: 18px; color: var(--high); }

.eta-main { flex: 1; min-width: 160px; }
.eta-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--light-grayish);
    margin-bottom: 2px;
}
.eta-value { font-size: 14px; font-weight: 700; color: var(--macadamia); }
.eta-value span { font-size: 11px; font-weight: 400; color: var(--light-grayish); margin-left: 4px; }

.eta-breakdown {
    flex-basis: 100%;
    font-size: 11px;
    color: var(--light-grayish);
    margin-top: 2px;
}

#sumEta.eta-highlight { color: var(--high); font-weight: 700; }

/* ---------- Delay Alerts (Manager) + Delay Reports (Admin) ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab { font-size: 12px; font-weight: 600; padding: 7px 14px; border-radius: 20px; border: 1px solid rgba(var(--border-rgb), 0.3); color: var(--light-grayish); cursor: pointer; }
.tab.active { background: var(--burnt-umber); border-color: var(--burnt-umber); color: #FFFFFF; }

.delay-card { background: rgba(var(--surface-rgb), 0.04); border: 1px solid rgba(var(--border-rgb), 0.18); border-radius: 10px; padding: 15px 18px; margin-bottom: 10px; display: flex; gap: 14px; align-items: flex-start; }
.delay-card.active-delay { border-color: var(--high); background: rgba(217,117,43,0.06); }
.delay-icon { width: 34px; height: 34px; border-radius: 8px; background: rgba(217,117,43,0.2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.delay-icon svg { width: 17px; height: 17px; color: var(--high); }
.delay-main { flex: 1; min-width: 0; }
.delay-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.delay-title { font-size: 13.5px; font-weight: 700; }
.delay-tag { font-size: 9.5px; font-weight: 700; text-transform: uppercase; padding: 2px 8px; border-radius: 20px; letter-spacing: 0.3px; }
.delay-meta { font-size: 11.5px; color: var(--light-grayish); margin-bottom: 4px; }
.delay-notes { font-size: 12px; color: var(--macadamia); opacity: 0.85; }
.delay-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.delay-duration { font-size: 11px; color: var(--light-grayish); text-align: right; }
.delay-duration strong { color: var(--macadamia); }

/* ---------- Live Unit Map ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; border-bottom: 1px solid rgba(var(--border-rgb), 0.15); flex-shrink: 0; }
.topbar h1 { font-size: 18px; color: var(--macadamia); margin-bottom: 3px; }
.live-indicator { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--light-grayish); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #3f7a5c; box-shadow: 0 0 0 0 rgba(63,122,92, 0.5); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(63,122,92, 0.5); } 70% { box-shadow: 0 0 0 6px rgba(63,122,92, 0); } 100% { box-shadow: 0 0 0 0 rgba(63,122,92, 0); } }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.last-updated { font-size: 10.5px; color: var(--light-grayish); }
.content { flex: 1; display: flex; overflow: hidden; min-height: 0; }
.units-panel { width: 320px; flex-shrink: 0; border-right: 1px solid rgba(var(--border-rgb), 0.15); display: flex; flex-direction: column; overflow: hidden; }
.panel-search { padding: 14px; border-bottom: 1px solid rgba(var(--border-rgb), 0.12); }
.search-input-wrap { position: relative; margin-bottom: 10px; }
.search-input-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--light-grayish); }
.search-input-wrap input { width: 100%; padding: 8px 10px 8px 30px; font-size: 12.5px; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 10.5px; font-weight: 600; padding: 5px 10px; border-radius: 20px; border: 1px solid rgba(var(--border-rgb), 0.3); color: var(--light-grayish); cursor: pointer; user-select: none; transition: all 0.15s; }
.chip.active { background: var(--burnt-umber); border-color: var(--burnt-umber); color: #FFFFFF; }
.units-list { flex: 1; overflow-y: auto; padding: 10px; }
.unit-card { display: flex; gap: 10px; padding: 11px; border-radius: 8px; border: 1px solid rgba(var(--border-rgb), 0.16); margin-bottom: 8px; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.unit-card:hover { border-color: var(--light-grayish); background: rgba(var(--surface-rgb), 0.03); }
.unit-card.focused { border-color: var(--redwood); background: rgba(176,32,41,0.08); }
.unit-icon { width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.unit-icon svg { width: 18px; height: 18px; color: #FFFFFF; }
.unit-info { flex: 1; min-width: 0; }
.unit-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 2px; }
.unit-name { font-size: 13px; font-weight: 700; color: var(--macadamia); }
.unit-sub { font-size: 11px; color: var(--light-grayish); margin-bottom: 4px; }
.unit-meta { display: flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--light-grayish); }
.unit-meta.alert { color: #f0b884; }
.unit-meta svg { width: 11px; height: 11px; }
.map-wrap { flex: 1; position: relative; min-width: 0; }
.map-wrap #map { height: 100%; width: 100%; }
.map-legend { position: absolute; bottom: 16px; left: 16px; z-index: 500; background: var(--cool-blue); border: 1px solid rgba(var(--border-rgb), 0.25); border-radius: 8px; padding: 10px 14px; font-size: 11px; color: var(--macadamia); display: flex; gap: 14px; }
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.leaflet-popup-content-wrapper { background: var(--cool-blue); color: var(--macadamia); border-radius: 8px; }
.leaflet-popup-tip { background: var(--cool-blue); }
.popup-title { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.popup-row { font-size: 11.5px; color: var(--light-grayish); margin-bottom: 2px; }
.popup-btn { display: inline-block; margin-top: 8px; background: var(--burnt-umber); color: #FFFFFF; font-size: 11px; font-weight: 700; padding: 6px 12px; border-radius: 20px; text-decoration: none; }

/* ---------- Admin: Users ---------- */
.role-select { background: rgba(var(--surface-rgb), 0.06); border: 1px solid rgba(var(--border-rgb), 0.28); border-radius: 5px; padding: 4px 7px; color: var(--macadamia); font-size: 11.5px; }
.row-actions { display: flex; gap: 6px; align-items: center; }

/* ---------- Admin: PTV/Unit Management ---------- */
.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; }
.ptv-unit-card {
    background: rgba(var(--surface-rgb), 0.04);
    border: 1px solid rgba(var(--border-rgb), 0.18);
    border-radius: 10px;
    padding: 18px 20px;
    min-width: 0;
}
.ptv-unit-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}
.ptv-unit-name { font-size: 15px; font-weight: 700; }
.unit-plate { font-size: 11px; color: var(--light-grayish); font-family: monospace; }
.status-select { font-size: 10.5px; font-weight: 700; text-transform: uppercase; padding: 4px 10px; border-radius: 20px; border: 0; cursor: pointer; letter-spacing: 0.3px; }
.st-Available { background: rgba(63,122,92,0.2); color: #3f7a5c; }
.st-EnRoute { background: rgba(217,117,43,0.2); color: var(--high); }
.st-OnSite { background: rgba(176,32,41,0.2); color: var(--redwood); }
.st-Returning { background: rgba(var(--border-rgb), 0.2); color: var(--light-grayish); }
.st-Offline { background: rgba(var(--border-rgb), 0.3); color: var(--light-grayish); }
.unit-field { margin-bottom: 10px; }
.unit-field .label { font-size: 10px; text-transform: uppercase; color: var(--light-grayish); margin-bottom: 5px; }
.unit-field select { width: 100%; }
.responder-tag { font-size: 12px; color: var(--macadamia); }
.no-responder { color: var(--light-grayish); font-style: italic; font-size: 12px; }

/* ---------- Admin: Settings ---------- */
.input-with-suffix { position: relative; }
.input-with-suffix .suffix { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--light-grayish); }
.card .desc { font-size: 11.5px; color: var(--light-grayish); margin-bottom: 14px; }

/* ---------- Admin: Delay Reports summary tiles ---------- */
.stats-grid.delays .stat-card .stat-value { font-size: 22px; }
.stats-grid.delays .stat-card .stat-label { font-size: 11px; }

/* ---------- Responder: Assigned Incident ---------- */
.incident-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.resources-list { display: flex; gap: 6px; flex-wrap: wrap; }
.resource-tag { background: rgba(var(--border-rgb), 0.15); color: var(--macadamia); font-size: 11.5px; padding: 4px 10px; border-radius: 20px; }
.cta-btn { display: block; text-align: center; width: 100%; padding: 14px; border-radius: 10px; background: var(--burnt-umber); color: #FFFFFF; font-weight: 700; font-size: 14.5px; text-decoration: none; margin-top: 6px; transition: background 0.15s; }
.cta-btn:hover { background: var(--redwood); }
.call-btn { display: inline-flex; align-items: center; gap: 6px; background: rgba(var(--border-rgb), 0.15); color: var(--macadamia); font-size: 12.5px; font-weight: 600; padding: 8px 14px; border-radius: 20px; text-decoration: none; }
.call-btn svg { width: 14px; height: 14px; }
.status-strip { font-size: 11px; color: var(--light-grayish); margin-bottom: 16px; display: flex; align-items: center; gap: 6px; }
.status-strip .dot { width: 8px; height: 8px; border-radius: 50%; background: #3f7a5c; }

/* ---------- Responder: Depart/Arrive Log timeline ---------- */
.incident-strip { background: rgba(var(--surface-rgb), 0.04); border: 1px solid rgba(var(--border-rgb), 0.18); border-radius: 10px; padding: 14px 18px; margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.incident-strip .title { font-size: 14px; font-weight: 700; }
.incident-strip .sub { font-size: 11px; color: var(--light-grayish); font-family: monospace; }

.timeline { display: flex; align-items: flex-start; margin-bottom: 30px; }
.tl-step { flex: 1; text-align: center; position: relative; min-width: 0; }
.tl-circle { width: 44px; height: 44px; border-radius: 50%; margin: 0 auto 10px; display: flex; align-items: center; justify-content: center; background: rgba(var(--border-rgb), 0.12); border: 2px solid rgba(var(--border-rgb), 0.3); color: var(--light-grayish); }
.tl-step.done .tl-circle { background: var(--burnt-umber); border-color: var(--burnt-umber); color: #FFFFFF; }
.tl-step.current .tl-circle { border-color: var(--redwood); color: var(--macadamia); animation: tlpulse 1.6s infinite; }
@keyframes tlpulse { 0% { box-shadow: 0 0 0 0 rgba(176,32,41,0.4); } 70% { box-shadow: 0 0 0 8px rgba(176,32,41,0); } 100% { box-shadow: 0 0 0 0 rgba(176,32,41,0); } }
.tl-circle svg { width: 18px; height: 18px; }
.tl-label { font-size: 12px; font-weight: 700; color: var(--macadamia); }
.tl-time { font-size: 10.5px; color: var(--light-grayish); margin-top: 2px; }
.tl-line { position: absolute; top: 22px; left: calc(-50% + 22px); width: calc(100% - 44px); height: 2px; background: rgba(var(--border-rgb), 0.25); z-index: -1; }
.tl-step.done .tl-line, .tl-step.current .tl-line { background: var(--burnt-umber); }
.tl-step:first-child .tl-line { display: none; }

.action-card { background: rgba(var(--surface-rgb), 0.04); border: 1px solid rgba(var(--border-rgb), 0.18); border-radius: 12px; padding: 26px; text-align: center; }
.elapsed-timer { font-size: 36px; font-weight: 700; font-family: monospace; margin-bottom: 6px; color: var(--macadamia); }
.elapsed-label { font-size: 11.5px; color: var(--light-grayish); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 20px; }
.done-msg { font-size: 14px; color: var(--macadamia); }

/* ---------- Responder: Report Delay ---------- */
.active-delay-card { background: rgba(217,117,43,0.1); border: 1px solid var(--high); border-radius: 12px; padding: 20px 22px; text-align: center; }
.active-delay-card .icon { width: 36px; height: 36px; margin: 0 auto 10px; color: var(--high); }
.active-delay-card h2 { font-size: 15px; margin-bottom: 4px; }
.active-delay-card .reason { font-size: 13px; color: var(--macadamia); margin-bottom: 2px; }
.active-delay-card .duration { font-size: 11.5px; color: var(--light-grayish); margin-bottom: 16px; }

/* ---------- Responder: Dashboard status banner + quick links ---------- */
.status-banner { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; border-radius: 12px; padding: 16px 20px; margin-bottom: 20px; border: 1px solid; }
.status-banner.available { background: rgba(63,122,92,0.1); border-color: #3f7a5c; }
.status-banner.assigned, .status-banner.en-route { background: rgba(217,117,43,0.1); border-color: var(--high); }
.status-banner.on-site { background: rgba(176,32,41,0.1); border-color: var(--redwood); }
.status-banner.returning { background: rgba(115,154,185,0.1); border-color: var(--returning); }
.status-banner .left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.status-banner .icon-wrap { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: rgba(var(--surface-rgb), 0.08); }
.status-banner .icon-wrap svg { width: 20px; height: 20px; color: var(--macadamia); }
.status-banner .title { font-size: 14.5px; font-weight: 700; }
.status-banner .sub { font-size: 12px; color: var(--light-grayish); }
.delay-note { font-size: 11.5px; color: var(--high); margin-top: 6px; font-weight: 600; }

.quick-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.quick-link { display: flex; align-items: center; gap: 12px; background: rgba(var(--surface-rgb), 0.04); border: 1px solid rgba(var(--border-rgb), 0.18); border-radius: 10px; padding: 14px 16px; text-decoration: none; color: var(--macadamia); transition: border-color 0.15s; }
.quick-link:hover { border-color: var(--light-grayish); }
.quick-link .qi { width: 34px; height: 34px; border-radius: 8px; background: rgba(var(--border-rgb), 0.15); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.quick-link .qi svg { width: 16px; height: 16px; color: var(--macadamia); }
.quick-link .qt { font-size: 13px; font-weight: 700; }
.quick-link .qs { font-size: 11px; color: var(--light-grayish); }

.hist-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(var(--border-rgb), 0.1); }
.hist-row:last-child { border-bottom: none; }
.hist-title { font-size: 12.5px; font-weight: 600; }
.hist-sub { font-size: 10.5px; color: var(--light-grayish); }

/* ---------- Responder: My Dispatch History cards ---------- */
.history-card { background: rgba(var(--surface-rgb), 0.04); border: 1px solid rgba(var(--border-rgb), 0.18); border-radius: 10px; padding: 15px 18px; margin-bottom: 10px; }
.hc-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.hc-title { font-size: 13.5px; font-weight: 700; }
.hc-ref { font-size: 10.5px; color: var(--light-grayish); font-family: monospace; }
.hc-grid { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));}
.hc-block .label { font-size: 9.5px; text-transform: uppercase; color: var(--light-grayish); margin-bottom: 3px; }
.hc-block .value { font-size: 12px; font-weight: 600; color: var(--macadamia); }
.hc-block .value.delay { color: var(--high); }
.outcome-pill{display:inline-block;margin:0 0 12px;padding:5px 12px;border-radius:20px;font-size:12px;font-weight:700}
.os-warn{background:rgba(217,117,43,.18);color:#a8540f}.os-ok{background:rgba(63,122,92,.2);color:#1d5139}.os-info{background:rgba(var(--border-rgb),.2);color:var(--macadamia)}
/* ---------- GPS status pill (every responder page) ---------- */
#gpsPill { position: fixed; top: 12px; right: 14px; z-index: 900; display: flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 20px; font-size: 11.5px; font-weight: 700; background: var(--cool-blue); color: var(--macadamia); border: 1px solid rgba(var(--border-rgb), 0.3); }
#gpsPill .gps-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--light-grayish); }
#gpsPill.gps-ok .gps-dot { background: #3f7a5c; box-shadow: 0 0 0 3px rgba(63,122,92,0.25); }
#gpsPill.gps-searching .gps-dot, #gpsPill.gps-starting .gps-dot, #gpsPill.gps-offline .gps-dot { background: var(--moderate); }
#gpsPill.gps-denied .gps-dot, #gpsPill.gps-unavailable .gps-dot, #gpsPill.gps-insecure .gps-dot { background: var(--critical); }

/* ---------- Blocking overlay when GPS is off / denied ---------- */
#gpsOverlay { display: none; position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,0.82); align-items: center; justify-content: center; padding: 24px; }
#gpsOverlay.show { display: flex; }
#gpsOverlay .gps-box { background: var(--cool-blue); border: 1px solid var(--critical); border-radius: 12px; padding: 24px; max-width: 380px; text-align: center; color: var(--macadamia); }
#gpsOverlay h2 { font-size: 17px; margin-bottom: 8px; }
#gpsOverlay p { font-size: 13px; color: var(--light-grayish); margin-bottom: 16px; line-height: 1.5; }
#gpsRetry { background: var(--burnt-umber); color: #FFFFFF; border: 0; padding: 10px 22px; border-radius: 50px; font-weight: 700; font-size: 13px; cursor: pointer; }
#gpsRetry:hover { background: var(--redwood); }

/* ---------- Responder navigation (assignment.php) ---------- */
.nav-card { background: rgba(var(--surface-rgb), 0.04); border: 1px solid rgba(var(--border-rgb), 0.18); border-radius: 12px; overflow: hidden; margin-bottom: 18px; }
.nav-banner { display: flex; align-items: center; gap: 14px; padding: 14px 18px; background: var(--burnt-umber); color: #FFFFFF; }
.nav-arrow { font-size: 34px; line-height: 1; width: 44px; text-align: center; flex-shrink: 0; }
.nav-instr { font-size: 17px; font-weight: 700; }
.nav-sub { font-size: 12px; opacity: 0.85; margin-top: 2px; }
.nav-map-wrap { position: relative; }
#navMap { height: 55vh; min-height: 340px; width: 100%; }
.btn-recenter { position: absolute; bottom: 14px; left: 14px; z-index: 500; display: none; background: var(--cool-blue); color: var(--macadamia); border: 1px solid rgba(var(--border-rgb), 0.4); border-radius: 20px; padding: 8px 14px; font-size: 12px; font-weight: 700; cursor: pointer; }
.btn-recenter.show { display: block; }
.nav-stats { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; padding: 12px; gap: 8px; }
.nav-stats .v { font-size: 18px; font-weight: 700; color: var(--macadamia); }
.nav-stats .l { font-size: 10.5px; color: var(--light-grayish); text-transform: uppercase; letter-spacing: 0.4px; }
.nav-note { font-size: 11.5px; color: var(--light-grayish); padding: 0 18px 12px; }
.me-arrow { width: 26px; height: 26px; }
.me-arrow svg { width: 26px; height: 26px; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.6)); }

/* =====================================================================
   7. RESPONSIVE
   ---------------------------------------------------------------------
   Breakpoints
     > 900px   full sidebar (248px, icons + labels)
     <= 900px  icon-only RAIL (60px) — also used on landscape phones
     <= 1050px stats 2-up, two-column pages become one column
     <= 700px  live map stacks (map over list), 2-col grids relax
     <= 600px  forms go single column, buttons go full width
     <= 480px  card grids go single column
     <= 340px  stat cards go single column
   ===================================================================== */

/* 7a. Helpers that apply at every size ------------------------------- */
.table-scroll { width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.layout > *, .dash-layout > * { min-width: 0; }

/* Touch screens have no keyboard: hide the ⌘K hint */
@media (hover: none) {
    .kbd { display: none; }
    .sidebar .search-wrap .search-input { padding-right: 10px; }
}

/* 7b. Tablets & small laptops (<= 1050px) ---------------------------- */
@media (max-width: 1050px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-layout, .layout { grid-template-columns: minmax(0, 1fr); }
    .side-sticky { position: static; max-height: none; overflow: visible; }
}

@media (max-width: 900px) {
    .incident-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 7c. ICON RAIL  (phones, small tablets, landscape phones) ----------- */
@media (max-width: 900px), (max-width: 1000px) and (max-height: 520px) {
    /* One variable swap resizes .sidebar AND .main's left margin */
    :root { --sidebar-w: var(--rail-w); }

    /* Let the page scroll naturally so the mobile address bar can collapse */
    html, body { height: auto; overflow: visible; }
    body { display: block; min-height: 100vh; min-height: 100dvh; overflow-x: hidden; }

    /* --- Rail --- */
    .sidebar { height: 100vh; height: 100dvh; }

    .sidebar-header { flex-direction: column; justify-content: center; gap: 8px; padding: 12px 0 8px; }
    .brand { gap: 0; justify-content: center; }
    .brand > div:not(.brand-mark) { display: none; }          /* HopeLine + role text */
   .sidebar-actions { flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 100%; }
    .header-icon { width: 40px; height: 40px; }
    .header-icon svg { width: 18px; height: 18px; }
    .notif-dot { top: 9px; right: 10px; }

    .search-wrap { display: none; }

    .nav { padding: 4px 8px; }
    .nav-section-label { height: 1px; margin: 8px 10px; padding: 0; font-size: 0; overflow: hidden; opacity: 1; background: rgba(var(--border-rgb), 0.18); }
   .nav-item { position: relative; justify-content: center; gap: 0; padding: 12px 0; margin-bottom: 4px; font-size: 0; }
    .nav-item svg { width: 20px; height: 20px; }
    .nav-item .nav-label { display: none; }
    .nav-item .badge { position: absolute; top: 3px; right: 3px; margin: 0; min-width: 16px; padding: 0 4px; font-size: 9px; line-height: 16px; text-align: center; }

    .sidebar-footer { flex-direction: column; gap: 8px; padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px)); }
    .status-card { flex: none; width: 40px; height: 40px; padding: 0; justify-content: center; }
    .status-text { display: none; }
    .logout-btn { width: 40px; height: 40px; }

    /* --- Page area --- */
    .main {
        width: auto; max-width: none; height: auto; overflow: visible;
        padding: 16px 14px calc(36px + env(safe-area-inset-bottom, 0px));
    }
    /* Responder pages: leave room for the floating GPS pill */
    body:has(#gpsPill) .main:not(.main-fullscreen) { padding-top: 52px; }
    #gpsPill { top: 10px; right: 10px; padding: 5px 10px; font-size: 11px; }

    .main-fullscreen { padding: 0; height: 100vh; height: 100dvh; overflow: hidden; }

    /* Form controls: 16px stops iOS zooming on focus; 42px = comfy tap target */
    .main input, .main select, .main textarea { font-size: 16px; }
    .main select, .main input:not([type="checkbox"]):not([type="radio"]) { min-height: 42px; }
    .main .role-select, .main .status-select { font-size: 12px; min-height: 0; }

    .btn-mini, .btn-resolve, .btn-cancel-inc, .btn-dispatch, .btn-cancel { padding: 8px 14px; }
    .row-actions { flex-wrap: wrap; }

    thead th { padding: 10px 12px; }
    tbody td { padding: 10px 12px; }

    .empty-state { padding: 36px 16px; }
    #gpsOverlay { padding: 16px; }
    #navMap { height: 50vh; height: 50dvh; min-height: 300px; }
}

/* 7d. <= 700px — live map stacks, grids relax ------------------------ */
@media (max-width: 700px) {
    .topbar { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
    .topbar h1 { font-size: 16px; }
    .topbar-right { gap: 10px; flex-wrap: wrap; }

    .content { flex-direction: column; }
    .map-wrap { order: 1; flex: 1 1 0; min-height: 260px; }
    .units-panel { order: 2; flex: 0 0 40%; width: 100%; border-right: 0; border-top: 1px solid rgba(var(--border-rgb), 0.2); }
    .map-legend { left: 10px; right: 10px; bottom: 10px; flex-wrap: wrap; gap: 6px 12px; }

    .incident-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .resource-grid { grid-template-columns: minmax(0, 1fr); }
}

/* 7e. <= 600px — single-column forms, full-width actions ------------- */
@media (max-width: 600px) {
    .page-head h1 { font-size: 19px; }
    .page-head--flex { align-items: flex-start; }
    .card, .incident-card, .history-card, .delay-card { padding-left: 14px; padding-right: 14px; }
    .card-sub { margin-left: 0; }

    .stat-card { padding: 14px; }
    .stat-value { font-size: 21px; }
    .audit-row { flex-wrap: wrap; }

    /* Filters / toolbars */
    .filter-bar { padding: 12px; }
    .filter-bar .filter-field { flex: 1 1 calc(50% - 10px); min-width: 130px; }
    .filter-field input, .filter-field select { width: 100%; }
    .filter-bar > input, .filter-bar > select { flex: 1 1 100%; }
    .filter-bar .btn-filter { width: 100%; padding: 11px 18px; }
    .toolbar > * { flex: 1 1 auto; }
    .pagination { flex-wrap: wrap; }

    /* Active incidents: dispatch form full width */
    .incident-actions { gap: 8px; }
    .dispatch-form { flex: 1 1 100%; flex-wrap: wrap; }
    .dispatch-form select { max-width: none; min-width: 0; }

    /* Delay cards */
    .delay-card { flex-wrap: wrap; }
    .delay-side { flex-direction: row; align-items: center; justify-content: space-between; width: 100%; }
    .delay-duration { text-align: left; }
    .tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
    .tab { flex-shrink: 0; white-space: nowrap; }

    /* CLIP report */
    .field-row { grid-template-columns: minmax(0, 1fr); }
    .severity-grid { grid-template-columns: repeat(2, 1fr); }
    .loc-tools > .btn-tool { flex: 1 1 auto; justify-content: center; }
    #map { height: 240px; }
    .submit-row { flex-direction: column-reverse; }
    .submit-row > * { width: 100%; justify-content: center; text-align: center; }
    .eta-panel { padding: 10px 12px; }

    /* Buttons */
    .btn-save, .btn-inline { width: 100%; text-align: center; }
    .btn-action { width: 100%; justify-content: center; padding: 14px 24px; }
    .modal { padding: 18px; }
    .modal-actions > * { flex: 1; }

    /* Responder: assignment + timeline */
    .nav-instr { font-size: 15px; }
    .nav-arrow { font-size: 28px; width: 36px; }
    .nav-stats .v { font-size: 16px; }
    .action-card { padding: 20px 16px; }
    .elapsed-timer { font-size: 30px; }
    .tl-label { font-size: 11px; }
    .tl-time { font-size: 10px; }
    .status-banner { padding: 14px; }
}

/* 7f. <= 480px — phones ---------------------------------------------- */
@media (max-width: 480px) {
    .info-grid, .quick-links { grid-template-columns: minmax(0, 1fr); }
    .incident-body { gap: 12px; }
    .filter-bar .filter-field { flex-basis: 100%; }
    .hc-grid { gap: 10px; }
    .tl-circle { width: 38px; height: 38px; }
    .tl-line { top: 19px; left: calc(-50% + 19px); width: calc(100% - 38px); }
}

/* 7g. <= 340px — very small phones ----------------------------------- */
@media (max-width: 340px) {
    .stats-grid { grid-template-columns: minmax(0, 1fr); }
    .incident-body { grid-template-columns: minmax(0, 1fr); }
}
[data-theme="light"] .alert-success, [data-theme="light"] .flash { background:#e3f3ea; color:#1d5139; }
[data-theme="light"] .alert-error { background:#fbe4e5; color:#8f1b24; }
[data-theme="light"] .btn-resolve { background:#e3f3ea; color:#1d5139; }
[data-theme="light"] .checklist li.done { color:#1d5139; }
[data-theme="light"] .unit-meta.alert { color:#a8540f; }
[data-theme="light"] .resource-option.unavailable .resource-available { color:#b02029; }
.btn-resolve:disabled { opacity:.6; }