/* SiteBalance — design system
   IBM Plex Sans + IBM Plex Mono
   Warm paper background, near-black ink, hi-vis amber accent. */

:root {
  --paper: #f6f3ec;
  --paper-2: #efebe1;
  --card: #ffffff;
  --ink: #1a1a17;
  --ink-2: #3b3a35;
  --ink-3: #6e6c63;
  --ink-4: #a09e92;
  --rule: #d9d4c5;
  --rule-2: #e6e1d2;
  --accent: oklch(0.68 0.17 55);     /* hi-vis amber */
  --accent-ink: #1a1a17;
  --accent-soft: oklch(0.93 0.07 80);
  --ok: oklch(0.55 0.10 150);
  --ok-soft: oklch(0.93 0.05 150);
  --warn: oklch(0.7 0.13 75);
  --warn-soft: oklch(0.94 0.07 85);
  --danger: oklch(0.55 0.15 25);
  --danger-soft: oklch(0.93 0.06 30);
  --info: oklch(0.55 0.09 240);
  --info-soft: oklch(0.93 0.04 240);

  --select-arrow: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%231a1a17' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  --r-sm: 4px;
  --r: 6px;
  --r-lg: 10px;

  --shadow-sm: 0 1px 0 rgba(20, 20, 17, 0.04), 0 1px 2px rgba(20, 20, 17, 0.04);
  --shadow: 0 1px 0 rgba(20, 20, 17, 0.05), 0 6px 18px -8px rgba(20, 20, 17, 0.12);
}

html[data-theme="dark"] {
  --paper: #15161a;
  --paper-2: #1d1f24;
  --card: #1a1c20;
  --ink: #ececea;
  --ink-2: #c4c3be;
  --ink-3: #8a8a82;
  --ink-4: #5d5d56;
  --rule: #2c2e34;
  --rule-2: #24262b;
  --accent: oklch(0.78 0.17 65);     /* slightly brighter hi-vis for dark */
  --accent-ink: #15161a;
  --accent-soft: oklch(0.30 0.08 75);
  --ok: oklch(0.72 0.13 150);
  --ok-soft: oklch(0.28 0.06 150);
  --warn: oklch(0.78 0.13 75);
  --warn-soft: oklch(0.30 0.07 75);
  --danger: oklch(0.70 0.16 25);
  --danger-soft: oklch(0.28 0.08 25);
  --info: oklch(0.72 0.10 240);
  --info-soft: oklch(0.28 0.07 240);

  --shadow-sm: 0 1px 0 rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 6px 18px -8px rgba(0, 0, 0, 0.6);

  --select-arrow: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23ececea' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

html[data-theme="dark"] .badge-ok { color: oklch(0.85 0.12 150); }
html[data-theme="dark"] .badge-draft { color: oklch(0.85 0.13 80); }
html[data-theme="dark"] .badge-danger { color: oklch(0.82 0.14 25); }
html[data-theme="dark"] .badge-info { color: oklch(0.82 0.10 240); }
html[data-theme="dark"] .banner-warn { color: oklch(0.85 0.13 80); }
html[data-theme="dark"] .banner-info { color: oklch(0.82 0.10 240); }

html[data-theme="dark"] .media-tile .ph {
  background: repeating-linear-gradient(135deg, transparent 0 8px, rgba(255,255,255,0.04) 8px 16px);
}
html[data-theme="dark"] .brand .mark { background: var(--accent); color: var(--accent-ink); }
html[data-theme="dark"] .user .av { background: var(--accent); color: var(--accent-ink); }
html[data-theme="dark"] .btn-dark { background: var(--ink); color: var(--paper); border-color: var(--ink); }
html[data-theme="dark"] .btn-dark:hover { background: #fff; }

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-feature-settings: "tnum"; }
.num { font-variant-numeric: tabular-nums; }
.uppercase { text-transform: uppercase; letter-spacing: 0.06em; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }

/* ------------------------------------------------------------ APP SHELL */

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topnav {
  position: sticky;
  top: 0;
  z-index: 90;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.topnav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 28px;
  height: 56px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 15px; letter-spacing: -0.01em;
}
.brand .mark {
  width: 22px; height: 22px;
  background: var(--ink); color: var(--paper);
  display: grid; place-items: center;
  font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 700;
  border-radius: 3px;
}
.brand .name { letter-spacing: -0.01em; }
.brand-logo {
  height: 38px;
  width: auto;
  display: block;
  object-fit: contain;
}
.brand-logo-dark { display: none; }
html[data-theme="dark"] .brand-logo-light { display: none; }
html[data-theme="dark"] .brand-logo-dark { display: block; }
.brand .sub { color: var(--ink-3); font-size: 11px; font-family: 'IBM Plex Mono', monospace; padding-left: 10px; border-left: 1px solid var(--rule); margin-left: 4px; }

.navlinks { display: flex; gap: 4px; flex: 1; }
.navlink {
  padding: 8px 12px;
  font-size: 13.5px;
  color: var(--ink-3);
  border-radius: var(--r);
  font-weight: 500;
  position: relative;
}
button.navlink {
  border: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
}
.navlink:hover { color: var(--ink); }
.navlink.active {
  color: var(--ink);
  background: var(--paper-2);
}
.navlink.active::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: -9px;
  height: 2px; background: var(--accent);
}
.nav-dropdown-menu,
.daily-nav-menu {
  position: relative;
  flex: 0 0 auto;
}
.nav-dropdown-toggle,
.daily-nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nav-caret {
  color: var(--ink-3);
  font-size: 10px;
  line-height: 1;
  transition: transform .16s ease, color .16s ease;
}
.nav-dropdown-toggle[aria-expanded="true"] .nav-caret,
.daily-nav-toggle[aria-expanded="true"] .nav-caret {
  transform: rotate(180deg);
  color: var(--accent);
}
.nav-dropdown-panel,
.daily-nav-panel {
  position: absolute;
  left: 0;
  top: calc(100% + 10px);
  min-width: 190px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  z-index: 85;
}
.nav-dropdown-panel[hidden],
.daily-nav-panel[hidden] { display: none; }
.nav-dropdown-panel a,
.nav-dropdown-panel .settings-logout-form button,
.daily-nav-panel a {
  display: flex;
  align-items: center;
  padding: 9px 10px;
  border-radius: 5px;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.nav-dropdown-panel a:hover,
.nav-dropdown-panel .settings-logout-form button:hover,
.daily-nav-panel a:hover {
  background: var(--paper-2);
  color: var(--ink);
}
.nav-dropdown-panel a.active,
.daily-nav-panel a.active {
  background: color-mix(in oklch, var(--accent) 12%, var(--paper-2));
  color: var(--ink);
  box-shadow: inset 2px 0 0 var(--accent);
}
.navlinks > .navlink { flex: 0 0 auto; }

.notification-menu { position: relative; }
.notification-bell {
  width: 36px; height: 28px;
  display: grid; place-items: center;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  background: var(--paper-2);
  color: var(--ink-3);
  position: relative;
  box-shadow: none;
  transition: background .18s, border-color .18s, color .18s;
}
.notification-bell:hover,
.notification-bell[aria-expanded="true"] {
  border-color: color-mix(in oklch, var(--accent) 45%, var(--rule));
  background: color-mix(in oklch, var(--accent) 6%, var(--paper-2));
  color: var(--ink);
}
.bell-icon { font-size: 13px; line-height: 1; }
.notification-count {
  position: absolute; top: -4px; right: -4px;
  min-width: 14px; height: 14px;
  display: grid; place-items: center;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 9px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px var(--paper);
}
.notification-panel {
  position: absolute;
  right: 0; top: calc(100% + 10px);
  width: min(360px, calc(100vw - 32px));
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  z-index: 80;
  overflow: hidden;
}
.notification-panel[hidden] { display: none; }
.notification-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--rule);
}
.notification-panel-head form { margin: 0; }
.notification-panel-head button {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 600;
}
.notification-panel-head button:hover { color: var(--ink); }
.notification-list { max-height: 360px; overflow: auto; }
.notification-item-form { margin: 0; }
.notification-item {
  display: grid; gap: 5px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.notification-item:last-child,
.notification-item-form:last-child .notification-item { border-bottom: 0; }
.notification-item:hover { background: var(--paper-2); color: var(--ink); }
.notification-item.unread {
  background: color-mix(in oklch, var(--accent) 10%, var(--card));
  color: var(--ink);
  font-weight: 600;
}
.notification-item small { color: var(--ink-3); font-weight: 400; }
.notification-empty { padding: 16px 14px; color: var(--ink-3); }

.settings-logout-form { margin: 0; }
.settings-logout-form button {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.user {
  display: flex; align-items: center; gap: 10px;
  padding-left: 16px; border-left: 1px solid var(--rule);
  font-size: 13px;
}

/* theme toggle — relative pill, absolute slider, two equal icon cells */
.theme-toggle {
  border: 0; background: transparent; padding: 0;
  display: inline-flex; align-items: center;
}
.tt-track {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 56px; height: 28px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 999px;
  transition: background .18s, border-color .18s;
}
.tt-track:hover { border-color: var(--ink-3); }

/* slider sits behind the icons */
.tt-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 24px; height: 24px;
  background: var(--card);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform .22s cubic-bezier(.4,.0,.2,1);
  z-index: 0;
}
html[data-theme="dark"] .tt-thumb,
.tt-track.dark .tt-thumb { transform: translateX(26px); }

/* each icon fills its half */
.tt-icon {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: var(--ink-3);
  transition: color .18s;
}
/* light mode: sun is active (dark ink), moon is muted */
.tt-track.light .tt-sun { color: var(--ink); }
.tt-track.light .tt-moon { color: var(--ink-3); }
/* dark mode: moon is active, sun is muted */
.tt-track.dark .tt-sun { color: var(--ink-3); }
.tt-track.dark .tt-moon { color: var(--ink); }
.user .av {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--ink); color: var(--paper);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
}
.user .role { color: var(--ink-3); font-size: 11px; font-family: 'IBM Plex Mono', monospace; text-transform: uppercase; letter-spacing: 0.06em; }

.main {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 20px 64px;
  flex: 1;
}

.legal-footer {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px 24px;
  display: flex;
  justify-content: center;
  gap: 18px;
  color: var(--ink-3);
  font-size: 12px;
}
.legal-footer a:hover { color: var(--ink); }

/* page header */
.pagehead {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; margin-bottom: 24px;
  padding-bottom: 18px; border-bottom: 1px solid var(--rule);
}
.pagehead h1 {
  margin: 0;
  font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1;
}
.pagehead .crumbs {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.pagehead .crumbs a:hover { color: var(--ink); }
.pagehead p {
  margin: 6px 0 0; color: var(--ink-3); max-width: 60ch;
}
.pagehead-actions { display: flex; gap: 8px; }

.legal-page .form-card-body {
  display: grid;
  gap: 14px;
  max-width: 820px;
}
.legal-page h2 {
  margin: 10px 0 0;
  font-size: 16px;
}
.legal-page p {
  margin: 0;
  color: var(--ink-2);
}
.legal-page a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}

/* ------------------------------------------------------------ FORMS */

.form {
  display: grid; gap: 22px;
}
.form-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.form-card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--rule-2);
  background: var(--paper-2);
}
.form-card-head .step {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  color: var(--ink-3); letter-spacing: 0.06em;
}
.form-card-head h2 {
  margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.005em;
}
.form-card-head .card-meta {
  margin-left: auto;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.form-card-body { padding: 18px; }

/* Weather bar (Create Diary) */
.weather-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr) minmax(0, 1.3fr) minmax(0, 1.3fr);
  gap: 14px;
  align-items: end;
}
.weather-row > .field { min-width: 0; }
.weather-header-field { grid-column: 1 / -1; }
.input-with-suffix { position: relative; display: flex; align-items: center; }
.input-with-suffix .input { padding-right: 38px; }
.input-with-suffix .input-suffix {
  position: absolute;
  right: 12px;
  color: var(--ink-3);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  pointer-events: none;
}
.weather-hint { margin: 10px 0 0; }
@media (max-width: 720px) {
  .weather-row { grid-template-columns: 1fr; gap: 10px; }
}

.field { display: grid; gap: 6px; }
.field-label {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-size: 12px; font-weight: 500; color: var(--ink-2);
}
.field-label .opt { color: var(--ink-4); font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; }
.field-hint { font-size: 12px; color: var(--ink-3); }

.input, .textarea, .select {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 11px 12px;
  font-size: 15px;
  color: var(--ink);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--ink) 12%, transparent);
}
.textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
.select {
  appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px;
}

.row { display: grid; gap: 14px; }
.row-2 { grid-template-columns: 1fr 1fr; }
.row-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 640px) {
  .row-2, .row-3 { grid-template-columns: 1fr; }
}

/* segmented */
.seg {
  display: inline-flex;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 3px;
  gap: 2px;
  width: fit-content;
}
.seg button {
  border: 0; background: transparent;
  padding: 8px 14px;
  font-size: 13px; font-weight: 500;
  color: var(--ink-3);
  border-radius: 4px;
}
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }

/* chip-input style for labour rows */
.tag-row {
  display: grid;
  grid-template-columns: 1fr 80px 28px;
  gap: 8px; align-items: center;
}
.tag-row .input-sm {
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--r);
  padding: 8px 10px; font-size: 14px;
}
.tag-row .num-input { text-align: center; font-family: 'IBM Plex Mono', monospace; }
.tag-row .x {
  width: 28px; height: 28px;
  border: 1px solid var(--rule); background: var(--card);
  border-radius: var(--r); display: grid; place-items: center;
  color: var(--ink-3); font-size: 14px;
}
.tag-row .x:hover { border-color: var(--ink); color: var(--ink); }

.resource-subfield {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
}

.resource-movement-row { margin-top: 14px; }
.resource-panel {
  border: 1px solid var(--rule);
  border-radius: var(--r);
  background: var(--paper-2);
  overflow: hidden;
}
.resource-panel > summary {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  list-style: none;
}
.resource-panel > summary .opt { margin-left: auto; }
.resource-panel > summary::-webkit-details-marker { display: none; }
.resource-panel > summary::marker { content: ""; }
.resource-panel > summary::before {
  content: "›";
  color: var(--ink-3);
  font-family: 'IBM Plex Mono', monospace;
  transition: transform .16s ease;
}
.resource-panel[open] > summary::before { transform: rotate(90deg); }
.resource-panel > summary:hover { color: var(--ink); border-color: var(--ink-3); }
.resource-panel-body {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}
.vehicle-action-card { margin-bottom: 18px; }
.vehicle-action-card .form-card-body {
  padding: 16px 18px;
}
.vehicle-action-card .field {
  max-width: 100%;
}
.vehicle-action-card .select {
  width: 100%;
  box-sizing: border-box;
}
.vehicle-action-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}
.vehicle-action-grid .vehicle-action-card .form-card-body {
  display: grid;
  gap: 12px;
  align-content: space-between;
  min-height: 170px;
}
.vehicle-action-grid h3 {
  margin: 0;
  font-size: 17px;
}
.vehicle-action-grid p {
  margin: 0;
  color: var(--ink-2);
}
.havs-home-actions {
  margin-top: 20px;
}
.havs-disclaimer {
  margin: 18px 0;
  line-height: 1.5;
}
.havs-threshold-note {
  margin: -4px 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--rule-2);
  border-radius: var(--r);
  background: var(--paper);
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.5;
}
.havs-threshold-note strong {
  color: var(--ink);
}
.settings-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.settings-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.settings-actions form {
  margin: 0;
}
.vehicle-form-narrow {
  max-width: 900px;
}
.vehicle-field-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px 18px;
  align-items: start;
}
.vehicle-field-grid .field,
.vehicle-field-grid .vehicle-field-spacer {
  min-width: 0;
}
.vehicle-field-grid .input,
.vehicle-field-grid .select,
.vehicle-field-grid .textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.vehicle-field-grid .field-label {
  min-height: 18px;
}
/* Native time inputs are oversized on some mobile browsers, so Vehicle
   uses a plain HH:MM text field with server-side validation. Keep it
   compact on desktop and let it fill the stacked mobile grid cell. */
.vehicle-time-input {
  width: 100%;
  max-width: 180px;
  min-width: 0;
  box-sizing: border-box;
  font-family: 'IBM Plex Mono', monospace;
}
@media (max-width: 640px) {
  .vehicle-time-input {
    max-width: 100%;
  }
}
.vehicle-wide-field {
  grid-column: 1 / -1;
}
.vehicle-field-spacer {
  min-height: 1px;
}
.vehicle-landing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.vehicle-choice-card .form-card-body {
  display: grid;
  gap: 18px;
  align-content: space-between;
  min-height: 190px;
}
.vehicle-choice-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
}
.vehicle-choice-card p {
  margin: 0;
  color: var(--ink-2);
  line-height: 1.5;
}
.vehicle-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}
.vehicle-dashboard-card {
  min-height: 260px;
}
.vehicle-dashboard-card .form-card-body {
  display: grid;
  gap: 14px;
}
.vehicle-compact-list {
  display: grid;
  gap: 8px;
}
.vehicle-compact-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(160px, 1.3fr) auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--rule-2);
  border-radius: var(--r);
  background: var(--paper);
  font-size: 12.5px;
}
.vehicle-compact-row > div:first-child {
  display: grid;
  gap: 2px;
}
.vehicle-compact-row strong {
  font-size: 13px;
}
.vehicle-compact-row span:not(.badge) {
  color: var(--ink-3);
}
.havs-control-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.havs-compact-row {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 8px;
}
.havs-compact-row > div {
  min-width: 0;
}
.havs-compact-row strong,
.havs-compact-row span,
.havs-compact-row div {
  overflow-wrap: anywhere;
}
.havs-compact-metrics,
.havs-compact-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
}
.havs-compact-actions {
  justify-content: flex-start;
}
.vehicle-missing-row {
  grid-template-columns: minmax(0, 1fr) max-content;
  grid-template-areas:
    "driver status"
    "assigned assigned";
  gap: 8px 12px;
  align-items: center;
}
.vehicle-missing-driver {
  grid-area: driver;
  min-width: 0;
}
.vehicle-missing-assigned {
  grid-area: assigned;
  min-width: 0;
  color: var(--ink-2);
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.vehicle-missing-status {
  grid-area: status;
  justify-self: end;
  white-space: nowrap;
}
.vehicle-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.vehicle-empty {
  border: 1px dashed var(--rule);
  border-radius: var(--r);
  padding: 14px;
  color: var(--ink-3);
  background: var(--paper);
  font-size: 13px;
}
.vehicle-helper {
  margin: 0;
  color: var(--ink-3);
  font-size: 12px;
}
.vehicle-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--rule-2);
  border-radius: var(--r);
  padding: 14px;
  background: var(--paper);
  color: var(--ink-2);
}
.vehicle-stat strong {
  font-size: 28px;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.vehicle-check-status-panel {
  grid-column: 1 / -1;
}
.vehicle-check-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.vehicle-check-status-item {
  display: grid;
  gap: 10px;
  align-content: start;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--rule-2);
  border-left-width: 4px;
  border-radius: var(--r);
  background: var(--paper);
}
.vehicle-check-status-passed {
  border-left-color: var(--ok);
}
.vehicle-check-status-issue {
  border-left-color: var(--danger);
}
.vehicle-check-status-resolved {
  border-left-color: var(--info);
}
.vehicle-check-status-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  min-width: 0;
  color: var(--ink-3);
  font-size: 12px;
}
.vehicle-check-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}
.vehicle-check-card-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}
.vehicle-check-group {
  display: grid;
  gap: 8px;
  align-content: start;
}
.vehicle-check-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--rule-2);
  border-radius: var(--r);
  background: var(--paper);
}
.vehicle-check-label { color: var(--ink-2); font-size: 13px; line-height: 1.3; }
.vehicle-answer-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  width: fit-content;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--r);
}
.vehicle-answer-wide {
  flex-wrap: wrap;
}
.vehicle-answer-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.vehicle-answer-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.vehicle-answer-option:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.vehicle-answer-option:has(input:checked) {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow);
}
.vehicle-check-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.vehicle-check-summary > div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--rule-2);
  border-radius: var(--r);
  background: var(--paper);
}
.vehicle-check-summary span {
  color: var(--ink-3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: 'IBM Plex Mono', monospace;
}
.vehicle-check-summary strong {
  font-size: 14px;
}
.vehicle-check-filters {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px 190px auto;
  gap: 8px;
  align-items: stretch;
  margin: 0 0 18px;
}
.vehicle-check-filters > * { min-width: 0; }
.vehicle-check-filters .search,
.vehicle-check-filters .filter-cell {
  position: relative;
  display: flex;
  align-items: center;
}
.vehicle-check-filters .search input,
.vehicle-check-filters .filter-select,
.vehicle-check-filters .date-filter {
  width: 100%;
  height: 44px;
  box-sizing: border-box;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  font-size: 13.5px;
  color: var(--ink);
  font-family: inherit;
}
.vehicle-check-filters .search input { padding: 0 12px 0 36px; }
.vehicle-check-filters .search-icon {
  position: absolute;
  left: 12px;
  color: var(--ink-3);
  pointer-events: none;
}
.vehicle-check-filters .filter-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding: 0 32px 0 12px;
}
.vehicle-check-filters .date-filter { padding: 0 12px; }
.vehicle-check-filters .filter-submit {
  display: inline-flex;
  height: 44px;
}
.vehicle-fault-filters {
  grid-template-columns: 190px auto;
  justify-content: start;
}
.vehicle-check-detail-list {
  display: grid;
  gap: 8px;
}
.vehicle-check-detail-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--rule-2);
  border-radius: var(--r);
  background: var(--paper);
  color: var(--ink-2);
  font-size: 13px;
}
/* ----- fault cards (vehicle faults list) ----- */
.fault-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: grid;
}
.fault-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--rule-2);
}
.fault-card-reg {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.fault-card-fleet {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 3px;
}
.fault-kv {
  display: grid;
}
.fault-kv-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--rule-2);
  align-items: baseline;
  font-size: 13.5px;
  min-width: 0;
}
.fault-kv-row:last-child { border-bottom: none; }
.fault-kv-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-3);
  padding-top: 3px;
  flex-shrink: 0;
}
.fault-kv-value {
  color: var(--ink);
  line-height: 1.5;
  word-break: break-word;
  min-width: 0;
}
.fault-card-foot {
  padding: 14px 16px;
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--rule-2);
  background: var(--paper-2);
}
.fault-card-note {
  margin: 0;
  color: var(--ink-3);
  font-size: 12.5px;
}
.fault-resolve-form {
  display: grid;
  gap: 8px;
}

/* ----- vehicle control issue items ----- */
.vehicle-issue-item {
  background: var(--paper);
  border: 1px solid var(--rule-2);
  border-radius: var(--r);
  padding: 12px 14px;
  display: grid;
  gap: 8px;
}
.vehicle-issue-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.vehicle-issue-info { display: grid; gap: 2px; min-width: 0; }
.vehicle-issue-reg { font-size: 14px; font-weight: 600; }
.vehicle-issue-user { font-size: 12px; color: var(--ink-3); }
.vehicle-issue-badges { display: flex; gap: 6px; flex-wrap: wrap; flex-shrink: 0; }
.vehicle-issue-desc { font-size: 13px; color: var(--ink-2); line-height: 1.45; }
.vehicle-issue-foot {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  border-top: 1px solid var(--rule-2);
  padding-top: 8px;
  margin-top: 2px;
}
.vehicle-issue-time {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  color: var(--ink-3);
}
.vehicle-issue-type {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.checkline {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 14px;
  color: var(--ink-2);
  font-size: 13.5px;
}
.checkline input { margin-top: 2px; }

.add-link {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 4px;
  font-size: 13px; color: var(--ink-2); font-weight: 500;
  background: none; border: 0; padding: 6px 0;
}
.add-link:hover { color: var(--accent); }
.add-link::before { content: "+"; font-family: 'IBM Plex Mono', monospace; font-weight: 600; }

/* checkbox card */
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check {
  border: 1px solid var(--rule);
  background: var(--card);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px; color: var(--ink-2);
  display: inline-flex; gap: 8px; align-items: center;
  cursor: pointer;
}
.check input { display: none; }
.check.on {
  border-color: var(--ink); background: var(--ink); color: var(--paper);
}

/* uploader */
.upload {
  border: 1.5px dashed var(--rule);
  background: var(--paper);
  border-radius: var(--r);
  padding: 22px;
  text-align: center;
  color: var(--ink-3);
  display: grid;
  gap: 4px;
}
.upload strong { color: var(--ink); font-weight: 600; }
.upload .hint { font-size: 12px; }
.upload-btn-row { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }

.media-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.media-tile {
  position: relative;
  aspect-ratio: 1;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  overflow: hidden;
}
.media-tile .ph {
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(135deg, transparent 0 8px, rgba(26,26,23,0.04) 8px 16px);
  display: grid; place-items: center;
  color: var(--ink-3); font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.media-tile .meta {
  position: absolute; bottom: 6px; left: 6px;
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  color: #fff;
  background: rgba(0,0,0,0.55);
  padding: 2px 5px; border-radius: 2px;
}
.media-tile .tag {
  position: absolute; top: 6px; left: 6px;
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  background: rgba(0,0,0,0.7); color: #fff;
  padding: 2px 5px; border-radius: 2px;
  letter-spacing: 0.04em;
}
.media-tile .x {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px;
  background: rgba(0,0,0,0.6); color: #fff;
  border: 0; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px;
}
/* ------------------------------------------------------------ BUTTONS */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--rule);
  background: var(--card);
  padding: 10px 14px;
  border-radius: var(--r);
  font-size: 13.5px; font-weight: 500;
  color: var(--ink);
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--paper-2); border-color: transparent; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(0.95); border-color: var(--accent); }
.btn-dark { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-dark:hover { background: #000; }
.btn-lg { padding: 12px 18px; font-size: 14px; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* status badge */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.07em;
  padding: 3px 8px;
  border-radius: 3px;
  border: 1px solid;
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; }
.badge-ok { color: oklch(0.4 0.10 150); background: var(--ok-soft); border-color: color-mix(in oklch, var(--ok) 30%, transparent); }
.badge-ok .dot { background: var(--ok); }
.badge-draft { color: oklch(0.5 0.13 75); background: var(--warn-soft); border-color: color-mix(in oklch, var(--warn) 30%, transparent); }
.badge-draft .dot { background: var(--warn); }
.badge-danger { color: oklch(0.45 0.15 25); background: var(--danger-soft); border-color: color-mix(in oklch, var(--danger) 30%, transparent); }
.badge-danger .dot { background: var(--danger); }
.badge-info { color: oklch(0.4 0.10 240); background: var(--info-soft); border-color: color-mix(in oklch, var(--info) 30%, transparent); }
.badge-info .dot { background: var(--info); }
.badge-neutral { color: var(--ink-2); background: var(--paper-2); border-color: var(--rule); }
.badge-neutral .dot { background: var(--ink-3); }

/* ------------------------------------------------------------ DASHBOARD */

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 8px;
  margin-bottom: 18px;
  align-items: stretch;
}
@media (max-width: 900px) { .toolbar { grid-template-columns: 1fr 1fr; } }
@media (max-width: 1200px) {
  .vehicle-check-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 900px) {
  .vehicle-landing-grid,
  .vehicle-dashboard-grid,
  .vehicle-check-status-grid,
  .vehicle-action-grid,
  .vehicle-field-grid {
    grid-template-columns: 1fr;
  }
  .vehicle-wide-field {
    grid-column: auto;
  }
  .vehicle-field-spacer {
    display: none;
  }
  .vehicle-compact-row,
  .vehicle-missing-row {
    grid-template-columns: 1fr;
    grid-template-areas: none;
    align-items: start;
  }
  .vehicle-missing-driver,
  .vehicle-missing-assigned,
  .vehicle-missing-status {
    grid-area: auto;
  }
  .vehicle-missing-status {
    justify-self: start;
  }
  .vehicle-check-card-body,
  .vehicle-check-summary {
    grid-template-columns: 1fr;
  }
  .vehicle-check-filters {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .vehicle-check-filters .search {
    grid-column: 1 / -1;
  }
}

.search {
  position: relative;
  display: flex; align-items: center;
}
.search input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 10px 12px 10px 36px;
  font-size: 14px;
}
.search svg { position: absolute; left: 12px; color: var(--ink-3); }

.pill-select {
  position: relative;
}
.pill-select select {
  appearance: none;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 10px 30px 10px 12px;
  font-size: 13.5px;
  color: var(--ink);
}
.pill-select::after {
  content: "";
  position: absolute; right: 12px; top: 50%; width: 8px; height: 8px;
  border-right: 1.5px solid var(--ink-2);
  border-bottom: 1.5px solid var(--ink-2);
  transform: translateY(-75%) rotate(45deg);
  pointer-events: none;
}

/* diary cards */
.diary-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px;
}
.diary-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 16px;
  display: grid;
  gap: 10px;
  transition: border-color .12s, transform .12s, box-shadow .12s;
}
.diary-card:hover { border-color: var(--ink-3); box-shadow: var(--shadow); }
.diary-card .card-top {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.diary-card .site {
  font-size: 14.5px; font-weight: 600; letter-spacing: -0.005em; line-height: 1.25;
}
.diary-card .meta {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--ink-3);
  display: flex; gap: 10px; flex-wrap: wrap;
  letter-spacing: 0.02em;
}
.diary-card .summary {
  font-size: 13.5px; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}
.diary-card .footer {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 10px; border-top: 1px solid var(--rule-2);
  font-size: 12px;
}
.media-counts { display: flex; gap: 12px; color: var(--ink-3); font-family: 'IBM Plex Mono', monospace; font-size: 11.5px; }

/* table */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.table-wrap .table { min-width: max-content; }
.table {
  width: 100%; border-collapse: collapse; font-size: 13.5px;
}
.table th, .table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--rule-2);
}
.table th {
  background: var(--paper-2);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3); font-weight: 500;
}
.table tr:last-child td { border-bottom: 0; }
.table tr.hover:hover td { background: var(--paper); cursor: pointer; }

/* sites */
.site-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
}
.site-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.site-card:hover { border-color: var(--ink-3); box-shadow: var(--shadow); }
.site-card .head {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--rule-2);
}
.site-card .id {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  color: var(--ink-3); letter-spacing: 0.04em;
  display: flex; justify-content: space-between; margin-bottom: 6px;
}
.site-card .title {
  font-size: 16px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25;
}
.site-card .client { font-size: 13px; color: var(--ink-3); margin-top: 2px; }

.site-card .stats {
  display: grid; grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--rule-2);
}
.stat {
  padding: 12px 16px;
}
.stat + .stat { border-left: 1px solid var(--rule-2); }
.stat .lbl {
  font-family: 'IBM Plex Mono', monospace; font-size: 10.5px;
  color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em;
}
.stat .val {
  font-size: 18px; font-weight: 600; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.stat .sub { font-size: 11.5px; color: var(--ink-3); font-family: 'IBM Plex Mono', monospace; }

.site-card .foot {
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
}

/* ------------------------------------------------------------ DETAIL */

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
}
@media (max-width: 960px) { .detail-grid { grid-template-columns: 1fr; } }

.kv-card {
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--r-lg);
  overflow: hidden;
}
.kv-card-head {
  padding: 14px 18px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--rule-2);
  background: var(--paper-2);
}
.kv-card-head h3 {
  margin: 0; font-size: 13px; font-weight: 600;
  font-family: 'IBM Plex Mono', monospace; text-transform: uppercase; letter-spacing: 0.06em;
}
.kv-card-body { padding: 18px; }
.kv-card-body p { margin: 0; line-height: 1.55; color: var(--ink-2); white-space: pre-wrap; }
.kv-card-body p + p { margin-top: 10px; }

.kv-list { display: grid; gap: 0; }
.kv-row {
  display: grid; grid-template-columns: 180px 1fr;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule-2);
  align-items: baseline;
}
.kv-row:last-child { border-bottom: 0; }
.kv-row .k {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3);
}
.kv-row .v { font-size: 14px; }

/* labour rows in detail */
.lab-table { width: 100%; border-collapse: collapse; }
.lab-table td { padding: 6px 0; border-bottom: 1px dashed var(--rule); font-size: 13.5px; }
.lab-table tr:last-child td { border-bottom: 0; }
.lab-table td:last-child { text-align: right; font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums; font-weight: 600; }

.gallery {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.gallery .media-tile { aspect-ratio: 4 / 3; }

/* sidebar summary */
.summary-card {
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--r-lg);
  padding: 18px;
}
.summary-card + .summary-card { margin-top: 14px; }
.summary-card h4 {
  margin: 0 0 14px;
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-3);
  font-weight: 500;
}
.summary-card .s-row {
  display: flex; justify-content: space-between; padding: 6px 0;
  border-bottom: 1px dashed var(--rule);
  font-size: 13.5px;
}
.summary-card .s-row:last-of-type { border-bottom: 0; }
.summary-card .s-row .k { color: var(--ink-3); }
.summary-card .s-row .v { font-weight: 500; font-variant-numeric: tabular-nums; }

/* draft banner */
.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border: 1px solid; border-radius: var(--r);
  font-size: 13px;
  margin-bottom: 18px;
}
.banner-warn { background: var(--warn-soft); border-color: color-mix(in oklch, var(--warn) 30%, transparent); color: oklch(0.45 0.13 75); }
.banner-info { background: var(--info-soft); border-color: color-mix(in oklch, var(--info) 30%, transparent); color: oklch(0.4 0.10 240); }

/* ------------------------------------------------------------ STICKY FOOTER (mobile) */

.sticky-foot {
  position: sticky;
  bottom: 0;
  left: 0; right: 0;
  background: var(--paper);
  border-top: 1px solid var(--rule);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 8px;
  z-index: 20;
  margin: 0 -20px;
}

/* status pill on form */
.draftpill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 12px; color: var(--ink-2);
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 0.04em;
}
.draftpill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.draftpill.saved .dot { background: var(--ok); }
.draftpill.submitted .dot { background: var(--ok); }

/* simple iconography (utility) */
.i { display: inline-flex; align-items: center; gap: 6px; }
.i svg { flex: 0 0 auto; }

/* divider */
.hr { height: 1px; background: var(--rule); margin: 20px 0; border: 0; }

/* progress (form) */
.progress {
  display: flex; gap: 4px; align-items: center;
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  color: var(--ink-3);
}
.progress .bar { flex: 0 0 auto; width: 80px; height: 6px; background: var(--paper-2); border-radius: 999px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: var(--accent); }

/* clickable cards */
button.diary-card, button.site-card {
  text-align: left; font: inherit; color: inherit; cursor: pointer; width: 100%;
}

/* responsive layout helpers */
@media (max-width: 720px) {
  .topnav-inner {
    gap: 8px 12px;
    padding: 8px 14px;
    flex-wrap: wrap;
    height: auto;
    min-height: 56px;
    overflow-x: visible;
    align-items: center;
  }
  .brand { flex: 0 0 auto; order: 1; }
  .brand-logo { height: 30px; }
  .theme-toggle { order: 2; margin-left: auto; }
  .notification-menu { order: 3; }
  .user { order: 4; }
  .account-settings-menu { order: 5; }
  .navlinks {
    order: 99;
    flex: 1 0 100%;
    width: 100%;
    /* overflow must stay visible: mobile browsers clip position:fixed
       descendants (the dropdown panels) to an overflow:auto/scroll ancestor.
       The 2-3 short nav items fit without scrolling; wrap as a fallback. */
    overflow: visible;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 0 2px;
    border-top: 1px solid var(--rule-2);
  }
  .navlinks > .nav-dropdown-menu,
  .navlinks > .navlink { flex: 0 0 auto; }
  .navlink { padding: 8px 10px; font-size: 13px; }
  .nav-dropdown-panel,
  .daily-nav-panel {
    position: fixed;
    left: 14px;
    right: 14px;
    top: 102px;
    min-width: 0;
    padding: 8px;
  }
  .nav-dropdown-panel a,
  .daily-nav-panel a {
    padding: 12px 12px;
    font-size: 14px;
  }
  .notification-panel {
    position: fixed;
    left: 14px;
    right: 14px;
    top: 60px;
    width: auto;
    max-width: none;
  }
  .account-settings-panel {
    top: 60px;
    max-height: calc(100vh - 76px);
    overflow-y: auto;
  }
  .vehicle-check-groups { grid-template-columns: 1fr; }
  .vehicle-check-row { grid-template-columns: 1fr; }
  .vehicle-answer-group { width: 100%; justify-content: stretch; }
  .vehicle-answer-option { flex: 1; }
  .vehicle-check-filters {
    grid-template-columns: 1fr;
  }
  .vehicle-check-detail-row {
    grid-template-columns: 1fr;
    align-items: start;
  }
  .user .role { display: none; }
  .user .name { display: none; }
  .main { padding: 18px 14px 100px; }
  .pagehead { flex-direction: column; align-items: flex-start; gap: 12px; }
  .pagehead h1 { font-size: 22px; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .toolbar .search { grid-column: 1 / -1; }
  .diary-grid { grid-template-columns: 1fr; }
  .site-grid { grid-template-columns: 1fr; }
  .kv-row { grid-template-columns: 1fr; gap: 2px; }
  .kv-row .k { color: var(--ink-3); }
  .form-card-body { padding: 14px; }
  .sticky-foot { margin: 0 -14px; }
  .fault-kv-row { grid-template-columns: 1fr; gap: 3px; padding: 8px 14px; }
  .fault-kv-label { padding-top: 0; }
  .fault-card-head, .fault-card-foot { padding: 12px 14px; }
  .vehicle-issue-foot { padding-top: 6px; }
}

/* ------------------------------------------------------------ FLASK COMPATIBILITY PATCH
   Keep these classes mapped to the Claude prototype system. */
.logout,
.account-settings-link {
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.account-settings-menu {
  position: relative;
  flex: 0 0 auto;
}
.account-settings-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.account-settings-panel {
  left: auto;
  right: 0;
  min-width: 220px;
}
.logout:hover,
.account-settings-link:hover,
.account-settings-link.active { color: var(--ink); }
.search-icon { position: absolute; left: 12px; color: var(--ink-3); z-index: 1; }
.date-filter {
  appearance: none;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 10px 12px;
  font-size: 13.5px;
  color: var(--ink);
  min-height: 42px;
}
.metric-num { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.metric-warn { color: oklch(0.55 0.13 75); }
.metric-copy { font-size: 12px; color: var(--ink-3); }
.list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.diary-card, .site-card { color: inherit; text-decoration: none; }
.diary-card .footer > div:last-child { color: var(--ink-3); font-size: 12px; }
.empty-state { background: var(--card); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 18px; color: var(--ink-3); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.flash-stack { display: grid; gap: 8px; margin-bottom: 16px; }
.resource-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.issue-grid { display: grid; gap: 18px; }
.mini-head { font-family: 'IBM Plex Mono', monospace; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); margin-bottom: 8px; }
.photo-real { aspect-ratio: 4 / 3; }
.photo-real img { width: 100%; height: 100%; object-fit: cover; display: block; }
.review-card form { display: grid; gap: 10px; }
.review-textarea {
  width: 100%;
  min-height: 84px;
  max-height: 140px;
  box-sizing: border-box;
  resize: vertical;
  font-size: 14px;
}
.review-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-start; margin-top: 2px; }
.note-submit {
  min-height: 30px;
  padding: 5px 10px;
  background: color-mix(in oklch, var(--accent) 8%, var(--card));
  border-color: color-mix(in oklch, var(--accent) 36%, var(--rule));
  color: var(--ink);
  font-size: 12px;
  line-height: 1.2;
  box-shadow: none;
}
.note-submit:hover {
  background: color-mix(in oklch, var(--accent) 12%, var(--card));
  border-color: color-mix(in oklch, var(--accent) 55%, var(--rule));
  color: var(--ink);
  filter: none;
}
.comment-list { display: grid; gap: 0; }
.comment-item { padding: 14px 0; border-bottom: 1px dashed var(--rule); }
.comment-item:first-child { padding-top: 0; }
.comment-item:last-child { border-bottom: 0; padding-bottom: 0; }
.comment-meta { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.comment-meta span { color: var(--ink-3); font-size: 12px; text-transform: capitalize; }
.comment-item p { margin: 0; color: var(--ink-2); white-space: pre-wrap; }
.image-lightbox { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; background: rgba(26,26,23,.82); }
.image-lightbox[hidden] { display: none; }
.image-lightbox img { max-width: min(1100px,94vw); max-height: 86vh; object-fit: contain; border-radius: var(--r); background: var(--card); }
.lightbox-close { position: fixed; top: 18px; right: 18px; border: 1px solid rgba(255,255,255,.28); border-radius: var(--r); background: rgba(0,0,0,.48); color: #fff; padding: 9px 12px; font-weight: 600; }
body.lightbox-open { overflow: hidden; }
.has-error .input, .has-error .textarea, .has-error .select { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in oklch, var(--danger) 14%, transparent); }
.field-error { min-height: 18px; color: var(--danger); font-size: 12px; font-weight: 500; }
.validation-summary { margin-bottom: 16px; padding: 10px 14px; border: 1px solid color-mix(in oklch, var(--danger) 30%, transparent); border-radius: var(--r); background: var(--danger-soft); color: oklch(0.45 0.15 25); }
.upload-helper { margin: 0 0 14px; color: var(--ink-3); font-size: 12px; }
.media-preview-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.preview-heading { margin-bottom: 8px; font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.preview-tile { display: grid; gap: 6px; min-width: 0; }
.preview-tile img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border: 1px solid var(--rule); border-radius: var(--r); background: var(--paper-2); }
.preview-tile span { color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-preview { padding: 13px; border: 1px dashed var(--rule); border-radius: var(--r); background: var(--paper-2); color: var(--ink-3); font-size: 12px; }
.sticky-foot .clear-form { min-width: 120px; }

/* ---- Section 05: Photos & Signature ---- */
/* Hide native file picker inside upload labels — styled button acts as trigger */
.upload input[type="file"] { display: none; }

/* Photo box: drop icon centered above the title */
.upload-dropicon { display: block; margin: 0 auto 10px; color: var(--ink-3); }

/* Segmented tab control (Draw / Upload image) */
.sig-segs {
  display: flex;
  background: var(--paper-2);
  border-radius: 6px;
  padding: 3px;
  gap: 2px;
  margin-bottom: 12px;
}
.sig-seg {
  flex: 1;
  padding: 5px 10px;
  border-radius: 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-3);
  line-height: 1.3;
  text-align: center;
  transition: background .12s, color .12s;
}
.sig-seg:hover { color: var(--ink); }
.sig-seg.active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.13);
}

/* Canvas wrapper: subtle shadow separates white canvas from dark UI */
.sig-canvas-wrap {
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.18);
}

/* Clear button row */
.sig-footer {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Upload-image panel: styled as a clickable dropzone */
.sig-upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 180px;
  border: 1.5px dashed var(--rule);
  border-radius: 5px;
  padding: 20px;
  cursor: pointer;
  text-align: center;
  color: var(--ink-3);
  transition: border-color .15s, background .15s;
}
.sig-upload-zone:hover { border-color: var(--ink-3); background: var(--paper-2); }
.sig-fname { font-size: 12px; color: var(--ink-3); text-align: center; margin-top: 6px; }

@media (max-width: 900px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr) !important; }
  .toolbar-sites { grid-template-columns: 1fr 1fr !important; }
  .resource-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .brand .sub { display: none; }
  .kpi-row { display: flex !important; overflow-x: auto; grid-template-columns: none !important; }
  .kpi-row .summary-card { min-width: 88px; }
  .toolbar-sites { grid-template-columns: 1fr !important; }
  .list-head { align-items: flex-start; gap: 10px; }
  .comment-meta { display: grid; }
}
@media print {
  .topnav, .report-nav, .pagehead-actions, .flash-stack, .image-lightbox { display: none !important; }
  body { background: #fff; }
  .main { max-width: none; padding: 0; }
  .kv-card, .summary-card { break-inside: avoid; }
}
.sr-control { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ============ Daily diary indicator ============ */
.daily-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid;
  border-radius: 3px;
  padding: 3px 8px;
  white-space: nowrap;
}
.daily-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}
.daily-status--ok {
  color: oklch(0.4 0.10 150);
  border-color: color-mix(in oklch, var(--ok) 30%, transparent);
  background: var(--ok-soft);
}
.daily-status--missing {
  color: oklch(0.45 0.15 25);
  border-color: color-mix(in oklch, var(--danger) 30%, transparent);
  background: var(--danger-soft);
}
html[data-theme="dark"] .daily-status--ok { color: oklch(0.85 0.12 150); }
html[data-theme="dark"] .daily-status--missing { color: oklch(0.82 0.14 25); }

/* ============ Latest Diaries: grouped site stack ============ */
.site-stack {
  display: grid;
  gap: 10px;
}
.site-stack__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--rule-2);
}
.site-stack__details {
  min-width: 0;
}
.site-stack__details > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  background: var(--paper-2);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 500;
  user-select: none;
}
.site-stack__details > summary::-webkit-details-marker { display: none; }
.site-stack__details > summary::marker { content: ""; }
.site-stack__details > summary::before {
  content: "▸";
  display: inline-block;
  font-size: 10px;
  color: var(--ink-3);
  transition: transform .15s ease;
}
.site-stack__details[open] > summary::before { transform: rotate(90deg); }
.site-stack__details > summary:hover { border-color: var(--ink-3); color: var(--ink); }
.site-stack__toggle-hide { display: none; }
.site-stack__details[open] .site-stack__toggle-show { display: none; }
.site-stack__details[open] .site-stack__toggle-hide { display: inline; }

.site-stack__history {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 0;
  border-top: 1px dashed var(--rule);
}
.site-stack__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px dashed var(--rule-2);
  min-width: 0;
}
.site-stack__row:last-child { border-bottom: 0; }
.site-stack__row-meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  color: var(--ink-3);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  letter-spacing: 0.02em;
  min-width: 0;
}
.site-stack__row-summary {
  grid-column: 1 / 2;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.4;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.site-stack__row-actions {
  grid-row: 1 / span 2;
  grid-column: 2 / 3;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.site-stack--empty .summary { color: var(--ink-3); font-style: italic; }
.site-stack--empty .site-stack__actions { justify-content: flex-start; }
.site-stack__empty-msg {
  padding: 12px 0;
  color: var(--ink-3);
  font-size: 13px;
}

@media (max-width: 560px) {
  .site-stack__actions {
    flex-direction: column;
    align-items: stretch;
  }
  .site-stack__details > summary { justify-content: center; }
  .site-stack__row { grid-template-columns: 1fr; }
  .site-stack__row-actions {
    grid-row: auto;
    grid-column: 1 / -1;
    justify-content: space-between;
  }
}

/* ============ Shared stat cards (Latest Diaries + Site Detail) ============ */
.stats-grid {
  display: grid;
  gap: 12px;
  margin: 0 0 18px;
}
.stats-grid.stats-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats-grid.stats-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat-card {
  min-height: 88px;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  background: var(--card);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 6px;
  box-sizing: border-box;
}
.stat-card__label {
  margin: 0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  line-height: 1.1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
}
.stat-card__value {
  margin: 0;
  font-size: 26px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stat-card__value--date {
  font-size: 22px;
  white-space: nowrap;
}
.stat-card__subtitle {
  margin: 0;
  font-size: 12px;
  line-height: 1.2;
  color: var(--ink-3);
  /* truncate long supervisor lists etc. so card never grows */
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

/* ============ Site Detail: filter toolbar (mirrors .latest-filters) ============ */
.site-detail-filters {
  display: grid !important;
  grid-template-columns: minmax(280px, 1fr) 170px 200px 160px;
  gap: 8px;
  align-items: stretch;
  margin: 0 0 18px;
}
.site-detail-filters > * { min-width: 0; }
.site-detail-filters .search,
.site-detail-filters .filter-cell {
  position: relative;
  display: flex;
  align-items: center;
}
.site-detail-filters .search input,
.site-detail-filters .filter-select,
.site-detail-filters .date-filter {
  width: 100%;
  height: 44px;
  box-sizing: border-box;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  font-size: 13.5px;
  color: var(--ink);
  font-family: inherit;
}
.site-detail-filters .search input { padding: 0 12px 0 36px; }
.site-detail-filters .search-icon { position: absolute; left: 12px; color: var(--ink-3); pointer-events: none; }
.site-detail-filters .filter-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding: 0 32px 0 12px;
}
.site-detail-filters .date-filter { padding: 0 12px; }
.site-detail-filters .filter-cell .flatpickr-input { width: 100%; }
@media (max-width: 1024px) {
  .site-detail-filters { grid-template-columns: 1fr 1fr 1fr; }
  .site-detail-filters .search { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .site-detail-filters { grid-template-columns: 1fr 1fr; }
  .site-detail-filters .search { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .latest-kpi { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .latest-kpi { grid-template-columns: 1fr; }
}

/* ============ Latest Diaries: filter toolbar ============ */
.latest-filters {
  display: grid !important;
  grid-template-columns: minmax(260px, 1fr) 200px 170px 200px 160px;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 18px;
}
.latest-filters > * { min-width: 0; }

/* Common control sizing */
.latest-filters .search,
.latest-filters .filter-cell {
  position: relative;
  display: flex;
  align-items: center;
}
.latest-filters .search input,
.latest-filters .filter-select,
.latest-filters .date-filter {
  width: 100%;
  height: 44px;
  box-sizing: border-box;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  font-size: 13.5px;
  color: var(--ink);
  font-family: inherit;
}
.latest-filters .search input { padding: 0 12px 0 36px; }
.latest-filters .search-icon { position: absolute; left: 12px; color: var(--ink-3); pointer-events: none; }

.latest-filters .filter-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding: 0 32px 0 12px;
}

.latest-filters .date-filter { padding: 0 12px; }
/* Flatpickr injects a wrapper sometimes; force the visible input to fill its cell */
.latest-filters .filter-cell .flatpickr-input { width: 100%; }

@media (max-width: 1100px) {
  .latest-filters { grid-template-columns: 1fr 1fr 1fr; }
  .latest-filters .search { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .latest-filters { grid-template-columns: 1fr 1fr; }
  .latest-filters .search { grid-column: 1 / -1; }
}
@media (max-width: 420px) {
  .latest-filters { grid-template-columns: 1fr; }
}

/* Diary header — clean 2×2 grid */
.diary-header-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px 18px;
  align-items: start;
}
.diary-header-grid .field { min-width: 0; }
.diary-header-grid .input,
.diary-header-grid .select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.shift-field { align-self: start; }

/* Shift radio toggle */
.shift-toggle {
  display: inline-flex;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 3px;
  gap: 2px;
}
.shift-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
}
.shift-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.shift-option.active,
.shift-option:has(input:checked) {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
@media (max-width: 640px) {
  .diary-header-grid { grid-template-columns: 1fr; }
  .shift-toggle { display: flex; width: 100%; }
  .shift-option { flex: 1; }
}
.filter-submit { display: none; }
.pagehead-actions [data-clear-form] { display: none; }
