/* =========================================================================
   Design system — Pilotage & Facturation
   Light theme only. Tokens first, then base, layout, components, utilities,
   responsive, print. Modules reuse these classes; module-specific additions go in
   /static/css/<module>.css, included from the module templates' {% block head %}.
   ========================================================================= */

@font-face {
  font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("../fonts/bricolage-grotesque-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Hanken Grotesk"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/hanken-grotesk-latin.woff2") format("woff2");
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fd;
  --surface-3: #ebeef6;
  --border: #e1e5ef;
  --border-strong: #c8cedd;
  --text: #111a33;
  --text-2: #404a66;
  --text-3: #5b6580;

  /* Brand: night blue carries the navigation and the hero, coral carries the primary action. */
  --brand: #0f1b3d;
  --brand-2: #1e2d5c;
  --brand-ink: #c9d2ee;
  --pop: #ff6b4a;
  --pop-strong: #f4573a;
  --accent: #2a4fd0;
  --accent-contrast: #ffffff;
  --focus: #2a4fd0;

  /* Status palette (reserved: never used as a chart series) */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-ink: #0b6e0b;
  --critical-ink: #b42f2f;

  /* Chart palette (categorical order validated for colour-vision deficiency on white) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #4a3aa7;
  --chart-grid: #e8ebf3;
  --chart-axis: #5b6580;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgb(15 27 61 / 0.05);
  --shadow: 0 1px 2px rgb(15 27 61 / 0.04), 0 8px 24px rgb(15 27 61 / 0.07);
  --shadow-lg: 0 16px 48px rgb(15 27 61 / 0.2);
  --sidebar-w: 264px;
  --font: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Bricolage Grotesque", "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, monospace;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; text-wrap: balance; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }
.icon { flex: none; }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }

.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.skip-link:focus { left: 8px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
  padding: 22px 16px; background: var(--brand); color: var(--brand-ink);
}
.sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 6px; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: 11px; background: var(--pop); color: var(--brand);
  font-family: var(--font-display); font-weight: 800; font-size: 17px;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 16px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .brand-name { color: #fff; }
.sidebar .brand-sub { color: var(--brand-ink); opacity: 0.75; }
.brand-sub { font-size: 12px; color: var(--text-3); }
.org-switcher { padding: 0 4px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav__section { margin: 18px 12px 6px; font-size: 12.5px; font-weight: 600; color: var(--brand-ink); opacity: 0.6; }
.nav__link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
  color: var(--brand-ink); font-weight: 550; transition: background 0.15s, color 0.15s;
}
.nav__link:hover { background: var(--brand-2); color: #fff; text-decoration: none; }
.nav__link.is-active { background: var(--pop); color: var(--brand); font-weight: 700; }
.nav__link .icon { opacity: 0.9; }
.nav__link.is-active .icon { opacity: 1; }
.sidebar__footer { display: flex; align-items: center; gap: 6px; padding-top: 14px; border-top: 1px solid rgb(255 255 255 / 0.12); }
.user-chip { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 6px; border-radius: 12px; color: #fff; }
.user-chip:hover { background: var(--brand-2); text-decoration: none; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--pop); color: var(--brand); font-weight: 700; font-size: 13px; flex: none; }
.user-chip__text { display: flex; flex-direction: column; min-width: 0; }
.user-chip__name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip__role { font-size: 12px; color: var(--brand-ink); opacity: 0.75; }
.sidebar .btn--ghost { color: var(--brand-ink); }
.sidebar .btn--ghost:hover { background: var(--brand-2); color: #fff; }
.sidebar .input { background-color: var(--brand-2); border-color: transparent; color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  min-height: 60px; padding: 12px 40px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid transparent;
}
.topbar__crumbs { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; color: var(--text-3); font-size: 13px; }
.topbar__crumbs a { color: var(--text-2); }
.topbar__crumbs .sep { color: var(--border-strong); }
.topbar__right { display: flex; align-items: center; gap: 8px; }
.btn.nav-toggle { display: none; }
.nav-backdrop { display: none; }
.page { width: 100%; max-width: 1360px; padding: 8px 40px 64px; outline: none; }
.page > * + * { margin-top: 24px; }

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-header__text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.page-title { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; }
.page-subtitle { color: var(--text-2); font-size: 16px; max-width: 64ch; }
.page-header__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-3); margin-bottom: 2px; }
.eyebrow { font-size: 14px; font-weight: 650; color: var(--accent); }

/* Hero: the night-blue banner that opens a dashboard. The coral disc is decoration only. */
.hero { position: relative; overflow: hidden; padding: 32px 36px; border-radius: 24px; background: var(--brand); color: #fff; }
.hero::after { content: ""; position: absolute; right: -70px; top: -110px; width: 300px; height: 300px; border-radius: 50%; background: var(--pop); opacity: 0.22; pointer-events: none; }
.hero::before { content: ""; position: absolute; right: 110px; bottom: -150px; width: 240px; height: 240px; border-radius: 50%; border: 2px solid var(--pop); opacity: 0.22; pointer-events: none; }
.hero > * { position: relative; z-index: 1; }
.hero__greeting { margin-bottom: 6px; font-size: 15px; font-weight: 650; color: var(--pop); }
.hero .page-title { font-size: 38px; color: #fff; }
.hero .page-subtitle { color: var(--brand-ink); }
.hero .page-header__actions { color: var(--brand-ink); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); border-radius: var(--radius-lg); box-shadow: var(--shadow); min-width: 0; }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 24px 0; }
.card-title { font-size: 18px; font-weight: 650; letter-spacing: -0.015em; }
.card-subtitle { font-size: 14px; color: var(--text-3); margin-top: 4px; }
.card-body { padding: 20px 24px 24px; }
.card-body--flush { padding: 0; }
.card-footer { padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ---------- Grid layouts ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-sidebar { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }

/* Dashboard widget grid: sm = 1/4, md = 1/2, lg = 3/4, full = 4/4 */
.widget-grid { display: grid; gap: 20px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.w-sm { grid-column: span 1; align-self: start; } /* a KPI tile keeps its own height beside a tall chart */
.w-md { grid-column: span 2; }
.w-lg { grid-column: span 3; }
.w-full { grid-column: 1 / -1; }

/* ---------- KPI tile ---------- */
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi__icon { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 8px; border-radius: 12px; background: color-mix(in srgb, var(--pop) 16%, var(--surface)); color: var(--brand); }
.kpi__label { font-family: var(--font); font-size: 14.5px; font-weight: 600; letter-spacing: 0; color: var(--text-2); }
.kpi__value { font-family: var(--font-display); font-size: 34px; font-weight: 700; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-3); }
.delta { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px 2px 6px; border-radius: 999px; font-weight: 700; font-variant-numeric: tabular-nums; }
.delta--good { color: var(--good-ink); background: color-mix(in srgb, var(--good) 12%, var(--surface)); }
.delta--bad { color: var(--critical-ink); background: color-mix(in srgb, var(--critical) 10%, var(--surface)); }
.delta--flat { color: var(--text-3); }

/* ---------- Charts ---------- */
.chart { position: relative; height: 240px; }
.chart--tall { height: 320px; }
.chart canvas { width: 100% !important; height: 100% !important; }
.chart-table { margin-top: 10px; font-size: 13px; }
.chart-table summary { cursor: pointer; color: var(--text-3); width: max-content; }
.chart-table summary:hover { color: var(--text); }
.chart-table[open] summary { margin-bottom: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.legend__swatch { width: 10px; height: 10px; border-radius: 3px; }
.widget__unavailable { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 13px; min-height: 60px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th {
  text-align: left; font-size: 13px; font-weight: 650; color: var(--text-3);
  padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; background: transparent;
}
.table td { padding: 14px 16px; border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions > * { display: inline-flex; }
.table--compact td, .table--compact th { padding: 8px 10px; }
.table a.row-link { color: var(--text); font-weight: 500; }
.table tfoot td { font-weight: 600; background: var(--surface-2); }
.card .table th:first-child, .card .table td:first-child { padding-left: 24px; }
.card .table th:last-child, .card .table td:last-child { padding-right: 24px; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; gap: 14px 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2, .form-grid .field--full { grid-column: 1 / -1; }
.form-grid-3 { display: grid; gap: 14px 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-section { display: flex; flex-direction: column; gap: 14px; }
.form-section + .form-section { padding-top: 18px; border-top: 1px solid var(--border); }
.form-section__title { font-size: 14px; font-weight: 600; }
.form-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 14px; font-weight: 650; color: var(--text); }
.req { color: var(--critical-ink); }
.field-help { font-size: 12.5px; color: var(--text-3); }
.field-error { font-size: 12.5px; color: var(--critical-ink); font-weight: 500; }
.input {
  width: 100%; min-height: 44px; padding: 10px 14px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input:hover { border-color: color-mix(in srgb, var(--text-3) 60%, var(--border-strong)); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input::placeholder { color: var(--text-3); opacity: 0.8; }
.input:disabled, .input[readonly] { background: var(--surface-3); color: var(--text-2); }
.input--sm { min-height: 36px; padding: 6px 11px; font-size: 14px; }
textarea.input { min-height: 80px; resize: vertical; }
select.input { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
input[type="file"].input { padding: 5px; cursor: pointer; }
input[type="file"].input::file-selector-button {
  margin-right: 12px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 550; color: var(--text);
  background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 6px; cursor: pointer;
}
input[type="file"].input::file-selector-button:hover { background: var(--border); }
input[type="color"].input { padding: 4px; height: 44px; width: 72px; }
.has-error .input { border-color: var(--critical); }
.field--check { gap: 4px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.inline-form { display: inline; margin: 0; }
.input-group { display: flex; gap: 8px; align-items: flex-end; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px; padding: 9px 20px; font: inherit; font-weight: 650; font-size: 14.5px; line-height: 1.2;
  color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px;
  cursor: pointer; white-space: nowrap; text-decoration: none; transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn--primary { background: var(--pop); border-color: var(--pop); color: var(--brand); font-weight: 700; }
.btn--primary:hover { background: var(--pop-strong); border-color: var(--pop-strong); }
.btn--secondary { }
.btn--danger { color: var(--critical-ink); border-color: color-mix(in srgb, var(--critical) 45%, var(--border-strong)); }
.btn--danger:hover { background: color-mix(in srgb, var(--critical) 10%, var(--surface)); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); }
.btn--sm { min-height: 34px; padding: 5px 14px; font-size: 13.5px; }
.btn--icon { min-height: 38px; width: 38px; padding: 0; }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Segmented control (period filters) ---------- */
.segmented { display: inline-flex; max-width: 100%; overflow-x: auto; padding: 3px; gap: 2px; background: var(--surface); border-radius: 999px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.segmented a, .segmented button {
  flex: none; padding: 7px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--text-2); border: 0; background: transparent; cursor: pointer; font-family: inherit;
}
.segmented a:hover, .segmented button:hover { color: var(--text); text-decoration: none; }
.segmented .is-active, .segmented .is-active:hover { background: var(--brand); color: #fff; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.toolbar__group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { padding: 11px 14px; margin-bottom: -1px; color: var(--text-3); font-size: 15.5px; font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active { color: var(--text); font-weight: 700; border-bottom-color: var(--accent); }

/* ---------- Badges (status always carries a text label) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px 3px 9px; border-radius: 999px;
  font-size: 13px; font-weight: 650; line-height: 1.6; white-space: nowrap;
  color: var(--text); background: var(--surface-3); border: 1px solid var(--border);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.badge--good { background: color-mix(in srgb, var(--good) 12%, var(--surface)); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.badge--good::before { background: var(--good); }
.badge--warning { background: color-mix(in srgb, var(--warning) 16%, var(--surface)); border-color: color-mix(in srgb, var(--warning) 40%, transparent); }
.badge--warning::before { background: var(--warning); }
.badge--serious { background: color-mix(in srgb, var(--serious) 14%, var(--surface)); border-color: color-mix(in srgb, var(--serious) 35%, transparent); }
.badge--serious::before { background: var(--serious); }
.badge--critical { background: color-mix(in srgb, var(--critical) 12%, var(--surface)); border-color: color-mix(in srgb, var(--critical) 32%, transparent); }
.badge--critical::before { background: var(--critical); }
.badge--info { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 28%, transparent); }
.badge--info::before { background: var(--accent); }
.badge--neutral::before { background: var(--text-3); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 550; }

/* ---------- Flash / callouts ---------- */
.flash, .callout {
  display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); font-size: 13.5px;
}
.flash .icon, .callout .icon { margin-top: 1px; }
.flash--success, .callout--good { border-color: color-mix(in srgb, var(--good) 35%, var(--border)); background: color-mix(in srgb, var(--good) 7%, var(--surface)); }
.flash--success .icon, .callout--good .icon { color: var(--good-ink); }
.flash--error, .callout--critical { border-color: color-mix(in srgb, var(--critical) 40%, var(--border)); background: color-mix(in srgb, var(--critical) 7%, var(--surface)); }
.flash--error .icon, .callout--critical .icon { color: var(--critical-ink); }
.flash--warning, .callout--warning { border-color: color-mix(in srgb, var(--warning) 50%, var(--border)); background: color-mix(in srgb, var(--warning) 10%, var(--surface)); }
.flash--warning .icon, .callout--warning .icon { color: color-mix(in srgb, var(--warning) 60%, var(--text)); }
.flash--info, .callout--info { border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.flash--info .icon, .callout--info .icon { color: var(--accent); }
.callout__title { font-weight: 600; }
.page > .flash { margin-top: 12px; }

/* ---------- Empty state ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 40px 20px; }
.empty__icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; background: color-mix(in srgb, var(--pop) 16%, var(--surface)); color: var(--brand); margin-bottom: 6px; }
.empty__title { font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: -0.015em; }
.empty__text { color: var(--text-3); max-width: 52ch; }
.empty__actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

/* ---------- Description list ---------- */
.dl { display: grid; grid-template-columns: minmax(120px, 190px) minmax(0, 1fr); gap: 9px 16px; margin: 0; font-size: 13.5px; }
.dl dt { color: var(--text-3); }
.dl dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Timeline (events) ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline__item { position: relative; display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; padding-bottom: 16px; }
.timeline__item::before { content: ""; position: absolute; left: 8px; top: 16px; bottom: 0; width: 2px; background: var(--border); }
.timeline__item:last-child::before { display: none; }
.timeline__dot { width: 12px; height: 12px; margin: 4px 0 0 3px; border-radius: 50%; background: var(--surface); border: 2px solid var(--text-3); }
.timeline__dot--good { border-color: var(--good); background: var(--good); }
.timeline__dot--critical { border-color: var(--critical); background: var(--critical); }
.timeline__dot--info { border-color: var(--accent); }
.timeline__title { font-weight: 550; }
.timeline__meta { font-size: 12.5px; color: var(--text-3); }

/* ---------- Stepper (lifecycle) ---------- */
.steps { display: flex; gap: 0; list-style: none; margin: 0; padding: 0; counter-reset: step; overflow-x: auto; }
.step { flex: 1; min-width: 110px; position: relative; padding-top: 22px; font-size: 12.5px; color: var(--text-3); text-align: center; }
.step::before { content: ""; position: absolute; top: 6px; left: 50%; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); z-index: 1; }
.step::after { content: ""; position: absolute; top: 11px; left: -50%; width: 100%; height: 2px; background: var(--border-strong); }
.step:first-child::after { display: none; }
.step.is-done { color: var(--text-2); }
.step.is-done::before { background: var(--accent); border-color: var(--accent); }
.step.is-done::after, .step.is-current::after { background: var(--accent); }
.step.is-current { color: var(--text); font-weight: 600; }
.step.is-current::before { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent); }
.step.is-failed { color: var(--critical-ink); font-weight: 600; }
.step.is-failed::before { background: var(--critical); border-color: var(--critical); }

/* ---------- Stats row (admin overview etc.) ---------- */
.stats { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat { padding: 20px 22px; background: var(--surface); border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.stat__label { font-size: 14px; color: var(--text-2); font-weight: 600; }
.stat__value { font-family: var(--font-display); font-size: 30px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; margin-top: 4px; }

/* ---------- Dropzone / upload ---------- */
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: 18px; background: var(--surface-2); }
.dropzone.is-dragover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px; }
.pagination__info { font-size: 13px; color: var(--text-3); }

/* ---------- Minimal layout (login, errors) ---------- */
.minimal { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.minimal__main { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 16px; }
.minimal__brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 4px; }
.minimal__brand .brand-name { font-size: 16px; }
.minimal__card .card-body { padding: 32px; }

/* ---------- Login: split layout with a product panel ---------- */
.minimal--split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); place-items: stretch; padding: 0; background: var(--bg); }
.minimal--split .minimal__main { justify-self: center; align-self: center; padding: 32px 24px; }
.minimal--split .minimal__brand { display: none; }
.auth-aside {
  --aside-ink: #ffffff; --aside-ink-2: var(--brand-ink); --aside-line: rgb(255 255 255 / 0.14);
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  padding: 48px 64px; color: var(--aside-ink); background: var(--brand);
}
.auth-aside__brand { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.auth-aside .brand-mark { background: var(--pop); color: var(--brand); }
.auth-aside .brand-name { font-size: 17px; }
.auth-aside__pitch { display: flex; flex-direction: column; gap: 28px; max-width: 34rem; }
.auth-aside__title { font-size: 46px; line-height: 1.08; font-weight: 700; letter-spacing: -0.035em; text-wrap: balance; }
.auth-aside__title em { font-style: normal; color: var(--pop); }
.auth-aside__points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; color: var(--aside-ink-2); font-size: 16.5px; }
.auth-aside__points li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 12px; align-items: start; }
.auth-aside__points .icon { margin-top: 4px; color: var(--pop); }
.auth-preview { margin: 0; max-width: 34rem; padding: 18px 20px 16px; border: 1px solid var(--aside-line); border-radius: var(--radius-lg); background: var(--brand-2); }
.auth-preview__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.auth-preview__label { font-weight: 600; font-size: 14px; }
.auth-preview__period { font-size: 12.5px; color: var(--aside-ink-2); }
.auth-preview__chart { width: 100%; height: 96px; margin-top: 12px; color: var(--pop); }
.auth-preview__steps { list-style: none; display: flex; gap: 0; margin: 14px 0 0; padding: 14px 0 0; border-top: 1px solid var(--aside-line); font-size: 12px; color: var(--aside-ink-2); }
.auth-preview__steps li { flex: 1; position: relative; padding-top: 16px; text-align: center; }
.auth-preview__steps li::before { content: ""; position: absolute; top: 0; left: 50%; width: 9px; height: 9px; margin-left: -4.5px; border-radius: 50%; background: var(--pop); z-index: 1; }
.auth-preview__steps li::after { content: ""; position: absolute; top: 3.5px; left: -50%; width: 100%; height: 2px; background: var(--pop); opacity: 0.55; }
.auth-preview__steps li:first-child::after { display: none; }
.auth-preview__steps .is-current { color: var(--aside-ink); font-weight: 600; }
.auth-preview__steps .is-current::before { background: #fff; box-shadow: 0 0 0 4px rgb(255 107 74 / 0.35); }
@media (max-width: 900px) {
  .minimal--split { grid-template-columns: minmax(0, 1fr); }
  .minimal--split .minimal__brand { display: flex; }
  .auth-aside { display: none; }
}

/* ---------- Utilities ---------- */
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mt-0 { margin-top: 0 !important; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.w-100 { width: 100%; }
.hidden { display: none !important; }
.good-ink { color: var(--good-ink); }
.critical-ink { color: var(--critical-ink); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font-mono); font-size: 12.5px; background: var(--surface-3); padding: 10px 12px; border-radius: var(--radius-sm); max-height: 320px; overflow: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .widget-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .w-sm { grid-column: span 1; }
  .w-md, .w-lg, .w-full { grid-column: 1 / -1; }
  .grid-sidebar { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; width: min(86vw, var(--sidebar-w));
    transform: translateX(-100%); transition: transform 0.2s ease;
  }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / 0.35); }
  .btn.nav-toggle { display: inline-flex; }
  .topbar { padding: 8px 16px; }
  .page { padding: 4px 16px 40px; }
  .hero { padding: 24px 22px; }
  .hero .page-title { font-size: 30px; }
}
@media (max-width: 640px) {
  .widget-grid { grid-template-columns: minmax(0, 1fr); }
  .w-sm, .w-md, .w-lg, .w-full { grid-column: 1 / -1; }
  .grid-2, .grid-3, .form-grid, .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .page-title { font-size: 26px; }
  .kpi__value { font-size: 28px; }
  .dl { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .dl dd { margin-bottom: 8px; }
  .page-header__actions { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Print (invoices) ---------- */
@media print {
  body { background: #fff; color: #000; font-size: 12px; }
  .sidebar, .topbar, .no-print, .flash, .page-header__actions, .nav-backdrop { display: none !important; }
  .shell { display: block; }
  .page { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; }
  a { color: inherit; }
}
