:root {
  --ink: #17202a;
  --muted: #687385;
  --line: #dfe4ea;
  --surface: #ffffff;
  --canvas: #f4f6f8;
  --accent: #2067e8;
  --accent-dark: #164fae;
  --danger: #b72d2d;
  --warning: #9a6400;
  --success: #117a47;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body { margin: 0; min-height: 100vh; padding-bottom: 92px; }
button, input, select, textarea { font: inherit; }
button { min-height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; background: var(--surface); color: var(--ink); cursor: pointer; }
button:hover { border-color: #aeb8c4; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #99baf7; outline-offset: 2px; }
button.primary { background: var(--accent); border-color: var(--accent); color: white; font-weight: 650; }
button.primary:hover { background: var(--accent-dark); }
button:disabled { opacity: .45; cursor: not-allowed; }
input, select, textarea { min-height: 42px; max-width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: white; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.topbar { height: 62px; padding: 10px max(16px, env(safe-area-inset-left)); display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar strong { display: block; font-size: 18px; }
.topbar span { color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.status-pill { border-radius: 999px; padding: 6px 10px; background: #edf2f7; }
.status-pill.ok { background: #ddf5e8; color: var(--success); }
.status-pill.warn { background: #fff1ce; color: var(--warning); }
.status-pill.danger { background: #ffe4e4; color: var(--danger); }
.icon-button { min-width: 32px; width: 32px; min-height: 32px; height: 32px; padding: 0; border-radius: 50%; font-weight: 750; color: var(--accent); }
.readonly-banner { background: #fff1ce; color: #6b4800; padding: 9px 16px; text-align: center; font-size: 13px; }
.tabs { display: flex; gap: 4px; padding: 10px 16px 0; max-width: 1280px; margin: auto; overflow-x: auto; }
.tabs, .filters { scrollbar-width: none; }
.tabs::-webkit-scrollbar, .filters::-webkit-scrollbar { display: none; }
.tab { border: 0; background: transparent; border-radius: 8px 8px 0 0; color: var(--muted); white-space: nowrap; }
.tab.active { color: var(--accent); background: var(--surface); box-shadow: inset 0 -2px var(--accent); }
main { max-width: 1280px; margin: auto; padding: 12px 16px 32px; }
.panel { display: none; }
.panel.active { display: block; }
.toolbar { display: grid; grid-template-columns: auto minmax(260px, 1fr); gap: 10px 16px; align-items: center; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.segmented { display: flex; padding: 3px; border-radius: 12px; background: #edf1f5; }
.segmented button { min-height: 36px; border: 0; background: transparent; padding: 6px 13px; }
.segmented button.active { background: white; color: var(--accent); box-shadow: 0 1px 5px #1f293722; }
.search { position: relative; display: block; }
.search span { position: absolute; left: 12px; top: 8px; font-size: 22px; color: var(--muted); }
.search input { width: 100%; padding-left: 38px; }
.filters { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.filters label { display: flex; align-items: center; gap: 7px; color: var(--ink); }
.filters input { min-height: 0; }
.summary-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; color: var(--muted); font-size: 13px; }
.summary-row span { background: #e9edf2; border-radius: 999px; padding: 5px 9px; }
.catalog { display: grid; gap: 8px; }
.product-row { display: grid; grid-template-columns: 34px minmax(240px, 1.7fr) 100px 100px 100px 130px; gap: 10px; align-items: center; min-width: 0; overflow: hidden; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.product-row.review { border-left: 4px solid #e3a321; }
.product-title { min-width: 0; }
.product-title strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-title small { display: block; margin-top: 3px; color: var(--muted); }
.cell-label { display: block; color: var(--muted); font-size: 11px; }
.price-cell b { font-variant-numeric: tabular-nums; }
.draft-price { width: 100%; min-width: 86px; }
.show-state { min-height: 34px; padding: 6px 8px; font-size: 12px; color: var(--muted); text-align: left; }
.show-state.on { color: var(--success); }
.both-row { grid-template-columns: 34px minmax(220px, 1fr) minmax(460px, 2fr); }
.both-prices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.context-price { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 9px; border: 1px solid var(--line); border-radius: 10px; }
.context-price > span { color: var(--muted); font-size: 12px; }
.context-price .price-cell { display: grid; grid-template-columns: 86px 1fr; gap: 8px; align-items: center; }
.context-price.missing { color: var(--muted); align-content: center; }
.action-bar { position: fixed; z-index: 25; bottom: 0; left: 0; right: 0; min-height: 72px; padding: 10px max(16px, calc((100vw - 1248px) / 2)); padding-bottom: max(10px, env(safe-area-inset-bottom)); background: #ffffffee; backdrop-filter: blur(12px); border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; box-shadow: 0 -8px 28px #17202a12; }
.action-bar > div { display: flex; gap: 7px; }
.section-heading { display: flex; align-items: start; justify-content: space-between; margin: 8px 0 14px; }
.section-heading h1 { margin: 0; font-size: 23px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); }
.card { padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.row-card { display: flex; gap: 12px; align-items: end; }
.row-card label { flex: 1; }
.price-preview { min-height: 360px; max-height: 62vh; overflow: auto; padding: 16px; background: #101820; color: #f6f7f9; border-radius: var(--radius); white-space: pre-wrap; font: 14px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
.publication-actions { display: flex; justify-content: end; gap: 8px; flex-wrap: wrap; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; min-width: 0; }
.setting-card, .form-grid, .form-grid > *, .inline-admin { min-width: 0; }
.setting-card h2 { margin: 0 0 4px; font-size: 17px; }
.setting-card p { color: var(--muted); margin: 0 0 12px; }
.settings-form { display: grid; gap: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.form-grid fieldset { display: flex; flex-wrap: wrap; gap: 12px; max-width: 100%; border: 1px solid var(--line); border-radius: 10px; }
.form-grid legend { color: var(--muted); font-size: 12px; }
.check { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 7px; color: var(--ink); }
.check input { min-height: 0; }
.wide-field { grid-column: 1 / -1; }
.wide-field textarea { width: 100%; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.inline-admin { display: grid; grid-template-columns: 140px minmax(120px, 1fr) auto auto auto; gap: 8px; align-items: center; margin-top: 8px; }
.stack { display: grid; gap: 12px; }
.wide { width: 100%; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.history-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.history-item > div small, .history-item > small { display: block; color: var(--muted); margin-top: 3px; }
.history-item > p { grid-column: 1 / -1; margin: 0; color: var(--danger); overflow-wrap: anywhere; }
.audit-row { display: grid; grid-template-columns: 165px minmax(160px, 1fr) minmax(100px, auto); gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.audit-row span { color: var(--muted); }
.login-page { display: grid; place-items: center; padding: 20px; }
.login-card { width: min(410px, 100%); padding: 28px; background: white; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 18px 70px #17202a18; }
.login-card h1 { margin: 12px 0 4px; }
.brand-mark { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 14px; background: var(--accent); color: white; font-weight: 800; }
.muted { color: var(--muted); }
.alert { padding: 10px 12px; border-radius: 10px; margin: 10px 0; }
.alert.danger { background: #ffe4e4; color: var(--danger); }
.hidden { display: none !important; }
dialog { width: min(760px, calc(100% - 24px)); max-height: 90vh; border: 0; padding: 0; border-radius: 18px; box-shadow: 0 30px 100px #0005; }
dialog::backdrop { background: #17202a88; backdrop-filter: blur(2px); }
.dialog-shell { padding: 18px; overflow: auto; max-height: 90vh; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-heading h2 { margin: 0; }
.dialog-heading button { border: 0; font-size: 24px; }
.dialog-actions { display: flex; justify-content: end; gap: 8px; margin-top: 14px; }
.diff-list { display: grid; gap: 7px; max-height: 54vh; overflow: auto; }
.diff-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
.diff-row .arrow { color: var(--muted); }
.toast { position: fixed; z-index: 50; right: 16px; bottom: 92px; max-width: min(430px, calc(100% - 32px)); background: #17202a; color: white; padding: 11px 14px; border-radius: 10px; opacity: 0; pointer-events: none; transform: translateY(10px); transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 760px) {
  body { padding-bottom: 128px; }
  .tabs { padding-inline: 8px; }
  main { padding: 8px; }
  .toolbar { grid-template-columns: 1fr; padding: 10px; }
  .toolbar, .card, .setting-card { min-width: 0; max-width: 100%; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; }
  .filters { grid-column: 1; gap: 8px 12px; overflow-x: auto; flex-wrap: nowrap; }
  .filters label { white-space: nowrap; }
  .product-row { grid-template-columns: 32px minmax(0, 1fr) 96px; grid-template-areas: "check title show" "check stock stock" "check current current" "check draft draft"; align-items: start; }
  .product-row > input { grid-area: check; }
  .product-title { grid-area: title; }
  .product-row .stock-cell { grid-area: stock; display: flex; gap: 12px; }
  .product-row .price-cell { display: grid; grid-template-columns: 90px 1fr; gap: 8px; align-items: center; }
  .product-row .current-price { grid-area: current; }
  .product-row .draft-cell { grid-area: draft; }
  .product-row .show-state { grid-area: show; text-align: right; }
  .both-row { grid-template-columns: 32px minmax(0, 1fr); grid-template-areas: "check title" "prices prices"; }
  .both-row .both-prices { grid-area: prices; grid-template-columns: 1fr; }
  .both-row .context-price .price-cell { grid-area: auto; }
  .both-row .context-price .show-state { grid-area: auto; text-align: left; }
  .desktop-only { display: none; }
  .action-bar { min-height: 116px; align-items: stretch; flex-direction: column; padding-inline: 10px; }
  .action-bar > div { display: grid; grid-template-columns: 1fr 1fr 2fr; }
  .action-bar button { padding-inline: 8px; }
  .settings-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .wide-field { grid-column: auto; }
  .inline-admin { grid-template-columns: 1fr; }
  .row-card { align-items: stretch; flex-direction: column; }
  .publication-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .publication-actions .primary { grid-column: 1 / -1; }
  .diff-row { grid-template-columns: 1fr auto; }
  .diff-row .name { grid-column: 1 / -1; }
  .audit-row { grid-template-columns: 1fr; gap: 2px; }
}
