/* Aranah web SPA — minimal read-only scorecard styles.
   Intentionally framework-free (no Tailwind, no design tokens). The brand
   palette here is the same palette used in the production logo: navy-teal,
   teal, teal-light, HuiDots Green as the destination accent. See
   `brand_explorations/production/02_endorsed_family/aranah_primary_logo_option_b.svg`
   for the canonical source. */

:root {
  --navy-teal: #0a2e2a;
  --teal: #0e7c6b;
  --teal-light: #3ec7b7;
  --huidots-green: #7bc143;
  --ink-soft: #2a3142;
  --ink-muted: #5b6473;
  --paper: #fafbfc;
  --paper-edge: #e3e7ec;
  --shadow: 0 2px 12px rgba(10, 46, 42, 0.06);
}

* {
  box-sizing: border-box;
}
[hidden] { display: none !important; }

html,
body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink-soft);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.masthead h1 {
  font-size: 36px;
  margin: 0 0 4px;
  color: var(--navy-teal);
  letter-spacing: -0.02em;
  font-weight: 700;
}
.masthead .tagline {
  margin: 0 0 32px;
  color: var(--teal);
  font-size: 14px;
  letter-spacing: 0.01em;
}
.masthead { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.auth-controls { text-align: right; max-width: 270px; }
.auth-controls button { font: inherit; border: 1px solid var(--teal); border-radius: 6px; padding: 8px 12px; color: var(--navy-teal); background: white; cursor: pointer; min-height: 40px; }
#auth-provider-buttons { display: flex; flex-direction: column; align-items: stretch; gap: 6px; margin-top: 6px; }
#auth-status { margin: 6px 0 0; color: var(--ink-muted); font-size: 12px; }
@media (max-width: 560px) { .masthead { flex-direction: column; } .auth-controls { text-align: left; max-width: none; } }

.dropzone-wrap {
  margin: 0 0 32px;
}
.dropzone {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 32px 24px;
  background: white;
  border: 2px dashed var(--paper-edge);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: border-color 120ms ease, background 120ms ease;
  box-shadow: var(--shadow);
}
.dropzone:hover,
.dropzone:focus,
.dropzone.is-dragging {
  border-color: var(--teal);
  background: #f3fbf9;
  outline: none;
}
.dropzone-headline {
  font-size: 18px;
  font-weight: 600;
  color: var(--navy-teal);
}
.dropzone-sub {
  font-size: 13px;
  color: var(--ink-muted);
}
.dropzone-hint {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--ink-muted);
  text-align: center;
}

/* M3.1 — vehicle-class persona picker. Lives below the dropzone hint.
   Radio buttons styled as compact pills so the scorecard stays the
   visual focus on phone screens. */
.persona-picker {
  margin: 18px 0 0;
  padding: 14px 14px 12px;
  border: 1px solid var(--paper-edge);
  border-radius: 10px;
  background: var(--paper);
}
.persona-legend {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 0 4px;
}
.persona-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.persona-option {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid var(--paper-edge);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  min-height: 44px;
  transition: border-color 120ms ease, background 120ms ease;
}
.persona-option:hover,
.persona-option:focus-within {
  border-color: var(--teal);
  background: #f3fbf9;
}
.persona-option input[type="radio"] {
  accent-color: var(--teal);
  margin: 0;
}
.persona-option-label {
  font-weight: 500;
}

/* M3.1 — platform-neutrality banner (rendered once on first load).
   Slim dismissable strip below the install hint. */
.platform-banner {
  margin: 12px 0 0;
  padding: 10px 14px;
  background: #f3fbf9;
  border: 1px solid var(--teal-light);
  border-radius: 10px;
  color: var(--ink-soft);
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 12px;
  line-height: 1.5;
}
.platform-banner-body {
  margin: 0;
  flex: 1;
}
.platform-banner-dismiss {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--paper-edge);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--ink-muted);
  cursor: pointer;
  min-height: 32px;
  font-family: inherit;
}

.scorecard {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.scorecard h2 {
  margin: 0 0 16px;
  color: var(--navy-teal);
  font-size: 18px;
  letter-spacing: -0.01em;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 0;
}
.metrics > div {
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: 8px;
  padding: 12px 14px;
}
.metrics .emphasis {
  background: linear-gradient(135deg, #f3fbf9 0%, #fafbfc 100%);
  border-color: var(--teal-light);
}
.metrics dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin: 0 0 4px;
}
.metrics dd {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: var(--navy-teal);
  font-variant-numeric: tabular-nums;
}
.metrics .emphasis dd {
  color: var(--teal);
}
.disclaimer {
  margin: 24px 0 0;
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.55;
}
.disclaimer code {
  font-size: 11px;
  background: var(--paper);
  padding: 1px 4px;
  border-radius: 3px;
}

.export-actions { display: flex; gap: 8px; margin-top: 16px; }
.export-actions button, .history-head select, .history-table button { font: inherit; border: 1px solid var(--teal); border-radius: 6px; padding: 8px 12px; color: var(--navy-teal); background: white; cursor: pointer; }
.export-actions button { background: var(--teal); color: white; min-height: 44px; }
.history { background: white; border-radius: 12px; padding: 24px; box-shadow: var(--shadow); margin-top: 24px; }
.history-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }.history-head h2 { margin: 0; color: var(--navy-teal); font-size: 18px; }
.trend-chart { width: 100%; height: auto; margin-top: 12px; background: var(--paper); border: 1px solid var(--paper-edge); border-radius: 8px; }
.history-table { width: 100%; border-collapse: collapse; font-size: 13px; }.history-table th,.history-table td { padding: 8px; text-align: right; border-bottom: 1px solid var(--paper-edge); }.history-table th:first-child,.history-table td:first-child { text-align: left; }

/* M3.1 — FEDR-aware tax preview block. Sits alongside the operational
   scorecard so the driver can see deemed expenses + taxable income in
   the same glance as the operational net take-home. The non-advice
   disclaimer copy (verbatim from ARANAH_COMMERCIAL_BRIEF.md §5.1) lives
   below the preview block. */
.tax-preview {
  margin: 0;
  padding: 16px;
  background: linear-gradient(135deg, #f3fbf9 0%, #fafbfc 100%);
  border: 1px solid var(--teal-light);
  border-radius: 10px;
}
.tax-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 0;
}
.tax-preview-grid > div {
  background: white;
  border: 1px solid var(--paper-edge);
  border-radius: 8px;
  padding: 10px 12px;
}
.tax-preview-grid > div.emphasis {
  background: white;
  border-color: var(--teal);
}
.tax-preview-grid dt {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin: 0 0 4px;
}
.tax-preview-grid dd {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--navy-teal);
  font-variant-numeric: tabular-nums;
}
.tax-preview-grid > div.emphasis dd {
  color: var(--teal);
}
.tax-preview-cap-note {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--ink-muted);
  background: #fff8e1;
  border: 1px solid #f5d76e;
  border-radius: 6px;
  padding: 8px 10px;
}
.preview-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  background: #fff8e1;
  border: 1px solid #f5d76e;
  color: #4a3700;
  font-size: 10px;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
}

/* M3.1 — S-plate non-deduction reminder (shown when the driver's
   vehicle class is not eligible for FEDR deemed expenses). Mirrors
   the S_PLATE_NON_DEDUCTION_REMINDER copy from fedr.ts. */
.s-plate-reminder {
  margin: 0;
  padding: 14px 16px;
  background: #fff5f5;
  border: 1px solid #f5c2c0;
  border-radius: 10px;
  color: #8a1f1c;
}
.s-plate-reminder-body {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.55;
}
.s-plate-reminder-link {
  margin: 0;
  font-size: 12px;
}
.s-plate-reminder-link a {
  color: var(--teal);
  text-decoration: none;
  font-weight: 600;
}
.s-plate-reminder-link a:hover,
.s-plate-reminder-link a:focus {
  text-decoration: underline;
}

/* M3.1 — mandatory non-advice disclaimer (verbatim copy from
   ARANAH_COMMERCIAL_BRIEF.md §5.1, also re-exported as
   TAX_NON_ADVICE_DISCLAIMER in src/services/fedr.ts). Always rendered
   on the scorecard so every view of the preview carries the same
   caveat. */
.tax-disclaimer {
  font-size: 11px;
  line-height: 1.55;
  background: var(--paper);
  border-left: 3px solid var(--teal-light);
  padding: 10px 12px;
  border-radius: 0 6px 6px 0;
}

.errors {
  background: #fff5f5;
  border: 1px solid #f5c2c0;
  border-radius: 8px;
  padding: 16px;
  margin-top: 24px;
  color: #8a1f1c;
}
.errors h2 {
  margin: 0 0 8px;
  font-size: 14px;
  color: #8a1f1c;
}
.errors pre {
  margin: 0;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* M1.2 — weekly review tables (5-band breakdown + drag analysis) */
.section-heading {
  margin: 24px 0 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--navy-teal);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.section-sub {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--ink-muted);
}
.section-sub code {
  font-size: 11px;
  background: var(--paper-edge);
  padding: 1px 4px;
  border-radius: 3px;
}
.band-table,
.drag-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 12px;
}
.band-table th,
.band-table td,
.drag-table th,
.drag-table td {
  text-align: right;
  padding: 6px 8px;
  border-bottom: 1px solid var(--paper-edge);
}
.band-table th:first-child,
.band-table td:first-child,
.drag-table th:first-child,
.drag-table td:first-child {
  text-align: left;
}
.band-table thead th,
.drag-table thead th {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--navy-teal);
}
.band-table tr.empty-row td,
.drag-table tr.empty-row td {
  color: var(--ink-muted);
  font-style: italic;
  text-align: center;
}

/* M2.1 — platform tag on the scorecard */
.platform-line {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--ink-muted);
}
.platform-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.02em;
}
.platform-tag[data-platform="grab"] {
  background: var(--teal-light);
  color: var(--navy-teal);
}
.platform-tag[data-platform="grabfood"] {
  background: var(--huidots-green);
  color: white;
}
.platform-tag[data-platform="unknown"] {
  background: #f5d76e;
  color: #4a3700;
}

/* M2.2 — responsive layout for phones (≤ 414px wide, iPhone Plus width
   and below). Collapses the scorecard into a single column, scales
   typography down a touch, and enforces the 44px touch-target minimum
   on the dropzone + dropzone hint so fat-finger taps still land.

   Desktop layout above this breakpoint is unchanged. */
@media (max-width: 414px) {
  .page {
    padding: 16px 14px 48px;
  }

  .masthead h1 {
    font-size: 28px;
  }
  .masthead .tagline {
    font-size: 13px;
    margin: 0 0 20px;
  }

  /* Drop zone — give it the 44px tap-target floor on the headline + sub
     rows (the label itself fills the box). */
  .dropzone {
    padding: 24px 18px;
    gap: 8px;
    border-radius: 10px;
  }
  .dropzone-headline {
    font-size: 17px;
    /* Min 44px tap target on the headline row so a finger tap anywhere
       on the dropzone triggers the file picker via the label. */
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .dropzone-sub {
    font-size: 13px;
  }
  .dropzone-hint {
    margin: 10px 0 0;
    font-size: 13px;
  }

  /* Scorecard — collapse the multi-column metric grid into a single
     column. The metric tiles stack vertically so each row has the
     width to show the label + value without truncation. The two
     emphasis tiles (Net earnings, Net hourly) get `order` so they
     lead the stack — drivers want to see the take-home number first. */
  .scorecard {
    padding: 18px 16px;
    border-radius: 10px;
  }
  .scorecard h2 {
    font-size: 17px;
    margin: 0 0 12px;
  }
  .metrics {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .metrics > div {
    padding: 12px 14px;
    /* Floor each metric tile at 44px so the rows have a comfortable
       tap target if the dashboard grows interactive later. */
    min-height: 44px;
  }
  /* Lead the column with Net earnings + Net hourly on phone screens
     via CSS order — DOM order stays desktop-friendly for screen
     readers and the existing 5-band / drag tables. */
  .metrics > div:nth-child(4) { order: 1; } /* Net earnings */
  .metrics > div:nth-child(6) { order: 2; } /* Net hourly */
  .metrics > div:nth-child(1) { order: 3; } /* Gross */
  .metrics > div:nth-child(2) { order: 4; } /* Platform fees */
  .metrics > div:nth-child(3) { order: 5; } /* Operating costs */
  .metrics > div:nth-child(5) { order: 6; } /* Hours */
  .metrics > div:nth-child(7) { order: 7; } /* Trips */
  .metrics dt {
    font-size: 12px;
  }
  .metrics dd {
    font-size: 22px;
  }
  .metrics .emphasis dd {
    font-size: 22px;
  }

  /* Tables — wrap the whole table in `.table-scroll` (CSS below) so a
     narrow phone viewport scrolls horizontally without the column
     misalignment that `display:block` on the table itself causes.
     The table keeps its native column widths; the wrapper does the
     overflow scrolling. */
  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .band-table,
  .drag-table {
    font-size: 13px;
    min-width: 100%;
    width: max-content;
  }
  .band-table th,
  .band-table td,
  .drag-table th,
  .drag-table td {
    padding: 8px 10px;
  }

  .section-heading {
    font-size: 13px;
    margin: 20px 0 4px;
  }
  .section-sub {
    font-size: 12px;
    margin: 0 0 10px;
  }

  .platform-line {
    font-size: 12px;
    margin: 0 0 10px;
  }
  .platform-tag {
    font-size: 11px;
    padding: 2px 7px;
  }

  .disclaimer {
    font-size: 12px;
    margin: 20px 0 0;
  }
  .errors {
    padding: 14px;
  }
  .errors h2 {
    font-size: 13px;
  }
  .errors pre {
    font-size: 12px;
  }

  /* M3.1 — persona picker, platform banner, tax preview, and S-plate
     reminder all collapse cleanly into the single-column phone layout. */
  .persona-picker {
    padding: 12px;
    margin: 14px 0 0;
  }
  .persona-options {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .persona-option {
    padding: 10px 12px;
    font-size: 13px;
  }
  .platform-banner {
    padding: 10px 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .platform-banner-dismiss {
    align-self: flex-end;
  }
  .tax-preview {
    padding: 14px;
  }
  .tax-preview-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .tax-preview-grid dd {
    font-size: 17px;
  }
  .tax-disclaimer {
    font-size: 11px;
    padding: 10px 12px;
  }
  .s-plate-reminder {
    padding: 12px 14px;
  }
  .s-plate-reminder-body {
    font-size: 12px;
  }

  /* Install hint — slim dismissable bar that lives below the dropzone
     hint. Hidden by default; main.ts reveals it when the browser fires
     `beforeinstallprompt`. Tap targets ≥44px (Install + Dismiss
     buttons). On a non-PWA-capable browser the hint never shows. */
  .install-hint {
    margin: 12px 0 0;
    padding: 12px 14px;
    background: #f3fbf9;
    border: 1px solid var(--teal-light);
    border-radius: 10px;
    color: var(--navy-teal);
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .install-hint-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .install-hint-title {
    font-size: 14px;
    font-weight: 600;
  }
  .install-hint-sub {
    font-size: 12px;
    color: var(--ink-muted);
  }
  .install-hint-actions {
    display: flex;
    gap: 8px;
  }
  .install-hint-btn {
    flex: 1;
    min-height: 44px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    font-family: inherit;
  }
  .install-hint-btn-primary {
    background: var(--teal);
    color: white;
  }
  .install-hint-btn-dismiss {
    background: transparent;
    color: var(--ink-muted);
    border-color: var(--paper-edge);
  }
}

/* M2.2 — touch-only behaviour. iOS Safari does not fire `drop` events for
   most file types; the file picker is the primary path on touch devices.
   We hide the drag-target affordance on coarse pointers (touch) and keep
   the "Tap to browse" copy unambiguous. Coarse pointer detection lives
   here in CSS so the JS path stays simple — the existing dropzone still
   accepts files when a desktop browser sends a drag-and-drop. */
@media (pointer: coarse) {
  /* Swap the desktop copy variants for the touch copy variants. The
     spans ship in the HTML; CSS controls which is visible. */
  .copy-desktop {
    display: none;
  }
  .copy-touch {
    display: inline;
  }
}

/* Default (desktop, fine pointer): hide the touch-only copy. */
.copy-touch {
  display: none;
}

/* Optional account sign-in remains usable on small screens. */
.auth-controls { max-width: 34rem; }
#auth-provider-buttons { display: flex; flex-wrap: wrap; gap: .5rem; margin-block: .5rem; }
#auth-provider-buttons[hidden], #auth-phone-form[hidden], #auth-code-fields[hidden] { display: none; }
#auth-phone-form { display: grid; gap: .75rem; padding: 1rem; border: 1px solid #829c97; border-radius: .75rem; }
#auth-phone-form input[type="tel"], #auth-phone-form input:not([type]) { width: 100%; box-sizing: border-box; padding: .75rem; font: inherit; }
.auth-consent { font-size: .875rem; line-height: 1.5; }
.auth-controls button { min-height: 44px; }
.auth-controls button:disabled { opacity: .55; cursor: not-allowed; }

.weekly-tools { padding: 1.25rem; border: 1px solid #829c97; border-radius: 1rem; margin-block: 1.5rem; }
.editor-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-block: 1rem; }
#weekly-editor label { display: grid; gap: .4rem; }
#weekly-editor input:not([type="checkbox"]) { width: 100%; box-sizing: border-box; padding: .7rem; font: inherit; border: 1px solid #829c97; border-radius: .4rem; }
#weekly-editor button, #manual-start, #save-week { min-height: 44px; margin-block: .75rem; }
