/* Advent Invoicing: Night Shift.
   The logo's sunrise gradient (#ED6325 ember -> #FFAF3B amber) on warm
   asphalt black, muscle-car cockpit rules: dual rally stripes down the left
   edge are the signature, everything else is disciplined instrument panel.
   The client-facing public invoice stays paper (scoped at the bottom). */

:root {
  --ember: #ED6325;
  --ember-deep: #C24E14;
  --glow: #F07818;
  --amber: #FFAF3B;
  --asphalt: #16110C;
  --panel: #201812;
  --panel-edge: #382A1E;
  --bone: #F6EFE7;
  --smoke: #A89684;
  --paid: #57B87C;
  --danger: #E5484D;
  --paper: #FCF9F5;
  --card: #FFFFFF;
  --ink: #291B0E;
  --line: #ECE1D4;
  --stone: #8A7666;
  --display: "Avenir Next", Futura, "Trebuchet MS", -apple-system, "Segoe UI", sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--asphalt);
  color: var(--bone);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
}

/* Rally stripes: one wide, one thin, down the left edge. The one loud thing. */
body::before {
  content: "";
  position: fixed;
  top: 0; bottom: 0; left: 0;
  width: 14px;
  background: linear-gradient(180deg, var(--ember), var(--amber));
  z-index: 10;
}
body::after {
  content: "";
  position: fixed;
  top: 0; bottom: 0; left: 20px;
  width: 4px;
  background: linear-gradient(180deg, var(--ember), var(--amber));
  opacity: 0.75;
  z-index: 10;
}

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--bone);
}
h1 { font-size: 26px; margin: 26px 0 10px; }
h2 { font-size: 17px; margin: 30px 0 8px; }

a { color: var(--amber); text-decoration: none; }
a:hover { color: #FFC46A; text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* Header: the dash top rail, with a tachometer tick strip underneath.
   The last stretch of ticks runs red: the redline. */
.site-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 16px 32px 20px 46px;
  background: linear-gradient(180deg, #241B13, var(--asphalt));
  border-bottom: 1px solid var(--panel-edge);
}
.site-header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 7px;
  background:
    repeating-linear-gradient(90deg, #4A3423 0 2px, transparent 2px 16px) left bottom / 86% 100% no-repeat,
    repeating-linear-gradient(90deg, var(--danger) 0 2px, transparent 2px 16px) right bottom / 14% 100% no-repeat;
}
.site-header .brand { display: flex; align-items: center; }
.site-header .brand img { height: 38px; width: auto; display: block; }
.site-header nav { display: flex; gap: 24px; flex: 1; }
.site-header nav a {
  font-family: var(--display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--smoke);
  padding: 6px 2px;
}
.site-header nav a:hover { color: var(--amber); text-decoration: none; }

/* Retired in Night Shift: the stripes carry the brand line now. */
.dash-rule { display: none; }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 8px 32px 72px 46px;
}

/* Tables: instrument panel */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  overflow: hidden;
  margin: 14px 0 20px;
}
.data-table th {
  text-align: left;
  font-family: var(--display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--smoke);
  padding: 10px 16px;
  border-bottom: 1px solid var(--panel-edge);
  background: #191410;
}
.data-table td {
  padding: 11px 16px;
  border-bottom: 1px solid #2A2018;
  font-variant-numeric: tabular-nums;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #281E15; }
.data-table tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--ember); }
.data-table th:last-child, .data-table td:last-child { text-align: right; }

/* Gauge cluster: the invoice's numbers read like instruments. */
.cluster { display: flex; gap: 14px; margin: 20px 0 24px; flex-wrap: wrap; }
.gauge {
  background: linear-gradient(180deg, #241B13, var(--panel));
  border: 1px solid var(--panel-edge);
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 0 100%);
  padding: 14px 26px 12px 18px;
  min-width: 170px;
}
.gauge-label {
  display: block;
  font-family: var(--display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--smoke);
  margin-bottom: 2px;
}
.gauge-value {
  display: block;
  font-family: var(--display);
  font-size: 27px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--bone);
  letter-spacing: 0.01em;
}
.gauge-balance { border-color: var(--ember-deep); }
.gauge-balance .gauge-value {
  color: var(--amber);
  text-shadow: 0 0 16px rgba(240, 120, 24, 0.45);
}

/* Status pills: idiot lights */
.pill {
  display: inline-block;
  font-family: var(--display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 2px 10px 3px;
  white-space: nowrap;
}
.pill-draft { border-color: #4A3A2C; color: var(--smoke); }
.pill-awaiting_quantity { border-color: #7A5A14; color: var(--amber); background: rgba(255, 175, 59, 0.08); }
.pill-sent { border-color: var(--ember-deep); color: #FF8A4A; background: rgba(237, 99, 37, 0.1); }
.pill-paid { border-color: #2E5C41; color: var(--paid); background: rgba(87, 184, 124, 0.08); }
.pill-void { border-color: #3A3A3A; color: #8A8A8A; text-decoration: line-through; }
.tag-overdue {
  display: inline-block;
  margin-left: 6px;
  font-family: var(--display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #FFFFFF;
  background: var(--danger);
  border-radius: 999px;
  padding: 2px 10px 3px;
}

/* Filter tabs */
.filter-nav { display: flex; gap: 8px; margin: 14px 0 4px; flex-wrap: wrap; }
.filter-nav a {
  font-size: 13px;
  color: var(--smoke);
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  border-radius: 999px;
  padding: 5px 14px;
}
.filter-nav a:hover { text-decoration: none; color: var(--amber); border-color: var(--amber); }
.filter-nav a.active {
  color: #1A0E04;
  background: linear-gradient(135deg, var(--glow), var(--amber));
  border-color: transparent;
  font-weight: 700;
}

/* Forms */
label {
  display: block;
  margin: 14px 0 4px;
  font-family: var(--display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--smoke);
}
input, select, textarea {
  width: 100%;
  max-width: 420px;
  padding: 9px 12px;
  font: inherit;
  color: var(--bone);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
}
input:focus, select:focus, textarea:focus { border-color: var(--amber); }
input::placeholder { color: #6B5C4E; }

button[type="submit"] {
  display: inline-block;
  margin-top: 16px;
  padding: 10px 24px;
  font-family: var(--display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #1A0E04;
  background: linear-gradient(135deg, var(--glow), var(--amber));
  border: none;
  border-radius: 0;
  clip-path: polygon(0 0, calc(100% - 11px) 0, 100% 11px, 100% 100%, 0 100%);
  cursor: pointer;
  transition: filter 120ms ease, box-shadow 120ms ease;
}
button[type="submit"]:hover {
  filter: brightness(1.08);
  box-shadow: 0 0 18px rgba(240, 120, 24, 0.35);
}
@media (prefers-reduced-motion: reduce) {
  button[type="submit"] { transition: none; }
}

.stacked-form { max-width: 420px; }

/* Sign out stays quiet; must outrank the primary button above. */
.logout-form { margin: 0; }
.logout-form button[type="submit"] {
  margin-top: 0;
  background: none;
  border: 1px solid var(--panel-edge);
  color: var(--smoke);
  font-weight: 500;
  padding: 6px 14px;
  font-size: 13px;
  box-shadow: none;
}
.logout-form button[type="submit"]:hover {
  color: var(--amber);
  border-color: var(--amber);
  filter: none;
  box-shadow: none;
}

/* Flash + errors */
.flash, .error {
  border-left: 4px solid var(--ember);
  background: var(--panel);
  border-radius: 0 8px 8px 0;
  padding: 10px 14px;
  margin: 14px 0;
}
.flash-error, .error { border-left-color: var(--danger); }

/* Sign-in: headlights on */
.login-card {
  max-width: 400px;
  margin: 10vh auto 0;
  background: linear-gradient(180deg, #241B13, var(--panel));
  border: 1px solid var(--panel-edge);
  border-radius: 0;
  clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 0 100%);
  padding: 38px 38px 32px;
}
.login-card .login-logo {
  width: 240px;
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto 20px;
  filter: drop-shadow(0 0 24px rgba(240, 120, 24, 0.35));
}
.login-card h1 {
  font-size: 13px;
  margin: 0 0 6px;
  text-align: center;
  color: var(--smoke);
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}
.login-card button[type="submit"] { width: 100%; }

/* ------------------------------------------------------------------ */
/* Public invoice page: the client gets the paper document, not the
   cockpit. Scoped light theme; the stripes stay off this page. */
body.public-page { background: var(--paper); color: var(--ink); }
body.public-page::before, body.public-page::after { content: none; }

.public-invoice {
  max-width: 720px;
  margin: 40px auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 44px 48px;
  color: var(--ink);
}
.public-invoice h1 { color: var(--ink); }
.public-invoice a { color: var(--ember-deep); }
.public-invoice .public-logo { width: 240px; height: auto; display: block; }
.public-invoice .dash-rule {
  display: block;
  width: 100%;
  height: 5px;
  background: url("/static/dash-rule.svg") repeat-x left center;
  background-size: 480px 4px;
  margin: 18px 0 26px;
}
.public-invoice .remit { color: var(--stone); font-size: 13px; margin-top: 10px; white-space: pre-line; }
.public-invoice .remit-name { font-family: var(--display); font-weight: 600; color: var(--ink); font-size: 14px; }
.public-invoice .meta { border-collapse: collapse; margin: 8px 0 18px; }
.public-invoice .meta td { padding: 3px 26px 3px 0; font-variant-numeric: tabular-nums; }
.public-invoice .meta .label,
.public-invoice .section-label {
  font-family: var(--display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--stone);
}
.public-invoice .section-label { margin: 20px 0 4px; }
.public-invoice .address { white-space: pre-line; }
.public-invoice .data-table {
  background: var(--card);
  border: 1px solid var(--line);
}
.public-invoice .data-table th {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  color: var(--stone);
}
.public-invoice .data-table td { border-bottom: 1px solid var(--line); }
.public-invoice .data-table tbody tr:hover td { background: #FDF4EA; }
.public-invoice .totals { margin-left: auto; border-collapse: collapse; }
.public-invoice .totals td { padding: 4px 0 4px 34px; font-variant-numeric: tabular-nums; text-align: right; }
.public-invoice .totals .label { color: var(--stone); font-size: 13px; text-align: left; padding-left: 0; }
.public-invoice .totals .balance td {
  font-family: var(--display);
  font-weight: 700;
  font-size: 16px;
  border-top: 2px solid var(--ember);
  padding-top: 8px;
  color: var(--ink);
}
.public-invoice .payment { margin-top: 26px; white-space: pre-line; }
.public-invoice .notes { margin-top: 18px; white-space: pre-line; }

@media print {
  body.public-page { background: #FFFFFF; }
  .public-invoice { border: none; margin: 0; padding: 0; }
  .public-invoice a { display: none; }
}

@media (max-width: 640px) {
  body::before { width: 8px; }
  body::after { left: 12px; width: 3px; }
  .site-header { flex-wrap: wrap; gap: 12px; padding: 12px 16px 12px 26px; }
  main { padding: 8px 16px 56px 26px; }
  .public-invoice { padding: 28px 20px; margin: 12px; }
  .data-table { display: block; overflow-x: auto; }
}
