/* ==========================================================================
   Vierboet Creations · Business Portal & Operations
   One calm design system. Family of the brand (warm canvas, coast green,
   hairlines, serif headings) but functional rather than commercial.
   ========================================================================== */

:root {
  --canvas: #FBF8F2;
  --surface: #FFFFFF;
  --surface-sunken: #F5F1E9;
  --mist: #E8EFED;
  --sand: #F0E8D9;
  --ink: #262B2D;
  --ink-muted: #5F6669;
  --ink-soft: #666D70;
  --border: #E3DED4;
  --border-strong: #C9C3B7;
  --green: #175058;
  --green-dark: #10393F;
  --green-soft: #E2ECEA;
  --red: #AD4A31;
  --signal: #A93820;
  --signal-soft: #F7E4DF;
  --orange: #9A4B17;
  --orange-soft: #F8E9DC;
  --note: #FFF6D6;
  --note-border: #E5CF7A;
  --note-ink: #6B4E00;
  --focus: #175058;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --radius: 3px;
  --radius-l: 6px;
  --shadow: 0 1px 2px rgba(38, 43, 45, 0.05);

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;
  --max-w: 1120px;
  --touch: 44px;
}

/* --------------------------------------------------------------------------
   Reset & base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--green); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { color: var(--green-dark); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; text-wrap: balance; }
h1 { font-family: var(--font-serif); font-weight: 500; font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.1rem); letter-spacing: -0.01em; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 var(--s-4); }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 0; padding: 0; }
.list-plain { list-style: none; }
small, .small { font-size: 0.875rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-5) 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: var(--green-soft); }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: var(--s-4); top: -60px; background: var(--green); color: #fff; padding: var(--s-2) var(--s-4); border-radius: var(--radius); z-index: 100; }
.skip-link:focus { top: var(--s-4); }

.muted { color: var(--ink-muted); }
.soft { color: var(--ink-soft); }
.kicker { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-muted); font-weight: 600; }
.mono, .ref { font-family: var(--font-mono); font-size: 0.875rem; letter-spacing: 0.01em; }
.num { font-variant-numeric: tabular-nums; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.serif { font-family: var(--font-serif); font-weight: 500; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.break { overflow-wrap: anywhere; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }

/* --------------------------------------------------------------------------
   Shell: portal (top bar) and operations (sidebar)
   -------------------------------------------------------------------------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar__inner { max-width: var(--max-w); margin: 0 auto; padding: 0 var(--s-4); display: flex; align-items: center; gap: var(--s-5); min-height: 64px; }
.brand { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); line-height: 1.1; }
.brand__name { font-family: var(--font-serif); font-size: 1.15rem; color: var(--green); letter-spacing: -0.005em; }
.brand__product { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-muted); margin-top: 3px; }
.nav { display: flex; gap: var(--s-1); list-style: none; }
.nav a, .nav button { display: inline-flex; align-items: center; min-height: var(--touch); padding: 0 var(--s-3); color: var(--ink-muted); text-decoration: none; border-radius: var(--radius); font-weight: 500; border: 0; background: none; font: inherit; cursor: pointer; }
.nav a:hover, .nav button:hover { color: var(--ink); background: var(--surface-sunken); }
.nav a.is-active { color: var(--green); box-shadow: inset 0 -2px 0 var(--green); border-radius: 0; }
.topbar__spacer { flex: 1; }
.topbar__user { display: flex; align-items: center; gap: var(--s-3); font-size: 0.9rem; color: var(--ink-muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--green-soft); color: var(--green); display: inline-flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; flex-shrink: 0; }
.menu-toggle { display: none; }
.menu-toggle summary { list-style: none; display: inline-flex; align-items: center; justify-content: center; min-width: var(--touch); min-height: var(--touch); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-weight: 500; padding: 0 var(--s-3); gap: var(--s-2); background: var(--surface); }
.menu-toggle summary::-webkit-details-marker { display: none; }
.menu-toggle[open] summary { background: var(--surface-sunken); }
.menu-toggle__panel { position: absolute; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); padding: var(--s-3) var(--s-4) var(--s-4); z-index: 40; box-shadow: 0 8px 24px rgba(38, 43, 45, 0.08); }
.menu-toggle__panel .nav { flex-direction: column; gap: 0; }
.menu-toggle__panel .nav a, .menu-toggle__panel .nav button { width: 100%; justify-content: flex-start; padding: var(--s-3); }
.menu-toggle__panel .nav a.is-active { box-shadow: none; background: var(--green-soft); border-radius: var(--radius); }

@media (max-width: 1023px) {
  .topbar__inner { min-height: 60px; gap: var(--s-3); position: relative; }
  .nav--primary, .topbar__user .name { display: none; }
  .menu-toggle { display: block; }
}

/* Operations layout */
.ops { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar { display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); padding: var(--s-5) var(--s-4); position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { margin-bottom: var(--s-6); }
.sidebar .nav { flex-direction: column; gap: 2px; }
.sidebar .nav a { padding: 0 var(--s-3); width: 100%; }
.sidebar .nav a.is-active { background: var(--green-soft); color: var(--green); box-shadow: none; border-radius: var(--radius); }
.sidebar__section { margin-top: var(--s-6); }
.sidebar__section .kicker { display: block; margin: 0 var(--s-3) var(--s-2); }
.sidebar__footer { margin-top: auto; padding-top: var(--s-6); font-size: 0.875rem; color: var(--ink-muted); }
.ops__main { min-width: 0; }
.ops-topbar { display: none; }
.search-form { display: flex; gap: var(--s-2); }
.search-form input { flex: 1; min-width: 0; }
@media (max-width: 1023px) {
  .ops { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .ops-topbar { display: block; }
}

/* --------------------------------------------------------------------------
   Page structure
   -------------------------------------------------------------------------- */
.page { max-width: var(--max-w); margin: 0 auto; padding: var(--s-6) var(--s-4) var(--s-8); }
.page--narrow { max-width: 720px; }
.page--wide { max-width: 1280px; }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-6); }
.page-header__text { min-width: 0; flex: 1 1 320px; }
.page-header__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); margin-top: var(--s-2); color: var(--ink-muted); font-size: 0.9rem; }
.page-header__actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.page-header h1 { overflow-wrap: anywhere; }
.subtitle { color: var(--ink-muted); margin-top: var(--s-1); }
.breadcrumb { font-size: 0.875rem; color: var(--ink-muted); margin-bottom: var(--s-3); display: flex; flex-wrap: wrap; gap: var(--s-2); list-style: none; }
.breadcrumb li + li::before { content: "/"; margin-right: var(--s-2); color: var(--border-strong); }

.stack > * + * { margin-top: var(--s-5); }
.stack--tight > * + * { margin-top: var(--s-3); }
.stack--loose > * + * { margin-top: var(--s-6); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-3); align-items: center; }
.cluster--between { justify-content: space-between; }
.grid { display: grid; gap: var(--s-4); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--s-6); align-items: start; }
.layout__aside { min-width: 0; }
@media (max-width: 1023px) {
  .layout { grid-template-columns: 1fr; }
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 599px) {
  .page { padding: var(--s-5) var(--s-4) var(--s-7); }
  .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; }
  .page-header { margin-bottom: var(--s-5); }
}

/* --------------------------------------------------------------------------
   Cards & sections
   -------------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); padding: var(--s-5); box-shadow: var(--shadow); min-width: 0; }
.card--flush { padding: 0; overflow: hidden; }
.card--sunken { background: var(--surface-sunken); box-shadow: none; }
.card--mist { background: var(--mist); border-color: transparent; box-shadow: none; }
.card--sand { background: var(--sand); border-color: transparent; box-shadow: none; }
.card__header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.card__header h2, .card__header h3 { margin: 0; }
.card--flush .card__header { padding: var(--s-4) var(--s-5) 0; }
.card--flush .card__body { padding: 0 var(--s-5) var(--s-5); }
.card__footer { margin-top: var(--s-4); padding-top: var(--s-4); border-top: 1px solid var(--border); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.section-title h2 { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); font-weight: 600; }
@media (max-width: 599px) { .card { padding: var(--s-4); } .card--flush .card__header { padding: var(--s-4) var(--s-4) 0; } .card--flush .card__body { padding: 0 var(--s-4) var(--s-4); } }

/* Definition lists */
.dl { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: var(--s-2) var(--s-4); margin: 0; font-size: 0.95rem; }
.dl dt { color: var(--ink-muted); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.dl--stack { grid-template-columns: 1fr; gap: var(--s-1); }
.dl--stack dt { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.dl--stack dd + dt { margin-top: var(--s-3); }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: var(--touch); padding: 0 var(--s-4); border-radius: var(--radius); border: 1px solid transparent; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; line-height: 1.2; transition: background-color 120ms ease, border-color 120ms ease; }
.btn--primary { background: var(--green); color: #fff; }
.btn--primary:hover { background: var(--green-dark); color: #fff; }
.btn--secondary { background: var(--surface); color: var(--green); border-color: var(--border-strong); }
.btn--secondary:hover { border-color: var(--green); background: var(--green-soft); color: var(--green-dark); }
.btn--ghost { background: transparent; color: var(--green); }
.btn--ghost:hover { background: var(--green-soft); }
.btn--danger { background: var(--surface); color: var(--signal); border-color: var(--border-strong); }
.btn--danger:hover { border-color: var(--signal); background: var(--signal-soft); }
.btn--sm { min-height: 36px; padding: 0 var(--s-3); font-size: 0.875rem; }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--green); text-decoration: underline; cursor: pointer; text-underline-offset: 2px; }
.inline-form { display: inline; }
@media (max-width: 599px) { .btn-row--stack .btn { width: 100%; } }

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; line-height: 1.3; white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge--neutral { background: var(--surface-sunken); color: var(--ink-muted); border-color: var(--border); }
.badge--muted { background: var(--surface-sunken); color: var(--ink-soft); border-color: var(--border); }
.badge--info { background: var(--mist); color: var(--green); }
.badge--active { background: var(--green-soft); color: var(--green); }
.badge--success { background: var(--green); color: #fff; }
.badge--warning { background: var(--orange-soft); color: var(--orange); }
.badge--danger { background: var(--signal-soft); color: var(--signal); }
.badge--lg { font-size: 0.9rem; padding: 6px 14px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: var(--radius); background: var(--surface-sunken); border: 1px solid var(--border); font-size: 0.75rem; color: var(--ink-muted); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.tag--internal { background: var(--note); border-color: var(--note-border); color: var(--note-ink); }

/* --------------------------------------------------------------------------
   Alerts & empty states
   -------------------------------------------------------------------------- */
.flash-stack { margin-bottom: var(--s-5); display: grid; gap: var(--s-2); }
.alert { padding: var(--s-3) var(--s-4); border-radius: var(--radius-l); border: 1px solid var(--border); background: var(--surface); display: flex; gap: var(--s-3); align-items: flex-start; }
.alert--success { background: var(--green-soft); border-color: transparent; color: var(--green-dark); }
.alert--info { background: var(--mist); border-color: transparent; color: var(--green-dark); }
.alert--warning { background: var(--orange-soft); border-color: transparent; color: #7A3A12; }
.alert--error { background: var(--signal-soft); border-color: transparent; color: #7F2C1B; }
.alert--attention { background: var(--surface); border-color: var(--orange); }
.empty { text-align: center; padding: var(--s-7) var(--s-4); color: var(--ink-muted); }
.empty h3 { color: var(--ink); margin-bottom: var(--s-2); font-family: var(--font-serif); font-weight: 500; font-size: 1.25rem; }
.empty p { max-width: 36ch; margin: 0 auto var(--s-4); }
.notice { font-size: 0.9rem; color: var(--ink-muted); padding: var(--s-3) var(--s-4); background: var(--surface-sunken); border-radius: var(--radius-l); }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.form { display: grid; gap: var(--s-5); }
.form--tight { gap: var(--s-4); }
.field { display: grid; gap: var(--s-2); min-width: 0; }
.field__label { font-weight: 600; }
.field__label .optional { font-weight: 400; color: var(--ink-soft); }
.field__help { font-size: 0.875rem; color: var(--ink-muted); }
.field__error { font-size: 0.875rem; color: var(--signal); font-weight: 500; }
.field--error input, .field--error textarea, .field--error select { border-color: var(--signal); }
input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input[type="number"], input[type="date"], input[type="search"], input[type="password"], select, textarea {
  width: 100%; min-height: var(--touch); padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); font: inherit; line-height: 1.4;
}
textarea { resize: vertical; min-height: 96px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--green); }
input[type="file"] { font: inherit; padding: var(--s-2) 0; max-width: 100%; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; accent-color: var(--green); margin: 0; flex-shrink: 0; }
.check { display: flex; align-items: flex-start; gap: var(--s-3); min-height: var(--touch); padding: var(--s-2) 0; cursor: pointer; }
.check input { margin-top: 2px; }
.check__text { font-weight: 500; }
.check__help { display: block; font-weight: 400; color: var(--ink-muted); font-size: 0.875rem; }
.radio-list { display: grid; gap: var(--s-2); list-style: none; }
.radio-card { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border: 1px solid var(--border-strong); border-radius: var(--radius-l); background: var(--surface); cursor: pointer; min-height: var(--touch); }
.radio-card:has(input:checked) { border-color: var(--green); background: var(--green-soft); box-shadow: inset 0 0 0 1px var(--green); }
.radio-card:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.radio-card input { margin-top: 3px; }
.radio-card__title { font-weight: 600; }
.radio-card__help { color: var(--ink-muted); font-size: 0.875rem; }
.radio-inline { display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-5); list-style: none; }
.radio-inline label { display: inline-flex; gap: var(--s-2); align-items: center; min-height: var(--touch); cursor: pointer; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; padding-top: var(--s-2); }
.form-actions--between { justify-content: space-between; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s-4); }
.errorlist { list-style: none; color: var(--signal); font-size: 0.875rem; font-weight: 500; display: grid; gap: var(--s-1); }
.form-errors { padding: var(--s-3) var(--s-4); background: var(--signal-soft); border-radius: var(--radius-l); color: #7F2C1B; }
.file-picker { display: grid; gap: var(--s-2); }
.file-picker__names { font-size: 0.875rem; color: var(--ink-muted); }
.file-picker__names li { padding: 2px 0; }
@media (max-width: 599px) { .form-actions .btn, .btn--block { width: 100%; white-space: normal; text-align: center; padding-top: var(--s-2); padding-bottom: var(--s-2); } .form-actions--between { flex-direction: column-reverse; align-items: stretch; } }

/* Wizard */
.wizard-steps { display: flex; gap: var(--s-2); list-style: none; margin-bottom: var(--s-5); font-size: 0.85rem; color: var(--ink-muted); flex-wrap: wrap; }
.wizard-steps li { display: inline-flex; align-items: center; gap: var(--s-2); padding: var(--s-1) var(--s-3); border-radius: 999px; background: var(--surface-sunken); border: 1px solid var(--border); }
.wizard-steps li.is-current { background: var(--green); color: #fff; border-color: var(--green); font-weight: 600; }
.wizard-steps li.is-done { color: var(--green); border-color: var(--green-soft); background: var(--green-soft); }
.wizard-steps .n { width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.7); color: inherit; font-size: 0.75rem; font-weight: 700; }
.wizard-steps li.is-current .n { background: rgba(255,255,255,0.22); }

/* --------------------------------------------------------------------------
   Lists & rows
   -------------------------------------------------------------------------- */
.rows { list-style: none; display: grid; }
.rows > li + li { border-top: 1px solid var(--border); }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-2) var(--s-4); align-items: center; padding: var(--s-4) 0; }
.row--link { text-decoration: none; color: inherit; padding-left: var(--s-2); padding-right: var(--s-2); margin: 0 calc(-1 * var(--s-2)); border-radius: var(--radius); }
.row--link:hover { background: var(--surface-sunken); color: inherit; }
.row__main { min-width: 0; display: grid; gap: 3px; }
.row__title { font-weight: 600; overflow-wrap: anywhere; }
.row__meta { font-size: 0.875rem; color: var(--ink-muted); display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); }
.row__side { display: flex; align-items: center; gap: var(--s-3); justify-self: end; text-align: right; }
.row__amount { font-weight: 600; }
.chev { color: var(--ink-soft); }
@media (max-width: 599px) {
  .row { grid-template-columns: 1fr; }
  .row__side { justify-self: start; text-align: left; flex-wrap: wrap; }
}

/* Work items (operations) */
.work { list-style: none; }
.work > li + li { border-top: 1px solid var(--border); }
.work__item { display: grid; grid-template-columns: 150px minmax(0, 1fr) 170px 150px 130px; gap: var(--s-3); align-items: center; padding: var(--s-3) var(--s-2); text-decoration: none; color: inherit; margin: 0 calc(-1 * var(--s-2)); border-radius: var(--radius); }
.work__item:hover { background: var(--surface-sunken); color: inherit; }
.work__ref { display: grid; gap: 2px; }
.work__title { min-width: 0; display: grid; gap: 2px; }
.work__company { font-size: 0.875rem; color: var(--ink-muted); }
.work__meta { font-size: 0.85rem; color: var(--ink-muted); }
.work__flag { color: var(--orange); font-weight: 600; font-size: 0.8rem; }
.work__flag--danger { color: var(--signal); }
@media (max-width: 1023px) {
  .work__item { grid-template-columns: minmax(0, 1fr) auto; }
  .work__item > :nth-child(n+3) { grid-column: 1 / -1; }
  .work__item .work__ref { grid-column: 1; }
}

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s-3); }
.stat { display: grid; gap: 2px; padding: var(--s-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); text-decoration: none; color: inherit; min-height: 84px; }
.stat:hover { border-color: var(--green); color: inherit; }
.stat__value { font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat__label { font-size: 0.85rem; color: var(--ink-muted); }
.stat--attention .stat__value { color: var(--orange); }
.stat--zero .stat__value { color: var(--ink-soft); }

/* Tables (operations) */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 0.925rem; }
.table th, .table td { text-align: left; padding: var(--s-3) var(--s-3); border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); font-weight: 600; white-space: nowrap; }
.table td.num, .table th.num { text-align: right; }
.table tr:hover td { background: var(--surface-sunken); }
.table a.strong { font-weight: 600; text-decoration: none; }
.table a.strong:hover { text-decoration: underline; }
.table--lines th:first-child, .table--lines td:first-child { padding-left: 0; }
.table--lines th:last-child, .table--lines td:last-child { padding-right: 0; }

/* Filters / tabs */
.tabs { display: flex; flex-wrap: wrap; gap: var(--s-1); list-style: none; border-bottom: 1px solid var(--border); margin-bottom: var(--s-5); }
.tabs a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 var(--s-3); text-decoration: none; color: var(--ink-muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a.is-active { color: var(--green); border-bottom-color: var(--green); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); list-style: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 var(--s-3); border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink-muted); text-decoration: none; font-size: 0.875rem; font-weight: 500; }
.chip:hover { border-color: var(--green); color: var(--green); }
.chip.is-active { background: var(--green); border-color: var(--green); color: #fff; }
.chip .count { font-variant-numeric: tabular-nums; opacity: 0.8; }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); margin-top: var(--s-5); font-size: 0.9rem; color: var(--ink-muted); }

/* --------------------------------------------------------------------------
   Timeline / conversation
   -------------------------------------------------------------------------- */
.timeline { list-style: none; display: grid; gap: var(--s-4); }
.msg { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: var(--s-3); }
.msg__body { min-width: 0; }
.msg__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-1) var(--s-3); margin-bottom: var(--s-1); }
.msg__author { font-weight: 600; }
.msg__time { font-size: 0.8rem; color: var(--ink-soft); }
.msg__bubble { padding: var(--s-3) var(--s-4); border-radius: var(--radius-l); background: var(--surface); border: 1px solid var(--border); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg--staff .msg__bubble { background: var(--mist); border-color: transparent; }
.msg--staff .avatar { background: var(--green); color: #fff; }
.msg--customer .msg__bubble { background: var(--surface); }
.msg--internal .msg__bubble { background: var(--note); border: 1px dashed var(--note-border); }
.msg--internal .avatar { background: var(--note); color: var(--note-ink); border: 1px solid var(--note-border); }
.msg__attachments { margin-top: var(--s-2); }
.event { display: flex; align-items: center; gap: var(--s-3); font-size: 0.85rem; color: var(--ink-muted); padding-left: 48px; }
.event::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); margin-left: -30px; margin-right: 8px; flex-shrink: 0; }
.event__time { color: var(--ink-soft); white-space: nowrap; }
.event--internal { color: var(--note-ink); }
@media (max-width: 599px) { .msg { grid-template-columns: 1fr; } .msg .avatar { display: none; } .event { padding-left: 0; } .event::before { margin-left: 0; } }

/* Files */
.files { list-style: none; display: grid; gap: var(--s-2); }
.file { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: inherit; min-height: var(--touch); }
.file:hover { border-color: var(--green); color: inherit; }
.file__icon { width: 34px; height: 34px; border-radius: var(--radius); background: var(--surface-sunken); display: inline-flex; align-items: center; justify-content: center; font-size: 0.65rem; font-weight: 700; color: var(--ink-muted); text-transform: uppercase; flex-shrink: 0; letter-spacing: 0.04em; overflow: hidden; }
.file__icon img { width: 100%; height: 100%; object-fit: cover; }
.file__name { font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.file__meta { font-size: 0.8rem; color: var(--ink-soft); }
.file__main { min-width: 0; display: grid; gap: 1px; flex: 1; }
.files--inline { display: flex; flex-wrap: wrap; }
.files--inline .file { padding: 4px var(--s-3) 4px 4px; min-height: 40px; }
.files--inline .file__icon { width: 28px; height: 28px; }

/* Design preview */
.design { display: grid; gap: var(--s-4); }
.design__preview { border: 1px solid var(--border); border-radius: var(--radius-l); background: var(--surface-sunken); overflow: hidden; display: flex; align-items: center; justify-content: center; min-height: 160px; }
.design__preview img { max-height: 420px; width: auto; object-fit: contain; }
.design__placeholder { padding: var(--s-6); color: var(--ink-muted); text-align: center; }
.design-versions { list-style: none; display: grid; gap: var(--s-2); }
.design-versions li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-3); padding: var(--s-2) 0; border-top: 1px solid var(--border); font-size: 0.9rem; }
.design-versions li:first-child { border-top: 0; }
.decision { display: grid; gap: var(--s-4); }
.decision__actions { display: grid; gap: var(--s-4); }
@media (min-width: 768px) { .decision__actions { grid-template-columns: 1fr 1fr; } }
.decision__box { padding: var(--s-4); border: 1px solid var(--border); border-radius: var(--radius-l); background: var(--surface); display: grid; gap: var(--s-3); align-content: start; }
.decision__box--primary { border-color: var(--green); }

/* Production checklist & progress */
.checklist { list-style: none; display: grid; gap: var(--s-1); }
.checklist li { display: flex; align-items: center; gap: var(--s-3); min-height: var(--touch); padding: var(--s-1) 0; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: 0; }
.checklist .mark { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--border-strong); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; color: #fff; font-size: 0.8rem; font-weight: 700; }
.checklist li.is-done .mark { background: var(--green); border-color: var(--green); }
.checklist li.is-done .label { color: var(--ink-muted); }
.checklist .label { flex: 1; font-weight: 500; }
.checklist form { margin-left: auto; }
.checklist .meta { font-size: 0.8rem; color: var(--ink-soft); }
progress { width: 100%; height: 10px; appearance: none; -webkit-appearance: none; border: 0; border-radius: 999px; background: var(--surface-sunken); overflow: hidden; display: block; }
progress::-webkit-progress-bar { background: var(--surface-sunken); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--green); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--green); border-radius: 999px; }
.progress-label { display: flex; justify-content: space-between; font-size: 0.875rem; color: var(--ink-muted); margin-top: var(--s-2); }

/* Quote presentation */
.quote-total { display: grid; gap: var(--s-1); justify-items: end; }
.quote-total__value { font-size: 1.75rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.totals { margin-left: auto; width: min(100%, 360px); display: grid; gap: var(--s-2); font-size: 0.95rem; }
.totals div { display: flex; justify-content: space-between; gap: var(--s-4); }
.totals .grand { font-weight: 700; border-top: 1px solid var(--ink); padding-top: var(--s-2); margin-top: var(--s-1); font-size: 1.05rem; }
.line-editor { display: grid; gap: var(--s-2); }
.line-editor__row { display: grid; grid-template-columns: minmax(0, 1fr) 90px 130px 110px 44px; gap: var(--s-2); align-items: start; }
.line-editor__head { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); font-weight: 600; }
.line-editor__total { min-height: var(--touch); display: flex; align-items: center; justify-content: flex-end; font-variant-numeric: tabular-nums; font-weight: 500; padding-right: var(--s-2); }
.line-editor__row .field { gap: 2px; }
.line-editor__row .btn { min-width: 44px; padding: 0; }
@media (max-width: 767px) {
  .line-editor__head { display: none; }
  .line-editor__row { grid-template-columns: 1fr 1fr; padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--radius-l); }
  .line-editor__row > :first-child { grid-column: 1 / -1; }
  .line-editor__row .line-editor__total { justify-content: flex-start; }
}

/* Attention list (portal dashboard) */
.attention { list-style: none; display: grid; gap: var(--s-2); }
.attention li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-4); padding: var(--s-3) var(--s-4); background: var(--surface); border: 1px solid var(--orange); border-radius: var(--radius-l); }
.attention__text { font-weight: 500; min-width: 0; flex: 1 1 240px; }

/* Misc */
.divider { border-top: 1px solid var(--border); }
.hero { padding: var(--s-6) 0 var(--s-5); }
.hero h1 { font-size: clamp(1.8rem, 1.4rem + 1.6vw, 2.4rem); }
.hero p { color: var(--ink-muted); max-width: 52ch; }
.auth { max-width: 440px; margin: 0 auto; padding: var(--s-8) var(--s-4); }
.auth .brand { align-items: center; margin-bottom: var(--s-6); }
.auth .card { padding: var(--s-6); }
.auth h1 { font-size: 1.5rem; margin-bottom: var(--s-2); }
.auth .lead { color: var(--ink-muted); margin-bottom: var(--s-5); }
.footer { text-align: center; color: var(--ink-soft); font-size: 0.8rem; padding: var(--s-6) var(--s-4); }
.footer a { color: inherit; }
details.disclosure summary { cursor: pointer; font-weight: 600; min-height: var(--touch); display: flex; align-items: center; gap: var(--s-2); list-style: none; }
details.disclosure summary::-webkit-details-marker { display: none; }
details.disclosure summary::before { content: "+"; width: 20px; color: var(--ink-muted); }
details.disclosure[open] summary::before { content: "–"; }
details.disclosure > :not(summary) { margin-top: var(--s-3); }
.debug-box { font-family: var(--font-mono); font-size: 0.8rem; background: var(--surface-sunken); padding: var(--s-3); border-radius: var(--radius); overflow-x: auto; }
@media print {
  .topbar, .sidebar, .ops-topbar, .btn, .form, .skip-link, .footer { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* Django RadioSelect nesting + small additions */
.radio-inline > div { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); }
.radio-inline > div > div { display: contents; }
.sidebar__links { margin-top: var(--s-2); }
.menu-toggle__search { margin-bottom: var(--s-2); }
.avatar--sm { width: 26px; height: 26px; font-size: 0.65rem; }
.queue-nav { margin-bottom: var(--s-5); }
.meta-list { list-style: none; display: grid; gap: var(--s-1); font-size: 0.9rem; color: var(--ink-muted); }
.card--attention { border-color: var(--orange); }
.status-hero { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-4); }
.next-step { padding: var(--s-4); background: var(--mist); border-radius: var(--radius-l); }
.next-step h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--green); margin-bottom: var(--s-1); }

/* Utilities (no inline styles: CSP style-src 'self') */
.mb-1 { margin-bottom: var(--s-1) !important; } .mb-2 { margin-bottom: var(--s-2) !important; } .mb-3 { margin-bottom: var(--s-3) !important; }
.mb-4 { margin-bottom: var(--s-4) !important; } .mb-5 { margin-bottom: var(--s-5) !important; } .mb-6 { margin-bottom: var(--s-6) !important; }
.mt-1 { margin-top: var(--s-1) !important; } .mt-2 { margin-top: var(--s-2) !important; } .mt-3 { margin-top: var(--s-3) !important; }
.mt-4 { margin-top: var(--s-4) !important; } .mt-5 { margin-top: var(--s-5) !important; } .mt-6 { margin-top: var(--s-6) !important; }
.pt-0 { padding-top: 0 !important; } .pt-2 { padding-top: var(--s-2) !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }
.maxw-480 { max-width: 480px; } .maxw-520 { max-width: 520px; } .maxw-640 { max-width: 640px; } .maxw-760 { max-width: 760px; }
.text-signal { color: var(--signal); }
.note-box { padding: var(--s-3) var(--s-4); border-radius: var(--radius-l); background: var(--note); border: 1px dashed var(--note-border); white-space: pre-wrap; overflow-wrap: anywhere; }
.note-box .tag { margin-bottom: var(--s-1); }
.row--stacked { grid-template-columns: 1fr; }
.brand__name { white-space: nowrap; }
@media (max-width: 1023px) {
  .topbar .nav--primary { display: none; }
}
@media (max-width: 767px) {
  .brand__name { font-size: 1.05rem; }
}
.layout > *, .grid > *, .stack > * { min-width: 0; }

/* Quote lines: stacked cards on phones instead of a squeezed table */
.table--lines td:first-child { overflow-wrap: break-word; }
@media (max-width: 599px) {
  .table--lines thead { display: none; }
  .table--lines, .table--lines tbody, .table--lines tr, .table--lines td { display: block; width: 100%; }
  .table--lines tr { padding: var(--s-3) 0; border-bottom: 1px solid var(--border); }
  .table--lines tr:hover td { background: transparent; }
  .table--lines td { border: 0; padding: 2px 0; text-align: left !important; display: flex; justify-content: space-between; gap: var(--s-3); }
  .table--lines td::before { content: attr(data-label); color: var(--ink-muted); font-size: 0.8rem; }
  .table--lines td:first-child { display: block; font-weight: 600; margin-bottom: 4px; }
  .table--lines td:first-child::before { display: none; }
}

/* Operations on tablet/phone: the sidebar is hidden, so the menu toggle must show */
@media (max-width: 1023px) {
  .ops-topbar .menu-toggle { display: block; }
  .work__item { grid-template-columns: 1fr; gap: var(--s-1); padding: var(--s-3) var(--s-2); }
  .work__item > .work__title { order: -1; }
  .work__item > .work__ref { display: flex; gap: var(--s-2); align-items: center; }
  .work__item > .work__meta { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); }
}
.work__ref .tag { width: fit-content; }

/* Bibliotheek */
.village-menu { position: sticky; top: 0; z-index: 5; background: var(--canvas); padding: var(--s-2) 0; margin-bottom: var(--s-5); }
.village-heading { display: flex; align-items: baseline; gap: var(--s-3); margin-bottom: var(--s-3); }
.village-heading h2 { font-family: var(--font-serif); font-weight: 500; font-size: 1.35rem; }
.village-heading .count { color: var(--ink-soft); font-size: 0.875rem; }
.pub { display: grid; gap: var(--s-3); }
.pub__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s-2) var(--s-4); align-items: flex-start; }
.pub__title { font-size: 1.1rem; font-weight: 600; }
.price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--s-2); }
.price-row-form { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) repeat(var(--cols, 1), minmax(0, 1fr)); gap: var(--s-2); align-items: start; }
@media (max-width: 767px) { .price-row-form { grid-template-columns: 1fr 1fr; padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--radius-l); } .price-row-form > :first-child { grid-column: 1 / -1; } }
.price-row-form .field { gap: 2px; }
.price-row-form .field__label { font-size: 0.75rem; color: var(--ink-muted); font-weight: 600; }
.price-row-form.cols-0 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); }
.price-row-form.cols-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) repeat(2, minmax(0, 1fr)); }
.price-row-form.cols-2 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) repeat(3, minmax(0, 1fr)); }
.price-row-form.cols-3 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) repeat(4, minmax(0, 1fr)); }
.price-row-form.cols-4 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) repeat(5, minmax(0, 1fr)); }
.price-row-form.cols-5, .price-row-form.cols-6 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Compact work lists (dashboard side-by-side cards) */
.work--compact .work__item { grid-template-columns: 1fr; gap: var(--s-1); padding: var(--s-3) var(--s-2); }
.work--compact .work__item > .work__title { order: -1; }
.work--compact .work__item > .work__ref { display: flex; gap: var(--s-2); align-items: center; }
.work--compact .work__item > .work__meta { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); }
.next-step__title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--green); margin-bottom: var(--s-1); font-weight: 600; }
.table-wrap:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
