/* ============================================================================
   Alerts bell, Alerts page and Bulk Upload. Kept apart from style.css so the
   additions are easy to find; every colour is a token from style.css, so both
   themes follow automatically.
   ==========================================================================*/

[hidden] { display: none !important; }

/* ------------------------------ alerts bell --------------------------- */
.bellwrap { position: relative; }
.icon-btn.bell { position: relative; }
.icon-btn.bell.ringing i { color: var(--signal-text); animation: bellSwing 1.1s var(--ease) 1; transform-origin: 50% 10%; }
@keyframes bellSwing {
  0%, 100% { transform: rotate(0); }
  15% { transform: rotate(14deg); }
  30% { transform: rotate(-12deg); }
  45% { transform: rotate(8deg); }
  60% { transform: rotate(-5deg); }
}
@media (prefers-reduced-motion: reduce) { .icon-btn.bell.ringing i { animation: none; } }

.bellcount {
  position: absolute; top: -4px; right: -5px;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  font: 600 10px/17px var(--font-mono); text-align: center;
  color: #fff; background: var(--stop); pointer-events: none;
}
.bellcount.warn { background: var(--signal); color: #181b20; }

.alertmenu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60;
  width: min(390px, calc(100vw - 24px));
  background: var(--panel); border: var(--hair) solid var(--line-hard);
  border-radius: var(--radius); box-shadow: var(--shadow-lift);
  text-transform: none; letter-spacing: 0;
}
/* On a narrow screen the bell is not at the right edge (theme and sign-out
   follow it), so a menu anchored to the bell would run off the left side.
   Pin it across the viewport instead. */
@media (max-width: 560px) {
  .alertmenu { position: fixed; top: 58px; left: 12px; right: 12px; width: auto; }
}
.alertmenu-head, .alertmenu-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px;
}
.alertmenu-head {
  border-bottom: var(--hair) solid var(--line);
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .15em; color: var(--muted);
}
.alertmenu-head .muted { font-weight: 500; letter-spacing: .06em; }
.alertmenu-foot { border-top: var(--hair) solid var(--line); font-size: 11.5px; }
.alertmenu-list { max-height: min(430px, 60vh); overflow: auto; }
.alertmenu .alert-item { padding: 9px 14px; }
.alertmenu-empty { display: grid; justify-items: center; gap: 6px; padding: 24px 14px; color: var(--muted); font-size: 12.5px; text-align: center; }
.alertmenu-empty i { font-size: 26px; color: var(--go-text); }

/* rows that lead somewhere, with a severity edge */
a.alert-item { color: inherit; text-decoration: none; }
a.alert-item:hover { background: var(--panel-2); }
.alert-item.sev-critical { box-shadow: inset 3px 0 0 var(--stop); padding-left: 10px; }
.alert-item.sev-warning { box-shadow: inset 3px 0 0 var(--signal); padding-left: 10px; }
.alert-item.sev-info { box-shadow: inset 3px 0 0 var(--info); padding-left: 10px; }
.alertmenu .alert-item.sev-critical, .alertmenu .alert-item.sev-warning { padding-left: 14px; }
.alert-item .badge { white-space: nowrap; flex: none; }
.alert-more { display: block; padding: 8px 2px 0; font-size: 11.5px; color: var(--signal-text); }

.ptitle > i.ph { font-size: 14px; color: var(--signal-text); }
.alert-off { opacity: .6; }
.clearline { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.clearline i { color: var(--go-text); font-size: 16px; }
.card.bad { border-top-color: var(--stop); }
.card.bad .v { color: var(--stop-text); }

/* sidebar count next to Alerts */
.navcount {
  margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 10px;
  font: 600 10px/17px var(--font-mono); text-align: center;
  background: var(--stop-fill); color: var(--stop-text); border: var(--hair) solid var(--stop);
}
.navcount.warn { background: var(--caution-fill); color: var(--signal-text); border-color: var(--signal); }
body.nav-collapsed .sidebar:not(:hover) .navcount { display: none; }

/* --------------------------- alert settings --------------------------- */
.settings-grid { display: grid; }
.setting-row {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.7fr) 170px;
  gap: 14px; align-items: center; padding: 10px 0; border-top: var(--hair) solid var(--line);
}
.setting-row:first-child { border-top: none; }
.setting-row .name { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 12.5px; cursor: pointer; }
.setting-row .name input { width: auto; accent-color: var(--signal); }
.setting-row .name i { color: var(--muted); font-size: 16px; }
.setting-row .hint { color: var(--muted); font-size: 12px; }
.setting-row .val { display: flex; align-items: center; gap: 6px; }
.setting-row .val input { width: 110px; }
@media (max-width: 760px) {
  .setting-row { grid-template-columns: 1fr; gap: 6px; }
}

/* ------------------------------ bulk upload --------------------------- */
.step-no {
  display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px;
  border: var(--hair) solid var(--line-hard); color: var(--text); letter-spacing: 0;
  font: 600 11px var(--font-mono);
}
.ptitle .filename { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 12px; }
.import-body { display: grid; gap: 12px; }
.import-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0; }
.import-actions.start { margin: 0; }
.import-actions .check { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; cursor: pointer; }
.import-actions .check input { width: auto; accent-color: var(--signal); }
.tabs .tab { background: none; border-top: none; border-left: none; border-right: none; cursor: pointer; }

.guide summary { cursor: pointer; font-size: 12.5px; color: var(--signal-text); padding: 4px 0; }
.guide[open] summary { margin-bottom: 8px; }

.dropzone {
  position: relative; display: grid; justify-items: center; gap: 5px; padding: 30px 16px;
  border: 1.5px dashed var(--line-hard); border-radius: var(--radius); background: var(--panel-2);
  color: var(--muted); text-align: center; cursor: pointer;
  transition: border-color var(--tick) var(--ease), background var(--tick) var(--ease);
}
.dropzone:hover, .dropzone.over { border-color: var(--signal); background: var(--caution-fill); color: var(--text); }
.dropzone:focus-within { outline: 2px solid var(--signal); outline-offset: 2px; }
.dropzone i { font-size: 32px; color: var(--signal-text); }
.dropzone .l { font-weight: 600; color: var(--text); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; font-size: 12px;
  border: var(--hair) solid var(--line); border-radius: var(--radius); background: var(--panel-2);
}
.chip b { font-family: var(--font-mono); font-size: 13px; }
.chip.ok { border-color: var(--go); background: var(--go-fill); color: var(--go-text); }
.chip.warn { border-color: var(--signal); background: var(--caution-fill); color: var(--signal-text); }
.chip.bad { border-color: var(--stop); background: var(--stop-fill); color: var(--stop-text); }

.note-list { display: grid; gap: 6px; margin-top: 12px; }
.note { padding: 8px 11px; border-left: 3px solid var(--signal); background: var(--caution-fill); font-size: 12.5px; }
.success {
  display: flex; align-items: center; gap: 9px; padding: 10px 12px; font-size: 13px;
  border-left: 3px solid var(--go); background: var(--go-fill); color: var(--go-text);
}
.success i { font-size: 18px; }

.issues { display: grid; gap: 3px; font-size: 12px; min-width: 260px; max-width: 520px; white-space: normal; }
.issues.error { color: var(--stop-text); }
.issues.duplicate { color: var(--signal-text); }

.autofill {
  display: grid; gap: 6px; padding: 10px 12px; font-size: 12.5px;
  border-left: 3px solid var(--info); background: var(--info-fill);
}
.autofill .k { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--info-text); }
.autofill ul { padding-left: 18px; display: grid; gap: 2px; }

/* --------------------------- drill-through ---------------------------- */
a.card.linkcard { color: inherit; text-decoration: none; transition: border-color var(--tick) var(--ease), background var(--tick) var(--ease); }
a.card.linkcard:hover { border-top-color: var(--signal); background: var(--panel-2); }
a.card.linkcard:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.chart-hint { margin-left: auto; font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 11.5px; color: var(--muted); }
a.recentrow { color: inherit; text-decoration: none; }
a.recentrow:hover { background: var(--panel-2); }
tr.clickrow { cursor: pointer; }
tr.clickrow:hover td { background: var(--panel-2); }
tr.clickrow:focus-visible { outline: 2px solid var(--signal); outline-offset: -2px; }

/* ---------------------------- bulk actions ---------------------------- */
.bulkbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  min-height: 42px; padding: 6px 10px; margin-bottom: 8px;
  border: var(--hair) solid var(--line); background: var(--panel);
}
.bulkbar.idle { color: var(--muted); }
.bulkbar.idle i { color: var(--signal-text); font-size: 16px; }
.bulk-spacer { flex: 1; }
.bulkbar .btn { white-space: nowrap; }
.selcol { width: 34px; min-width: 34px; text-align: center; }
.selcol input { width: 16px; height: 16px; accent-color: var(--signal); cursor: pointer; }
.selbox { display: flex; justify-content: center; cursor: pointer; }
tr.selected td { background: var(--caution-fill); }
.bulk-progress { display: block; width: 100%; height: 8px; accent-color: var(--signal); }
.bulk-summary { display: grid; gap: 5px; }
.bulk-failures, .bulk-preview { max-height: 240px; overflow: auto; border-top: var(--hair) solid var(--line); padding-top: 8px; }
.bulk-failures ul, .bulk-preview ul { display: grid; gap: 5px; padding-left: 20px; }
.bulk-failures li { overflow-wrap: anywhere; }
@media (max-width: 560px) {
  .bulkbar { align-items: stretch; }
  .bulkbar > .bulk-spacer { display: none; }
  .bulkbar > .btn { flex: 1; justify-content: center; }
}

/* ------------------------------ approvals ----------------------------- */
.req { display: grid; gap: 12px; }
.req-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.req-icon {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 34px; height: 34px; font-size: 18px; border: var(--hair) solid;
}
.req-icon.ok { color: var(--go-text); border-color: var(--go); background: var(--go-fill); }
.req-icon.warn { color: var(--signal-text); border-color: var(--signal); background: var(--caution-fill); }
.req-icon.bad { color: var(--stop-text); border-color: var(--stop); background: var(--stop-fill); }
.req-title { display: grid; gap: 2px; min-width: 0; flex: 1; }
.req-title .l { font-weight: 600; font-size: 14px; }
.req-title .s { font-size: 12px; }
.diff-table { width: 100%; border-collapse: collapse; }
.diff-table td.field { color: var(--muted); width: 30%; }
.diff-table tr.chg td.from { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-hard); }
.diff-table tr.chg td.to { font-weight: 600; background: var(--caution-fill); }
.diff-table.removed td.val { color: var(--stop-text); }
.req-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.req-foot > .muted { font-size: 12px; }
.linkbtn { background: none; border: none; padding: 0; cursor: pointer; font: inherit; font-size: 12px; color: var(--signal-text); text-decoration: underline; text-underline-offset: 2px; }

/* ---------------------------- vehicle page ---------------------------- */
.detail-shortcuts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.detail-shortcuts > .muted { font-size: 12px; margin-right: 4px; }
/* dividers drawn on the cells, not as a coloured gap, so a short last row
   leaves panel-coloured space rather than a grey block */
.status-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  background: var(--panel); border-top: var(--hair) solid var(--line); border-left: var(--hair) solid var(--line);
}
.status-item {
  background: var(--panel); padding: 12px 14px; display: grid; gap: 4px; align-content: start;
  border-right: var(--hair) solid var(--line); border-bottom: var(--hair) solid var(--line);
}

/* buttons that are links read as buttons, not underlined text */
a.btn { text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.status-item .k { display: flex; align-items: center; gap: 6px; font-size: 9.5px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.status-item .k i { font-size: 14px; }
.status-item .v { font-size: 13.5px; font-weight: 600; }
.status-item .s { font-size: 11.5px; color: var(--muted); }
.status-item .badge { justify-self: start; }
.detail-group + .detail-group { margin-top: 18px; padding-top: 16px; border-top: var(--hair) solid var(--line); }
.detail-group h4 {
  font-family: var(--font-body); font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .15em; color: var(--signal-text); margin-bottom: 12px;
}
.overview-grid .wide { grid-column: 1 / -1; white-space: pre-wrap; }

/* ---------------------------- unit picker ----------------------------- */
.pick { position: relative; display: inline-block; }
.pick-btn {
  display: inline-flex; align-items: center; gap: 8px; min-width: 200px;
  text-transform: none; letter-spacing: 0; font-size: 12.5px; font-weight: 500;
}
.pick-btn .pick-text { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-btn i { font-size: 15px; color: var(--muted); flex: none; }
.pick-menu {
  position: absolute; z-index: 60; top: calc(100% + 6px); left: 0;
  min-width: 250px; max-width: 330px; max-height: 340px; overflow: auto; padding: 6px;
  background: var(--panel); border: var(--hair) solid var(--line-hard);
  border-radius: var(--radius); box-shadow: var(--shadow-lift);
}
.pick-row { display: flex; align-items: center; gap: 9px; padding: 7px 8px; font-size: 13px; cursor: pointer; }
.pick-row:hover { background: var(--panel-2); }
.pick-row input { width: auto; accent-color: var(--signal); }
.pick-all { border-bottom: var(--hair) solid var(--line); font-weight: 600; }
.pick-foot { display: flex; justify-content: flex-end; padding: 6px 4px 2px; margin-top: 4px; border-top: var(--hair) solid var(--line); }
/* search by name sits above the list and stays put while it scrolls */
.pick-searchrow { position: sticky; top: -6px; z-index: 1; display: grid; gap: 6px; padding: 4px 2px 8px; margin-bottom: 4px;
  background: var(--panel); border-bottom: var(--hair) solid var(--line); }
.pick-search { width: 100%; }
.pick-match { justify-self: start; }
.pick-none { padding: 8px; }
.pick-menu [hidden] { display: none !important; }
@media (max-width: 560px) {
  .pick-menu { position: fixed; left: 12px; right: 12px; min-width: 0; max-width: none; }
}

/* --------------------------- access requests -------------------------- */
.login-extra { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 10px; font-size: 12.5px; }
.access-form { display: grid; gap: 12px; }
.access-form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .access-form .row2 { grid-template-columns: 1fr; } }
.access-sent { display: grid; gap: 8px; justify-items: center; text-align: center; padding: 8px 0; }
.access-sent i { font-size: 34px; color: var(--go-text); }
.access-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  background: var(--panel); border-top: var(--hair) solid var(--line); border-left: var(--hair) solid var(--line);
}
.grant { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .grant { grid-template-columns: 1fr; } }

/* ------------------- dashboard cost breakdown tables ------------------ */
/* These tables are read-only, so their headings do not offer a sort, and
   the foot row carries the totals the bars above only show as heights. */
.costtable-wrap { margin-top: 13px; }
.costtable th { cursor: default; }
.costtable th:hover { color: var(--muted); }
.costtable tfoot td {
  font-weight: 700; background: var(--panel-2);
  border-top: 2px solid var(--line-hard); border-bottom: none;
}

/* One block per vehicle type, each holding its two rankings: a truck and a
   motorbike are never in the same race, so they are never in the same list. */
.typeblocks { display: grid; gap: 18px; }
.typeblock + .typeblock { border-top: var(--hair) solid var(--line); padding-top: 16px; }
.tb-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.tb-head > i.ph { font-size: 18px; color: var(--muted); flex: none; }
.tb-name { font-weight: 700; font-size: 14px; }
.tb-head .seeall {
  color: var(--signal-text); text-decoration: none;
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .12em; white-space: nowrap;
}
.tb-head .seeall:hover { text-decoration: underline; }
.tb-total { margin-left: auto; font-size: 14px; font-weight: 600; }
.tb-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .tb-lists { grid-template-columns: 1fr; } }
.tb-listhead {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .13em; color: var(--muted);
}
.tb-listhead .mono { font-size: 12px; color: var(--text); letter-spacing: 0; text-transform: none; }
.tb-list .costtable-wrap { margin-top: 7px; }

/* ---------------- alert rows that open a record pop-up ---------------- */
/* A row that opens a pop-up is a button, not a link, so it has to be made
   to sit in the list exactly as the linked rows do. */
button.alert-item {
  width: 100%; font: inherit; color: inherit; text-align: left;
  background: none; border: none; border-bottom: var(--hair) solid var(--line);
  border-radius: 0; text-transform: none; letter-spacing: 0; cursor: pointer;
}
button.alert-item:last-child { border-bottom: none; }
button.alert-item:hover { background: var(--panel-2); }
button.alert-item:hover .l { color: var(--signal-text); }
/* a pop-up opened from the bell has to cover the menu behind it */
.modal-back { z-index: 90; }

/* ------------------------ form section headings ----------------------- */
/* A block of many controls sits in a plain box rather than a <label> (see
   buildForm), and takes the same look a labelled field has. */
div.f { display: grid; gap: 4px; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .09em; }
.form-section {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .15em; color: var(--signal-text);
  padding: 6px 0 7px; border-bottom: 2px solid var(--line-hard); margin-top: 6px;
}
.form-section:first-child { margin-top: 0; }

/* ------------------ inspection checklist, paper layout ----------------- */
/* Item | Check | Yes / No | Remarks, sections as numbered bands: the same
   sheet the depot fills in by hand, so nobody has to learn a second one. */
.cl-wrap { display: grid; gap: 8px; text-transform: none; letter-spacing: 0; color: var(--text); font-size: 12.5px; }
.cl-scroll { border: var(--hair) solid var(--line-hard); border-radius: var(--radius); overflow: auto; background: var(--panel); }
.cl-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.cl-table th {
  background: var(--panel-2); color: var(--muted); font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .13em; text-align: left; cursor: default;
  padding: 8px 10px; border-bottom: 2px solid var(--line-hard);
}
.cl-table th:hover { color: var(--muted); }
.cl-table td { padding: 5px 10px; border-bottom: var(--hair) solid var(--line); vertical-align: middle; white-space: normal; }
.cl-table tbody tr:hover { background: transparent; }
.cl-table .cl-item { width: 32%; }
.cl-table .cl-check { width: 26%; color: var(--muted); }
.cl-table .cl-answer { width: 150px; }
.cl-table td.cl-remarks input { padding: 5px 8px; font-size: 12.5px; }
.cl-sec td { background: var(--panel-2); border-top: var(--hair) solid var(--line-hard); padding: 7px 10px; }
.cl-sechead { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 700; font-size: 12.5px; }
.cl-table tr.is-no td { background: var(--stop-fill); }
.cl-table tr.is-no .cl-item { color: var(--stop-text); font-weight: 600; }

/* Yes / No / N/A as one segmented control: a click per item, and the
   answer readable at a glance down the column */
.cl-seg { display: inline-flex; border: var(--hair) solid var(--line-hard); border-radius: var(--radius); overflow: hidden; }
.cl-opt {
  background: var(--bg); color: var(--muted); border: none; border-right: var(--hair) solid var(--line-hard);
  padding: 5px 11px; font: 600 11.5px var(--font-body); cursor: pointer; min-width: 42px;
}
.cl-opt:last-child { border-right: none; }
.cl-opt:hover { color: var(--text); background: var(--panel-2); }
.cl-opt:focus-visible { outline: 2px solid var(--signal); outline-offset: -2px; }
.cl-opt.cl-yes[aria-pressed="true"] { background: var(--go-fill); color: var(--go-text); box-shadow: inset 0 -2px 0 var(--go); }
.cl-opt.cl-no[aria-pressed="true"] { background: var(--stop); color: #fff; }
.cl-opt.cl-na[aria-pressed="true"] { background: var(--panel-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--line-hard); }

.cl-rest {
  background: none; border: none; padding: 0; cursor: pointer; color: var(--signal-text);
  font: 600 10px var(--font-body); text-transform: uppercase; letter-spacing: .1em; white-space: nowrap;
}
.cl-rest:hover { text-decoration: underline; }
.cl-tally { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: 12px; color: var(--muted); font-family: var(--font-mono); }
.cl-tally .cl-t-main { color: var(--text); font-weight: 600; }
.cl-tally .cl-t-no.on { color: var(--stop-text); font-weight: 700; }
.cl-tally .cl-rest { margin-left: auto; font-family: var(--font-body); }

/* On a phone four columns do not fit: each item becomes a small card with
   the answer and the remark under its name. */
@media (max-width: 640px) {
  .cl-table thead { display: none; }
  .cl-table, .cl-table tbody { display: block; }
  .cl-table tr { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; padding: 8px 10px; border-bottom: var(--hair) solid var(--line); }
  .cl-table tr.cl-sec { display: block; padding: 0; }
  .cl-table td { display: block; border: none; padding: 0; width: auto !important; }
  .cl-table .cl-item, .cl-table .cl-check { grid-column: 1 / -1; }
  .cl-table .cl-check { font-size: 11.5px; }
  .cl-table tr.is-no { background: var(--stop-fill); }
  .cl-opt { padding: 7px 12px; }
}
