/* Design v3 (2026-08-26) — complete overhaul, replacing the navy/brass/rust
   report-styled theme with a clean light dashboard system: white cards on a
   pale violet-grey ground, one confident violet structural accent, rust/
   copper kept as the secondary series color (a deliberate thread back to
   "construction material" — brick, copper pipe — rather than a generic
   dashboard teal/green pairing). No left-border cards anymore; hierarchy now
   comes from spacing, soft elevation and icon-circle color-coding instead.
   System font stack only, no Google Fonts — the staff PWA has to load and
   work from a job site on patchy signal, so this can't depend on a CDN font
   fetch succeeding. */

:root {
  /* Structure */
  --ink: #1e1b3a;
  --ink-soft: #6b6b85;
  --ink-faint: #a3a3ba;
  --bg: #f5f5fb;
  --surface: #ffffff;
  --surface-sunken: #eef0f8;
  --border: #e7e7f3;

  /* Accent — violet, the dominant structural color now (replaces navy) */
  --accent: #5a4fcf;
  --accent-600: #473ea8;
  --accent-100: #ece9fc;
  --accent-rgb: 90, 79, 207;

  /* Rust/copper — kept from the old brand as the second true accent,
     construction-material-coded, used for secondary chart series */
  --rust: #c1552f;
  --rust-600: #a4431f;
  --rust-100: #f7e0d5;

  /* Brass — reduced to a rare highlight (paid/premium state), not a structural color */
  --brass: #c9a84c;
  --brass-100: #f6ecd3;

  /* Semantic */
  --success: #1f9d6b;
  --success-600: #16805a;
  --success-bg: #e3f7ee;
  --warning: #c07a1a;
  --warning-600: #9c6210;
  --warning-bg: #fbedd6;
  --danger: #d13f3f;
  --danger-600: #ab3232;
  --danger-bg: #fbe7e7;
  --info: #3f63d6;
  --info-bg: #e8edfd;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --shadow-sm: 0 2px 8px rgba(30, 27, 58, .06);
  --shadow-md: 0 8px 28px rgba(30, 27, 58, .08);
  --shadow-lift: 0 16px 40px rgba(30, 27, 58, .14);
  --ease: cubic-bezier(.4, 0, .2, 1);

  /* legacy aliases some pages still reference directly */
  --navy: var(--ink);
  --navy-700: var(--ink);
  --navy-900: var(--ink);
  --navy-2: var(--accent);
  --gold: var(--brass);
  --gold-light: var(--brass);
  --ink-muted: var(--ink-soft);
  --surface-warm: var(--surface-sunken);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #ece9f7; --ink-soft: #a8a4c4; --ink-faint: #726f8f;
    --bg: #131120; --surface: #1c1a30; --surface-sunken: #262340; --border: #322e4e;
    --accent: #8f83f2; --accent-600: #a89bfa; --accent-100: #2c2750; --accent-rgb: 143, 131, 242;
    --rust: #e2895e; --rust-600: #f0a884; --rust-100: #3a2a22;
    --brass: #d9bd75; --brass-100: #3a3120;
    --success: #4bcb96; --success-600: #6adcae; --success-bg: #16332a;
    --warning: #e3a94b; --warning-600: #eebc70; --warning-bg: #3a2c14;
    --danger: #e2696d; --danger-600: #ec8b8e; --danger-bg: #3a1e20;
    --info: #8ba2f5; --info-bg: #202a4a;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, .25);
    --shadow-md: 0 8px 28px rgba(0, 0, 0, .32);
    --shadow-lift: 0 16px 40px rgba(0, 0, 0, .45);
  }
}
:root[data-theme="dark"] {
  --ink: #ece9f7; --ink-soft: #a8a4c4; --ink-faint: #726f8f;
  --bg: #131120; --surface: #1c1a30; --surface-sunken: #262340; --border: #322e4e;
  --accent: #8f83f2; --accent-600: #a89bfa; --accent-100: #2c2750; --accent-rgb: 143, 131, 242;
  --rust: #e2895e; --rust-600: #f0a884; --rust-100: #3a2a22;
  --brass: #d9bd75; --brass-100: #3a3120;
  --success: #4bcb96; --success-600: #6adcae; --success-bg: #16332a;
  --warning: #e3a94b; --warning-600: #eebc70; --warning-bg: #3a2c14;
  --danger: #e2696d; --danger-600: #ec8b8e; --danger-bg: #3a1e20;
  --info: #8ba2f5; --info-bg: #202a4a;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .25);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, .32);
  --shadow-lift: 0 16px 40px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.tabular { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace; }

header {
  background: var(--surface);
  color: var(--ink);
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
header h1 { font-size: 16px; margin: 0; font-weight: 700; letter-spacing: -.01em; }

main { padding: 20px; margin: 0 auto; }

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
  transition: box-shadow .2s var(--ease), transform .2s var(--ease);
}

h2 {
  font-size: 14px; letter-spacing: -.005em;
  color: var(--ink); margin: 0 0 14px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}

button {
  padding: 11px 18px; border-radius: var(--radius-sm); border: none;
  background: var(--accent);
  color: #fff; font-weight: 600; font-size: 14px;
  cursor: pointer; font-family: inherit;
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), filter .12s var(--ease), background .15s var(--ease);
}
button:hover { box-shadow: var(--shadow-sm); filter: brightness(1.06); }
button:active { transform: scale(.97); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.danger { background: var(--danger); }
button.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--border); }
button.ghost:hover { background: var(--surface-sunken); }
button.ghost.active { background: var(--accent-100); color: var(--accent-600); border-color: var(--accent); }

.link-btn {
  background: none; border: none; color: var(--accent); cursor: pointer; padding: 0;
  font-size: 13px; font-weight: 600; text-decoration: none; transition: opacity .12s var(--ease);
}
.link-btn:hover { opacity: .7; text-decoration: underline; }
.link-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
a.link-btn { display: inline-block; }

input[type=text], input[type=password], input[type=number], input[type=email],
input[type=tel], input[type=date], input[type=month], select, textarea {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 15px; font-family: inherit; background: var(--surface); color: var(--ink);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .18);
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; color: var(--ink-soft); font-size: 11px; text-transform: uppercase;
  letter-spacing: .05em; padding: 10px 8px; border-bottom: 1px solid var(--border); font-weight: 700;
}
td { padding: 12px 8px; border-bottom: 1px solid var(--surface-sunken); vertical-align: top; }
tbody tr { transition: background .12s var(--ease); }
tbody tr:hover { background: var(--surface-sunken); }
.empty-row td { color: var(--ink-faint); font-style: italic; text-align: center; padding: 26px 8px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px 3px 8px;
  border-radius: var(--radius-pill); font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .02em;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-draft, .badge-lead { background: var(--surface-sunken); color: var(--ink-soft); }
.badge-sent, .badge-scheduled { background: var(--warning-bg); color: var(--warning-600); }
.badge-accepted, .badge-invoiced { background: var(--success-bg); color: var(--success-600); }
.badge-rejected, .badge-snagging { background: var(--danger-bg); color: var(--danger-600); }
.badge-expired { background: var(--surface-sunken); color: var(--ink-faint); }
.badge-quoted { background: var(--info-bg); color: var(--info); }
.badge-in_progress { background: var(--rust-100); color: var(--rust-600); }
.badge-paid { background: var(--brass-100); color: #8a6d1f; }
.badge-paid::before { background: var(--brass); }
.badge-unpaid { background: var(--surface-sunken); color: var(--ink-soft); }
.badge-available { background: var(--success-bg); color: var(--success-600); }
.badge-in_use { background: var(--info-bg); color: var(--info); }
.badge-returned { background: var(--surface-sunken); color: var(--ink-soft); }
.badge-maintenance { background: var(--warning-bg); color: var(--warning-600); }

.hidden { display: none !important; }

/* ---------- Icon-circle stat tiles (shared by any surface) ---------- */
.icon-circle {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
}
.icon-circle svg { width: 20px; height: 20px; }
.icon-circle.tone-accent { background: var(--accent-100); color: var(--accent); }
.icon-circle.tone-rust { background: var(--rust-100); color: var(--rust-600); }
.icon-circle.tone-success { background: var(--success-bg); color: var(--success-600); }
.icon-circle.tone-warning { background: var(--warning-bg); color: var(--warning-600); }
.icon-circle.tone-danger { background: var(--danger-bg); color: var(--danger-600); }
.icon-circle.tone-info { background: var(--info-bg); color: var(--info); }

.theme-toggle {
  width: 36px; height: 36px; border-radius: 50%; flex: none; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-sunken); color: var(--ink-soft); border: 1px solid var(--border);
}
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle:hover { background: var(--border); filter: none; box-shadow: none; }
.theme-toggle-corner { position: absolute; top: 14px; right: 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
