:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e3e6eb;
  --text: #16181d;
  --muted: #6a7180;
  --accent: #2f6fed;
  --accent-soft: #e8efff;
  --ok: #138a4c;
  --ok-soft: #e4f5ec;
  --warn: #b25e00;
  --warn-soft: #fff1df;
  --bad: #c62f2f;
  --bad-soft: #fde9e9;
  --yandex: #2a78d6;
  --glovo: #eb6834;
  --buyam: #1baf7a;
  --seq: #2a78d6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1d2128;
    --border: #2a2f38;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --accent: #6b9bff;
    --accent-soft: #1d2a44;
    --ok: #4cc38a;
    --ok-soft: #15301f;
    --warn: #f0a845;
    --warn-soft: #34260f;
    --bad: #ff7b7b;
    --bad-soft: #3a1818;
    --yandex: #3987e5;
    --glovo: #d95926;
    --buyam: #199e70;
    --seq: #5b9cf0;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Inter", "Noto Sans Armenian", system-ui, sans-serif;
}
main { max-width: 1600px; margin: 0 auto; padding: 16px; display: grid; gap: 14px; }
.hidden { display: none !important; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; gap: 12px; align-items: center; }
.logo { font-size: 26px; color: var(--accent); }
h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.sub { margin: 0; color: var(--muted); font-size: 12px; }

.pill { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.pill.idle { background: var(--surface-2); color: var(--muted); }
.pill.running { background: var(--accent-soft); color: var(--accent); }
.pill.done { background: var(--ok-soft); color: var(--ok); }
.pill.error { background: var(--bad-soft); color: var(--bad); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.controls { display: grid; grid-template-columns: auto 1fr auto; gap: 24px; padding: 16px 20px; align-items: start; }
@media (max-width: 1000px) { .controls { grid-template-columns: 1fr; } }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .04em; }
.field .check { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text); font-size: 13px; display: flex; gap: 8px; align-items: center; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 13px;
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }

.dates { display: flex; gap: 8px; align-items: center; margin-top: 10px; color: var(--muted); }
input[type=date], input[type=search], select {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
}
input:focus, select:focus, .btn:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.actions .buttons { display: flex; gap: 8px; margin-top: 12px; }
.btn {
  font: inherit; font-weight: 600; font-size: 13px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 16px; border-radius: 8px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.small { padding: 7px 12px; font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; max-width: 340px; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; }

.progress { padding: 12px 20px; }
.progress-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.log {
  margin: 10px 0 0; max-height: 220px; overflow: auto; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 12px; white-space: pre-wrap;
}
.spinner {
  display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px;
  border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .k { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .v { font-size: 20px; font-weight: 700; margin-top: 2px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 11px; color: var(--muted); margin-top: 2px; }

.grid-card { padding: 0; overflow: hidden; }
.grid-toolbar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.tabs { display: flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 9px; border: 1px solid var(--border); }
.tab { border: 0; background: none; padding: 6px 14px; border-radius: 7px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters input[type=search] { width: 240px; }
.empty { color: var(--muted); text-align: center; padding: 40px 16px; margin: 0; }

/* Tabulator theming */
#grid { border: 0; }
.tabulator { background: var(--surface); border: 0; font-size: 13px; color: var(--text); }
.tabulator .tabulator-header { background: var(--surface-2); border-bottom: 1px solid var(--border); color: var(--muted); }
.tabulator .tabulator-header .tabulator-col { background: var(--surface-2); border-right: 1px solid var(--border); }
.tabulator .tabulator-header .tabulator-col .tabulator-col-title { font-weight: 600; font-size: 12px; }
.tabulator .tabulator-header .tabulator-col input,
.tabulator .tabulator-header .tabulator-col select { padding: 4px 6px; font-size: 12px; border-radius: 6px; width: 100%; }
.tabulator .tabulator-tableholder .tabulator-table { background: var(--surface); color: var(--text); }
.tabulator-row { background: var(--surface); border-bottom: 1px solid var(--border); }
.tabulator-row.tabulator-row-even { background: var(--surface-2); }
.tabulator-row.tabulator-selectable:hover { background: var(--accent-soft); }
.tabulator-row .tabulator-cell { border-right: 0; padding: 7px 10px; }
.tabulator .tabulator-footer { background: var(--surface-2); border-top: 1px solid var(--border); color: var(--text); }
.tabulator .tabulator-footer .tabulator-calcs-holder { background: var(--surface-2); border-top: 0; }
.tabulator .tabulator-footer .tabulator-calcs-holder .tabulator-row { background: var(--surface-2); font-weight: 700; }
.tabulator-placeholder span { color: var(--muted) !important; font-weight: 500 !important; font-size: 14px !important; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.tag.yandex, .tag.glovo, .tag.buyam { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.tag.yandex::before, .tag.glovo::before, .tag.buyam::before { content: ""; display: inline-block; width: 7px; height: 7px;
  border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.tag.yandex::before { background: var(--yandex); }
.tag.glovo::before { background: var(--glovo); }
.tag.buyam::before { background: var(--buyam); }
.tag.Completed { background: var(--ok-soft); color: var(--ok); }
.tag.Cancelled { background: var(--bad-soft); color: var(--bad); }
.tag.progress { background: var(--accent-soft); color: var(--accent); }
.warn-text { color: var(--warn); font-weight: 600; }

/* ---------- navigation & views ---------- */
.topbar { gap: 16px; flex-wrap: wrap; }
.mainnav { display: flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 10px; border: 1px solid var(--border); }
.navbtn { border: 0; background: none; padding: 7px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); }
.navbtn:hover { color: var(--text); }
.navbtn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.view { max-width: 1600px; margin: 0 auto; padding: 16px; display: grid; gap: 14px; }
.muted { color: var(--muted); font-weight: 400; }
.hint.wide { max-width: none; margin: 0 4px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; padding: 12px 16px; }
.toolbar-left { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar input[type=search] { width: 240px; }
.toolbar input:not([type=search]):not([type=date]):not([type=checkbox]) {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
}
label.inline { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); font-weight: 600; }
.section-title { font-size: 14px; margin: 0; padding: 12px 14px; border-bottom: 1px solid var(--border); }

.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.btn.danger:hover { background: var(--bad-soft); }
.iconbtn { border: 0; background: none; font-size: 18px; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.iconbtn:hover { background: var(--surface-2); color: var(--text); }

.fc-good { color: var(--ok); font-weight: 600; }
.fc-mid { color: var(--warn); font-weight: 600; }
.fc-bad { color: var(--bad); font-weight: 600; }
.thumb { width: 34px; height: 34px; object-fit: cover; border-radius: 6px; vertical-align: middle; }

/* ---------- editor drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 12, 16, .35); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(860px, 100vw); z-index: 21;
  background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column;
  box-shadow: -8px 0 24px rgba(0, 0, 0, .12);
}
.drawer-head, .drawer-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.drawer-foot { border-bottom: 0; border-top: 1px solid var(--border); }
.drawer-head h2 { flex: 1; margin: 0; font-size: 16px; }
.drawer-body { flex: 1; overflow: auto; padding: 16px 18px 24px; }
.drawer-body h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 0 8px; }
.spacer { flex: 1; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid label, .drawer-body > label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.span2 { grid-column: span 2; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } .span2 { grid-column: auto; } }
.drawer input:not([type=radio]):not([type=file]), .drawer select, .drawer textarea {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; width: 100%;
}
.drawer textarea { resize: vertical; }
.seg { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--text); }
.seg label { display: flex; gap: 6px; align-items: center; font-weight: 500; color: var(--text); flex-direction: row; }
.pair { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.form-grid .pair { margin-top: 0; }
.pair select { width: auto !important; }

table.lines { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 8px; }
table.lines th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; padding: 4px 4px; border-bottom: 1px solid var(--border); }
table.lines td { padding: 4px; vertical-align: middle; }
table.lines td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.lines input { padding: 6px 7px !important; }
table.lines .c-comp { width: 40%; }
table.lines .c-qty { width: 10%; }
table.lines .c-sec select { min-width: 128px; }
table.lines .c-unit select { min-width: 68px; }

.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-top: 14px; }
.totals .kpi { box-shadow: none; padding: 10px 12px; }
.totals .kpi .v { font-size: 17px; }
.warnings { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.warnings li { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 6px 10px; font-size: 12px; font-weight: 500; }
.chip .x { margin-left: 6px; border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 13px; }
.photo-row { display: flex; gap: 14px; align-items: flex-start; }
.photo { width: 160px; height: 120px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.error { background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: 8px 12px; font-size: 13px; font-weight: 500; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 40;
  background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 10px; font-size: 13px; font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
}
.toast.bad { background: var(--bad); color: #fff; }

/* ---------- modal window ---------- */
dialog.modal {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--border);
  border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: 0 16px 48px rgba(0, 0, 0, .25);
}
dialog.modal::backdrop { background: rgba(10, 12, 16, .4); }
dialog.modal form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-body h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }
dialog.modal .form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
dialog.modal input, dialog.modal select, dialog.modal textarea {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%;
}
dialog.modal input:disabled, dialog.modal select:disabled, dialog.modal textarea:disabled { background: var(--surface-2); color: var(--text); opacity: 1; }
.used-list { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.used-list li { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 12px; }
.row-actions { display: flex; gap: 4px; }
.row-actions button { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 6px; padding: 3px 9px; font: inherit; font-size: 12px; cursor: pointer; }
.row-actions button:hover { border-color: var(--accent); color: var(--accent); }
.row-actions button.del:hover { border-color: var(--bad); color: var(--bad); }
.no-price { color: var(--muted); font-size: 12px; }
dialog.modal { width: min(760px, calc(100vw - 32px)); }
table.goods td input { padding: 6px 8px !important; }
table.goods .g-name { width: 44%; } table.goods .g-sup { width: 24%; } table.goods .g-unit { width: 14%; } table.goods .g-qty { width: 14%; }

.modal-body .hint { max-width: none; }

dialog.modal.wide { width: min(1000px, calc(100vw - 32px)); }
.price-now { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.price-now b { font-size: 18px; }
details.history { margin-top: 10px; }
details.history summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent); }
details.history table { margin-top: 8px; }
label.check { flex-direction: row !important; align-items: center; gap: 8px !important; color: var(--text) !important; font-weight: 500 !important; }
label.check input { width: auto !important; }

.mtabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 8px 18px 0; border-bottom: 1px solid var(--border); }
.mtab { border: 0; background: none; padding: 8px 12px; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.mtab.active { color: var(--accent); border-bottom-color: var(--accent); }
.mtab .dot-count { font-weight: 500; color: var(--muted); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 12px; }
.checks label { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text); font-weight: 500; }
.checks input { width: auto !important; }
.form-grid.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 640px) { .form-grid.four { grid-template-columns: 1fr 1fr; } }
.log-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 12.5px; }
.log-list li { border-left: 3px solid var(--border); padding: 4px 10px; }
.log-list .when { color: var(--muted); margin-right: 8px; }
input.narrow { width: 70px !important; }
.tabulator-row.archived .tabulator-cell { color: var(--muted); }
.allergen { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 999px; margin: 1px 2px 1px 0;
  background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.label-chip { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; margin: 1px 2px 1px 0;
  background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.stock-out { color: var(--bad); font-weight: 600; } .stock-low { color: var(--warn); font-weight: 600; } .stock-ok { color: var(--ok); }

.chips-line { margin-bottom: 8px; }

a.btn { text-decoration: none; display: inline-block; }

:root { --chart: #2f6fed; }
@media (prefers-color-scheme: dark) { :root { --chart: #5b8ef5; } }
.chart-wrap { position: relative; margin-top: 12px; }
.price-chart { width: 100%; height: auto; display: block; }
.price-chart .grid { stroke: var(--border); stroke-width: 1; }
.price-chart .axis { fill: var(--muted); font-size: 11px; }
.price-chart .line { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.price-chart .area { fill: var(--chart); opacity: .1; }
.price-chart .dot { fill: var(--chart); stroke: var(--surface); stroke-width: 2; }
.price-chart .dot.active { r: 6; }
.price-chart .cross { stroke: var(--muted); stroke-width: 1; }
.price-chart .hit { fill: transparent; cursor: crosshair; }
.chart-tip { position: absolute; width: 180px; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 8px; font-size: 12px; box-shadow: var(--shadow); }

/* ---- Sales */
.subtabs { display: flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 9px; border: 1px solid var(--border); }
.subtab { border: 0; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); }
.subtab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.sub { display: flex; flex-direction: column; gap: 12px; }
.sub.hidden { display: none; }
.notice { margin: 0; padding: 10px 14px; border-radius: var(--radius); background: var(--warn-soft); color: var(--text); font-size: 13px; border: 1px solid var(--border); }
.chart-card { padding-bottom: 10px; }
.chart-card .chart-wrap { margin: 6px 14px 0; }
.legend { display: flex; gap: 14px; padding: 10px 14px 0; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.table-view { margin: 6px 14px 0; font-size: 12px; overflow-x: auto; }
.table-view summary { cursor: pointer; color: var(--muted); }
.table-view table { border-collapse: collapse; margin-top: 6px; font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { padding: 3px 10px; border-bottom: 1px solid var(--border); text-align: right; }
.table-view th:first-child, .table-view td:first-child { text-align: left; }
.svg-chart { width: 100%; height: auto; display: block; overflow: visible; }
.svg-chart .grid { stroke: var(--border); stroke-width: 1; }
.svg-chart .axis { fill: var(--muted); font-size: 11px; }
.svg-chart .seg { stroke: var(--surface); stroke-width: 2; }
.svg-chart .hit { fill: transparent; }
.svg-chart .hit:hover { fill: var(--text); fill-opacity: .05; }
.svg-chart .qline { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.svg-chart .qlabel { fill: var(--muted); font-size: 12px; font-weight: 600; }
.svg-chart .dot { fill: var(--seq); stroke: var(--surface); stroke-width: 2; fill-opacity: .85; cursor: default; }
.svg-chart .dot:hover { stroke: var(--text); }
.svg-chart .dlabel { fill: var(--text); font-size: 11px; }
.heat { display: grid; grid-template-columns: 36px repeat(24, minmax(0, 1fr)); gap: 2px; font-size: 10px; color: var(--muted); }
.heat .cell { aspect-ratio: 1.6; border-radius: 3px; background: var(--surface-2); }
.heat .cell:hover { outline: 2px solid var(--text); }
.heat .hl { text-align: center; }
.heat .wl { align-self: center; }
.heat-scale { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); margin-top: 8px; }
.heat-scale .r { width: 120px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, color-mix(in srgb, var(--seq) 10%, var(--surface)), var(--seq)); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; }
.pad { padding: 10px 14px; }
.report-text { margin: 0 14px 14px; padding: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  white-space: pre-wrap; font: 13px/1.45 ui-monospace, Consolas, monospace; }
.up { color: var(--ok); } .down { color: var(--bad); }
@media (max-width: 640px) { .two-col { grid-template-columns: 1fr; } .heat { grid-template-columns: 28px repeat(24, minmax(0, 1fr)); font-size: 8px; } }
.chart-tip .sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.svg-chart .dlabel { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
@media (max-width: 760px) {
  .mainnav, .subtabs { max-width: 100%; overflow-x: auto; }
  .mainnav .navbtn, .subtab { white-space: nowrap; flex: 0 0 auto; }
  #view-sales .toolbar-left > * { max-width: 100%; }
  .two-col { grid-template-columns: minmax(0, 1fr); }
  .view > *, .sub > * { min-width: 0; }
}

/* ---- tax portal run */
.tax-run { padding: 12px 14px; }
.tax-run-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tax-run .run-log { max-height: 180px; overflow: auto; margin: 8px 0 0; padding: 8px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; font: 12px/1.4 ui-monospace, Consolas, monospace; white-space: pre-wrap; }

/* ---- invoice details */
.inv-meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0 0 12px; font-size: 13px; }
.inv-meta dt { color: var(--muted); }
.inv-meta dd { margin: 0; }
.atg-box { font-size: 13px; }
.atg-box .chips { margin-top: 6px; }

/* ---- invoices: selection actions, suggestions */
.grid-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 14px; border-bottom: 1px solid var(--border); }
.grid-actions .spacer { flex: 1; }
.grid-actions select { margin: 0 4px; }
#aSuggest, #bSuggest { align-items: center; }
#bRows input.narrow { width: 110px; }
/* tables never widen their section (a wide Tabulator scrolls inside its card instead of the whole page) */
.view > *, .sub > *, .two-col > * { min-width: 0; }
.grid-card { max-width: 100%; }

/* ---- waste log, other costs */
.view-tabs { align-self: start; }
.waste-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 12px; padding: 12px 14px 4px; align-items: end; }
.waste-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.waste-grid label.check { flex-direction: row; align-items: center; gap: 6px; padding-bottom: 8px; }
.waste-grid .wide { grid-column: span 2; }
.waste-grid input, .waste-grid select { width: 100%; }
.waste-actions { display: flex; gap: 8px; justify-content: flex-end; padding-bottom: 2px; }
@media (max-width: 640px) { .waste-grid .wide { grid-column: auto; } }

/* ---- usage calculation window */
.usage-calc .dish-row td { border-top: 2px solid var(--border); padding-top: 8px; }
.usage-calc .calc-row td { padding: 2px 8px 10px 22px; font-size: 12px; color: var(--muted); }
.usage-calc .calc-row b { color: var(--text); font-weight: 600; }
.usage-calc .calc-step { margin: 2px 0; }
.usage-calc tfoot td { border-top: 2px solid var(--border); padding-top: 8px; }

/* ---- orders: grouping */
.groupbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.groupbar .spacer { flex: 1; }
.groupbar select { max-width: 200px; }
#grid .tabulator-group { background: var(--surface-2); border-bottom: 1px solid var(--border); font-weight: 400; }
#grid .tabulator-group .group-sum { margin-left: 10px; font-variant-numeric: tabular-nums; }
#grid .tabulator-row.tabulator-calcs { background: var(--surface-2); font-weight: 600; }

/* ---- linked products: unsaved corrections */
#linkedGrid .tabulator-row.row-pending { background: var(--warn-soft); }

/* ---- supplier orders */
.badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.po-head { display: flex; align-items: center; gap: 10px; padding-right: 14px; }
.po-head .section-title { flex: 1; border-bottom: 0; }
.pad-x { margin: 0 14px; }
.po-add { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; padding: 6px 14px 0; }
.po-add label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.po-add .grow { flex: 1 1 220px; }
.po-add .qty { flex: 0 0 170px; }
.po-add input, .po-add select { width: 100%; }
.qty-row { display: flex; gap: 6px; align-items: center; }
.qty-row input { width: 90px; }
.po-lines { margin: 10px 14px; width: calc(100% - 28px); }
.po-lines .sup-row td { background: var(--surface-2); font-weight: 600; }
.po-lines input.narrow { width: 90px; }
.po-lines tr.removed td { text-decoration: line-through; color: var(--muted); }
.po-lines tr.removed td:last-child { text-decoration: none; }
.po-lines tr.changed td, .po-lines tr.added td { background: var(--warn-soft); }
.po-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px 14px; }
.po-actions .spacer { flex: 1; }
.waste-grid .full { grid-column: 1 / -1; }
.waste-grid textarea { width: 100%; font: inherit; }
.msg-label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.msg-label textarea { width: 100%; font: 13px/1.45 ui-monospace, Consolas, monospace; }
#poOrderDialog .po-actions { padding: 10px 0; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }

/* ---- supplier orders: kitchen link, pictures */
.kitchen-link { display: flex; align-items: center; gap: 16px; justify-content: space-between; padding: 14px 16px; }
.cat-pics { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; padding: 12px 14px 16px; }
.cat-pic { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-size: 12px; }
.cat-pic-img { width: 100%; aspect-ratio: 4 / 3; border-radius: 12px; border: 1px dashed var(--border); background: var(--surface-2); font-size: 44px; overflow: hidden; cursor: pointer; padding: 0; }
.cat-pic-img img { width: 100%; height: 100%; object-fit: cover; }
.cat-pic-name { font-weight: 600; }

/* ---- orders: columns menu, order window */
.col-menu-wrap { position: relative; }
.col-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 240px; max-height: 60vh; overflow: auto; padding: 8px 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(16, 24, 40, .14); }
.col-menu-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 12px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.col-menu .link { border: 0; background: none; color: var(--accent); cursor: pointer; font: inherit; font-size: 12px; padding: 0; }
.col-item { display: flex; align-items: center; gap: 8px; padding: 5px 12px; font-size: 13px; cursor: pointer; }
.col-item:hover { background: var(--surface-2); }
#grid.rows-open .tabulator-row:not(.tabulator-group):not(.tabulator-calcs) { cursor: pointer; }
.od-top { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; margin-bottom: 14px; }
.od-money dd { text-align: right; font-variant-numeric: tabular-nums; }
#odItems th.num, #odItems td.num { text-align: right; }
#odItems tfoot td { border-top: 2px solid var(--border); }
#odTitle .tag { vertical-align: 3px; }
@media (max-width: 700px) { .od-top { grid-template-columns: 1fr; } }

/* ---- dish mapping */
#mapDishGrid .tabulator-cell.map-actions { white-space: normal; }
#mapDishGrid .map-btns { display: flex; flex-wrap: wrap; gap: 4px; }
#mapCardGrid .tabulator-cell { white-space: normal; }

/* ---- logged-in user, roles */
.me { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.me-name { font-weight: 600; }
.me-role { color: var(--muted); }
.role-name { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 12px; max-width: 360px; }
.role-matrix td, .role-matrix th { text-align: center; }
.role-matrix td:first-child, .role-matrix th:first-child { text-align: left; }
.role-matrix input { width: 18px; height: 18px; }
/* supplier orders: what a role without these rights doesn't need */
body:not(.can-approve) #poApprove, body:not(.can-approve) #poReject { display: none !important; }
body:not(.purch-full) #poTabs .subtab[data-sub=sending], body:not(.purch-full) #poTabs .subtab[data-sub=suppliers],
body:not(.purch-full) #poTabs .subtab[data-sub=items], body:not(.purch-full) #poTabs .subtab[data-sub=settings],
body:not(.purch-full) #poTabs .subtab[data-sub=calendar], body:not(.purch-full) #poTabs .subtab[data-sub=standing],
body:not(.purch-full) #poTabs .subtab[data-sub=returns], body:not(.purch-full) #poTabs .subtab[data-sub=prices] { display: none; }

/* ---- supplier orders: calendar, invoice check, flags */
.po-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.po-day { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px; min-height: 110px; min-width: 0; }
.po-day.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.po-day.past { opacity: .7; }
.po-day h4 { margin: 0 0 6px; font-size: 13px; display: flex; justify-content: space-between; gap: 6px; }
.po-cal-order { display: block; width: 100%; text-align: left; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2, var(--bg));
  padding: 4px 6px; margin-bottom: 4px; font-size: 12px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.po-cal-order:hover { border-color: var(--accent); }
.po-cal-order .tag { float: right; margin-left: 4px; }
.po-cal-free { font-size: 12px; color: var(--muted); padding: 2px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 900px) { .po-cal { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.flag { display: inline-block; margin: 1px 4px 1px 0; padding: 1px 6px; border-radius: 6px; font-size: 12px;
  background: var(--warn-soft, #fff4e0); color: var(--warn, #b45309); }
.flag.ok { background: var(--ok-soft, #dcfce7); color: var(--ok, #15803d); }
.cheapest { color: var(--ok, #15803d); font-weight: 600; }
body.no-money .money-only { display: none !important; }

/* ---- Data page */
.dp-checks { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.dp-checks li.ok { color: var(--ok); }
.dp-checks li.bad { color: var(--bad); font-weight: 600; }
.dp-days-wrap { max-height: 460px; overflow: auto; }
.dp-days td, .dp-days th { text-align: center; }
.dp-days td:first-child, .dp-days th:first-child { text-align: left; white-space: nowrap; }
.dp-day { border-radius: 6px; padding: 2px 8px; font-variant-numeric: tabular-nums; }
.dp-day.settled { background: var(--ok-soft); color: var(--ok); }
.dp-day.fetched { background: var(--warn-soft); color: var(--warn); }
.dp-day.missing { background: var(--surface-2); color: var(--muted); }

/* Settings (company details) */
#view-settings .card { display: grid; gap: 14px; padding: 16px 18px; }
#view-settings input:not([type=checkbox]):not([type=radio]), #view-settings select {
  font: inherit; font-size: 13px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%;
}
#view-settings input:disabled, #view-settings select:disabled { background: var(--surface-2); color: var(--text); opacity: 1; }
#view-settings .form-grid label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
#view-settings .hint { max-width: none; }
.st-table label.check { display: inline-flex; gap: 4px; align-items: center; margin-right: 8px; font-size: 13px; }
.set-actions { display: flex; gap: 10px; align-items: center; border-top: 1px solid var(--border); padding-top: 12px; }
.st-table { width: 100%; border-collapse: collapse; }
.st-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 6px; }
.st-table td { padding: 4px 6px; vertical-align: middle; border-top: 1px solid var(--border); }
.st-table input:not([type=checkbox]):not([type=radio]) { width: 100%; min-width: 0; }
.st-table .st-short { width: 64px; }
.st-label { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.st-logo { display: flex; gap: 10px; align-items: center; }
.st-logo img { height: 40px; max-width: 120px; object-fit: contain; border: 1px solid var(--border); border-radius: 6px; background: #fff; padding: 2px; }
.st-history { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 13px; }
@media (max-width: 720px) { .st-table thead { display: none; } .st-table tr { display: grid; gap: 4px; padding: 6px 0; } .st-table td { border: 0; } }
#view-settings .st-table input.st-short { width: 80px; display: inline-block; }
.st-table td:has(> input.st-short) { white-space: nowrap; }

/* Reporting */
.rp-bar { display: grid; gap: 10px; padding: 12px 14px; }
.rp-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.rp-controls { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; font-size: 13px; }
.rp-controls label:not(.check) { display: flex; gap: 6px; align-items: center; color: var(--muted); font-weight: 600; font-size: 12px; }
.rp-controls input[type=date], .rp-controls select { font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.notice-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.rp-scroll { overflow-x: auto; }
.rp-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.rp-table th, .rp-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.rp-table th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: left; position: sticky; top: 0; background: var(--surface); }
.rp-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.rp-table .rp-line { position: sticky; left: 0; background: var(--surface); min-width: 260px; white-space: normal; }
.rp-table tr.rp-header td { background: var(--surface-2); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.rp-table tr.rp-total td { font-weight: 700; border-top: 1px solid var(--text); }
.rp-table tr.rp-sub td.rp-line, .rp-table tr.rp-info td.rp-line { padding-left: 28px; color: var(--muted); }
.rp-table tr.rp-info td { color: var(--muted); font-style: italic; }
/* better / worse markers (reconciliation differences, report changes) - always with ▲▼ or +/− as well as colour */
span.good { color: var(--ok); font-weight: 600; }
span.bad { color: var(--bad); font-weight: 600; }

/* Settings -> Data collection */
.dc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 12px; }
.dc-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 8px; align-content: start; background: var(--surface); }
.dc-card header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dc-card h3 { margin: 0; font-size: 15px; }
.dc-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; font-size: 13px; }
.dc-row label { display: flex; gap: 6px; align-items: center; color: var(--muted); font-weight: 600; font-size: 12px; }
#view-settings .dc-row input[type=time], #view-settings .dc-row input[type=date], #view-settings .dc-row select { width: auto; }
.dc-switch { font-weight: 600; }
.dc-pill { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.dc-ok { background: var(--ok-soft); color: var(--ok); } .dc-warn { background: var(--warn-soft); color: var(--warn); }
.dc-bad { background: var(--bad-soft); color: var(--bad); } .dc-run { background: var(--accent-soft); color: var(--accent); }
.dc-off { background: var(--surface-2); color: var(--muted); }
.dc-paused { background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: 8px 10px; font-size: 13px; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.dc-facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; font-size: 13px; }
.dc-facts dt { color: var(--muted); } .dc-facts dd { margin: 0; }
.dc-now summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--accent); }
.dc-now[open] { display: grid; gap: 8px; }
.dc-job { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--surface-2); }
.dc-job .log { max-height: 180px; overflow: auto; margin: 6px 0 0; }
.dc-report { max-width: 520px; }

/* Data collection: on/off switch + schedule choice */
.dc-toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; width: fit-content; }
.dc-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.dc-slider { position: relative; width: 42px; height: 24px; border-radius: 999px; background: var(--border); transition: background .15s; flex: none; }
.dc-slider::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.dc-toggle input:checked + .dc-slider { background: var(--ok); }
.dc-toggle input:checked + .dc-slider::after { transform: translateX(18px); }
.dc-toggle input:focus-visible + .dc-slider { outline: 2px solid var(--accent); outline-offset: 2px; }
.dc-toggle input:disabled + .dc-slider { opacity: .5; }
.dc-sched { display: grid; gap: 6px; font-size: 13px; }
.dc-sched label.check { display: flex; gap: 8px; align-items: center; }
#view-settings .dc-sched input[type=time], #view-settings .dc-sched select { width: auto; }

/* tech card editor: restaurants as on/off chips */
.cstores { display: grid; gap: 6px; }
.cstores-label { font-size: 12px; font-weight: 600; color: var(--muted); }
