/* ================================================================
   Kilometre Log (wave246-kmlog; wave253 restyle, 2026-10-30) —
   the Kilometres page (kmlog.js): header with the Vehicle / Year
   dropdowns, the per-vehicle year report cards, the trip register,
   and the trip / Vehicles / rates / import dialogs. The Timesheets
   look (timesheets.css): quiet cards, small-caps column heads,
   navy month rows, status-style tags, and gold ONLY for the one
   main action (+ Add trip — the house gold button). Wave253 reads
   trips as a day-by-day list (month band, date gutter, purpose
   pill, weekends shaded) and each year card as a summary table;
   the one money figure it styles is the reimbursement row, which
   only exists when the owner has set mileage rates.
   ================================================================ */

.km-page { max-width: none; }
.km-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.km-title { margin: 0 8px 0 0; font-size: 22px; font-weight: 700; align-self: center; }
.km-head-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.km-f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.km-f select {
  font-size: 14px; padding: 7px 9px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card-bg, #fff); color: var(--ink); min-width: 150px;
}
.km-flash {
  border: 1px solid #b7dfc2; background: #eefaf1; color: #14532d;
  border-radius: 8px; padding: 9px 12px; font-size: 13.5px; margin-bottom: 12px;
}
.km-flash-bad { border-color: #f5c2c0; background: #fdf0ef; color: #8a1c13; }
.km-notice { font-size: 13px; color: var(--muted); margin: 0 0 6px; }
.km-note { font-size: 12.5px; color: var(--muted); margin: 0 0 16px; max-width: 86ch; line-height: 1.5; }
.km-h {
  font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  font-weight: 650; margin: 18px 0 8px;
}
.km-empty { margin: 4px 0 8px; }

/* --- the year report: one card per vehicle --- */
.km-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.km-card {
  background: var(--card-bg, #fff); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 16px;
}
.km-card-h { margin: 0 0 8px; font-weight: 700; font-size: 15px; }
.km-sub-inline { font-weight: 500; color: var(--muted); font-size: 12.5px; }
.km-card-row {
  display: flex; justify-content: space-between; gap: 12px; padding: 4px 0;
  font-size: 13.5px; border-bottom: 1px dashed var(--line); font-variant-numeric: tabular-nums;
}
.km-card-row span { color: var(--muted); }
.km-card-row b { font-weight: 600; text-align: right; }
.km-card-key b { font-size: 15px; }
.km-card-pct { border-bottom: none; }
.km-card-pct b { font-size: 18px; color: var(--navy, #0B2235); }
.km-card-why { margin: 8px 0 0; font-size: 12.5px; line-height: 1.45; color: #92400e; background: #fffbeb; border-radius: 6px; padding: 7px 9px; }
.km-card-foot { margin: 8px 0 0; font-size: 12px; color: var(--muted); }

/* --- the year card's summary table (wave253): Type | Distance | Percentage --- */
.km-sum { width: 100%; border-collapse: collapse; margin: 0 0 8px; }
.km-sum th {
  text-align: left; font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); font-weight: 650; padding: 3px 8px 5px 0; border-bottom: 1px solid var(--line);
}
.km-sum th.km-num, .km-sum td.km-num { text-align: right; padding-right: 0; }
.km-sum td {
  padding: 5px 8px 5px 0; font-size: 13.5px; border-bottom: 1px dashed var(--line);
  font-variant-numeric: tabular-nums;
}
.km-sum tr.km-sum-total td { font-weight: 650; border-bottom: none; }
.km-card-reimb b { color: var(--navy, #0B2235); }

/* --- the trip register --- */
.km-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--card-bg, #fff); }
.km-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.km-table th {
  text-align: left; font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.km-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
.km-table tr:last-child td { border-bottom: none; }
.km-table tr.km-month td {
  background: #f1f5f9; font-size: 12px; font-weight: 650; letter-spacing: .03em;
  text-transform: uppercase; color: var(--navy, #0B2235); padding: 7px 10px;
}
.km-month-sum { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); margin-left: 8px; }

/* --- the trip register as a day-by-day list (wave253) --- */
.km-list { border: 1px solid var(--line); border-radius: 10px; background: var(--card-bg, #fff); overflow: hidden; }
.km-month {
  background: #f1f5f9; font-size: 12px; font-weight: 650; letter-spacing: .03em;
  text-transform: uppercase; color: var(--navy, #0B2235); padding: 7px 12px;
  border-top: 1px solid var(--line);
}
.km-list > .km-month:first-child { border-top: none; }
.km-day { display: flex; gap: 14px; padding: 10px 12px; border-top: 1px solid var(--line); }
.km-day-wknd { background: #f8fafc; }
.km-date { flex: 0 0 42px; text-align: center; padding-top: 1px; }
.km-date-d { display: block; font-size: 21px; font-weight: 700; line-height: 1.1; color: var(--navy, #0B2235); }
.km-date-w { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-top: 1px; }
.km-day-trips { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.km-trow { display: flex; gap: 12px; align-items: flex-start; padding: 5px 0; }
.km-trow + .km-trow { border-top: 1px dashed var(--line); }
.km-tmain { flex: 1; min-width: 0; font-size: 14px; }
.km-dest { font-weight: 600; }
.km-tsub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.km-tuse { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; flex: 0 0 auto; padding-top: 1px; }
.km-pill {
  background: #f1f5f9; color: #475569; border-radius: 999px; padding: 1px 8px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
}
.km-tkm {
  flex: 0 0 auto; min-width: 72px; text-align: right; font-size: 14px; font-weight: 600;
  white-space: nowrap; font-variant-numeric: tabular-nums; padding-top: 1px;
}

/* --- the import preview + the dialogs' solid button (wave253) --- */
.km-imp-prev {
  background: #f7f9fb; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 13.5px; margin-top: 12px;
}
.km-imp-prev p { margin: 0 0 4px; }
.km-imp-prev ul { margin: 6px 0 0; padding-left: 18px; }
.km-imp-prev li { margin: 2px 0; }
.km-btn-solid {
  background: var(--navy, #0B2235); border: 1px solid var(--navy, #0B2235); color: #fff;
}
.km-btn-solid:hover { filter: brightness(1.2); }
.km-btn-solid:disabled { opacity: .5; cursor: default; filter: none; }
.km-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.km-nowrap { white-space: nowrap; }
.km-strong { font-weight: 600; }
.km-sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.km-faint { color: var(--muted); }
.km-act { width: 36px; text-align: right; }
.km-iconbtn {
  appearance: none; border: 1px solid transparent; background: none; color: var(--muted);
  border-radius: 7px; width: 30px; height: 30px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.km-iconbtn:hover, .km-iconbtn:focus-visible { border-color: var(--line); color: var(--navy, #0B2235); }

/* tags read like the Timesheets status pills */
.km-tag { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.km-tag-business { background: #dcfce7; color: #166534; }
.km-tag-personal { background: #e0e7ef; color: #334155; }
.km-tag-off { background: #f1f5f9; color: #64748b; }
.km-tag-work { background: #ede9fe; color: #5b21b6; }

/* --- dialogs (inside fxDialog) --- */
.fx-dialog.km-dialog { max-width: 680px; width: calc(100vw - 32px); }
.fx-dialog.km-veh-dialog { max-width: 820px; }
.km-dlg-p { font-size: 14px; line-height: 1.5; }
.km-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin-top: 6px; }
.km-form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.km-form-grid input, .km-form-grid select, .km-form-grid textarea {
  font-size: 14px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card-bg, #fff); color: var(--ink); width: 100%; box-sizing: border-box; font-family: inherit;
}
.km-form-grid .wide { grid-column: 1 / -1; }
.km-form-grid label.km-check { flex-direction: row; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink); align-self: end; padding-bottom: 8px; }
.km-form-grid label.km-check input { width: auto; }
.km-field-note { font-size: 12px; color: var(--muted); font-weight: 400; }
.km-use { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.km-use-opt {
  flex-direction: row !important; align-items: center; gap: 7px !important; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 13.5px !important; color: var(--ink) !important;
}
.km-use-opt input { width: auto !important; margin: 0; }
.km-use-opt:has(input:checked) { background: var(--navy, #0B2235); border-color: var(--navy, #0B2235); color: #fff !important; }
.km-use-opt.km-use-fixed { background: var(--navy, #0B2235); border-color: var(--navy, #0B2235); color: #fff !important; cursor: default; }
.km-form-err { margin: 10px 0 0; font-size: 13px; color: #b42318; }
.km-form-err.hidden { display: none; }
.km-linkbtn {
  appearance: none; border: none; background: none; cursor: pointer; padding: 4px 0;
  font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px;
}
.km-linkbtn-danger { color: #b42318; }
.km-delq { font-size: 13px; color: #b42318; margin-right: 6px; }
#km-delzone { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.km-veh-tools { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 10px; }
.km-veh-tools .grow { flex: 1; }
.km-veh-table { min-width: 620px; }
.km-veh-form { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #f7f9fb; }
.km-veh-form h4 { margin: 0 0 4px; font-size: 14px; }
.km-veh-form > .km-field-note { margin: 10px 0 0; line-height: 1.45; }
.km-veh-form-actions { display: flex; gap: 8px; margin-top: 12px; }
.km-veh-form-actions .grow { flex: 1; }

@media (max-width: 760px) {
  .km-head { align-items: stretch; }
  .km-title { flex: 1 1 100%; }
  .km-f, .km-f select { flex: 1 1 100%; width: 100%; }
  .km-head-actions { margin-left: 0; width: 100%; }
  .km-head-actions .btn { flex: 1 1 auto; }
  .km-form-grid { grid-template-columns: 1fr; }
  .km-day { gap: 10px; padding: 10px; }
  .km-date { flex-basis: 34px; }
  .km-tkm { min-width: 58px; }
  .km-trow { flex-wrap: wrap; }
  .km-tmain { flex: 1 1 55%; }
}

/* ---- wave590-fullwidth (2026-11-11): the page cap comes off
 * in EVERY rail state. Micheal ruled 2026-10-16 that every
 * portal screen fills the whole window; the shell cap came off
 * then, but this page kept its own 1240px cap. The Nov 10 fix
 * (wave550, in styles.css) lifted the cap only while the rail
 * was collapsed — his 2026-11-11 screenshots of Obligations
 * and Inventory with the sidebar EXPANDED, stopped mid-screen,
 * settle it for the whole capped set: the collapsed-only lift
 * is superseded, uncapped here in all states. The day cards
 * inside are fluid (auto-fill minmax 260px/1fr; flex rows). ---- */
.km-page { max-width: none; }
