/* ==========================================================
   PROJECT WEST MIDLANDS
   FORCE MANAGEMENT SYSTEM
   App Stylesheet (dashboard, MDT, CAD)
========================================================== */

:root {
    --primary: #E2834D;
    --primary-rgb: 226, 131, 77;
    --primary-dark: #C86D37;
    --primary-light: #F3A46E;

    /* Colours live in theme.css (light + dark). */
    --transition: all .15s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--background);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

[hidden] {
    display: none !important;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

ul {
    list-style: none;
}

.container {
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 22px;
}

/* ==========================================================
   TOP BAR
========================================================== */

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--navy);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.brand-mark img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.brand-text strong {
    display: block;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .4px;
    color: var(--ink);
}

.brand-text small {
    font-size: 12px;
    color: var(--text-light);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    transition: var(--transition);
}

.topbar-link:hover {
    background: var(--background);
}

.topbar-link .caret {
    font-size: 10px;
    color: var(--text-light);
}

.avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: grid;
    place-items: center;
}

.notify {
    background: var(--accent-bg);
    border: 1px solid var(--accent-line);
    color: var(--primary-dark);
}

.notify:hover {
    background: var(--accent-bg);
}

.badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 3px;
    background: var(--bad);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: grid;
    place-items: center;
}

.badge.empty {
    display: none;
}

.show-sm {
    display: none;
}

/* ==========================================================
   DROPDOWNS
========================================================== */

.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 210px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .14);
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: var(--transition);
    z-index: 200;
}

.dropdown-menu.right {
    left: auto;
    right: 0;
}

.dropdown.open > .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu > a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.dropdown-menu > a i {
    width: 16px;
    color: var(--text-light);
}

.dropdown-menu > a:hover {
    background: var(--background);
    color: var(--primary-dark);
}

.notifications {
    width: 320px;
    padding: 0;
}

.dropdown-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
}

.dropdown-head button {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-dark);
}

.notification {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    line-height: 1.45;
}

.notification:last-child {
    border-bottom: none;
}

.notification.unread {
    background: var(--accent-bg);
}

.notification i {
    margin-top: 2px;
    color: var(--primary);
}

.notification small {
    display: block;
    margin-top: 3px;
    color: var(--text-light);
}

/* ==========================================================
   MAIN NAVIGATION
========================================================== */

.mainnav {
    background: var(--navy);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(15, 23, 42, .2);
}

.mainnav-inner {
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.nav-links {
    display: flex;
    align-items: center;
    height: 100%;
}

.nav-links > li {
    height: 100%;
}

.nav-links > li > a {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 13px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    position: relative;
    transition: var(--transition);
}

.nav-links > li > a .caret {
    font-size: 9px;
    opacity: .8;
}

.nav-links > li > a:hover {
    background: rgba(255, 255, 255, .07);
}

.nav-links > li > a.active {
    background: rgba(255, 255, 255, .12);
}

.nav-links > li > a.active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: var(--primary);
}

.nav-links .dropdown-menu {
    top: 100%;
    border-radius: 0 0 6px 6px;
}

.search {
    display: flex;
    height: 34px;
    width: 300px;
    flex-shrink: 1;
}

.search input {
    flex: 1;
    min-width: 0;
    border: none;
    padding: 0 12px;
    font: inherit;
    font-size: 14px;
    border-radius: 3px 0 0 3px;
    outline: none;
}

.search button {
    width: 42px;
    background: var(--primary);
    color: #fff;
    border-radius: 0 3px 3px 0;
    transition: var(--transition);
}

.search button:hover {
    background: var(--primary-dark);
}

.menu-toggle {
    display: none;
    color: #fff;
    font-size: 18px;
    padding: 8px;
}

/* ==========================================================
   PAGE
========================================================== */

.page {
    flex: 1;
    padding-top: 24px;
    padding-bottom: 40px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* ==========================================================
   WELCOME BANNER
========================================================== */

.welcome {
    position: relative;
    min-height: 172px;
    padding: 34px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
    color: #fff;
    background:
        linear-gradient(90deg, rgba(15, 23, 42, .94) 0%, rgba(15, 23, 42, .72) 45%, rgba(15, 23, 42, .35) 100%),
        url("../assets/hero.jpg") center 60% / cover no-repeat;
    border-radius: var(--radius);
    overflow: hidden;
}

.greeting {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--primary-light);
    margin-bottom: 4px;
}

.welcome h1 {
    font-size: 34px;
    font-weight: 700;
    margin-bottom: 14px;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, .45);
    background: rgba(15, 23, 42, .45);
    border-radius: 3px;
}

.chip i {
    font-size: 11px;
    opacity: .85;
}

.chip.strong {
    font-weight: 700;
    letter-spacing: .5px;
}

.chip-muted {
    font-size: 12px;
    color: rgba(255, 255, 255, .7);
}

.duty-status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.duty-label {
    font-size: 11px;
    font-weight: 700;
    color: rgba(255, 255, 255, .7);
}

.duty-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    border-radius: 3px;
    font-size: 14px;
    font-weight: 700;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .35);
    transition: var(--transition);
}

.duty-toggle:hover {
    background: rgba(255, 255, 255, .2);
}

.duty-toggle .dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--muted);
}

.duty-toggle.on {
    background: var(--success);
    border-color: var(--success);
}

.duty-toggle.on .dot {
    background: var(--ok-line);
    box-shadow: 0 0 0 4px rgba(187, 247, 208, .3);
}

/* ==========================================================
   PANELS
========================================================== */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--navy);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

.head-action {
    font-size: 12px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 3px;
    background: var(--primary);
    transition: var(--transition);
}

.head-action:hover {
    background: var(--primary-dark);
}

.panel-body {
    padding: 14px;
}

.panel-foot {
    display: flex;
    justify-content: flex-end;
    margin-top: 14px;
}

.text-link {
    font-size: 14px;
    font-weight: 500;
    color: var(--primary-dark);
}

.text-link:hover {
    text-decoration: underline;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

/* ==========================================================
   QUICK LINK TILES
========================================================== */

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}

.tile {
    aspect-ratio: 1 / 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px;
    text-align: center;
    color: #fff;
    border-radius: 2px;
    transition: var(--transition);
}

.tile i {
    font-size: 26px;
}

.tile span {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.25;
}

.tile:hover {
    transform: translateY(-3px);
    filter: brightness(1.1);
    box-shadow: 0 10px 20px rgba(15, 23, 42, .18);
}

.tile-blue   { background: #26508F; }
.tile-navy   { background: #253A63; }
.tile-green  { background: #2E7058; }
.tile-purple { background: #6A4A8C; }
.tile-slate  { background: #1E2B4D; }
.tile-orange { background: var(--primary); }
.tile-dark   { background: #172238; }

/* ==========================================================
   EVENTS
========================================================== */

.events {
    display: grid;
    gap: 10px;
}

.event {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 2px;
    transition: var(--transition);
}

.event:hover {
    border-color: var(--primary-light);
}

.event h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.3;
    margin-bottom: 6px;
}

.event-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    font-size: 12px;
    color: var(--text-light);
}

.event-meta i {
    margin-right: 5px;
}

.event-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
}

.book-btn {
    font-size: 12px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 3px;
    border: 1px solid var(--primary);
    color: var(--primary-dark);
    transition: var(--transition);
}

.book-btn:hover {
    background: var(--accent-bg);
}

.book-btn.booked {
    background: var(--primary);
    color: #fff;
}

/* ==========================================================
   STATUS PILLS
========================================================== */

.status {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 3px;
    white-space: nowrap;
}

.status.open,
.status.approved { color: var(--success); background: var(--ok-bg); }

.status.pending  { color: var(--warning); background: var(--warn-bg); }

.status.full,
.status.denied   { color: var(--danger);  background: var(--bad-bg); }

/* ==========================================================
   ANNOUNCEMENTS
========================================================== */

.announcements li {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.announcements li:first-child {
    padding-top: 0;
}

.announcements li:last-child {
    border-bottom: none;
}

.tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: var(--primary-dark);
    margin-bottom: 4px;
}

.announcements h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 4px;
}

.announcements p {
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-light);
}

.announcements small {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--muted);
}

/* ==========================================================
   TABLE
========================================================== */

.table-wrap {
    overflow-x: auto;
    padding: 0;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th {
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
    background: var(--surface-2);
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table tr:last-child td {
    border-bottom: none;
}

.table td:first-child {
    font-weight: 700;
    color: var(--ink);
}

/* ==========================================================
   FOOTER
========================================================== */

.footer {
    background: var(--navy-dark);
    color: rgba(255, 255, 255, .7);
    font-size: 13px;
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    padding-top: 18px;
    padding-bottom: 18px;
}

/* ==========================================================
   BUTTONS
========================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 3px;
    font-size: 14px;
    font-weight: 700;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink);
    transition: var(--transition);
    white-space: nowrap;
}

.btn:hover { background: var(--background); }

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-navy {
    background: var(--navy);
    border-color: var(--navy);
    color: #fff;
}

.btn-navy:hover { background: var(--ink); }

.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.1); background: var(--success); }

.btn-danger { background: var(--surface); border-color: var(--bad-line); color: var(--danger); }
.btn-danger:hover { background: var(--bad-bg); }

.btn-sm { padding: 6px 11px; font-size: 12px; }

/* ==========================================================
   FORMS
========================================================== */

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field.full { grid-column: 1 / -1; }

.field label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
}

.input,
.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--line-2);
    border-radius: 3px;
    outline: none;
    transition: var(--transition);
}

.field textarea { min-height: 110px; resize: vertical; }

.input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .18);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.inline-form {
    display: flex;
    gap: 8px;
}

.inline-form .input { flex: 1; min-width: 0; }

/* ==========================================================
   GRADES / UNIT STATUS / EXTRA STATUS
========================================================== */

.grade {
    display: inline-grid;
    place-items: center;
    min-width: 34px;
    height: 24px;
    padding: 0 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.grade.g1 { background: #DC2626; }
.grade.g2 { background: var(--primary); }
.grade.g3 { background: #2563EB; }
.grade.g4 { background: #6B7280; }

.unit-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 3px;
    white-space: nowrap;
}

.unit-pill::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.u-available { color: var(--ok); background: var(--ok-bg); }
.u-enroute   { color: var(--info); background: var(--info-bg); }
.u-onscene   { color: var(--warn); background: var(--accent-bg); }
.u-busy      { color: #6D28D9; background: #EDE9FE; }
.u-offduty   { color: var(--muted); background: var(--surface-2); }

.status.closed { color: var(--muted); background: var(--surface-2); }

/* ==========================================================
   INCIDENT DETAIL (shared)
========================================================== */

.inc-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}

.inc-head > div { flex: 1; min-width: 0; }

.inc-head h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.25;
}

.inc-ref {
    font-size: 12px;
    color: var(--text-light);
}

.inc-facts {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 8px 12px;
    font-size: 14px;
    margin-bottom: 12px;
}

.inc-facts dt {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
    padding-top: 2px;
}

.inc-desc {
    font-size: 14px;
    line-height: 1.6;
    padding: 12px;
    background: var(--surface-2);
    border-left: 3px solid var(--primary);
    margin-bottom: 14px;
}

.inc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.sub-head {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
    margin: 16px 0 8px;
}

.inc-log {
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 3px;
    margin-top: 10px;
}

.inc-log li {
    display: grid;
    grid-template-columns: 46px 70px 1fr;
    gap: 8px;
    padding: 8px 10px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

.inc-log li:last-child { border-bottom: none; }

.log-time   { color: var(--text-light); font-variant-numeric: tabular-nums; }
.log-author { font-weight: 700; color: var(--ink); }

/* ==========================================================
   STAT CARDS
========================================================== */

.stat-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--navy);
    border-radius: var(--radius);
    padding: 14px 16px;
}

.stat-card span {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
}

.stat-card strong {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--ink);
    margin-top: 4px;
}

.stat-card.red    { border-left-color: var(--bad); }
.stat-card.green  { border-left-color: var(--success); }
.stat-card.orange { border-left-color: var(--primary); }

/* ==========================================================
   MODAL + DRAWER
========================================================== */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    z-index: 300;
    display: none;
}

.overlay.open { display: block; }

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    width: min(620px, calc(100vw - 32px));
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    transform: translate(-50%, -50%);
    background: var(--surface);
    border-radius: 3px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, .35);
    z-index: 310;
    display: none;
}

.modal.open { display: block; }

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(480px, 100vw);
    background: var(--surface);
    box-shadow: -20px 0 50px rgba(0, 0, 0, .25);
    z-index: 310;
    display: flex;
    flex-direction: column;
    transform: translateX(105%);
    visibility: hidden;
    transition: transform .25s ease, visibility .25s;
}

.drawer.open { transform: translateX(0); visibility: visible; }

.modal-head,
.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--navy);
    color: #fff;
    font-weight: 700;
}

.close-btn {
    color: #fff;
    font-size: 18px;
    padding: 2px 6px;
    opacity: .8;
}

.close-btn:hover { opacity: 1; }

.modal-body,
.drawer-body {
    padding: 18px;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
}

/* ==========================================================
   EMPTY / MESSAGE STATES
========================================================== */

.empty {
    padding: 28px 16px;
    text-align: center;
    font-size: 14px;
    color: var(--text-light);
}

.empty i {
    display: block;
    font-size: 26px;
    margin-bottom: 10px;
    opacity: .5;
}

.message-panel {
    padding: 60px 24px;
    text-align: center;
}

.message-panel i {
    font-size: 40px;
    color: var(--primary);
    margin-bottom: 16px;
}

.message-panel h2 {
    font-size: 24px;
    margin-bottom: 8px;
}

.message-panel p {
    color: var(--text-light);
    margin-bottom: 22px;
}

.dropdown-user {
    padding: 10px 12px 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.dropdown-user strong { display: block; font-size: 14px; color: var(--ink); }
.dropdown-user span   { font-size: 12px; color: var(--text-light); }

img.avatar { object-fit: cover; }

/* ==========================================================
   TOASTS
========================================================== */

.toasts {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 500;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 240px;
    max-width: 360px;
    padding: 12px 16px;
    border-radius: 4px;
    background: var(--ink);
    color: #fff;
    font-size: 14px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .25);
    border-left: 4px solid var(--success);
    transition: opacity .35s ease, transform .35s ease;
}

.toast.error { border-left-color: var(--bad); }

.toast.success i { color: var(--ok); }
.toast.error i   { color: var(--bad); }

.toast.hide {
    opacity: 0;
    transform: translateY(8px);
}

/* ==========================================================
   RESPONSIVE
========================================================== */

@media (max-width: 980px) {
    .stat-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
    .toasts { left: 16px; right: 16px; }
    .toast { max-width: none; }
}

@media (max-width: 980px) {

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .menu-toggle {
        display: block;
    }

    .nav-links {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        height: auto;
        flex-direction: column;
        align-items: stretch;
        background: var(--navy);
        border-top: 1px solid rgba(255, 255, 255, .1);
        display: none;
        padding: 6px 0;
    }

    .nav-links.open {
        display: flex;
    }

    .nav-links > li > a {
        padding: 13px 22px;
    }

    .nav-links .dropdown-menu {
        position: static;
        display: none;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border: none;
        border-radius: 0;
        background: var(--navy-dark);
    }

    .nav-links .dropdown.open > .dropdown-menu {
        display: block;
    }

    .nav-links .dropdown-menu > a {
        color: #fff;
        padding-left: 36px;
    }

    .nav-links .dropdown-menu > a:hover {
        background: rgba(255, 255, 255, .06);
        color: var(--primary-light);
    }

    .search {
        width: auto;
        flex: 1;
        max-width: 320px;
    }
}

@media (max-width: 640px) {

    .container {
        padding: 0 16px;
    }

    .brand-text small,
    .hide-sm {
        display: none;
    }

    .brand-text strong {
        font-size: 12px;
    }

    .show-sm {
        display: inline-block;
    }

    .topbar-link {
        padding: 9px 11px;
    }

    .notifications {
        width: calc(100vw - 32px);
        right: -60px;
    }

    .welcome {
        padding: 26px 18px;
    }

    .welcome h1 {
        font-size: 28px;
    }

    .duty-status {
        align-items: flex-start;
    }

    .tiles {
        grid-template-columns: repeat(2, 1fr);
    }

    .event {
        flex-direction: column;
    }

    .event-side {
        flex-direction: row;
        align-items: center;
    }

    .footer-inner {
        flex-direction: column;
        gap: 4px;
    }
}

/* ==========================================================
   SHARED HEADER - live search + use on dark pages
========================================================== */

#pwm-header {
    color: var(--text);
    position: relative;
    z-index: 120;
    flex-shrink: 0;
    font-family: var(--font);
}

.picker-page .picker { flex: 1; }

.search { position: relative; }
.search input { background: var(--surface); color: var(--text); color-scheme: light; }

.search-results {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: min(440px, calc(100vw - 24px));
    max-height: min(70vh, 520px);
    overflow-y: auto;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 3px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, .22);
    padding: 6px;
    z-index: 200;
}

.search-group {
    padding: 8px 10px 4px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-light);
}

.search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 3px;
    font-size: 14px;
}

.search-item i {
    width: 30px;
    height: 30px;
    border-radius: 3px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    font-size: 13px;
    color: var(--primary);
    background: rgba(var(--primary-rgb), .1);
}

.search-item span { min-width: 0; }
.search-item strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-item small { display: block; font-size: 12px; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-item:hover, .search-item.active { background: var(--background); }
.search-empty { padding: 14px 12px; font-size: 13px; color: var(--text-light); }

/* Full-width header on the dark full-screen pages (MDT, map, duty, intranet) */
.pwm-header-wide .container { max-width: none; padding: 0 28px; }

@media (max-width: 980px) {
    .search-results { position: fixed; top: auto; left: 12px; right: 12px; width: auto; margin-top: 6px; }
    .pwm-header-wide .container { padding: 0 16px; }
}
