/* ==========================================================================
   Your shifts and mileage (/dashboard/ only)
   --------------------------------------------------------------------------
   Owner ruling 2026-10-03 (web shifts, Option B): the account page opens the
   mileage file the app saves, in the browser. Linked by /dashboard/ only
   (src/lib/render.mjs), so no other route downloads it. Colours and type come
   from the global.css tokens. Classes starting "shift-mileage-" style the
   static frame in render.mjs; "sm-" styles what src/client/shift-mileage.js
   draws. Source states pair colour with words: a badge always says what it
   means, so colour is never the only signal.
   ========================================================================== */

.shift-mileage {
  display: grid;
  gap: 18px;
  margin-top: 24px;
  scroll-margin-top: 96px;
}

/* Every block below sets a display, which beats the UA's [hidden] rule, so
   hidden has to be restated (the account.css lesson). */
.shift-mileage [hidden] {
  display: none !important;
}

.shift-mileage-head {
  display: grid;
  gap: 10px;
  max-width: 72ch;
}

.shift-mileage-head .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
}

.shift-mileage-head h2 {
  margin: 0;
  font-family: var(--font-brand);
  font-weight: var(--font-weight-heading);
  font-size: clamp(24px, 2.6vw, 30px);
  line-height: 1.2;
  color: var(--ink);
}

.shift-mileage-head p,
.shift-mileage p {
  margin: 0;
}

/* global.css gives every `details p` the FAQ's 58px indent, every `details` a
   bottom rule, and every `summary` a four-column grid with no disclosure
   marker. The tool's disclosures are reset here and get their own chevron, so
   a driver can see that a month or a note opens. */
.shift-mileage details p {
  padding: 0;
}

.shift-mileage details {
  border-bottom: 0;
}

.shift-mileage summary {
  grid-template-columns: none;
  list-style: none;
}

.shift-mileage summary::-webkit-details-marker {
  display: none;
}

.shift-mileage summary::before {
  content: "";
  flex: 0 0 auto;
  align-self: center;
  width: 7px;
  height: 7px;
  margin: 0 4px 0 2px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 160ms ease;
}

.shift-mileage details[open] > summary::before {
  transform: rotate(45deg);
}

@media (prefers-reduced-motion: reduce) {
  .shift-mileage summary::before {
    transition: none;
  }
}

.shift-mileage-head > p {
  color: var(--muted);
  font-size: 15px;
  font-weight: var(--font-weight-body);
  line-height: 1.55;
}

.shift-mileage-head > .shift-mileage-local {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  border: 1px solid rgba(20, 147, 90, 0.3);
  border-radius: 12px;
  background: var(--green-soft);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

.shift-mileage-local .rg-icon {
  flex: 0 0 auto;
  margin-top: 1px;
}

.shift-mileage-local strong {
  color: var(--green-text);
}

.shift-mileage-steps {
  display: grid;
  gap: 8px;
  max-width: 72ch;
  margin: 0;
  padding-left: 22px;
  color: var(--ink);
  font-size: 14px;
  font-weight: var(--font-weight-body);
  line-height: 1.5;
}

.shift-mileage-open {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 16px;
  border: 1.5px dashed #b6c9e6;
  border-radius: 16px;
  background: var(--wash);
}

.shift-mileage-open.is-dragover {
  border-color: var(--blue);
  background: #eef5ff;
}

/* The file input is visually hidden but stays in the tab order; its label is
   the visible button, and it shows the input's keyboard focus. */
.shift-mileage-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.shift-mileage-input:focus-visible + .shift-mileage-pick {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

.shift-mileage-input:disabled + .shift-mileage-pick {
  opacity: 0.55;
  cursor: not-allowed;
}

.shift-mileage-hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: var(--font-weight-body);
  line-height: 1.4;
}

.shift-mileage .shift-mileage-nojs {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 13px;
}

.shift-mileage-status {
  color: var(--ink);
  font-size: 14px;
  font-weight: var(--font-weight-body);
  line-height: 1.5;
}

.shift-mileage-status:empty {
  display: none;
}

.shift-mileage-status[data-state="ok"] {
  padding: 10px 12px;
  border: 1px solid rgba(20, 147, 90, 0.3);
  border-radius: 12px;
  background: var(--green-soft);
  color: var(--green-text);
}

.shift-mileage-status[data-state="error"] {
  padding: 10px 12px;
  border: 1px solid rgba(201, 42, 42, 0.25);
  border-radius: 12px;
  background: var(--error-soft);
  color: var(--error);
}

.shift-mileage-status[data-state="pending"] {
  color: var(--muted);
}

/* The mileage log opened, but part of the file (its shift summary) could not
   be used: said in the yellow caution tone, with the words saying why. */
.shift-mileage-status[data-state="warn"],
.shift-mileage-pay-note[data-state="warn"] {
  padding: 10px 12px;
  border: 1px solid #e8c56a;
  border-radius: 12px;
  background: var(--yellow-soft);
  color: var(--ink);
}

.shift-mileage-results {
  display: grid;
  gap: 16px;
}

.shift-mileage-files {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
}

.shift-mileage-file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.shift-mileage-file-list li {
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.shift-mileage-file-list strong {
  color: var(--ink);
}

.shift-mileage-range {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px 12px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.shift-mileage-range legend {
  padding: 0 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: var(--font-weight-ui-strong);
}

/* global.css styles every `fieldset label` as a bordered two-column chip (the
   option cards); these are plain stacked fields. */
.shift-mileage-range label,
.shift-mileage-odometer-fields label {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 5px;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: var(--font-weight-body);
}

.shift-mileage select,
.shift-mileage input[type="date"],
.shift-mileage input[type="number"] {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid #d4dfed;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
}

.shift-mileage select:focus-visible,
.shift-mileage input:focus-visible,
.shift-mileage button:focus-visible,
.shift-mileage summary:focus-visible,
.shift-mileage a:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.shift-mileage-range-note {
  color: var(--muted);
  font-size: 14px;
}

.shift-mileage-subhead {
  margin: 4px 0 0;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: var(--font-weight-ui-strong);
}

.shift-mileage-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 0;
}

.shift-mileage-totals > div {
  display: grid;
  align-content: start;
  gap: 3px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.shift-mileage-totals dt {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: var(--font-weight-ui-strong);
}

.shift-mileage-totals dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.shift-mileage-value {
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 21px;
  font-weight: var(--font-weight-ui-strong);
  line-height: 1.25;
}

.shift-mileage-detail {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: var(--font-weight-body);
  line-height: 1.4;
}

.shift-mileage-pay-note {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--gray-soft);
  color: #4b5563;
  font-size: 13.5px;
  line-height: 1.5;
}

.shift-mileage-fineprint {
  max-width: 78ch;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: var(--font-weight-body);
  line-height: 1.5;
}

.shift-mileage .shift-mileage-odometer {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.shift-mileage-odometer > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 12px 14px;
  color: var(--ink);
  font-size: 14px;
  font-weight: var(--font-weight-ui-strong);
  cursor: pointer;
}

.shift-mileage-odometer > p,
.shift-mileage-odometer-fields {
  margin: 0 14px 12px;
}

.shift-mileage-odometer > p {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.shift-mileage-odometer-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.shift-mileage-odometer > .shift-mileage-odometer-result {
  color: var(--ink);
  font-weight: var(--font-weight-ui-strong);
}

.shift-mileage-odometer-result:empty {
  display: none;
}

.shift-mileage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.shift-mileage-actions .button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.shift-mileage-action-note {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.shift-mileage-action-note:empty {
  display: none;
}

.shift-mileage-months {
  display: grid;
  gap: 8px;
}

/* --- drawn by shift-mileage.js ------------------------------------------- */

.shift-mileage .sm-month {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.sm-month > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  min-height: 44px;
  padding: 12px 14px;
  color: var(--ink);
  font-size: 15px;
  cursor: pointer;
}

.sm-month-name {
  color: var(--ink);
  font-size: 15px;
}

.sm-month-facts {
  color: var(--muted);
  font-size: 13px;
  font-weight: var(--font-weight-body);
}

.sm-shifts {
  margin: 0;
  padding: 0 14px 4px;
  list-style: none;
}

.sm-shift {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 6px 18px;
  padding: 12px 0;
  border-top: 1px solid var(--soft-line);
}

.sm-shift-when,
.sm-shift-figures {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  min-width: 0;
}

.sm-shift-when {
  flex-direction: column;
  align-items: flex-start;
}

.sm-shift-day,
.sm-shift-miles {
  color: var(--ink);
  font-size: 14px;
}

.sm-shift-time,
.sm-shift-apps,
.sm-shift-online,
.sm-shift-deduction,
.sm-shift-gross,
.sm-shift-orders {
  color: var(--muted);
  font-size: 13px;
  font-weight: var(--font-weight-body);
  overflow-wrap: anywhere;
}

.sm-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--gray-soft);
  color: #4b5563;
  font-size: 12px;
  font-weight: var(--font-weight-ui-strong);
  line-height: 1.5;
}

.sm-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.sm-badge[data-source="MEASURED"] {
  border-color: rgba(20, 147, 90, 0.35);
  background: var(--green-soft);
  color: var(--green-text);
}

.sm-badge[data-source="MEASURED_LIMITED"] {
  border-color: #e8c56a;
  background: var(--yellow-soft);
  color: #7a5100;
}

.sm-shift > .sm-shift-reason,
.sm-shift > .sm-shift-notes {
  grid-column: 1 / -1;
}

.sm-shift-reason {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.sm-shift-notes > summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 4px 0;
  color: var(--blue);
  font-size: 13px;
  font-weight: var(--font-weight-ui-strong);
  cursor: pointer;
}

.sm-shift-notes ul {
  display: grid;
  gap: 4px;
  margin: 2px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.sm-print {
  display: none;
}

@media (max-width: 760px) {
  .shift-mileage-range {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .shift-mileage-range label:first-of-type {
    grid-column: 1 / -1;
  }

  .sm-shift {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 600px) {
  .shift-mileage-open {
    padding: 14px;
  }

  .shift-mileage-open .shift-mileage-pick,
  .shift-mileage-actions .button {
    width: 100%;
  }

  .shift-mileage-totals {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .shift-mileage-value {
    font-size: 19px;
  }

  .shift-mileage-odometer-fields {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --- print: the mileage log only -------------------------------------------
   shift-mileage.js puts the report (.sm-print) straight under <body> and sets
   data-shift-mileage-print on <html> while it exists. Without it, nothing here
   applies and the page prints as it is. */
@media print {
  @page {
    margin: 12mm;
  }

  html[data-shift-mileage-print] body > :not(.sm-print) {
    display: none !important;
  }

  html[data-shift-mileage-print] body {
    background: #fff !important;
  }

  html[data-shift-mileage-print] body::before,
  html[data-shift-mileage-print] body::after {
    display: none !important;
  }

  /* A plain document: the site's display type (global h1, h2 and p rules)
     is reset, so the log reads like the app's own printable summary. */
  html[data-shift-mileage-print] .sm-print {
    display: block;
    color: #111;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 10pt;
    font-weight: 400;
    line-height: 1.4;
  }

  .sm-print h1,
  .sm-print h2 {
    max-width: none;
    color: #111;
    font-family: inherit;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.25;
  }

  .sm-print h1 {
    margin: 0 0 4pt;
    font-size: 16pt;
  }

  .sm-print h2 {
    margin: 14pt 0 5pt;
    font-size: 12pt;
    break-after: avoid;
  }

  .sm-print p {
    max-width: none;
    margin: 0 0 5pt;
    color: #111;
    font-size: 10pt;
    font-weight: 400;
    line-height: 1.4;
  }

  .sm-print .sm-print-meta {
    color: #444;
  }

  .sm-print .sm-print-strong {
    font-weight: 700;
  }

  .sm-print table {
    width: 100%;
    margin: 0 0 5pt;
    border-collapse: collapse;
    font-size: 8.5pt;
  }

  .sm-print .sm-print-totals {
    width: auto;
    min-width: 60%;
  }

  .sm-print th,
  .sm-print td {
    padding: 3pt 4pt;
    border: 0.5pt solid #999;
    color: #111;
    font-weight: 400;
    text-align: left;
    vertical-align: top;
    overflow-wrap: break-word;
  }

  .sm-print th {
    background: #eee;
    font-weight: 700;
  }

  .sm-print .sm-nowrap {
    white-space: nowrap;
  }

  .sm-print thead {
    display: table-header-group;
  }

  .sm-print tr {
    break-inside: avoid;
  }
}
