:root {
  color-scheme: dark;
  --bg: #14110e;
  --surface: #1f1a16;
  --surface-2: #29221c;
  --text: #ece6df;
  --muted: #a3978b;
  --border: #3a3129;
  --brand: #c9a37b;
  --brand-hover: #d9b78f;
  --on-brand: #1a1410;
  --danger: #f2766b;
  --ok-bg: #173022;
  --ok-text: #93d6a7;
  --err-bg: #3b1916;
  --err-text: #f5a59d;
  --info-bg: #172338;
  --info-text: #a3c0ea;
  --shadow: rgba(0, 0, 0, 0.45);
  --hover-wash: rgba(255, 255, 255, 0.05);
  --chart-grid: #2e2722;
  --chart-base: #4a4037;
  /* Chart series: the reference palette's dark steps, validated against #1f1a16 */
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
}

/* Light look (header switch). Series: the palette's light steps, validated against #ffffff. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f2ed;
  --surface: #ffffff;
  --surface-2: #f3ede6;
  --text: #2b2118;
  --muted: #6f6257;
  --border: #e3d9ce;
  --brand: #8a5a2b;
  --brand-hover: #6f4620;
  --on-brand: #ffffff;
  --danger: #b3261e;
  --ok-bg: #e3f3e6;
  --ok-text: #1d6b35;
  --err-bg: #fbe9e7;
  --err-text: #b3261e;
  --info-bg: #e8f0fb;
  --info-text: #1f4f8a;
  --shadow: rgba(60, 40, 20, 0.14);
  --hover-wash: rgba(0, 0, 0, 0.04);
  --chart-grid: #eee7df;
  --chart-base: #cfc4b8;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--brand); }
a:hover { color: var(--brand-hover); }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { color: var(--text); }
.brand img { height: 36px; width: auto; display: block; }
.mainnav { display: flex; gap: 6px 16px; flex: 1; flex-wrap: wrap; align-items: center; }
.navmenu { position: relative; }
.navmenu > summary { color: var(--muted); display: inline-block; }
.navmenu > summary::after { content: ' ▾'; font-size: 11px; }
.navmenu > summary:hover, .navmenu > summary.active, .navmenu[open] > summary { color: var(--text); }
.navmenu-list { position: absolute; top: calc(100% + 10px); left: -12px; z-index: 40; min-width: 190px; padding: 6px 0;
                background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 18px var(--shadow); }
.navmenu-list a { display: block; padding: 7px 14px; }
.navmenu-list a:hover { background: var(--surface); }
.mainnav a, .usermenu a { text-decoration: none; color: var(--muted); }
.mainnav a.active, .mainnav a:hover, .usermenu a:hover, .langswitch a.active { color: var(--text); }
.langswitch a.active { font-weight: 700; }
.usermenu { display: flex; gap: 14px; align-items: center; margin-left: auto; }
/* Notifications: the one-time question under the header, and the switch on the account page */
.push-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 18px; padding: 10px 14px;
            background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
.push-bar[hidden], .push-box [hidden], .push-status:empty { display: none; }
.push-bar .push-question { flex: 1 1 240px; }
.push-bar .push-buttons { display: flex; gap: 8px; }
.push-bar.done .push-question, .push-bar.done .push-buttons { display: none; }
.err-text { color: var(--err-text); }
.form-row { display: flex; flex-wrap: wrap; gap: 0 16px; }
.form-row > label { flex: 1 1 200px; }
.price-decision .choice { display: block; font-weight: 400; margin: 2px 0; white-space: nowrap; }
.price-decision .choice input { accent-color: var(--brand); margin-right: 6px; }
.push-account .push-status { display: block; margin-top: 8px; color: var(--muted); }
.topmenu { display: contents; }   /* wide screens: the nav and user menu sit in the bar itself */
.menu-toggle { display: none; }

/* Phones and narrow tablets: logo + menu button; the rest opens as a list under the bar. */
@media (max-width: 1000px) {
  .topbar { gap: 0 12px; padding: 8px 16px; }
  .menu-toggle { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; padding: 7px 9px;
                 border: 1px solid var(--border); border-radius: 8px; background: none; color: var(--text); cursor: pointer; }
  .menu-toggle[aria-expanded="true"] { background: var(--surface-2); }
  .topmenu { display: none; flex-basis: 100%; flex-direction: column; padding: 8px 0 4px; }
  .topbar.menu-open .topmenu { display: flex; }
  .topmenu .mainnav { flex-direction: column; align-items: stretch; gap: 0; }
  .topmenu .mainnav > a, .topmenu .navmenu > summary { display: block; padding: 10px 2px; font-size: 16px; }
  .topmenu .navmenu-list { position: static; min-width: 0; padding: 0 0 4px 16px; background: none; border: 0; box-shadow: none; }
  .topmenu .navmenu-list a { padding: 8px 2px; font-size: 15px; }
  .topmenu .navmenu-list a:hover { background: none; }
  .topmenu .usermenu { margin: 6px 0 0; padding-top: 12px; border-top: 1px solid var(--border); flex-wrap: wrap; gap: 10px 18px; }
}

main { margin: 32px auto; padding: 0 16px; }
main.wide { max-width: 1100px; }
main.narrow { max-width: 440px; }

h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.cards .card { margin-bottom: 0; }
.cards + .card, .cards + section { margin-top: 20px; }
.narrow-card { max-width: 480px; margin-top: 24px; }

.form label { display: block; margin-bottom: 14px; font-weight: 600; }
.form input[type=text], .form input[type=email], .form select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
}
.form input:focus, .form select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.form .checkbox { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.form .checkbox input { margin-top: 4px; accent-color: var(--brand); }
.form fieldset.plain { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.form fieldset.plain legend { padding: 0; margin-bottom: 8px; font-weight: 600; }
.form fieldset.plain .checkbox { margin-bottom: 6px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; margin-top: 12px; }
.inline-form label { margin-bottom: 0; }

button {
  font: inherit;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
button:hover { border-color: var(--brand); }
button.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 600; }
button.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
button.danger { color: var(--danger); }
button.danger:hover { border-color: var(--danger); }
button.small { padding: 4px 9px; font-size: 13px; }
.linkbutton { border: 0; background: none; padding: 0; color: var(--muted); text-decoration: underline; }
.linkbutton:hover { color: var(--text); }
form.inline { display: inline; }
select { color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; font: inherit; }

.login-logo { display: block; width: 120px; height: auto; margin: 0 auto 20px; }
.login-card { text-align: center; }
.google-button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 16px;
  padding: 10px 22px;
  border: 1px solid #8e918f;
  border-radius: 6px;
  background: #131314;
  color: #e3e3e3;
  font-weight: 600;
  text-decoration: none;
}
.google-button:hover { background: #1f1f20; color: #e3e3e3; }
/* Google's own light button on the light look */
:root[data-theme="light"] .google-button { background: #ffffff; border-color: #747775; color: #1f1f1f; }
:root[data-theme="light"] .google-button:hover { background: #f8f9fa; color: #1f1f1f; }

/* Header: language flags and the dark/light switch */
.prefs { display: flex; align-items: center; gap: 4px; margin: 0; }
.prefs .flag, .prefs .theme-toggle { padding: 3px; border: 1px solid transparent; border-radius: 6px; background: none; line-height: 0; cursor: pointer; }
.prefs .flag img { display: block; width: 22px; height: 15px; object-fit: cover; border-radius: 2px; }
.prefs .flag { opacity: 0.45; }
.prefs .flag.active, .prefs .flag:hover { opacity: 1; }
.prefs .flag.active { border-color: var(--border); }
.prefs .theme-toggle { color: var(--muted); margin-left: 4px; }
.prefs .theme-toggle:hover { color: var(--text); border-color: var(--border); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash ul { margin: 0; padding-left: 18px; }
.flash-success { background: var(--ok-bg); color: var(--ok-text); }
.flash-error { background: var(--err-bg); color: var(--err-text); }
.flash-info { background: var(--info-bg); color: var(--info-text); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 12px; }

.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: 13px; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.table tr.inactive td { color: var(--muted); }
.table td.actions { white-space: nowrap; }
.table td.actions form + form { margin-left: 4px; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.filters { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 16px; flex-wrap: wrap; }
.filters label { font-weight: 600; font-size: 13px; }
.filters select { display: block; margin-top: 4px; padding: 6px 8px; }

.pager { display: flex; gap: 16px; justify-content: center; margin: 16px 0; color: var(--muted); }

h3 { font-size: 14px; margin: 20px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
textarea {
  display: block;
  width: 100%;
  margin: 6px 0 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  resize: vertical;
}
textarea:focus, .limit-form input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
details > summary { cursor: pointer; color: var(--brand); list-style: none; display: inline-block; }
details > summary::-webkit-details-marker { display: none; }
details > summary:hover { color: var(--brand-hover); }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a { padding: 6px 12px; border: 1px solid var(--border); border-radius: 16px; text-decoration: none; color: var(--muted); background: var(--surface); }
.tabs a:hover { color: var(--text); border-color: var(--brand); }
.rule-group { scroll-margin-top: 16px; }
.rule-group h2 { font-size: 19px; }
.rule-list { margin: 0; padding-left: 22px; }
.rule-list > li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.rule-list > li:last-child { border-bottom: 0; }
.archived-list { list-style: none; padding-left: 0; }
.rule-text { white-space: pre-wrap; }
.rule-tools { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-top: 6px; font-size: 13px; }
.rule-tools details[open] { flex-basis: 100%; }
details.add { margin-top: 12px; }
details.add[open] form, details.edit[open] form { max-width: 640px; }
details.archived { margin-top: 16px; }
.history ul { list-style: none; margin: 8px 0 0; padding: 0; }
.history li { padding: 6px 0; border-top: 1px dashed var(--border); }
.diff-old { color: var(--muted); text-decoration: line-through; white-space: pre-wrap; }
.diff-new { white-space: pre-wrap; }
.status { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; vertical-align: middle; }
.status-allowed { background: var(--ok-bg); color: var(--ok-text); }
.status-manual { background: var(--err-bg); color: var(--err-text); }
.status-off { background: var(--surface-2); color: var(--muted); }
h1 .status { font-size: 13px; margin-left: 8px; }
.badge.warn { background: var(--err-bg); color: var(--err-text); margin-left: 6px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 20px; }
.filters input[type=search], .filters input.js-date { display: block; margin-top: 4px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit; color: var(--text); background: var(--surface-2); width: 240px; }
.price-add { display: grid; grid-template-columns: 2fr 1fr 1.2fr auto; gap: 12px; align-items: end; }
.price-add label { margin-bottom: 0; }
@media (max-width: 800px) { .price-add { grid-template-columns: 1fr; } }
#prices details.history { margin-top: 18px; }
.mail-body { white-space: pre-wrap; word-wrap: break-word; font: inherit; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin: 0; max-height: 70vh; overflow: auto; }
.button-link { display: inline-block; padding: 8px 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); color: var(--text); text-decoration: none; margin-right: 8px; }
.button-link:hover { border-color: var(--brand); color: var(--text); }
.actions-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.items-grid { display: grid; grid-template-columns: 1fr 90px; gap: 8px; margin-bottom: 16px; }
.items-grid input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font: inherit; color: var(--text); background: var(--surface-2); }
.items-grid input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.form select { color: var(--text); }
.attachments { margin: 0; padding-left: 18px; }
.attachments li { padding: 4px 0; }
.attachments .muted { margin-left: 8px; }
.limits td { vertical-align: top; }
.limit-value { width: 260px; }
.limit-form { display: flex; gap: 6px; align-items: center; }
.limit-form input {
  width: 90px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
}

/* Approvals */
.mainnav .count, .menu-toggle .count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--brand); color: var(--on-brand); font-size: 12px; font-weight: 700; text-align: center; }
.tabs a.active { color: var(--text); border-color: var(--brand); }
.status-pending { background: var(--brand); color: var(--on-brand); }
.approval-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.approval-head .badge.type { background: var(--surface-2); color: var(--text); font-weight: 600; }
.approval h2 { margin-top: 6px; }
.customer-said { margin: 0 0 10px; border-left: 3px solid var(--info-text); padding: 8px 12px; background: var(--info-bg); color: var(--info-text); border-radius: 0 6px 6px 0; font-size: 1.05em; }
.customer-said span { white-space: pre-line; color: var(--text); font-style: italic; }
.approval-reason { border-left: 3px solid var(--brand); padding: 6px 12px; background: var(--surface-2); border-radius: 0 6px 6px 0; }
.approval .table.compact { margin: 12px 0; }
.table.compact th, .table.compact td { padding: 6px 10px; }
.approval-form { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.approval-form .actions-row { margin-top: 4px; }
.table tr.totals td { border-top: 1px solid var(--border); }
.facts.decided { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }

/* Task timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li { position: relative; margin-left: 6px; padding: 8px 0 12px 20px; border-left: 2px solid var(--border); }
.timeline > li:last-child { border-left-color: transparent; }
.timeline > li::before { content: ''; position: absolute; left: -7px; top: 12px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface-2); border: 2px solid var(--border); }
.timeline > li.actor-agent::before { background: var(--brand); border-color: var(--brand); }
.timeline > li.actor-person::before { background: var(--ok-text); border-color: var(--ok-text); }
.ev-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.ev-who { font-weight: 600; }
.ev-what { color: var(--muted); }
.ev-body { margin-top: 4px; white-space: pre-wrap; word-wrap: break-word; }
.timeline details { margin-top: 6px; }
.timeline .mail-body { margin-top: 6px; max-height: 40vh; }
.proposal-details > .card { margin: 8px 0 0; background: var(--surface-2); }
h1 .status { white-space: nowrap; }
.timeline > li.ev-security::before { background: var(--err-text); border-color: var(--err-text); }
.invoice-items { display: block; margin-top: 2px; }
.invoice-items summary { font-size: 12px; }
.invoice-items ul { margin: 4px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.issues-card { border-color: var(--err-text); }
.issues-card h2 { color: var(--err-text); }
.issue-list { margin: 0; padding-left: 18px; }
.issue-list li { padding: 6px 0; }
.mainnav .count.alert, .menu-toggle .count.alert { background: var(--err-text); }
.security-notes { margin: 6px 0 0; padding-left: 18px; color: var(--err-text); }
.big-number { font-size: 34px; font-weight: 700; margin: 4px 0; }
.month-nav { justify-content: flex-start; gap: 16px; margin-bottom: 16px; }

/* Dashboard */
.dash-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 20px; margin-bottom: 20px; align-items: start; }
.dash-row > .card { margin-bottom: 0; }
.dash-row .table.compact td { vertical-align: top; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { padding: 12px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); text-decoration: none; }
a.tile:hover { border-color: var(--brand); color: var(--text); }
.tile-label { font-size: 13px; color: var(--muted); }
.tile-value { font-size: 26px; font-weight: 600; margin: 4px 0 2px; }
.tile-delta { font-size: 12px; color: var(--muted); }
.tile-alert { border-color: var(--err-text); }
.tile-alert .tile-value, .tile-alert .tile-delta { color: var(--err-text); }

/* Dashboard: what the AI is doing */
.ai-now { margin: 0 0 10px; }
.ai-now.working .dot { display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%; background: var(--s3); vertical-align: 1px; }
.ai-feed { list-style: none; margin: 0; padding: 0; }
.ai-feed li { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 7px 0; border-top: 1px solid var(--border); }
.ai-feed .ai-what { flex: 1 1 260px; }

/* Charts. Series colours are the --s1..--s4 tokens (dark and light sets at the top), validated
   (colour-blind separation, contrast) against the card surface #1f1a16. */
.chart { display: block; width: 100%; height: auto; margin: 10px 0 4px; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .base { stroke: var(--chart-base); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .cap { fill: var(--text); font-size: 12px; font-weight: 600; }
.chart .hit { fill: transparent; outline: none; }
.chart .hit:hover, .chart .hit:focus-visible { fill: var(--hover-wash); }
.s1 { fill: var(--s1); background: var(--s1); }
.s2 { fill: var(--s2); background: var(--s2); }
.s3 { fill: var(--s3); background: var(--s3); }
.s4 { fill: var(--s4); background: var(--s4); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; margin: 10px 0 0; padding: 0; font-size: 13px; color: var(--muted); }
.chart-legend .key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.chart-table summary { font-size: 13px; color: var(--muted); }
.chart-table .table { margin-top: 8px; }
.chart-empty { padding: 36px 0; text-align: center; color: var(--muted); }
.chart-tip { position: absolute; z-index: 50; pointer-events: none; min-width: 150px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
             background: var(--surface-2); box-shadow: 0 6px 18px var(--shadow); font-size: 13px; }
.chart-tip .tip-title { color: var(--muted); margin-bottom: 4px; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 8px; line-height: 1.6; }
.chart-tip .tip-row strong { font-variant-numeric: tabular-nums; }
.chart-tip .line { display: inline-block; width: 12px; height: 2px; flex: none; }

@media (max-width: 700px) {
  .dash-row { grid-template-columns: 1fr; }
  .chart .tick, .chart .cap { font-size: 17px; }
  .table { display: block; overflow-x: auto; }
}

/* Order confirmation: lines a person can correct, with what the customer wrote */
.order-lines input[type=text] { width: 100%; min-width: 220px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font: inherit; color: var(--text); background: var(--surface-2); }
.order-lines input.num { min-width: 0; width: 80px; }
.order-lines input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.order-lines input[type=checkbox] { accent-color: var(--brand); width: 16px; height: 16px; }
.order-lines td { vertical-align: top; }
.order-lines tr.new-line input[type=text] { border-style: dashed; }
.line-meta { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.line-meta .badge { margin-left: 0; }
.hub-add { margin-top: 4px; }
.hub-add-card > summary { font-weight: 600; }
.hub-add-card[open] > summary { margin-bottom: 8px; }
.hub-add > summary { font-size: 13px; }
.hub-add-form { margin-top: 6px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); max-width: 520px; }
.hub-add-form label { display: block; font-size: 13px; }
.hub-add-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-top: 6px; }
.hub-add-row input { width: 9em; }
.special-price-form label.check { display: flex; gap: 6px; align-items: center; margin-top: 6px; font-size: 13px; }
.special-price-form label.check input { width: auto; margin: 0; }
.special-status { color: var(--ok-text); }
.special-status.err { color: var(--err-text); }
.badge.ok { background: var(--ok-bg); color: var(--ok-text); }
/* Prices page: special prices sit under their product, indented */
form.prices-refresh { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.table.prices tr.product td { font-weight: 600; border-top: 1px solid var(--border); }
.table.prices tr.product td .muted, .table.prices tr.product td .badge { font-weight: 400; }
.table.prices tr.special td { background: var(--surface-2); border-bottom: 0; padding-top: 5px; padding-bottom: 5px; }
.table.prices tr.special td:first-child { padding-left: 26px; }
.table.prices input.pickup-price { width: 80px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; font: inherit; font-weight: 400; color: var(--text); background: var(--surface-2); }
.prices-pickup-save { margin: 6px 0 10px; }
.badge.new { background: var(--info-bg); color: var(--info-text); }
.limit-form input.ean { width: 150px; font-variant-numeric: tabular-nums; }
@media (max-width: 800px) { .order-lines input[type=text] { min-width: 140px; } }

/* Demo (training) tasks: the banner on the task page */
.demo-banner p { margin: 0 0 8px; }
.demo-banner .actions-row { margin-top: 8px; }

/* The dashboard chat with the AI (index.php, chat.php) */
.chat-log { list-style: none; margin: 12px 0; padding: 0; display: flex; flex-direction: column; gap: 10px; max-height: 480px; overflow-y: auto; }
.chat-msg { max-width: 85%; display: flex; flex-direction: column; gap: 2px; }
.chat-msg.me { align-self: flex-end; align-items: flex-end; }
.chat-msg.ai { align-self: flex-start; }
.chat-body { padding: 8px 12px; border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--border); }
.chat-msg.me .chat-body { background: var(--surface-2); }
.chat-msg.ai .chat-body { background: var(--surface); }
.chat-msg.thinking .chat-body { color: var(--muted); font-style: italic; }
.chat-msg.failed .chat-body { background: var(--err-bg); color: var(--err-text); }
.chat-form textarea { width: 100%; }
.chat-form .actions-row { margin-top: 8px; }
.link-button { background: none; border: none; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; }
.link-button:hover { color: var(--brand); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* A checkbox with its text on one line inside a form */
.form label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: normal; }
.form label.check input { accent-color: var(--brand); width: 16px; height: 16px; margin-top: 3px; flex: none; }

/* Product suggestions under a product field (app.js) */
.suggest-box {
  position: absolute;
  z-index: 50;
  max-height: 340px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px var(--shadow);
  padding: 4px;
}
.suggest-item {
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.3;
}
.suggest-item small {
  display: block;
  color: var(--muted);
}
.suggest-item:hover,
.suggest-item.active {
  background: var(--surface-2);
}

/* Date fields (dd.mm.rrrr) and their calendar (app.js) */
input.js-date { width: 9.5em; }
.filters input.js-date { width: 9.5em; }
.datepick { position: absolute; z-index: 1000; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.35); font-size: 14px; user-select: none; }
.datepick-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-weight: 600; }
.datepick-head button { background: none; border: 1px solid var(--border); color: var(--text); border-radius: 6px; width: 30px; height: 28px; cursor: pointer; font: inherit; }
.datepick table { border-collapse: collapse; }
.datepick th { color: var(--muted); font-weight: 600; font-size: 12px; padding: 2px 0; width: 34px; text-align: center; }
.datepick td { padding: 1px; }
.datepick td button { width: 34px; height: 30px; border: 0; border-radius: 6px; background: none; color: var(--text); cursor: pointer; font: inherit; }
.datepick td button:hover, .datepick td button:focus-visible { background: var(--surface-2); outline: none; }
.datepick td button.other { color: var(--muted); opacity: .6; }
.datepick td button.today { box-shadow: inset 0 0 0 1px var(--brand); }
.datepick td button.sel { background: var(--brand); color: #1a1410; }

/* Photo previews on a card, and the slider they open (app.js) */
.photo-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.photo-thumbs a { display: block; width: 96px; height: 96px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.photo-thumbs a:hover, .photo-thumbs a:focus-visible { border-color: var(--brand); }
.photo-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
html.lb-open { overflow: hidden; }
.lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(0, 0, 0, 0.92); display: flex; align-items: center; justify-content: center; }
.lightbox .lb-img { max-width: calc(100vw - 32px); max-height: calc(100vh - 80px); object-fit: contain; margin-top: 40px; user-select: none; }
.lightbox .lb-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 14px; padding: 8px 12px; color: #ece6df; font-size: 14px; }
.lightbox .lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #a3978b; }
.lightbox .lb-download { color: #c9a37b; }
.lightbox button { background: rgba(255, 255, 255, 0.08); color: #ece6df; border: 0; border-radius: 999px; cursor: pointer; line-height: 1; }
.lightbox button:hover, .lightbox button:focus-visible { background: rgba(255, 255, 255, 0.2); }
.lightbox .lb-close { width: 40px; height: 40px; font-size: 26px; padding: 0; }
.lightbox .lb-prev, .lightbox .lb-next { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; font-size: 34px; padding: 0 0 4px; }
.lightbox .lb-prev { left: 12px; }
.lightbox .lb-next { right: 12px; }
.lightbox.single .lb-prev, .lightbox.single .lb-next { display: none; }
@media (max-width: 700px) {
  .photo-thumbs a { width: 76px; height: 76px; }
  .lightbox .lb-prev, .lightbox .lb-next { top: auto; bottom: 16px; transform: none; }
}

/* ─── Guide (guide.php): a top-to-bottom flow chart per kind of task ─── */
.guide { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.guide-side .card { margin-bottom: 20px; }
.guide-flow > p { max-width: 640px; }
.guide-legend { display: flex; flex-wrap: wrap; gap: 6px 8px; list-style: none; margin: 0 0 18px; padding: 0; }
.guide-who { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600;
             border: 1px solid var(--who, var(--border)); color: var(--text); background: var(--surface); }
.who-system { --who: var(--chart-base); }
.who-ai     { --who: var(--s1); }
.who-person { --who: var(--s4); }
.who-auto   { --who: var(--s3); }
.who-end    { --who: var(--brand); }
.flow { list-style: none; margin: 0; padding: 0; max-width: 680px; }
.flow-step { position: relative; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--who);
             border-radius: 10px; padding: 12px 16px 14px; margin-bottom: 30px; }
.flow-step:not(:last-child)::after { content: ""; position: absolute; left: 32px; bottom: -31px; width: 2px; height: 22px; background: var(--chart-base); }
.flow-step:not(:last-child)::before { content: ""; position: absolute; left: 27px; bottom: -31px; border: 6px solid transparent;
                                      border-top: 8px solid var(--chart-base); border-bottom: 0; }
.flow-step.who-end { border-style: solid; border-width: 2px 2px 2px 4px; }
.flow-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.flow-num { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%;
            background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.flow-step h3 { font-size: 16px; margin: 0 0 4px; color: var(--text); text-transform: none; letter-spacing: 0; }
.flow-step p { margin: 0; }
.flow-branches { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.flow-branches li { padding: 7px 10px; border: 1px dashed var(--border); border-radius: 8px; background: var(--surface-2); font-size: 14px; }
.flow-if { font-weight: 600; }
.flow-then { color: var(--muted); }
.flow-details { margin-top: 10px; font-size: 14px; }
.flow-details ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }
.flow-details li + li { margin-top: 4px; }
.guide-dl { margin: 0; font-size: 14px; }
.guide-dl dt { font-weight: 600; margin-top: 12px; }
.guide-dl dt:first-child { margin-top: 0; }
.guide-dl dd { margin: 2px 0 0; color: var(--muted); }
.guide-link { margin: -8px 0 16px; font-size: 14px; }
@media (max-width: 1000px) {
  .guide { grid-template-columns: minmax(0, 1fr); }
}

/* A choice on a card (e.g. the special price: only this order, or from now on) */
.approval fieldset.choice { border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px 10px; margin: 12px 0; }
.approval fieldset.choice legend { padding: 0 6px; color: var(--muted); font-size: 14px; }
.approval fieldset.choice label.check { display: flex; gap: 8px; align-items: center; margin: 6px 0; font-weight: normal; }
.approval fieldset.choice input[type=radio] { accent-color: var(--brand); }
