/* Reseller - working-tool styling. Mobile first; sidebar + tables from 900px. */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --text: #17202e;
  --muted: #5d6b82;
  --border: #dde2ea;
  --primary: #1f4fb8;
  --primary-ink: #ffffff;
  --primary-soft: #e6edfb;
  --good: #14733f;   --good-bg: #e3f4ea;   --good-line: #9fd5b6;
  --warn: #8f5600;   --warn-bg: #fdf0d6;   --warn-line: #ecc77a;
  --bad: #b32a1e;    --bad-bg: #fce7e4;    --bad-line: #eeaba3;
  --neutral-bg: #eceff4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --nav-h: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141c; --surface: #18202b; --surface-2: #202a37; --text: #e8edf4; --muted: #96a3b8;
    --border: #2b3646; --primary: #6b9bff; --primary-ink: #0b1220; --primary-soft: #1d2a45;
    --good: #5fd08f; --good-bg: #123322; --good-line: #1f5a3a;
    --warn: #f0b95a; --warn-bg: #3a2a0c; --warn-line: #6a4d14;
    --bad: #ff8b7e;  --bad-bg: #3c1814;  --bad-line: #75302a;
    --neutral-bg: #263040; --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }

/* ---- layout */
.app { min-height: 100vh; }
.sidebar { display: none; }
main#view { padding: 14px 14px calc(var(--nav-h) + 22px + env(safe-area-inset-bottom)); width: 100%; max-width: 1240px; margin: 0 auto; outline: none; }
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom); height: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.bottom-nav a, .bottom-nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: none; border: 0; color: var(--muted); font-size: .75rem; font-weight: 600; min-height: 48px; cursor: pointer; text-decoration: none;
}
.bottom-nav .ico, .side-link .ico { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bottom-nav .active { color: var(--primary); }
.bottom-nav .check-btn .ico-wrap { background: var(--primary); color: var(--primary-ink); border-radius: 999px; width: 44px; height: 44px; display: grid; place-items: center; margin-top: -14px; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.bottom-nav .check-btn.active { color: var(--primary); }
.bottom-nav .check-btn { font-size: .7rem; }

/* 900-1359px: compact icon rail so tables get the room; 1360px+: full sidebar */
@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 68px minmax(0, 1fr); }
  .sidebar { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 8px; position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--border); }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--text); padding: 4px 0 12px; }
  .brand:hover { text-decoration: none; }
  .brand > span:last-child { display: none; }
  .brand-mark { background: var(--primary); color: var(--primary-ink); width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; }
  #side-nav { display: flex; flex-direction: column; gap: 2px; width: 100%; }
  .side-link { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px; border-radius: 8px; color: var(--text); font-weight: 550; text-decoration: none; min-height: 44px; }
  .side-link > span { display: none; }
  .side-link:hover { background: var(--surface-2); text-decoration: none; }
  .side-link.active { background: var(--primary-soft); color: var(--primary); }
  main#view { padding: 22px 24px 40px; min-width: 0; }
  .bottom-nav { display: none; }
}
@media (min-width: 1360px) {
  .app { grid-template-columns: 220px minmax(0, 1fr); }
  .sidebar { align-items: stretch; padding: 18px 12px; }
  .brand { padding: 4px 8px 12px; }
  .brand > span:last-child { display: inline; }
  .side-link { justify-content: flex-start; padding: 9px 10px; }
  .side-link > span { display: inline; }
  main#view { padding: 22px 28px 40px; }
}

/* ---- page header */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: .875rem; margin-bottom: 4px; display: inline-block; }

/* ---- cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 12px; }
.grid > .card, .grid > .stack > :first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: 1fr; }
.g3 { grid-template-columns: 1fr; }
@media (min-width: 700px) { .g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .g3-wide { grid-template-columns: repeat(3, 1fr); } }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1100px) { .kpis { grid-template-columns: repeat(5, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.kpi .label { color: var(--muted); font-size: .8125rem; }
.kpi .value { font-size: 1.3rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.pos { color: var(--good); } .neg { color: var(--bad); }

.budget { display: grid; gap: 14px; }
@media (min-width: 700px) { .budget { grid-template-columns: 1fr 1.2fr; align-items: center; } }
.budget .big { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.sumlist { display: grid; gap: 4px; font-size: .95rem; }
.sumlist div { display: flex; justify-content: space-between; gap: 10px; font-variant-numeric: tabular-nums; }
.sumlist .total { border-top: 1px solid var(--border); padding-top: 6px; margin-top: 2px; font-weight: 700; }

/* ---- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.08); background: var(--primary); }
.btn.danger { color: var(--bad); border-color: var(--bad-line); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.sm { min-height: 36px; padding: 0 10px; font-size: .875rem; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row.stretch > * { flex: 1 1 auto; }

/* ---- forms */
.form { display: grid; gap: 12px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }
@media (min-width: 700px) { .form-grid.cols3 { grid-template-columns: repeat(3, 1fr); } }
label.f { display: grid; gap: 4px; font-size: .875rem; font-weight: 600; color: var(--muted); }
label.f > span.req::after { content: " *"; color: var(--bad); }
.inp, select.inp, textarea.inp {
  width: 100%; min-height: 44px; padding: 8px 11px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text); font-weight: 400; font-size: 1rem;
}
textarea.inp { min-height: 76px; resize: vertical; }
.inp:focus, .btn:focus-visible, a:focus-visible, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.money { position: relative; }
.money::before { content: "£"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-weight: 400; }
.money .inp { padding-left: 24px; }
details.more { border: 1px dashed var(--border); border-radius: 9px; padding: 8px 12px; }
details.more > summary { cursor: pointer; font-weight: 600; color: var(--primary); min-height: 32px; display: flex; align-items: center; }
details.more[open] > summary { margin-bottom: 10px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 500; color: var(--text); }
.check input { width: 20px; height: 20px; }
.err { color: var(--bad); font-size: .9rem; min-height: 1.2em; }

/* ---- toolbar / filters */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar .search { flex: 1 1 200px; min-width: 0; }
.filters { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
@media (min-width: 900px) { .filters { grid-template-columns: repeat(5, 1fr); } }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 36px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: .875rem; cursor: pointer; color: var(--text); }
.chip.on { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.count { color: var(--muted); font-size: .875rem; margin: 2px 2px 8px; }

/* ---- badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--neutral-bg); color: var(--muted); white-space: nowrap; border: 1px solid transparent; }
.badge.good { background: var(--good-bg); color: var(--good); border-color: var(--good-line); }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.badge.demo { background: var(--primary-soft); color: var(--primary); }

/* ---- responsive table: cards on mobile, grid table on desktop */
.tbl { display: grid; gap: 10px; }
.tbl .thead { display: none; }
.tbl .tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; box-shadow: var(--shadow); }
.tbl .td { min-width: 0; font-variant-numeric: tabular-nums; }
.tbl .td[data-label]::before { content: attr(data-label); display: block; font-size: .75rem; color: var(--muted); font-weight: 600; }
.tbl .td.main { grid-column: 1 / -1; }
.tbl .td.full { grid-column: 1 / -1; }
.tbl .td.acts { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; padding-top: 4px; border-top: 1px solid var(--border); margin-top: 2px; }
.tbl .td.hide-m { display: none; }
.item-cell { display: flex; gap: 10px; align-items: center; min-width: 0; }
.item-cell .tt { min-width: 0; }
.item-cell .tt .title { color: var(--text); font-weight: 650; display: block; overflow: hidden; text-overflow: ellipsis; }
.item-cell .tt .sub { color: var(--muted); font-size: .85rem; }
.thumb { width: 54px; height: 54px; border-radius: 8px; object-fit: cover; background: var(--surface-2); flex: none; border: 1px solid var(--border); display: grid; place-items: center; color: var(--muted); font-size: 1.2rem; }
.thumb.lg { width: 88px; height: 88px; }
@media (min-width: 700px) and (max-width: 1179px) { .tbl { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1180px) {
  .tbl { gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
  .tbl .thead, .tbl .tr { display: grid; grid-template-columns: var(--cols); gap: 8px; align-items: center; padding: 8px 14px; }
  .tbl .thead { background: var(--surface-2); font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
  .tbl .tr { border: 0; border-top: 1px solid var(--border); border-radius: 0; box-shadow: none; }
  .tbl .tr:hover { background: var(--surface-2); }
  .tbl .td[data-label]::before { display: none; }
  .tbl .td.main, .tbl .td.full, .tbl .td.acts { grid-column: auto; }
  .tbl .td.acts { border: 0; padding: 0; margin: 0; justify-content: flex-end; flex-wrap: wrap; }
  .tbl .td.hide-m { display: block; }
  .tbl .td.num, .tbl .th.num { text-align: right; }
}

/* ---- Quick Check */
.verdict { border: 2px solid var(--border); border-radius: var(--radius); padding: 14px; background: var(--surface); }
.verdict .word { font-size: 2.2rem; font-weight: 800; letter-spacing: .02em; line-height: 1; }
.verdict.good { border-color: var(--good-line); background: var(--good-bg); color: var(--good); }
.verdict.warn { border-color: var(--warn-line); background: var(--warn-bg); color: var(--warn); }
.verdict.bad { border-color: var(--bad-line); background: var(--bad-bg); color: var(--bad); }
.verdict.empty { color: var(--muted); }
.verdict .why { color: var(--text); margin-top: 6px; }
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px; }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; color: var(--text); }
.metric .label { font-size: .78rem; color: var(--muted); }
.metric .value { font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.qc { display: grid; gap: 12px; }
@media (min-width: 900px) { .qc { grid-template-columns: 1fr 1fr; align-items: start; } }

/* ---- lists with bars */
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; gap: 3px; }
.bar-row .top { display: flex; justify-content: space-between; gap: 8px; font-size: .95rem; }
.bar-row .track { height: 7px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--primary); border-radius: 4px; }
.bar-row .fill.neg { background: var(--bad); }
.bar-row .meta { font-size: .8rem; color: var(--muted); }
.list { display: grid; gap: 0; }
.list > .li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.list > .li:first-child { border-top: 0; }
.kv { display: grid; grid-template-columns: 1fr; gap: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--border); }
.kv > div:first-child { border-top: 0; }
.kv .k { color: var(--muted); }
.kv .v { text-align: right; font-weight: 600; overflow-wrap: anywhere; }
.cols { display: flex; gap: 8px; align-items: stretch; height: 160px; }
.cols .col { flex: 1; max-width: 72px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-width: 0; }
.cols .cv { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cols .cw { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.cols .cbar { width: 100%; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 3px; }
.cols .cbar.neg { background: var(--bad); }
.cols .cl { font-size: .75rem; color: var(--muted); margin-top: 4px; border-top: 1px solid var(--border); width: 100%; text-align: center; padding-top: 3px; }
.empty { text-align: center; padding: 26px 12px; color: var(--muted); }
.notice { border: 1px solid var(--warn-line); background: var(--warn-bg); color: var(--warn); border-radius: var(--radius); padding: 10px 12px; }
.notice.info { border-color: var(--primary-soft); background: var(--primary-soft); color: var(--primary); }

/* ---- gallery */
.gallery { display: flex; gap: 8px; flex-wrap: wrap; }
.gallery .g { position: relative; }
.gallery img { width: 78px; height: 78px; object-fit: cover; border-radius: 8px; border: 2px solid transparent; background: var(--surface-2); display: block; }
.gallery .g.primary img { border-color: var(--primary); }
.gallery .g button { position: absolute; width: 28px; height: 28px; border-radius: 999px; border: 0; background: rgba(0,0,0,.65); color: #fff; font-size: .8rem; cursor: pointer; }
.gallery .g .x { top: 3px; right: 3px; }
.gallery .g .star { bottom: 3px; left: 3px; }
.hero { width: 100%; max-height: 420px; object-fit: contain; background: var(--surface-2); border-radius: var(--radius); display: block; aspect-ratio: 4 / 3; }
.detail { display: grid; gap: 12px; }
@media (min-width: 900px) { .detail { grid-template-columns: 380px 1fr; align-items: start; } }

/* ---- sheet (bottom sheet on mobile, modal on desktop) */
.backdrop { position: fixed; inset: 0; background: rgba(8, 12, 20, .5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-height: 92vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 16px 14px calc(18px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; position: sticky; top: -16px; background: var(--surface); padding: 4px 0 8px; z-index: 1; }
.sheet-head .x { border: 0; background: var(--surface-2); width: 40px; height: 40px; border-radius: 999px; font-size: 1.1rem; cursor: pointer; }
@media (min-width: 700px) {
  .backdrop { align-items: center; }
  .sheet { max-width: 640px; border-radius: 14px; padding: 18px; }
}
.sheet.wide { max-width: 860px; }

#toast-root { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); z-index: 80; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
@media (min-width: 900px) { #toast-root { bottom: 20px; } }
.toast { background: #172033; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.3); pointer-events: auto; max-width: 520px; font-weight: 550; }
.toast.error { background: #a32a1e; }
.toast a { color: #bcd4ff; margin-left: 8px; font-weight: 700; }

.skeleton { height: 90px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: sh 1.2s infinite linear; margin-bottom: 10px; }
@keyframes sh { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

.more-menu { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.more-menu a { display: flex; align-items: center; gap: 10px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-weight: 600; min-height: 56px; }
.more-menu a:hover { background: var(--surface-2); text-decoration: none; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.tabs .chip { border-radius: 8px; }
.sel-inline { min-height: 36px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: .9rem; max-width: 100%; }
