:root {
  --navy-950: #0b1726;
  --navy-900: #10233a;
  --navy-800: #183554;
  --navy-700: #254f78;
  --blue-100: #e8f0f7;
  --canvas: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --ink: #17202c;
  --muted: #687585;
  --line: #dbe1e7;
  --line-strong: #c5ced7;
  --red: #b52a2a;
  --red-soft: #fff0f0;
  --amber: #8a5b09;
  --amber-soft: #fff6e2;
  --green: #14704e;
  --green-soft: #e9f7f0;
  --focus: #2477bd;
  --radius: 10px;
  --shadow: 0 10px 30px rgb(15 35 57 / 7%);
}

* { box-sizing: border-box; }
html { min-width: 320px; color: var(--ink); background: var(--canvas); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { min-height: 100vh; margin: 0; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* App frame */
.shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: 244px; display: flex; flex-direction: column; padding: 28px 16px 16px; color: #d7e1ec; background: var(--navy-950); }
.brand { width: 220px; max-width: 100%; }
.brand-logo { display: block; width: 100%; height: auto; aspect-ratio: 1796 / 428; }
.brand-link { display: inline-flex; min-height: 44px; align-items: center; text-decoration: none; }
.brand-link:has(.organization-name) { flex-direction: column; justify-content: center; align-items: flex-start; gap: 3px; }
.organization-name { display: block; max-width: 100%; overflow: hidden; color: var(--muted); font-size: .75rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .organization-name, .loading-side .organization-name { color: #b9c6d3; }
.sidebar > .brand { width: 100%; padding: 0 11px; margin-bottom: 14px; }
.sidebar .brand-logo, .login-art .brand-logo, .loading-side .brand-logo { filter: brightness(0) invert(1); }
.module-picker { display: grid; gap: 6px; min-width: 0; }
.module-picker label { font-size: .7rem; font-weight: 700; }
.module-picker select { width: 100%; min-height: 40px; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); background: #fff; }
.sidebar > .module-picker { margin: 0 11px 24px; color: #b9c6d3; }
.sidebar > .module-picker select { color: #fff; border-color: #415368; background: var(--navy-900); }
.module-state-icon svg { width: 48px; height: 48px; color: var(--navy-700); }
.nav { min-height: 0; flex: 1; overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; scrollbar-width: thin; scrollbar-color: #415368 transparent; }
.nav:hover, .nav:focus-within { scrollbar-color: #6b869f transparent; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav::-webkit-scrollbar-thumb { border-radius: 6px; background: #415368; }
.nav::-webkit-scrollbar-thumb:hover { background: #6b869f; }
.nav::-webkit-scrollbar-button { display: none; }
.nav-group { display: grid; gap: 3px; margin-bottom: 22px; }
.nav-heading { padding: 0 11px 8px; color: #8393a5; font-size: .64rem; font-weight: 900; letter-spacing: .15em; text-transform: uppercase; }
.side-link { position: relative; width: 100%; min-height: 42px; display: flex; align-items: center; gap: 11px; padding: 9px 11px; border: 0; border-radius: 8px; color: #b9c6d3; background: transparent; font-size: .82rem; font-weight: 720; text-align: left; text-decoration: none; }
.side-link:hover { color: #fff; background: rgb(255 255 255 / 7%); }
.side-link.active, .side-link[aria-current="page"] { color: #fff; background: #24415f; box-shadow: inset 3px 0 #78a7d2; }
.side-link.red-link { color: #f2b9b9 !important; }
.side-link.has-alert { color: #ffd0d0; }
.nav-icon { display: inline-flex; width: 21px; min-width: 21px; height: 21px; align-items: center; justify-content: center; color: currentColor; }
.nav-icon svg { display: block; width: 100%; height: 100%; }
.sidebar-user > a svg, .mobile-alert > svg, .mobile-more-head button svg { display: block; width: 21px; height: 21px; }
.nav-alert-count { display: inline-grid; min-width: 19px; height: 19px; place-items: center; padding: 0 5px; margin-left: auto; border-radius: 20px; color: #fff; background: var(--red); font-size: .65rem; }
.sidebar-user { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 9px; padding: 16px 7px 0; border-top: 1px solid rgb(255 255 255 / 12%); }
.user-avatar { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; color: var(--navy-950); background: #a9c5df; font-weight: 900; }
.sidebar-user strong, .sidebar-user small { display: block; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user strong { color: #fff; font-size: .76rem; }
.sidebar-user small { margin-top: 2px; color: #8fa0b2; font-size: .66rem; }
.sidebar-user a { color: #9eb0c2; text-decoration: none; }
.mobile-topbar, .mobile-bottom, .mobile-more, .nav-scrim { display: none; }
.main { width: auto; max-width: 1540px; min-height: 100vh; margin-left: 244px; padding: 42px 46px 70px; }

/* Type and shared controls */
.eyebrow { color: var(--navy-700); font-size: .68rem; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.page-head, .fleet-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-head h1, .fleet-head h1 { margin: 6px 0 7px; color: var(--navy-900); font-size: clamp(2rem, 3.5vw, 2.75rem); line-height: 1; letter-spacing: -.045em; }
.page-head p, .fleet-head p { max-width: 650px; margin: 0; color: var(--muted); line-height: 1.5; }
.card { padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.primary, .secondary, .danger, .tab { min-height: 44px; padding: 10px 15px; border: 1px solid transparent; border-radius: 8px; font-weight: 800; transition: background .14s ease, border-color .14s ease, transform .14s ease; }
.primary { color: #fff; background: var(--navy-800); }
.primary:hover { background: var(--navy-700); }
.secondary { color: var(--navy-800); border-color: var(--line-strong); background: #fff; }
.secondary:hover { background: var(--blue-100); }
.danger { color: #fff; background: var(--red); }
.danger:hover { background: #972020; }
.primary:active, .secondary:active, .danger:active { transform: translateY(1px); }
.subtle, .back-link { min-height: 38px; padding: 6px 0; border: 0; color: var(--navy-700); background: transparent; font-size: .79rem; font-weight: 850; }
.back-link { display: none; }
.wide { width: 100%; }
.compact { min-height: 36px; padding: 7px 10px; font-size: .76rem; }
.field { display: grid; gap: 7px; margin-bottom: 18px; }
.field label, .label { color: #29394b; font-size: .82rem; font-weight: 850; }
.field input, .field select, .field textarea, .searchbox { width: 100%; min-height: 46px; padding: 11px 12px; border: 1px solid var(--line-strong); border-radius: 8px; outline: none; color: var(--ink); background: #fff; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .searchbox:focus { border-color: var(--focus); box-shadow: 0 0 0 3px rgb(36 119 189 / 12%); }
.field small, .notes, .meta { color: var(--muted); font-size: .75rem; line-height: 1.45; }
.field-error { color: var(--red) !important; font-weight: 800; }
[aria-invalid="true"] { border-color: var(--red) !important; box-shadow: 0 0 0 3px rgb(181 42 42 / 10%) !important; }
.actions, .row-actions, .photo-actions, .pagination { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { display: inline-flex; width: max-content; padding: 4px 7px; border-radius: 5px; color: var(--navy-800); background: var(--blue-100); font-size: .72rem; font-weight: 900; }
.status-pill { display: inline-flex; width: max-content; align-items: center; padding: 5px 8px; border-radius: 99px; font-size: .66rem; font-weight: 900; white-space: nowrap; }
.ok-pill { color: var(--green); background: var(--green-soft); }
.danger-pill { color: var(--red); background: var(--red-soft); }
.rejected-pill { color: var(--amber); background: var(--amber-soft); }
.danger-text { color: var(--red) !important; }
.redbox { padding: 13px; margin: 12px 0; border: 1px solid #edc7c7; border-radius: 8px; color: #8e2020; background: var(--red-soft); font-weight: 800; }

/* Start */
.home-status { display: grid; grid-template-columns: 180px 190px minmax(260px, 1fr); max-width: 940px; margin: 0 auto 24px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.home-status button { min-height: 70px; padding: 12px 17px; border: 0; border-right: 1px solid var(--line); color: var(--ink); background: #fff; text-align: left; }
.home-status button:last-child { border-right: 0; }
.home-status button:hover { background: var(--surface-2); }
.home-status span, .home-status strong { display: block; }
.home-status span { margin-bottom: 5px; color: var(--muted); font-size: .64rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.home-status strong { color: var(--navy-900); font-size: .88rem; }
.home-status .needs-attention strong { color: var(--red); }
.home-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; max-width: 780px; margin: 0 auto; }
.home-tile { aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 20px; border: 1px solid var(--line); border-radius: 12px; color: var(--navy-900); background: #fff; text-align: center; transition: border-color .15s ease, background .15s ease, transform .15s ease; }
.home-tile:hover { border-color: #9fb2c4; background: var(--surface-2); transform: translateY(-2px); }
.home-tile svg { width: 42px; height: 42px; color: var(--navy-700); }
.home-tile strong { font-size: .96rem; }
.home-tile.red-link { color: var(--navy-900) !important; }
.home-tile.red-link svg { color: var(--red); }

/* Add */
.main-add { display: block; }
.add-page { width: min(100%, 680px); margin: 0 auto; }
.form-card { padding: 28px; }
.recent-block { padding-bottom: 17px; margin-bottom: 23px; border-bottom: 1px solid var(--line); }
.recent-block > span { display: block; margin-bottom: 8px; color: var(--muted); font-size: .65rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.recent-block > div { display: flex; flex-wrap: wrap; gap: 6px; }
.recent-chip { display: inline-flex; gap: 5px; padding: 6px 8px; border-radius: 6px; color: var(--navy-800); background: var(--blue-100); font-size: .72rem; font-weight: 700; }
.bus-field input { min-height: 58px; font-size: 1.3rem; font-weight: 850; }
.types { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.type { min-height: 67px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); background: #fff; text-align: left; }
.type strong, .type small { display: block; }
.type strong { color: var(--navy-900); font-size: 1rem; }
.type small { margin-top: 2px; color: var(--muted); font-size: .72rem; }
.type.active { border-color: var(--navy-700); background: var(--blue-100); box-shadow: inset 0 0 0 1px var(--navy-700); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.note-details { margin: 0 0 20px; }
.note-details summary { color: var(--navy-700); font-size: .8rem; font-weight: 800; }
.nested { margin-top: 12px; }

/* Fleet */
.fleet-controls { padding: 0; margin-bottom: 14px; overflow: hidden; }
.fleet-toolbar { display: grid; grid-template-columns: minmax(230px, 1fr) auto auto minmax(150px, auto); align-items: center; gap: 10px; padding: 11px; }
.fleet-search { display: flex; min-height: 44px; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; }
.fleet-search:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px rgb(36 119 189 / 12%); }
.fleet-search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; }
.fleet-search button { width: 30px; min-height: 30px; padding: 0; border: 0; color: var(--muted); background: transparent; }
.filter-tabs, .tabs { display: flex; gap: 3px; padding: 3px; border-radius: 8px; background: #edf1f4; }
.filter-tabs button, .tab { min-height: 34px; padding: 6px 10px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: .72rem; font-weight: 850; white-space: nowrap; }
.filter-tabs button.active, .tab.active { color: var(--navy-900); background: #fff; box-shadow: 0 1px 5px rgb(15 35 57 / 10%); }
.filter-toggle { min-height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--navy-800); background: #fff; font-size: .73rem; font-weight: 850; }
.filter-toggle.active { border-color: #8aa7c1; background: var(--blue-100); }
.sort-control { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .7rem; font-weight: 800; }
.sort-control select { min-height: 40px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); background: #fff; }
.fleet-advanced { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)) auto; align-items: end; gap: 11px; padding: 13px; border-top: 1px solid var(--line); background: var(--surface-2); }
.fleet-advanced label { display: grid; gap: 5px; color: var(--muted); font-size: .66rem; font-weight: 850; }
.fleet-advanced select { min-height: 40px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); background: #fff; }
.fleet-layout { display: grid; grid-template-columns: minmax(410px, .82fr) minmax(490px, 1.18fr); gap: 14px; align-items: start; }
.fleet-list-panel { padding: 0; overflow: hidden; }
.fleet-list-head { display: grid; grid-template-columns: 1fr 1.2fr .8fr; padding: 11px 43px 11px 15px; border-bottom: 1px solid var(--line); color: var(--muted); background: var(--surface-2); font-size: .62rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.bus-overview-list { display: grid; }
.bus-overview { width: 100%; min-height: 72px; display: grid; grid-template-columns: 1fr 1.2fr .8fr 16px; align-items: center; gap: 9px; padding: 12px 15px; border: 0; border-bottom: 1px solid #e9edf1; border-radius: 0; color: var(--ink); background: #fff; text-align: left; }
.bus-overview:last-child { border-bottom: 0; }
.bus-overview:hover { background: var(--surface-2); }
.bus-overview.selected { background: var(--blue-100); box-shadow: inset 3px 0 var(--navy-700); }
.bus-overview.alerting { background: #fffafa; }
.bus-overview strong, .bus-overview small { display: block; }
.bus-overview small { margin-top: 3px; color: var(--muted); font-size: .68rem; }
.bus-number strong { color: var(--navy-900); font-size: 1rem; }
.latest-turn strong { font-size: .75rem; }
.row-chevron { color: #9ba6b1; font-size: 1.25rem; }
.bus-detail-panel { position: sticky; top: 18px; }
.detail-placeholder { min-height: 420px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); text-align: center; }
.detail-placeholder h2 { margin: 14px 0 5px; color: var(--ink); }
.detail-placeholder p { max-width: 340px; margin: 0; line-height: 1.5; }
.placeholder-icon { color: #91a1b2; font-size: 2.3rem; }

/* Bus detail */
.history-card { padding: 0; overflow: hidden; }
.back-list { display: none; }
.bus-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.bus-hero h2 { margin: 2px 0 8px; color: var(--navy-900); font-size: 2.1rem; letter-spacing: -.045em; }
.bus-status-line, .bus-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.bus-summary { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.bus-summary > div { min-width: 0; padding: 13px 15px; border-right: 1px solid var(--line); }
.bus-summary > div:last-child { border-right: 0; }
.bus-summary span, .bus-summary strong { display: block; }
.bus-summary span { color: var(--muted); font-size: .62rem; font-weight: 850; }
.bus-summary strong { margin-top: 4px; overflow: hidden; color: var(--navy-900); font-size: .84rem; text-overflow: ellipsis; white-space: nowrap; }
.bus-tabs { display: flex; padding: 0 15px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.bus-tabs button { min-height: 47px; padding: 0 11px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; font-size: .7rem; font-weight: 850; white-space: nowrap; }
.bus-tabs button.active { color: var(--navy-900); border-bottom-color: var(--navy-700); }
.bus-tab-content { min-height: 170px; }
.history-list { padding: 0 20px 10px; margin: 0; list-style: none; }
.history-item { display: grid; grid-template-columns: 82px 46px 1fr auto; align-items: start; gap: 10px; padding: 14px 0; border-bottom: 1px solid #e9edf1; }
.history-item:last-child { border-bottom: 0; }
.history-item > strong { color: #2f4052; font-size: .75rem; }
.location { color: var(--ink); font-size: .8rem; font-weight: 800; }
.rejection-summary { padding: 10px; margin-top: 8px; border-left: 3px solid var(--red); color: #7b2525; background: var(--red-soft); }
.rejection-summary p { margin: 5px 0; overflow-wrap: anywhere; font-size: .78rem; }
.rejection-summary > div { font-size: .68rem; }
.rejection-summary button { min-height: 34px; margin-top: 8px; padding: 6px 9px; font-size: .7rem; }
.rejected-label { display: inline-flex; padding: 4px 7px; border-radius: 5px; color: var(--red); background: #ffe1e1; font-size: .68rem; font-weight: 900; }
.detail-alert-list { display: grid; padding: 5px 20px 14px; }
.detail-alert { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid #e9edf1; }
.detail-alert:last-child { border-bottom: 0; }
.detail-alert strong, .detail-alert small { display: block; }
.detail-alert small { margin-top: 4px; color: var(--muted); font-size: .68rem; }
.detail-alert p { margin: 6px 0 0; color: var(--muted); font-size: .74rem; }
.event-dot { color: var(--red); }
.event-dot.closed { color: #8794a0; }
.compact-empty { padding: 30px 8px; }

/* Alerts */
.alert-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.alert-toolbar .fleet-search { width: min(430px, 100%); }
.compact-alert-list { padding: 0; overflow: hidden; }
.alert-row { min-height: 70px; display: grid; grid-template-columns: 11px 70px 1fr auto; align-items: center; gap: 11px; padding: 11px 15px; border-bottom: 1px solid #e9edf1; }
.alert-row:last-child { border-bottom: 0; }
.alert-row.closed { background: var(--surface-2); }
.severity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
.alert-row.closed .severity-dot { background: #9ba6b1; }
.alert-bus { padding: 0; border: 0; color: var(--navy-800); background: transparent; font-weight: 900; text-align: left; }
.alert-copy strong, .alert-copy small { display: block; }
.alert-copy strong { font-size: .8rem; }
.alert-copy small { margin-top: 4px; color: var(--muted); font-size: .67rem; }

/* Rejections and documents */
.filter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.filter-grid .field { margin: 0; }
.filter-grid > button { align-self: end; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 13px; }
.filter-chip { min-height: 34px; padding: 6px 9px; border: 1px solid #b9cadd; border-radius: 99px; color: var(--navy-800); background: var(--blue-100); font-size: .7rem; font-weight: 800; }
.rejection-list { display: grid; gap: 8px; }
.rejection-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; }
.rejection-row > div { min-width: 0; }
.rejection-reason { white-space: pre-wrap; overflow-wrap: anywhere; }
.pagination { align-items: center; justify-content: center; margin-top: 15px; }
.pagination span { color: var(--muted); font-size: .76rem; font-weight: 800; }
.document-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.document-card { min-height: 270px; display: flex; flex-direction: column; align-items: flex-start; }
.document-card > div { flex: 1; }
.document-card h2 { margin: 14px 0 7px; }
.document-card p { color: var(--muted); line-height: 1.5; }
.document-card button { width: 100%; }
.document-icon { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 8px; color: var(--navy-800); background: var(--blue-100); font-weight: 900; }
.document-icon svg { width: 24px; height: 24px; }
.home-status:empty { display: none; }
.rejection-filter-panel { padding: 14px 16px; margin-bottom: 12px; }
.rejection-filter-main { display: grid; grid-template-columns: minmax(120px, 1.2fr) minmax(95px, .65fr) minmax(150px, 1fr) auto; align-items: end; gap: 10px; }
.rejection-filter-panel .field { min-width: 0; gap: 4px; margin: 0; }
.rejection-filter-panel label { font-size: .72rem; }
.rejection-filter-panel input, .rejection-filter-panel select { min-width: 0; min-height: 40px; padding: 8px 10px; font-size: .8rem; }
.rejection-filter-actions { display: flex; gap: 6px; }
.rejection-filter-actions button { min-height: 40px; padding: 8px 12px; font-size: .78rem; }
.rejection-filter-extra { margin-top: 10px; }
.rejection-filter-extra summary { width: fit-content; padding: 4px 0; color: var(--navy-700); font-size: .75rem; font-weight: 750; cursor: pointer; }
.rejection-filter-dates { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding-top: 10px; }
.archive-form { max-width: 760px; }
.archive-form > p { color: var(--muted); line-height: 1.5; }
.archive-stats { display: flex; flex-wrap: wrap; gap: 12px 24px; margin-bottom: 20px; color: var(--muted); font-size: .85rem; }
.archive-stats strong { color: var(--navy-900); }
.archive-notice { padding: 12px 14px; border-radius: 8px; color: var(--navy-800); background: var(--blue-100); font-size: .8rem; line-height: 1.5; }
.archive-entry { display: grid; gap: 8px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.archive-entry p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.archive-entry small, .muted { color: var(--muted); }
.archive-entry button { justify-self: start; }
.archived-summary { border-color: #8fa0b2; color: var(--muted); background: var(--surface-2); }
.archived-summary .rejected-label { color: #485b70; background: #e7ecf1; }
.rights-layout { display: grid; grid-template-columns: minmax(200px, .65fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.role-list { display: grid; gap: 8px; }
.role-list h2, .rights-form h2 { margin-top: 0; }
.role-choice { display: grid; gap: 5px; width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--surface-2); text-align: left; }
.role-choice.active { border-color: #78a7d2; background: var(--blue-100); }
.role-choice small { color: var(--muted); font-size: .72rem; }
.permission-sections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.permission-sections fieldset { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.permission-sections legend { padding: 0 6px; color: var(--navy-800); font-size: .8rem; font-weight: 800; }
.permission-option { display: flex; align-items: flex-start; gap: 9px; padding: 7px 0; font-size: .78rem; line-height: 1.4; }
.permission-option input { flex-shrink: 0; width: 18px; height: 18px; margin: 0; accent-color: var(--navy-700); }
.role-form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

/* Admin */
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.admin-tile { display: grid; grid-template-columns: 43px 1fr auto; align-items: center; gap: 13px; padding: 18px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: #fff; text-align: left; }
.admin-tile:hover { border-color: #a1b3c4; background: var(--surface-2); }
.admin-tile svg { width: 28px; color: var(--navy-700); }
.admin-tile strong, .admin-tile small { display: block; }
.admin-tile strong { color: var(--navy-900); }
.admin-tile small { margin-top: 3px; color: var(--muted); font-size: .73rem; line-height: 1.35; }
.admin-tile > b { color: #9aa6b1; font-size: 1.4rem; }
.account-grid { display: grid; grid-template-columns: minmax(300px, .72fr) minmax(440px, 1.28fr); align-items: start; gap: 13px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.section-head h2 { margin: 0; }
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: .75rem; }
.compact-search { max-width: 190px; }
.table-list, .admin-rows { display: grid; }
.table-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 0; border-top: 1px solid #e9edf1; }
.table-row:first-child { border-top: 0; }
.table-row strong, .table-row small { display: block; }
.table-row small { margin-top: 3px; color: var(--muted); font-size: .72rem; }
.table-row.inactive { opacity: .58; }
.code-badge { display: inline-flex !important; padding: 3px 6px; border-radius: 4px; color: var(--navy-800) !important; background: var(--blue-100); font-weight: 900; }
.admin-toolbar { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; margin-bottom: 13px; }
.admin-toolbar .field { margin: 0; }
.management-list { display: grid; gap: 10px; }
.management-list summary { font-weight: 900; cursor: pointer; }
.admin-rows { margin-top: 14px; }
.audit-list { padding-top: 8px; }
.limit-note { color: var(--muted); font-size: .75rem; font-weight: 800; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.settings-grid .field { margin: 0; }
.warning-box { padding: 13px 14px; margin: 0 0 16px; border: 1px solid #e4cd94; border-radius: 8px; color: #68480d; background: var(--amber-soft); font-size: .8rem; line-height: 1.45; }
.danger-zone { margin-top: 22px; border: 1px solid #e4b3b3; border-radius: 9px; background: #fff; }
.danger-zone summary { padding: 16px; color: var(--red); font-weight: 900; cursor: pointer; }
.danger-zone form { padding: 0 18px 18px; }

/* Empty, toast, modal, uploads */
.empty-state, .empty { padding: 40px 20px; color: var(--muted); text-align: center; }
.empty-state h2 { margin: 0 0 6px; color: var(--ink); }
.empty-state p { max-width: 450px; margin: 0 auto 16px; }
.state-icon { display: grid; width: 46px; height: 46px; place-items: center; margin: 0 auto 10px; border-radius: 50%; color: var(--navy-800); background: var(--blue-100); font-size: 1.35rem; font-weight: 900; }
.error-icon { color: var(--red); background: var(--red-soft); }
.toast { position: fixed; top: 14px; right: 14px; z-index: 100; min-width: min(360px, calc(100vw - 28px)); max-width: 430px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 12px 13px; border: 1px solid rgb(255 255 255 / 22%); border-radius: 9px; color: #fff; background: var(--green); box-shadow: 0 18px 44px rgb(0 0 0 / 18%); }
.toast.error { background: #9b2424; }
.toast.warning { background: #82550b; }
.toast-icon { display: grid; width: 26px; height: 26px; place-items: center; border: 2px solid currentColor; border-radius: 50%; font-weight: 900; }
.toast strong, .toast small { display: block; }
.toast small { margin-top: 2px; line-height: 1.3; }
.toast button { width: 36px; min-height: 36px; border: 0; color: #fff; background: transparent; font-size: 1.35rem; }
.modal-backdrop { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 18px; background: rgb(7 18 30 / 62%); }
.modal { width: min(100%, 480px); max-height: 90dvh; overflow: auto; padding: 24px; border-radius: 12px; background: #fff; box-shadow: 0 28px 80px rgb(0 0 0 / 30%); }
.modal h2 { margin: 0 0 8px; color: var(--navy-900); }
.modal > p { color: var(--muted); line-height: 1.5; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal-error[hidden] { display: none; }
.rejection-modal { width: min(760px, 100%); }
.stepper { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; margin-bottom: 18px; color: var(--muted); font-size: .78rem; }
.stepper i { height: 2px; background: var(--line); }
.stepper span { display: flex; align-items: center; gap: 6px; }
.stepper .active, .stepper .done { color: var(--navy-800); font-weight: 800; }
.photo-gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); gap: 10px; margin: 16px 0; }
.photo-gallery figure { min-width: 0; margin: 0; }
.photo-gallery img { width: 100%; height: 145px; object-fit: contain; border-radius: 7px; background: #edf1f4; }
.photo-button { min-height: 0; padding: 0; overflow: hidden; border: 0; border-radius: 7px; background: #edf1f4; }
.photo-button img { display: block; }
.photo-button span { display: block; padding: 7px; font-size: .72rem; font-weight: 800; }
.photo-gallery figcaption { display: flex; align-items: center; justify-content: space-between; gap: 5px; margin-top: 5px; font-size: .72rem; font-weight: 800; }
.photo-gallery figcaption > span { display: flex; align-items: center; gap: 2px; }
.photo-gallery figcaption button { width: auto; min-height: 32px; padding: 3px 6px; }
.confirm-rejection { display: flex; align-items: flex-start; gap: 10px; line-height: 1.45; }
.confirm-rejection input { width: 22px; min-width: 22px; height: 22px; }
.rejection-error { color: var(--red); }
.upload-status { display: flex; align-items: center; gap: 10px; padding: 12px; margin: 14px 0; border: 1px solid #c5d6e5; border-radius: 8px; color: var(--navy-800); background: var(--blue-100); font-weight: 750; }
.upload-status[hidden] { display: none; }
.spinner { display: inline-block; width: 17px; height: 17px; margin-right: 7px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; vertical-align: -3px; animation: spin .75s linear infinite; }
.lightbox { position: fixed; inset: 0; z-index: 110; display: grid; grid-template-rows: auto 1fr auto; gap: 10px; padding: 14px; color: #fff; background: rgb(2 10 18 / 95%); }
.lightbox > img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.lightbox-bar, .lightbox-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lightbox-bar button { width: 44px; height: 44px; border: 0; border-radius: 50%; font-size: 1.4rem; }
.lightbox-actions { justify-content: center; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Login and loading */
.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; background: #fff; }
.login-art { display: flex; flex-direction: column; justify-content: center; padding: 8vw; color: #fff; background: linear-gradient(145deg, var(--navy-950), #1d466d); }
.login-art .eyebrow { color: #a9c5df; }
.login-art .login-brand { width: min(100%, 560px); margin: 14px 0 24px; }
.login-art p { max-width: 480px; color: #d3e0ec; font-size: 1.05rem; line-height: 1.6; }
.login-panel { display: grid; place-items: center; padding: 28px; }
.login-card { width: min(100%, 410px); }
.login-card h2 { margin: 20px 0 7px; font-size: 1.9rem; }
.login-card > p { margin: 0 0 24px; color: var(--muted); }
.loading { display: grid; min-height: 100vh; place-items: center; color: var(--muted); }
.app-state { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 26px; color: var(--muted); text-align: center; }
.app-state h1 { margin: 12px 0 0; color: var(--ink); }
.loading-shell { min-height: 100vh; display: grid; grid-template-columns: 244px 1fr; background: var(--canvas); }
.loading-side { display: flex; flex-direction: column; gap: 13px; padding: 28px 18px; background: var(--navy-950); }
.loading-side > .brand { margin-bottom: 12px; }
.loading-main { max-width: 1100px; padding: 44px; }
.skeleton { display: block; border-radius: 7px; background: linear-gradient(90deg, #e3e8ed 25%, #f2f5f7 50%, #e3e8ed 75%); background-size: 200% 100%; animation: skeleton-wave 1.3s ease-in-out infinite; }
.loading-side .skeleton { background: linear-gradient(90deg, #1a3048 25%, #253d57 50%, #1a3048 75%); background-size: 200% 100%; }
.logo-skeleton { width: 135px; height: 28px; margin-bottom: 22px; }
.nav-skeleton { height: 41px; }
.title-skeleton { width: 260px; height: 42px; margin-bottom: 24px; }
.status-skeleton { width: 100%; height: 70px; margin-bottom: 22px; }
.loading-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.tile-skeleton { aspect-ratio: 1; }
@keyframes skeleton-wave { to { background-position: -200% 0; } }

@media (max-width: 1120px) {
  .main { padding: 36px 27px 64px; }
  .fleet-toolbar { grid-template-columns: 1fr auto auto; }
  .fleet-toolbar .fleet-search { grid-column: 1 / -1; }
  .fleet-layout { grid-template-columns: minmax(350px, .85fr) minmax(420px, 1.15fr); }
  .document-grid { grid-template-columns: 1fr 1fr; }
  .account-grid { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  body { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
  .sidebar { display: none; }
  .mobile-topbar { position: sticky; top: 0; z-index: 25; min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: rgb(255 255 255 / 96%); backdrop-filter: blur(12px); }
  .mobile-brand { display: flex; flex: 1; min-width: 0; align-items: center; gap: 12px; }
  .mobile-brand .module-picker { flex: 1; min-width: 0; max-width: 180px; }
  .mobile-brand .module-picker label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
  .mobile-brand .module-picker select { min-height: 40px; padding: 7px 8px; font-size: .8rem; }
  .mobile-topbar .brand { flex-shrink: 0; width: 112px; }
  .mobile-topbar .organization-name { font-size: .6rem; }
  .mobile-alert { position: relative; display: grid; flex-shrink: 0; width: 40px; height: 40px; place-items: center; border: 0; border-radius: 50%; color: var(--red); background: var(--surface-2); }
  .mobile-alert b { position: absolute; top: 0; right: 0; display: grid; min-width: 17px; height: 17px; place-items: center; padding: 0 4px; border-radius: 20px; color: #fff; background: var(--red); font-size: .6rem; }
  .mobile-bottom { position: fixed; inset: auto 0 0; z-index: 35; height: calc(72px + env(safe-area-inset-bottom, 0px)); display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); padding: 5px 4px env(safe-area-inset-bottom, 0px); border-top: 1px solid var(--line); background: #fff; box-shadow: 0 -8px 25px rgb(15 35 57 / 7%); }
  .mobile-bottom .side-link { min-height: 60px; flex-direction: column; justify-content: center; gap: 1px; padding: 3px; color: var(--muted); font-size: .6rem; }
  .mobile-bottom .side-link:hover { color: var(--navy-900); background: transparent; }
  .mobile-bottom .side-link.active { color: var(--navy-800); background: var(--blue-100); box-shadow: none; }
  .mobile-bottom .nav-icon { height: 22px; }
  .mobile-bottom.module-bottom { grid-template-columns: repeat(2, 1fr); }
  .mobile-more { position: fixed; inset: auto 0 0; z-index: 45; max-height: 82dvh; display: block; overflow-y: auto; padding: 18px 14px calc(18px + env(safe-area-inset-bottom, 0px)); border-radius: 18px 18px 0 0; background: #fff; box-shadow: 0 -24px 70px rgb(0 0 0 / 22%); transform: translateY(105%); transition: transform .2s ease; }
  .mobile-more.open { transform: translateY(0); }
  .mobile-more-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .mobile-more-head button { display: grid; place-items: center; width: 40px; min-height: 40px; border: 0; border-radius: 50%; background: #edf1f4; }
  .mobile-more-links { display: grid; gap: 3px; }
  .mobile-more .side-link { min-height: 48px; color: #445366; }
  .mobile-more .side-link.active { color: var(--navy-900); background: var(--blue-100); box-shadow: none; }
  .nav-scrim.visible { position: fixed; inset: 0; z-index: 40; display: block; border: 0; background: rgb(7 18 30 / 48%); }
  .main { width: auto; min-height: calc(100vh - 130px); margin: 0; padding: 22px 12px 28px; }
  .page-head, .fleet-head { align-items: flex-start; margin-bottom: 18px; }
  .page-head h1, .fleet-head h1 { font-size: 1.9rem; }
  .page-head > .primary, .fleet-head > .primary { display: none; }
  .page-head:has(> #new-role) { flex-wrap: wrap; }
  .page-head > #new-role { display: inline-flex; }
  .card { padding: 17px; }
  .home-status { grid-template-columns: 1fr 1fr; margin-bottom: 16px; }
  .home-status button { min-height: 61px; padding: 10px 12px; }
  .home-status button:nth-child(2) { border-right: 0; }
  .home-status button:last-child { grid-column: 1 / -1; border-top: 1px solid var(--line); }
  .home-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .home-tile { gap: 10px; padding: 12px; }
  .home-tile svg { width: 34px; height: 34px; }
  .home-tile strong { font-size: .84rem; }
  .form-card { padding: 19px 16px; }
  .form-row, .settings-grid, .admin-toolbar { grid-template-columns: 1fr; }
  .mobile-submit-bar { position: sticky; bottom: 72px; z-index: 5; padding: 10px 16px; margin: 0 -16px -19px; border-top: 1px solid var(--line); background: rgb(255 255 255 / 96%); backdrop-filter: blur(10px); }
  .fleet-toolbar { grid-template-columns: 1fr 1fr; }
  .fleet-toolbar .fleet-search, .filter-tabs { grid-column: 1 / -1; }
  .filter-tabs button { flex: 1; }
  .filter-toggle, .sort-control, .sort-control select { width: 100%; }
  .fleet-advanced { grid-template-columns: 1fr; }
  .fleet-layout { display: block; }
  .fleet-layout .bus-detail-panel { display: none; }
  .fleet-layout.has-selection .fleet-list-panel { display: none; }
  .fleet-layout.has-selection .bus-detail-panel { display: block; }
  .bus-detail-panel { position: static; }
  .fleet-list-head { grid-template-columns: 1fr 1.1fr .8fr; padding-right: 35px; }
  .bus-overview { grid-template-columns: 1fr 1.1fr .8fr 12px; padding: 11px 12px; }
  .back-list { width: 100%; min-height: 44px; display: block; padding: 10px 16px; border: 0; border-bottom: 1px solid var(--line); color: var(--navy-800); background: var(--surface-2); font-weight: 850; text-align: left; }
  .bus-hero { display: grid; padding: 17px; }
  .bus-actions { width: 100%; }
  .bus-actions button { flex: 1; }
  .bus-summary { grid-template-columns: 1fr 1fr; }
  .bus-summary > div:nth-child(2) { border-right: 0; }
  .bus-summary > div:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
  .bus-tabs { padding: 0 7px; }
  .history-list { padding: 0 15px 9px; }
  .history-item { grid-template-columns: 72px 42px 1fr; }
  .history-item > .subtle { grid-column: 1 / -1; justify-self: start; }
  .alert-toolbar { align-items: stretch; flex-direction: column; }
  .alert-toolbar .fleet-search { width: 100%; }
  .alert-row { grid-template-columns: 10px 55px 1fr; padding: 11px 12px; }
  .alert-row .row-actions { grid-column: 2 / -1; justify-content: flex-start; }
  .filter-grid { grid-template-columns: 1fr 1fr; padding: 14px; }
  .rejection-row { display: grid; gap: 12px; }
  .document-grid, .admin-grid, .account-grid { grid-template-columns: 1fr; }
  .rights-layout { grid-template-columns: 1fr; }
  .role-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .role-list h2 { grid-column: 1 / -1; }
  .rejection-filter-main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rejection-filter-dates { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rejection-filter-actions button { flex: 1; }
  .permission-sections { grid-template-columns: 1fr; }
  .table-row { align-items: flex-start; flex-direction: column; }
  .table-row .row-actions { width: 100%; }
  .modal-backdrop { align-items: end; padding: 8px; }
  .modal { padding: 20px 16px; border-radius: 14px 14px 8px 8px; }
  .modal-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .modal-actions button { width: 100%; }
  .toast { top: 66px; right: 9px; left: 9px; min-width: 0; }
  .login-shell { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .login-panel { padding: 22px 16px; }
  .loading-shell { display: block; }
  .loading-side { display: none; }
  .loading-main { padding: 78px 12px 20px; }
  .loading-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
}

@media (max-width: 420px) {
  .main { padding-right: 9px; padding-left: 9px; }
  .home-tile strong { font-size: .78rem; }
  .fleet-list-head { display: none; }
  .bus-overview { grid-template-columns: 1fr 1fr 14px; }
  .bus-overview-status { grid-column: 1 / -1; }
  .history-item { grid-template-columns: 67px 40px 1fr; }
  .history-item > div { grid-column: 1 / -1; }
  .filter-grid { grid-template-columns: 1fr; }
  .photo-gallery figcaption { align-items: flex-start; flex-direction: column; }
  .stepper b { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  .sidebar, .mobile-topbar, .mobile-bottom, .mobile-more, .actions, .toolbar { display: none !important; }
  .main { width: 100%; max-width: none; margin: 0; padding: 0; }
  .card { box-shadow: none; }
}
