/* ============================================================
   Fleet Manager - stylesheet
   ============================================================ */
:root {
  color-scheme: light;
  --bg:            #f4f6f9;
  --surface:       #ffffff;
  --surface-2:     #fafbfc;
  --border:        #e3e7ed;
  --border-strong: #cfd6e0;
  --text:          #16202e;
  --text-dim:      #5c6b80;
  --text-faint:    #8a97a8;
  /* sidebar - a clean white panel in the light theme */
  --sidebar:            #ffffff;
  --sidebar-line:       #e3e7ed;
  --sidebar-text:       #45546a;
  --sidebar-strong:     #16202e;
  --sidebar-muted:      #8a97a8;
  --sidebar-hover-bg:   #f1f4f8;
  --sidebar-hover-text: #16202e;
  --sidebar-active-bg:  #e8efff;
  --sidebar-active:     #1d4ed8;
  --accent:        #2563eb;
  --accent-dark:   #1d4ed8;
  --accent-soft:   #e8efff;
  --ok:            #0f8a5f;
  --ok-soft:       #e2f5ec;
  --warn:          #b8760a;
  --warn-soft:     #fdf1dc;
  --danger:        #c92a2a;
  --danger-soft:   #fdeaea;
  --neutral:       #5c6b80;
  --neutral-soft:  #eef1f5;
  --radius:        10px;
  --radius-sm:     7px;
  --shadow:        0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --shadow-lg:     0 12px 32px rgba(16,24,40,.16);
  --sidebar-w:     236px;
  --font:          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono:          ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

/* dark theme - picked by the person (Settings or the sidebar switch), stored
   per device; data-theme is set on <html> before the page paints */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:            #0e141d;
  --surface:       #161e2a;
  --surface-2:     #1b2430;
  --border:        #26313f;
  --border-strong: #354354;
  --text:          #e8edf4;
  --text-dim:      #9aa8ba;
  --text-faint:    #718093;
  --sidebar:            #0a0f17;
  --sidebar-line:       rgba(255,255,255,.07);
  --sidebar-text:       #a7b4c6;
  --sidebar-strong:     #ffffff;
  --sidebar-muted:      #6b7a90;
  --sidebar-hover-bg:   rgba(255,255,255,.06);
  --sidebar-hover-text: #dce4ef;
  --sidebar-active-bg:  rgba(255,255,255,.11);
  --sidebar-active:     #ffffff;
  --accent-soft:   #1b2b4d;
  --ok-soft:       #10291f;
  --warn-soft:     #2c2412;
  --danger-soft:   #301616;
  --neutral-soft:  #212b38;
  --ok:            #35b57f;
  --warn:          #dc9a2c;
  --danger:        #ef5350;
  --shadow:        0 1px 2px rgba(0,0,0,.3);
  --shadow-lg:     0 12px 32px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
/* .app and .auth-gate set display:flex/grid, which beats the UA stylesheet's
   [hidden] { display: none } - without this the hidden one still paints. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.011em; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--sidebar); color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-line);
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0; z-index: 40;
}
.brand { display: flex; gap: 11px; align-items: center; padding: 18px 18px 20px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 34px;
  background: linear-gradient(135deg, var(--accent), #4f8cff);
  color: #fff; font-weight: 700; font-size: 13px;
  display: grid; place-items: center; letter-spacing: .5px;
}
.brand-name { color: var(--sidebar-strong); font-weight: 600; font-size: 14px; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.brand-sub { font-size: 11px; color: var(--sidebar-muted); }

.nav { display: flex; flex-direction: column; gap: 1px; padding: 0 10px 10px; flex: 1;
  min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 11px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); font-size: 13.5px; font-weight: 500;
  transition: background .13s, color .13s;
}
.nav a:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-hover-text); }
.nav a.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); font-weight: 600; }
.nav .ico { width: 16px; text-align: center; opacity: .75; font-size: 12px; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  border-radius: 20px; padding: 1px 7px; font-size: 11px; font-weight: 700;
}
.sidebar-foot {
  padding: 11px 14px 11px 18px; font-size: 11.5px; color: var(--sidebar-muted); white-space: nowrap;
  border-top: 1px solid var(--sidebar-line); display: flex; align-items: center; gap: 7px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sidebar-muted); flex: 0 0 7px; }
.dot.up { background: var(--ok); box-shadow: 0 0 0 3px rgba(53,181,127,.18); }
.dot.down { background: var(--danger); }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 15px 26px; display: flex; align-items: center; gap: 14px;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar h1 { font-size: 19px; }
.topbar p { margin: 2px 0 0; color: var(--text-dim); font-size: 12.5px; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.hamburger {
  display: none; background: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: 16px; padding: 5px 10px; cursor: pointer;
}
.content { padding: 22px 26px 60px; flex: 1; }
.loading { color: var(--text-dim); padding: 40px 0; text-align: center; }

/* ---------- generic bits ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-head {
  padding: 14px 17px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-head h3 { font-size: 14px; }
.card-head .sub { color: var(--text-dim); font-size: 12px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 17px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid.split-2-1 { grid-template-columns: minmax(0,2fr) minmax(0,1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background .13s, border-color .13s, opacity .13s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { opacity: .88; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-dim); }
.btn.ghost:hover { background: var(--neutral-soft); color: var(--text); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-group { display: inline-flex; gap: 6px; }

/* ---------- forms ---------- */
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px;
  font-weight: 500; color: var(--text-dim); }
input, select, textarea {
  font: inherit; font-size: 13.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 7px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 64px; }
.field .help { font-weight: 400; color: var(--text-faint); font-size: 11.5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.req { color: var(--danger); }

.filters {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
  padding: 13px 17px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.filters label.field { min-width: 132px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 600; font-size: 11px; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-faint);
  padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
  background: var(--surface-2); position: sticky; top: 0;
}
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table .muted { color: var(--text-dim); }
tr.clickable { cursor: pointer; }

/* ---------- badges & status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
  background: var(--neutral-soft); color: var(--neutral); white-space: nowrap;
}
.badge.ok        { background: var(--ok-soft);     color: var(--ok); }
.badge.due_soon  { background: var(--warn-soft);   color: var(--warn); }
.badge.overdue   { background: var(--danger-soft); color: var(--danger); }
.badge.no_baseline,
.badge.inactive  { background: var(--neutral-soft); color: var(--neutral); }
.badge.critical  { background: var(--danger-soft); color: var(--danger); }
.badge.accent    { background: var(--accent-soft); color: var(--accent); }
.pos { color: var(--ok); font-weight: 600; }
.neg { color: var(--danger); font-weight: 600; }
.mono { font-family: var(--mono); font-size: 12px; }

/* ---------- KPI cards ---------- */
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi .k-label { font-size: 11.5px; color: var(--text-dim); font-weight: 500;
  text-transform: uppercase; letter-spacing: .04em; }
.kpi .k-value { font-size: 23px; font-weight: 650; margin-top: 5px;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .k-foot { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.kpi.accent-bar::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent);
}
.kpi.ok::before      { background: var(--ok); }
.kpi.warn::before    { background: var(--warn); }
.kpi.danger::before  { background: var(--danger); }

/* ---------- progress ---------- */
.progress { height: 6px; background: var(--neutral-soft); border-radius: 4px; overflow: hidden; min-width: 60px; }
.progress > span { display: block; height: 100%; border-radius: 4px; background: var(--ok); }
.progress.due_soon > span { background: var(--warn); }
.progress.overdue  > span { background: var(--danger); }
.progress.no_baseline > span { background: var(--neutral); }

/* ---------- vehicle cards ---------- */
.veh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(288px, 1fr)); gap: 16px; }
.veh-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; cursor: pointer;
  transition: border-color .13s, transform .13s, box-shadow .13s;
}
.veh-card:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.veh-top { padding: 15px 16px 13px; border-bottom: 1px solid var(--border); }
.veh-name { font-size: 15px; font-weight: 600; }
.veh-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.veh-stats { display: grid; grid-template-columns: repeat(3, 1fr); }
.veh-stat { padding: 11px 12px; border-right: 1px solid var(--border); }
.veh-stat:last-child { border-right: none; }
.veh-stat .s-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-faint); font-weight: 600; }
.veh-stat .s-value { font-size: 14px; font-weight: 600; margin-top: 2px;
  font-variant-numeric: tabular-nums; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--border); margin-bottom: 18px;
  overflow-x: auto; }
.tabs button {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 9px 13px; font: inherit; font-size: 13.5px; font-weight: 500;
  color: var(--text-dim); cursor: pointer; white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- modal ---------- */
.scrim {
  position: fixed; inset: 0; background: rgba(12,18,28,.45); z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.scrim.show { opacity: 1; pointer-events: auto; }
.modal {
  position: fixed; z-index: 60; inset: 0; display: grid; place-items: center;
  padding: 20px; pointer-events: none;
}
.modal-box {
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg);
  width: min(640px, 100%); max-height: 88vh; display: flex; flex-direction: column;
  pointer-events: auto; border: 1px solid var(--border);
}
.modal-box.wide { width: min(880px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; }
.modal-head h3 { font-size: 15.5px; flex: 1; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 9px; justify-content: flex-end; background: var(--surface-2);
  border-radius: 0 0 12px 12px; }
.close-x { background: none; border: none; font-size: 20px; line-height: 1;
  color: var(--text-faint); cursor: pointer; padding: 0 4px; }
.close-x:hover { color: var(--text); }

/* ---------- toast ---------- */
.toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 80;
  display: flex; flex-direction: column; gap: 9px; align-items: flex-end; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--ok);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  padding: 11px 15px; font-size: 13px; max-width: 340px;
  animation: slidein .18s ease-out;
}
.toast.error { border-left-color: var(--danger); }
@keyframes slidein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 44px 20px; color: var(--text-dim); }
.empty .e-icon { font-size: 30px; opacity: .35; }
.empty h4 { margin: 10px 0 5px; font-size: 14.5px; color: var(--text); }
.empty p { margin: 0 0 15px; font-size: 13px; max-width: 380px; margin-inline: auto; }

/* ---------- charts ---------- */
.chart { width: 100%; display: block; overflow: visible; }
.chart text { font-family: var(--font); fill: var(--text-dim); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-dim); }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 5px; }

.mix-list { display: flex; flex-direction: column; gap: 10px; }
.mix-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13px; }
.mix-row .bar { grid-column: 1 / -1; height: 5px; background: var(--neutral-soft);
  border-radius: 3px; overflow: hidden; }
.mix-row .bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid.split-2-1, .grid.cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  /* above the scrim (50) so the open menu takes taps, below dialogs (60) */
  .sidebar.open { transform: none; z-index: 55; box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .hamburger { display: block; }
  .content, .topbar { padding-inline: 15px; }
  .grid.cols-2, .grid.cols-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .veh-grid { grid-template-columns: 1fr; }
}

/* ---------- kpi grid ---------- */
.kpi-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); }
.attn-list { display: flex; flex-direction: column; }
.attn-row {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 17px; border-bottom: 1px solid var(--border);
}
.attn-row:last-child { border-bottom: none; }
.attn-row .a-main { flex: 1; min-width: 0; }
.attn-row .a-task { font-weight: 550; font-size: 13px; }
.attn-row .a-meta { font-size: 11.5px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.detail-list .d-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-faint); font-weight: 600; }
.detail-list .d-value { font-size: 13.5px; margin-top: 2px; }

/* ---------- service checklist ---------- */
.checklist-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 9px; font-size: 12.5px; color: var(--text-dim); }
.checklist {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  max-height: 310px; overflow-y: auto; background: var(--surface-2);
}
.check-row { border-bottom: 1px solid var(--border); }
.check-row:last-child { border-bottom: none; }
.check-head {
  display: flex; align-items: center; gap: 9px; padding: 8px 11px; cursor: pointer;
}
.check-head:hover { background: var(--surface); }
.check-row.on { background: var(--surface); }
.check-row.on > .check-head { border-left: 3px solid var(--accent); padding-left: 8px; }
.check-head input[type="checkbox"] { width: 15px; height: 15px; flex: 0 0 15px;
  accent-color: var(--accent); cursor: pointer; }
.check-title { flex: 1; min-width: 0; font-size: 13px; font-weight: 500; }
.check-sub { font-size: 11px; color: var(--text-dim); font-weight: 400; }
.check-detail {
  display: none; gap: 9px; padding: 0 11px 10px 35px;
  grid-template-columns: minmax(0,2fr) minmax(0,1fr);
}
.check-row.on .check-detail { display: grid; }
.check-detail input { font-size: 12.5px; padding: 5px 8px; }
.check-detail .lbl { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase;
  letter-spacing: .04em; font-weight: 600; display: block; margin-bottom: 3px; }
.extra-row { display: grid; grid-template-columns: minmax(0,2fr) minmax(0,1.5fr) minmax(0,1fr) auto;
  gap: 8px; align-items: end; margin-bottom: 8px; }
.total-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 11px 13px; margin-top: 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
}
.total-bar .t-label { font-size: 12.5px; color: var(--text-dim); }
.total-bar .t-sum { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.total-bar input { width: 130px; }
.section-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-faint); margin: 18px 0 8px; }
.section-label:first-child { margin-top: 0; }

/* ---------- plan bits ---------- */
.plan-tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  padding: 3px 9px; border-radius: 20px;
  background: var(--accent-soft); color: var(--accent); font-weight: 500;
}
.plan-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; cursor: pointer;
  transition: border-color .13s, transform .13s;
}
.plan-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.plan-card h4 { font-size: 14.5px; margin-bottom: 3px; }
.plan-card .p-meta { font-size: 12px; color: var(--text-dim); }
.plan-card .p-foot { display: flex; gap: 14px; margin-top: 12px; padding-top: 11px;
  border-top: 1px solid var(--border); font-size: 12px; color: var(--text-dim); }
.record-items { padding: 2px 0 0 0; }
.record-items li { list-style: none; font-size: 11.5px; color: var(--text-dim);
  padding: 1px 0; }
.record-items li b { font-weight: 550; color: var(--text); }

/* ---------- next-due preview in the service log ---------- */
.check-detail .next-due {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  padding: 6px 9px; border-radius: var(--radius-sm);
  background: var(--accent-soft); margin-top: 2px;
}
.check-detail .next-due .lbl { color: var(--accent); opacity: .8; }
.check-detail .nd-value { font-size: 12.5px; font-weight: 600; color: var(--accent);
  font-variant-numeric: tabular-nums; }

.return-bar {
  display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap;
  margin-top: 14px; padding: 11px 14px; border-radius: var(--radius-sm);
  background: var(--ok-soft); border: 1px solid var(--border);
  font-size: 13px; color: var(--ok);
}
.return-bar b { font-size: 14.5px; font-variant-numeric: tabular-nums; }
.return-bar .rb-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; opacity: .85; }
.return-bar .rb-task { color: var(--text-dim); font-size: 11.5px; }
.return-bar .rb-sep { color: var(--text-faint); font-size: 11.5px; margin: 0 4px; }
.return-bar .rb-empty { color: var(--text-dim); font-size: 12.5px; }

/* ---------- sign-in ---------- */
.auth-gate {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  padding: 24px; background: var(--bg); overflow-y: auto;
}
.login-card {
  width: min(400px, 100%); background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  padding: 26px; display: flex; flex-direction: column; gap: 15px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 3px; }
.login-brand h1 { font-size: 18px; }
.login-brand p { margin: 2px 0 0; color: var(--text-dim); font-size: 13px; }
.login-note {
  font-size: 12.5px; line-height: 1.5; color: var(--text-dim);
  background: var(--accent-soft); border-radius: var(--radius-sm); padding: 11px 13px;
}
.login-note strong { color: var(--text); }
.login-note code {
  font-family: var(--mono); font-size: 12px; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 4px; padding: 1px 5px;
}
.login-note.warn { background: var(--warn-soft); color: var(--warn); }
.login-error {
  font-size: 13px; color: var(--danger); background: var(--danger-soft);
  border-radius: var(--radius-sm); padding: 9px 12px;
}
.login-submit { justify-content: center; padding: 9px; font-size: 14px; }

/* ---------- signed-in user in the sidebar ---------- */
.sidebar-user {
  display: flex; align-items: center; gap: 9px; padding: 11px 14px;
  border-top: 1px solid var(--sidebar-line);
}
.su-avatar {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
}
.su-meta { flex: 1; min-width: 0; }
.su-name { color: var(--sidebar-strong); font-size: 12.5px; font-weight: 550;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.su-role { color: var(--sidebar-muted); font-size: 11px; text-transform: capitalize; }
.su-out {
  background: none; border: none; color: var(--sidebar-muted); cursor: pointer;
  font-size: 15px; padding: 3px 5px; border-radius: 5px; line-height: 1;
}
.su-out:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-hover-text); }

/* ---------- must-change-password banner ---------- */
.pw-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 18px;
  background: var(--warn-soft); border: 1px solid var(--border);
  border-left: 3px solid var(--warn); border-radius: var(--radius);
  font-size: 13px; color: var(--warn);
}
.pw-banner strong { color: var(--text); }
.pw-banner .spacer { flex: 1; }


/* ============================================================
   Poultry module + business overview
   ============================================================ */
.nav-section {
  font-size: 10.5px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase;
  color: var(--sidebar-muted); padding: 14px 11px 5px;
}
.nav-section:empty { padding: 6px 0 0; border-top: 1px solid var(--sidebar-line); margin-top: 10px; }

/* date-range presets */
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface); flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 12px; font: inherit; font-size: 12.5px;
  color: var(--text-dim); cursor: pointer; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--text); background: var(--neutral-soft); }
.seg button.active { background: var(--accent); color: #fff; }
.range-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.range-bar .field { min-width: 0; flex: 0 1 150px; }
.range-bar .seg { flex: 0 1 auto; }

/* end-of-day strip */
.eod { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px;
  background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
@media (max-width: 1100px) { .eod { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 520px)  { .eod { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.eod > div { background: var(--surface); padding: 12px 14px; }
.eod .l { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); }
.eod .v { font-size: 18px; font-weight: 650; margin-top: 3px; font-variant-numeric: tabular-nums; }

/* metric list (label left, value right) */
.metrics { display: grid; gap: 0; }
.metrics > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0;
  border-bottom: 1px dashed var(--border); font-size: 13px; }
.metrics > div:last-child { border-bottom: 0; }
.metrics .m-l { color: var(--text-dim); }
.metrics .m-v { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.metrics .m-v small { display: block; font-weight: 400; color: var(--text-faint); font-size: 11px; }

/* daily log entry grid */
.daily-grid { width: 100%; border-collapse: collapse; }
.daily-grid th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint);
  font-weight: 600; text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.daily-grid td { padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.daily-grid input, .daily-grid select { width: 100%; min-width: 70px; }
.daily-grid .already { font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.daily-grid .flock-cell { font-weight: 600; min-width: 120px; }
.daily-grid .flock-cell small { display: block; font-weight: 400; color: var(--text-faint); }

@media (max-width: 820px) {
  /* stack the daily grid into one card per flock */
  .daily-grid thead { display: none; }
  .daily-grid, .daily-grid tbody, .daily-grid tr, .daily-grid td { display: block; width: 100%; }
  .daily-grid tr { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 12px;
    padding: 6px 10px; display: grid; grid-template-columns: 1fr 1fr; column-gap: 10px; }
  .daily-grid td.flock-cell, .daily-grid td[data-label="Cause"] { grid-column: 1 / -1; }
  .daily-grid input, .daily-grid select { min-width: 0; }
  .daily-grid td { border: 0; padding: 6px 0; }
  .daily-grid td[data-label]::before { content: attr(data-label); display: block; font-size: 11px;
    text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); margin-bottom: 4px; }
  .seg button { padding: 7px 9px; }
}

/* flock cards */
.flock-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.flock-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; cursor: pointer; transition: border-color .15s; }
.flock-card:hover { border-color: var(--accent); }
.flock-card .f-top { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.flock-card .f-name { font-weight: 650; font-size: 15px; }
.flock-card .f-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.flock-card .f-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.flock-card .f-stats .l { font-size: 10.5px; text-transform: uppercase; color: var(--text-faint); letter-spacing: .04em; }
.flock-card .f-stats .v { font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.module-split { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* role-gated controls: anything marked admin-only disappears for recorders */
body:not(.is-admin) .admin-only { display: none !important; }

/* date fields: the whole box opens the calendar, so say so */
input[type="date"] { cursor: pointer; }
input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer; opacity: .75; padding: 2px; border-radius: 4px;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; background: var(--neutral-soft); }

/* recorders cannot open vehicle or project pages, so those names are plain text */
body:not(.is-admin) a[data-vehicle], body:not(.is-admin) a[data-project] {
  pointer-events: none; color: inherit; text-decoration: none;
}

/* theme switch in the sidebar footer */
.theme-switch { margin-left: auto; display: inline-flex; border: 1px solid var(--sidebar-line);
  border-radius: 7px; overflow: hidden; }
.theme-switch button { background: none; border: 0; color: var(--sidebar-muted); cursor: pointer;
  font-size: 12px; line-height: 1; padding: 5px 7px; }
.theme-switch button:hover { color: var(--sidebar-hover-text); background: var(--sidebar-hover-bg); }
.theme-switch button.active { color: var(--sidebar-active); background: var(--sidebar-active-bg); }

/* sidebar user block opens the profile */
.su-link { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; color: inherit;
  text-decoration: none; border-radius: var(--radius-sm); padding: 3px 4px; margin: -3px -4px; }
.su-link:hover { background: var(--sidebar-hover-bg); }

/* profile page */
.profile-head { display: flex; align-items: center; gap: 16px; }
.profile-avatar { width: 64px; height: 64px; flex: 0 0 64px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #4f8cff); color: #fff;
  display: grid; place-items: center; font-size: 26px; font-weight: 700; }
.profile-name { font-size: 20px; font-weight: 650; }
.profile-id { min-width: 0; }
