/* Fleet Desk — brand tokens per Design/fleetdesk-design-brief.md (Bansir Investment
   Group's confirmed brand material). Custom-property NAMES kept stable across this
   restyle even where they don't match the brief's own token names 1:1 (e.g. --accent
   now holds the brief's "Ink" value) so every existing page/JS reference — including
   inline `style="color: var(--danger)"` usages — keeps working without a markup pass.
   --ok (success green) and --warn-* (amber warning) are NOT brief tokens: the brief only
   covers brand/decorative colour, not functional UI status. Kept as small, desaturated
   utility colours for the photo-capture grid's captured/missing states and soft-warning
   boxes, since removing them would hurt at-a-glance usability with no brief alternative. */
@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;500;600;700&display=swap');

:root {
  color-scheme: light;
  --bg: #FAFAF8;           /* Paper */
  --surface: #ffffff;      /* card fill — not an explicit brief token, plain white for
                               separation from Paper now that shadows are gone (brief:
                               "hairlines, not shadows") */
  --ink: #000028;          /* Ink */
  --ink-muted: #6b6b63;    /* Muted */
  --faint: #9a988f;        /* Faint — captions/helper text */
  --border: #E3E1D9;       /* Hairline */
  --ocean: #003741;        /* Ocean — secondary buttons, section eyebrow labels */
  --accent: #000028;       /* Ink, used for primary buttons */
  --accent-ink: #ffffff;
  --danger: #F04623;       /* Signal — accent bar, destructive-button exception, single-
                               word emphasis. Never a fill/background wash per the brief. */
  --warn-bg: #fff4e5;
  --warn-ink: #7a4a00;
  --ok: #3d7a52;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Bahnschrift', 'Archivo', 'Arial Narrow', sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.45;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
}

img { max-width: 100%; }
[hidden] { display: none !important; }

h1 { font-size: 1.4rem; font-weight: 700; margin: 0 0 4px; }
h2 { font-size: 1.05rem; font-weight: 700; margin: 20px 0 8px; }
p.subtitle { color: var(--ink-muted); margin: 0 0 20px; }

.home-link {
  display: inline-block;
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 10px;
}

/* ── Brand header: accent bar + small restrained mark, once per page (one "major
   section" per screen in this app) — never repeated per card/subsection. ── */
.accent-bar { width: 32px; height: 3px; background: var(--danger); margin-bottom: 10px; }
.brand-row { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.brand-row img { width: 13px; height: 13px; display: block; flex-shrink: 0; }
.eyebrow {
  margin: 0;
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ocean);
}

/* Home-screen-only footer line — see fleetdesk-design-brief.md's "Home screen" rule. */
.app-footer {
  text-align: center;
  color: var(--faint);
  font-size: 0.72rem;
  margin: 24px 0 0;
}

/* Login-page entrance — brief and considered, not decorative: the accent bar draws
   itself in, the mark/wordmark and the login card fade and settle up slightly. Scoped by
   id to the home screen only (not the shared .accent-bar/.brand-row classes used on every
   other page), and skipped entirely under prefers-reduced-motion. */
@keyframes fd-accent-draw { from { width: 0; } to { width: 32px; } }
@keyframes fd-settle-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
#home-accent-bar { animation: fd-accent-draw 280ms ease-out; }
#home-brand-row { animation: fd-settle-in 240ms ease-out both; }
#login-view { animation: fd-settle-in 320ms ease-out 60ms both; }
@media (prefers-reduced-motion: reduce) {
  #home-accent-bar, #home-brand-row, #login-view { animation: none; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 18px;
  margin-bottom: 16px;
}

label { display: block; font-size: 0.85rem; color: var(--ink-muted); margin: 12px 0 4px; }
label:first-child { margin-top: 0; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], textarea, select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 16px;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
}
textarea { min-height: 80px; resize: vertical; }

/* Solid fill only, per the brief — ink for primary actions, ocean for everything else.
   Destructive actions (.danger) keep an explicit exception: signal-coloured outline on a
   paper fill, never a signal background (the brief reserves Signal as accent-only, never
   a background wash) — deliberately kept apart from the plain ink/ocean fills below so
   delete/reject actions still read as distinct at a glance. */
button, .btn {
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  padding: 12px 18px;
  border-radius: 3px;
  border: 1px solid var(--ocean);
  background: var(--ocean);
  color: #ffffff;
  cursor: pointer;
  min-height: 44px;
}
button.primary, .btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  width: 100%;
}
button.danger, .btn.danger {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--danger);
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

.field-warning {
  color: var(--warn-ink);
  background: var(--warn-bg);
  border-radius: 3px;
  padding: 6px 10px;
  font-size: 0.85rem;
  margin-top: 6px;
}
/* Item 1 (Fleet Desk unblock session): a plain <select> among a dozen other form fields is
   too easy to miss or mis-set — confirmed live: a real organisation ("Riley Auctioneers")
   got saved as type=financier instead of disposer this way, and nothing in the disposer
   dropdown query was wrong, the source data was. Used wherever a form field is genuinely
   load-bearing (org type today) and deserves to be impossible to skim past. */
.type-selector { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.type-selector button {
  flex: 1;
  min-width: 100px;
  padding: 12px 10px;
  border: 2px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.85rem;
}
.type-selector button.active { border-color: var(--ink); background: var(--ink); color: #fff; }

.field-source {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ok);
}

.save-confirm { color: var(--ok); text-align: center; font-size: 0.85rem; margin: 6px 0 10px; }

/* Error/status banners use the accent-bar motif (a signal-coloured edge, not a signal
   background wash) instead of a generic red alert box. */
.error-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--danger);
  color: var(--ink);
  border-radius: 3px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.camera-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.camera-tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 3px;
  border: 2px solid var(--border);
  background: var(--surface) center/cover no-repeat;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 8px;
  overflow: hidden;
}
.camera-tile.captured { border-color: var(--ok); }
.camera-tile.missing { border-color: var(--danger); }
.camera-tile-thumb {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: var(--ink-muted);
}
.camera-tile.captured .camera-tile-thumb { font-size: 0; }
.camera-tile-label {
  position: relative;
  z-index: 1;
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 3px;
  padding: 2px 4px;
}
.camera-tile.captured .camera-tile-label { align-self: flex-end; margin-top: auto; }
.camera-tile-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--ink);
  color: #fff;
  border-radius: 3px;
  padding: 1px 5px;
  z-index: 1;
}
.camera-tile-badge:empty { display: none; }
.camera-tile-badge.optional { background: var(--ink-muted); }
.camera-tile-warning {
  grid-column: span 2;
  color: var(--warn-ink);
  background: var(--warn-bg);
  border-radius: 3px;
  padding: 6px 10px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.camera-tile-warning button { padding: 4px 8px; font-size: 0.8rem; width: auto; }

.annotate-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
}
.annotate-canvas-wrap { position: relative; display: inline-block; max-height: calc(100% - 190px); }
.annotate-canvas {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 190px);
  touch-action: none;
  background: #111;
}
.annotate-marker-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.annotate-colors { display: flex; gap: 10px; justify-content: center; padding: 10px 0; }
.annotate-swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%; /* utility colour-picker swatch — kept circular, not a "button" in
                          the brief's sense, a square swatch reads worse for this purpose */
  border: 2px solid rgba(255, 255, 255, 0.4);
  padding: 0;
  min-height: 0;
}
.annotate-swatch.active { border-color: #fff; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6); }
.annotate-widths { display: flex; gap: 10px; justify-content: center; padding: 4px 0; }
.annotate-width-btn {
  width: auto;
  min-height: 0;
  padding: 6px 12px;
  background: #333;
  color: #fff;
  border-color: #555;
}
.annotate-width-btn.active { border-color: #fff; background: #555; }
.annotate-modes { display: flex; gap: 10px; justify-content: center; padding: 4px 0; }
.annotate-mode-btn {
  width: auto;
  min-height: 0;
  padding: 6px 14px;
  background: #333;
  color: #fff;
  border-color: #555;
}
.annotate-mode-btn.active { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.annotate-toolbar {
  display: flex;
  gap: 8px;
  padding: 12px;
  width: 100%;
  max-width: 480px;
}
.annotate-toolbar button { flex: 1; }
.annotate-btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.annotate-btn-secondary { background: #333; color: #fff; border-color: #333; }

.scan-capture-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  padding-top: calc(24px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}
.scan-capture-status { color: #fff; text-align: center; font-size: 0.95rem; margin-bottom: 8px; }
.scan-capture-overlay button { min-height: 48px; }
.scan-toolbar button { flex: 1; }

.scan-video-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.scan-video { width: 100%; height: 100%; object-fit: contain; }
/* Wide and short, matching PDF417's own shape — "fill the frame with the barcode only",
   not the whole disc. Percentages are of .scan-video-wrap, not of the video's native
   resolution — the capture code re-derives native pixel coordinates from this element's
   actual rendered box (getBoundingClientRect), so this can be tuned freely here without
   touching any JS. */
.scan-guide {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 50%;
  height: 20%;
  transform: translateY(-50%);
  border: 3px solid #fff;
  border-radius: 4px;
  box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}
.scan-guide.focused { border-color: var(--ok); }

.tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.report-photo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.report-photo-cell { border: 1px solid var(--border); border-radius: 3px; padding: 6px; }
.report-photo-cell img { display: block; width: 100%; border-radius: 3px; margin-bottom: 4px; }

#action-bar { display: flex; gap: 10px; margin-top: 12px; }
#action-bar button { flex: 1; }

.queue-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.queue-row-meta { flex: 1; }
.queue-badge {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--ink-muted);
  color: #fff;
  border-radius: 3px;
  padding: 2px 6px;
}

@media print {
  .no-print, #action-bar { display: none !important; }
  body { background: #fff; padding: 0; }
  .card { border: none; padding: 8px 0; margin-bottom: 8px; page-break-inside: avoid; }
  .report-photo-cell { page-break-inside: avoid; }
}

/* Generous desktop spacing per the brief; the app is phone-first, so this only kicks in
   above phone/tablet widths rather than assuming a wide viewport by default. */
@media (min-width: 768px) {
  body { max-width: 640px; margin: 0 auto; padding: 72px 24px; }
  .card { padding: 28px; }
}
/* Opt-out of the 640px cap for pages with genuinely wide content (splits.html's
   multi-column financial tables) — still centred and padded, just roomier. */
body.wide-page { max-width: none; }
@media (min-width: 768px) {
  body.wide-page { max-width: 980px; }
}

/* Restricted zone — invented within the brief's existing tokens (no mockup existed to
   match): Ink as a dark banner background, exactly as the brief's own colour table
   sanctions ("Ink — ... dark backgrounds (headers, hero blocks)"), white mark
   (logo-mark-on-blue.svg) and eyebrow text on it instead of the usual black mark. */
.restricted-banner {
  background: var(--ink);
  color: #ffffff;
  border-radius: 3px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.restricted-banner .brand-row { margin-bottom: 8px; }
.restricted-banner .eyebrow { color: #ffffff; }
.restricted-banner .accent-bar { margin-bottom: 8px; }
.restricted-label {
  margin: 0;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffffff;
}

/* Splits report tables */
.splits-table-wrap { overflow-x: auto; margin: 12px 0; }
.splits-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; white-space: nowrap; }
.splits-table th, .splits-table td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--border); }
.splits-table th:first-child, .splits-table td:first-child,
.splits-table th:nth-child(2), .splits-table td:nth-child(2) { text-align: left; }
.splits-table thead th {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.68rem;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--ink);
  white-space: normal;
}
.splits-table tr.subtotal-row td { font-weight: 700; border-top: 1px solid var(--ink); }
.splits-table tr.client-total-row td { font-weight: 700; background: var(--bg); border-top: 2px solid var(--danger); }
.splits-auction-heading { margin: 16px 0 4px; font-size: 0.9rem; }
.splits-auction-heading:first-of-type { margin-top: 4px; }

/* Pipeline board — stacked columns on mobile (default), side-by-side on desktop. */
.pipeline-board { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 768px) {
  .pipeline-board { grid-template-columns: repeat(5, 1fr); align-items: start; }
}
.pipeline-column {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 14px;
}
.pipeline-column-heading {
  margin: 0 0 10px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ocean);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pipeline-count {
  background: var(--ink);
  color: #fff;
  border-radius: 3px;
  padding: 1px 7px;
  font-size: 0.72rem;
}
.pipeline-column-body { display: flex; flex-direction: column; gap: 8px; max-height: 480px; overflow-y: auto; }
.pipeline-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 8px 10px;
  text-decoration: none;
  color: var(--ink);
}
.pipeline-card:hover { border-color: var(--ink); }
.pipeline-card .subtitle { margin: 0; font-size: 0.78rem; }
.pipeline-card-client { display: block; font-size: 0.7rem; color: var(--faint); margin-top: 2px; }
.pipeline-column-link {
  display: block;
  margin-top: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ocean);
  text-decoration: none;
}
