/* =====================================================================
   YieldSync design system
   Palette derived from the Siinqee brand marks:
   olive green #5A8126, leaf #6D9A49, orange #F39221, pale green #E5F6D2
   ===================================================================== */

:root {
  /* Type scale */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);

  /* Spacing */
  --space-1: 0.25rem; --space-2: 0.5rem;  --space-3: 0.75rem;
  --space-4: 1rem;    --space-5: 1.25rem; --space-6: 1.5rem;
  --space-8: 2rem;    --space-10: 2.5rem; --space-12: 3rem;
  --space-16: 4rem;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;

  --font-sans: 'DM Sans', 'Noto Sans Ethiopic', system-ui, sans-serif;
  --font-num: 'DM Sans', system-ui, sans-serif;

  --shadow-sm: 0 1px 2px oklch(0.3 0.05 130 / 0.08);
  --shadow: 0 4px 16px oklch(0.3 0.05 130 / 0.10);
  --shadow-lg: 0 12px 32px oklch(0.3 0.05 130 / 0.14);
}

/* Light (default) */
:root, [data-theme='light'] {
  --brand:        oklch(0.52 0.11 128);   /* #5A8126 olive */
  --brand-strong: oklch(0.44 0.10 128);
  --brand-soft:   oklch(0.62 0.13 130);   /* #6D9A49 leaf */
  --brand-wash:   oklch(0.95 0.05 130);   /* #E5F6D2 pale */
  --accent:       oklch(0.74 0.16 60);    /* #F39221 orange */
  --accent-wash:  oklch(0.95 0.04 70);

  --bg:        oklch(0.985 0.006 120);
  --surface:   oklch(1 0 0);
  --surface-2: oklch(0.97 0.008 125);
  --border:    oklch(0.90 0.012 125);
  --text:      oklch(0.24 0.02 130);
  --text-mute: oklch(0.50 0.015 130);
  --on-brand:  oklch(0.99 0.01 120);

  --ok:    oklch(0.58 0.13 150);
  --warn:  oklch(0.74 0.16 60);
  --danger:oklch(0.55 0.19 25);
}

[data-theme='dark'] {
  --brand:        oklch(0.68 0.14 130);
  --brand-strong: oklch(0.76 0.15 130);
  --brand-soft:   oklch(0.60 0.12 130);
  --brand-wash:   oklch(0.30 0.05 130);
  --accent:       oklch(0.78 0.16 62);
  --accent-wash:  oklch(0.32 0.06 60);

  --bg:        oklch(0.19 0.015 130);
  --surface:   oklch(0.24 0.018 130);
  --surface-2: oklch(0.28 0.02 130);
  --border:    oklch(0.36 0.02 130);
  --text:      oklch(0.96 0.008 120);
  --text-mute: oklch(0.74 0.015 125);
  --on-brand:  oklch(0.16 0.02 130);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

:lang(am), [data-lang='am'] { --font-sans: 'Noto Sans Ethiopic', 'DM Sans', system-ui, sans-serif; }

h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-base); }
p  { margin: 0; }

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.mute { color: var(--text-mute); }
.xs { font-size: var(--text-xs); }
.sm { font-size: var(--text-sm); }

/* ---------- Brand mark ---------- */
.logo { display: inline-flex; align-items: center; gap: var(--space-3); }
.logo svg { display: block; width: 30px; height: 30px; flex: none; }
.logo-word { font-size: var(--text-lg); font-weight: 700; letter-spacing: -0.02em; }
.logo-word em { font-style: normal; color: var(--accent); }

/* ---------- Links ---------- */
/* Underlines are reserved for text a reader is meant to follow inside prose or
   a table cell, and they only appear on hover so dense tables stay calm.
   Controls that already look like controls never get one. */
a { color: var(--brand-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
.btn, .btn:hover, .nav a, .nav a:hover, .seg a, .seg a:hover,
.icon-btn, .portal-card, .portal-card:hover, .logo, .logo:hover,
.back-link:hover, .pager a:hover { text-decoration: none; }
table.data a { color: var(--text); font-weight: 500; }
table.data a:hover { color: var(--brand-strong); text-decoration: underline; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--brand-strong);
  color: var(--on-brand);
  padding: var(--space-6) var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-6);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .logo { color: var(--on-brand); }
.sidebar .logo-word em { color: var(--accent); }

.nav { display: flex; flex-direction: column; gap: var(--space-1); }
.nav-label {
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.08em;
  opacity: 0.6; padding: var(--space-3) var(--space-3) var(--space-1);
}
.nav a {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3); border-radius: var(--radius-sm);
  color: inherit; text-decoration: none; font-size: var(--text-sm);
  transition: background 160ms ease;
}
.nav a:hover { background: oklch(1 0 0 / 0.10); }
.nav a[aria-current='page'] { background: oklch(1 0 0 / 0.18); font-weight: 600; }
.nav a svg { flex: none; width: 18px; height: 18px; opacity: 0.9; }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { flex: 1; font-size: var(--text-lg); }
.content { padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-6); }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-3) var(--space-5); border-radius: var(--radius-sm);
  background: var(--brand); color: var(--on-brand);
  font-size: var(--text-sm); font-weight: 600;
  transition: transform 120ms ease, background 160ms ease, box-shadow 160ms ease;
}
.btn:hover { background: var(--brand-strong); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn-accent { background: var(--accent); color: oklch(0.22 0.04 60); }
.btn-accent:hover { background: oklch(0.68 0.16 55); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--brand-wash); }
.btn-lg { padding: var(--space-5) var(--space-8); font-size: var(--text-base); border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.seg button {
  padding: var(--space-2) var(--space-4); border-radius: 999px;
  font-size: var(--text-xs); font-weight: 600; color: var(--text-mute);
}
.seg button[aria-pressed='true'] { background: var(--brand); color: var(--on-brand); }
/* The language switch uses links rather than buttons, so it borrows the same
   pill shape. */
.seg a {
  padding: 4px 11px; border-radius: 999px; font-size: var(--text-xs);
  font-weight: 600; color: var(--text-mute); line-height: 1.5;
}
.seg a:hover { background: var(--surface); color: var(--text); }
.seg a.on { background: var(--brand); color: var(--on-brand); }

.icon-btn {
  width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border);
}
.icon-btn:hover { background: var(--brand-wash); }

.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field label { font-size: var(--text-xs); font-weight: 600; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.05em; }
.field .req { color: var(--danger); }
.field .seg { align-self: flex-start; }
.input, select.input {
  width: 100%; padding: var(--space-3) var(--space-4);
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: var(--text-base);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-wash); outline: none; }
.input-lg { padding: var(--space-4) var(--space-5); font-size: var(--text-lg); font-weight: 600; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.card-head h2 { flex: 1; }

.grid, .grid-kpi, .grid-2 { display: grid; gap: var(--space-4); }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(242px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* A KPI is a card in its own right, so it carries the card surface itself. */
.kpi {
  display: flex; flex-direction: column; gap: var(--space-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.kpi-label { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-mute); }
.kpi-value {
  font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.02em;
  display: flex; align-items: baseline; gap: var(--space-2); white-space: nowrap;
}
.kpi-unit { font-size: var(--text-sm); font-weight: 500; color: var(--text-mute); }
.kpi-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.kpi-bar span { display: block; height: 100%; border-radius: 999px; background: var(--brand-soft); }
.kpi.accent { border-left: 4px solid var(--accent); padding-left: var(--space-4); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
thead th {
  text-align: left; padding: var(--space-3) var(--space-4);
  background: var(--brand-wash); color: var(--brand-strong);
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700;
  white-space: nowrap;
}
[data-theme='dark'] thead th { color: var(--brand-strong); }

/* Dark mode: the sidebar becomes a deep surface so light text stays legible */
[data-theme='dark'] .sidebar { background: oklch(0.22 0.025 130); color: var(--text); border-right: 1px solid var(--border); }
[data-theme='dark'] .sidebar .nav a:hover { background: oklch(1 0 0 / 0.06); }
[data-theme='dark'] .sidebar .nav a[aria-current='page'] { background: var(--brand-wash); color: var(--text); }
[data-theme='dark'] .login-art { color: oklch(0.99 0.01 120); }
/* The wordmark sits on the green panel, so it keeps the panel's own text colour
   instead of picking up the default link colour. */
.login-art .logo, .login-art .logo:hover { color: var(--on-brand); }
.login-art .logo-word em, .login-art .logo-word span { color: var(--accent); }
[data-theme='dark'] .sidebar .logo { color: var(--text); }
tbody td { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); }
tbody tr:hover { background: var(--surface-2); }
td.right, th.right { text-align: right; }

/* ---------- Badges / status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-1) var(--space-3); border-radius: 999px;
  font-size: var(--text-xs); font-weight: 600;
  background: var(--surface-2); color: var(--text-mute);
}
.badge-ok { background: color-mix(in oklch, var(--ok) 18%, transparent); color: var(--ok); }
.badge-warn { background: var(--accent-wash); color: oklch(0.5 0.14 55); }
.badge-brand { background: var(--brand-wash); color: var(--brand-strong); }
[data-theme='dark'] .badge-brand { color: var(--brand-strong); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ---------- Login ---------- */
.login {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr;
}
.login-art {
  background:
    radial-gradient(120% 90% at 15% 10%, oklch(0.62 0.13 130) 0%, transparent 55%),
    linear-gradient(160deg, var(--brand) 0%, var(--brand-strong) 70%);
  color: var(--on-brand);
  padding: var(--space-12); display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-art::after {
  content: ''; position: absolute; inset: auto -12% -30% 40%;
  height: 60%; border-radius: 50%;
  background: oklch(0.74 0.16 60 / 0.22); filter: blur(10px);
}
.login-art h2 { font-size: var(--text-xl); max-width: 22ch; }
.login-art ul { list-style: none; margin: var(--space-6) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.login-art li { display: flex; gap: var(--space-3); align-items: center; font-size: var(--text-sm); opacity: 0.92; }
.login-art .chain { font-size: var(--text-sm); opacity: 0.9; }
.login-form { display: grid; place-items: center; padding: var(--space-8); background: var(--bg); }
.login-form form { width: min(400px, 100%); display: flex; flex-direction: column; gap: var(--space-5); }

/* ---------- PC tablet home ---------- */
.tiles { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-6); border-radius: var(--radius-lg); min-height: 168px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  text-align: left; transition: transform 160ms ease, box-shadow 160ms ease;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.tile-icon { width: 52px; height: 52px; border-radius: var(--radius); display: grid; place-items: center; background: var(--brand-wash); color: var(--brand-strong); }
.tile-primary { background: var(--brand); color: var(--on-brand); border-color: transparent; }
.tile-primary .tile-icon { background: oklch(1 0 0 / 0.18); color: var(--on-brand); }
.tile-accent { background: var(--accent); color: oklch(0.22 0.04 60); border-color: transparent; }
.tile-accent .tile-icon { background: oklch(1 0 0 / 0.28); color: inherit; }
.tile strong { font-size: var(--text-lg); font-weight: 700; }

/* ---------- Sell screen ---------- */
.sell {
  display: grid; gap: var(--space-6); align-items: start;
  grid-template-columns: 1.6fr 1fr;
  /* The farmer and the cash sit in one reading column; the fertilizer list runs
     alongside them so the counter never shows a hole in the middle. */
  grid-template-areas: "farmer products" "cash products";
  align-content: start;
}
.sell-farmer   { grid-area: farmer; }
.sell-products { grid-area: products; }
.sell .summary { grid-area: cash; }
.product-row {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: var(--space-4);
  padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.product-row + .product-row { margin-top: var(--space-3); }
.product-row.picked { border-color: var(--brand); background: var(--brand-wash); }
.stepper { display: inline-flex; align-items: center; gap: var(--space-2); }
.stepper button {
  width: 48px; height: 48px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: var(--text-lg); font-weight: 700; display: grid; place-items: center;
}
.stepper button:hover { background: var(--brand-wash); border-color: var(--brand-soft); }
.stepper output { min-width: 3ch; text-align: center; font-size: var(--text-lg); font-weight: 700; }

.summary { position: sticky; top: 96px; display: flex; flex-direction: column; gap: var(--space-4); }
.sum-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-4); font-size: var(--text-sm); }
.sum-total { padding-top: var(--space-4); border-top: 2px solid var(--border); }
.sum-total .kpi-value { color: var(--brand-strong); }
[data-theme='dark'] .sum-total .kpi-value { color: var(--brand-strong); }

.receipt {
  background: var(--brand-wash); border: 1px dashed var(--brand-soft);
  border-radius: var(--radius); padding: var(--space-4); font-size: var(--text-sm);
}

/* ---------- Misc ---------- */
.flow { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; font-size: var(--text-sm); }
.flow span.node { padding: var(--space-2) var(--space-4); border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 600; }
.flow span.node.on { background: var(--brand); color: var(--on-brand); border-color: transparent; }
.flow .arrow { color: var(--text-mute); }

.toast {
  position: fixed; left: 50%; bottom: var(--space-8); transform: translate(-50%, 140%);
  background: var(--brand-strong); color: var(--on-brand);
  padding: var(--space-4) var(--space-6); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); font-size: var(--text-sm); font-weight: 600;
  transition: transform 320ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 200ms ease;
  z-index: 60; max-width: 90vw; opacity: 0; visibility: hidden;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }

.screen { display: none; }
.screen.active { display: block; }
.login.active,
.shell.active { display: grid; }

@media (max-width: 1024px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar .nav { flex-direction: row; }
  .nav-label { display: none; }
  .sell { grid-template-columns: 1fr; grid-template-areas: "farmer" "products" "cash"; }
  .summary { position: static; }
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
}
@media (max-width: 600px) {
  .content, .topbar { padding: var(--space-4); }
  .product-row { grid-template-columns: 1fr; align-items: start; }
}

/* =========================================================================
   Server application additions
   The prototype only had to look right; these are the pieces the real
   dashboard needs — navigation groups, tables, forms, alerts, empty states.
   ========================================================================= */

/* --- sidebar ----------------------------------------------------------- */
.nav-group{
  margin:18px 12px 6px;font-size:.68rem;font-weight:700;letter-spacing:.09em;
  text-transform:uppercase;color:var(--text-mute);opacity:.75;
}
.nav-group:first-child{margin-top:4px}
.sidebar-foot{
  margin-top:auto;padding:14px 16px;border-top:1px solid var(--border);
  display:flex;flex-direction:column;gap:3px;
}
.sidebar-foot .who{font-weight:600;font-size:.9rem;margin:0}
.sidebar-foot .xs{margin:0}
.sidebar-foot .badge{align-self:flex-start;margin-top:6px}

/* --- topbar ------------------------------------------------------------ */
.topbar-right{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.btn.ghost{
  background:transparent;color:var(--text);border:1px solid var(--border);
}
.btn.ghost:hover{background:var(--surface-2);border-color:var(--brand)}
.badge.soft{background:var(--surface-2);color:var(--text-mute);border:1px solid var(--border)}

/* --- alerts ------------------------------------------------------------ */
.alert{
  display:flex;gap:10px;align-items:flex-start;
  padding:12px 14px;border-radius:var(--radius);margin-bottom:16px;
  font-size:.92rem;line-height:1.45;border:1px solid transparent;
}
.alert.ok{background:color-mix(in srgb,var(--brand) 12%,transparent);border-color:color-mix(in srgb,var(--brand) 32%,transparent);color:var(--brand-strong)}
.alert.error{background:color-mix(in srgb,var(--danger) 12%,transparent);border-color:color-mix(in srgb,var(--danger) 34%,transparent);color:var(--danger)}
.alert.warn{background:color-mix(in srgb,var(--accent) 14%,transparent);border-color:color-mix(in srgb,var(--accent) 34%,transparent);color:var(--accent)}
.alert.info{background:var(--surface-2);border-color:var(--border);color:var(--text)}
/* A standing notice with its own action, used for stock that has arrived but has
   not been counted yet. It sits above the figures because it needs a person. */
.alert.notice{background:var(--accent-wash);border-color:color-mix(in srgb,var(--accent) 38%,transparent);color:var(--text)}
.notice-action{display:flex;align-items:center;justify-content:space-between;gap:var(--space-4);flex-wrap:wrap}
.notice-action span{font-weight:500}

/* --- page header ------------------------------------------------------- */
.page-head{
  display:flex;justify-content:space-between;align-items:flex-end;
  gap:16px;flex-wrap:wrap;margin-bottom:18px;
}
.page-head h2{margin:0 0 4px;font-size:1.15rem}
.page-head p{margin:0;color:var(--text-mute);font-size:.9rem}
.page-actions{display:flex;gap:8px;flex-wrap:wrap}

/* --- tables ------------------------------------------------------------ */
table.data{width:100%;border-collapse:collapse;font-size:.9rem}
table.data th,table.data td{
  padding:11px 14px;text-align:left;border-bottom:1px solid var(--border);
  vertical-align:middle;
}
table.data thead th{
  position:sticky;top:0;background:var(--surface-2);z-index:1;
  font-size:.72rem;letter-spacing:.07em;text-transform:uppercase;
  color:var(--text-mute);font-weight:700;white-space:nowrap;
}
table.data tbody tr:hover{background:var(--surface-2)}
table.data tbody tr:last-child td{border-bottom:0}
table.data td.num,table.data th.num{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
table.data .sub{display:block;color:var(--text-mute);font-size:.78rem;margin-top:2px}
.table-wrap{max-height:none;overflow:auto;border-radius:var(--radius)}
tfoot td{font-weight:700;background:var(--surface-2)}

/* --- forms ------------------------------------------------------------- */
.form-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:14px}
.form-grid .span-2{grid-column:span 2}
@media (max-width:640px){.form-grid .span-2{grid-column:span 1}}
.form-actions{display:flex;gap:10px;justify-content:flex-end;margin-top:18px;flex-wrap:wrap}
select.input{appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right 10px center;background-size:16px;padding-right:34px}
textarea.input{min-height:84px;resize:vertical;font-family:inherit}
.field-hint{font-size:.78rem;color:var(--text-mute);margin:4px 0 0}
.checkline{display:flex;align-items:center;gap:9px;font-size:.9rem}
.checkline input{width:17px;height:17px;accent-color:var(--brand)}
fieldset.block{border:1px solid var(--border);border-radius:var(--radius);padding:16px;margin:0 0 16px}
fieldset.block legend{padding:0 8px;font-weight:600;font-size:.85rem;color:var(--text-mute)}

/* --- filter bar -------------------------------------------------------- */
.filters{display:flex;gap:10px;align-items:flex-end;flex-wrap:wrap;margin-bottom:16px}
.filters .field{margin:0;min-width:150px}
.filters .field label{font-size:.72rem}

/* --- collapsible form panel ------------------------------------------- */
details.panel{border:1px solid var(--border);border-radius:var(--radius-lg);background:var(--surface);margin-bottom:20px}
details.panel>summary{
  cursor:pointer;padding:14px 18px;font-weight:600;list-style:none;
  display:flex;align-items:center;gap:10px;
}
details.panel>summary::-webkit-details-marker{display:none}
details.panel>summary::after{content:"+";margin-left:auto;font-size:1.15rem;color:var(--text-mute)}
details.panel[open]>summary::after{content:"–"}
details.panel[open]>summary{border-bottom:1px solid var(--border)}
details.panel .panel-body{padding:18px}

/* --- empty state ------------------------------------------------------- */
.empty{text-align:center;padding:46px 20px;color:var(--text-mute)}
.empty svg{width:34px;height:34px;margin-bottom:12px;opacity:.5}
.empty h3{margin:0 0 6px;font-size:1rem;color:var(--text)}
.empty p{margin:0;font-size:.9rem;max-width:42ch;margin-inline:auto}

/* --- misc -------------------------------------------------------------- */
.grid-3{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:16px}
.pager{display:flex;gap:8px;justify-content:center;margin-top:18px}
.chip{display:inline-flex;align-items:center;gap:6px;padding:3px 9px;border-radius:999px;
  background:var(--surface-2);border:1px solid var(--border);font-size:.76rem;color:var(--text-mute)}
.stack{display:flex;flex-direction:column;gap:16px}
.row-between{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap}
.trend{display:flex;align-items:flex-end;gap:3px;height:56px}
.trend span{flex:1;background:var(--brand);border-radius:2px 2px 0 0;min-height:2px;opacity:.85}
.trend span:hover{opacity:1}
.inline-form{display:inline}
.danger-text{color:var(--danger)}
.ok-text{color:var(--brand-strong)}

/* --- sign-in shell ----------------------------------------------------- */
.login-art{display:flex;flex-direction:column;justify-content:space-between}
.login-art .art-body h2{
  font-size:clamp(1.5rem,1.2rem+1.4vw,2.1rem);line-height:1.2;margin:0 0 20px;max-width:22ch;
}
.art-points{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:12px;max-width:34ch}
.art-points li{position:relative;padding-left:26px;font-size:.95rem;line-height:1.5;opacity:.92}
.art-points li::before{
  content:"";position:absolute;left:0;top:.45em;width:12px;height:12px;border-radius:3px;
  background:var(--accent);
}
.art-chain{font-size:.8rem;letter-spacing:.08em;text-transform:uppercase;opacity:.72;margin:0}
.login-box{width:100%;max-width:400px}
.login-box h2{margin:0 0 6px;font-size:1.3rem}
.login-box .sub{margin:0 0 22px;color:var(--text-mute);font-size:.92rem}
.lang-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:26px;
  padding-top:18px;border-top:1px solid var(--border)}
.portal-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin:22px 0 6px}
@media (max-width:480px){.portal-grid{grid-template-columns:1fr}}
.portal-card{
  display:flex;flex-direction:column;gap:6px;padding:16px;border-radius:var(--radius);
  border:1px solid var(--border);background:var(--surface);text-decoration:none;color:var(--text);
  transition:border-color .16s ease,transform .16s ease,box-shadow .16s ease;
}
.portal-card:hover{border-color:var(--brand);transform:translateY(-2px);box-shadow:var(--shadow)}
.portal-card svg{width:22px;height:22px;color:var(--brand)}
.portal-card strong{font-size:.98rem}
.portal-card span{font-size:.8rem;color:var(--text-mute);line-height:1.4}
.back-link{display:inline-flex;align-items:center;gap:6px;font-size:.85rem;color:var(--text-mute);
  text-decoration:none;margin-bottom:16px}
.back-link:hover{color:var(--brand)}

/* --- printable receipt ------------------------------------------------- */
.print-page{max-width:520px;margin:32px auto;padding:0 16px}
.print-actions{display:flex;gap:10px;justify-content:center;margin:22px 0}
@media print{
  .print-actions,.lang-foot{display:none!important}
  .print-page{margin:0;max-width:none}
  body{background:#fff}
  .receipt{box-shadow:none;border:0}
}

/* ============================================================================
   Components added for the live app: the selling counter, sparkline, small
   form details. Same tokens as everything above.
   ========================================================================== */

.req { color: var(--danger); font-weight: 600; }

/* --- the selling counter -------------------------------------------------- */


.product-row {
  display: flex; align-items: center; gap: var(--space-4);
  flex-wrap: wrap;
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
}
.product-row:last-child { border-bottom: 0; }
.product-row > div:first-child { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 2px; }
.product-row.over { background: var(--accent-wash); border-radius: var(--radius-sm); }

.stepper { display: flex; align-items: center; gap: 6px; }
.stepper .input { width: 96px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }

.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.25rem; line-height: 1;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  cursor: pointer; transition: background .15s ease, border-color .15s ease;
}
.icon-btn:hover { background: var(--brand-wash); border-color: var(--brand); }
.icon-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.summary { border-top: 3px solid var(--brand); }

.sum-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-4);
  padding: 9px 0; border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}
.sum-row:last-child { border-bottom: 0; }
.sum-row > span:first-child { color: var(--text-mute); }
.sum-row .num { font-variant-numeric: tabular-nums; }

.sum-total {
  border-bottom: 0; margin-top: 4px; padding-top: 12px;
  border-top: 2px solid var(--text);
  font-size: var(--text-lg); font-weight: 700;
}
.sum-total > span:first-child { color: var(--text); }

button.busy { opacity: .6; pointer-events: none; }
button[disabled] { opacity: .45; cursor: not-allowed; }

/* --- sparkline ------------------------------------------------------------ */

.spark {
  display: flex; align-items: flex-end; gap: 3px;
  height: 108px; padding-top: var(--space-2);
}
.spark-bar {
  flex: 1; min-width: 3px;
  background: linear-gradient(to top, var(--brand), var(--brand-soft));
  border-radius: 2px 2px 0 0;
  transition: filter .15s ease;
}
.spark-bar:hover { filter: brightness(1.15); }

/* --- inline manage panel in tables ---------------------------------------- */

details.panel.inline { border: 0; background: none; padding: 0; }
details.panel.inline > summary { display: inline-flex; list-style: none; }
details.panel.inline > summary::-webkit-details-marker { display: none; }
details.panel.inline .panel-body {
  position: relative; text-align: left; margin-top: 8px;
  min-width: 220px; padding: var(--space-4);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
}

.btn.sm, .btn-accent.sm { padding: 6px 12px; font-size: var(--text-xs); }

.alert.fade-out { opacity: 0; transition: opacity .5s ease; }

@media (max-width: 640px) {
  .product-row { align-items: stretch; }
  .stepper { width: 100%; }
  .stepper .input { flex: 1; width: auto; }
}

/* ---------- Audit snapshots ---------- */
/* Before/after values are raw JSON. They have no spaces to break on, so they
   are told explicitly to wrap rather than push the table sideways. */
.audit-json {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere; word-break: break-word; white-space: pre-wrap;
  max-width: 52ch; line-height: 1.45;
}
