/* Same tokens as EB Remote, so the two panels look like one family. */
:root {
  color-scheme: light dark;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --border: #dbe1ec;
  --text: #17202e;
  --muted: #647387;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --accent-soft: #e4ecff;
  --ok: #138a4b;
  --ok-soft: #dff5e8;
  --warn: #a15c00;
  --warn-soft: #fff1d6;
  --bad: #c62f2f;
  --bad-soft: #fde4e4;
  --series: #257de0;
  --grid: #e7e7e7;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.06), 0 2px 8px rgb(16 24 40 / 0.06);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1218;
    --surface: #151c25;
    --surface-2: #1c2531;
    --border: #263243;
    --text: #e6ebf3;
    --muted: #8fa0b5;
    --accent: #5b8def;
    --accent-text: #0b1220;
    --accent-soft: #1b2a47;
    --ok: #3ccf82;
    --ok-soft: #123222;
    --warn: #f0b04a;
    --warn-soft: #3a2a0c;
    --bad: #ff7676;
    --bad-soft: #3b1717;
    --series: #338ced;
    --grid: #263243;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.btn { appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-block; }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn.wide { width: 100%; padding: 10px 12px; }
.btn:focus-visible, .input:focus-visible, .tab:focus-visible, .lane:focus-visible, .col:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.input { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; min-width: 0; }
.input.tiny { width: 76px; text-align: right; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field > span { font-weight: 600; font-size: 13px; }
.field small { color: var(--muted); }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 12px; }
.inline { display: inline-flex; align-items: center; gap: 8px; }
.form-error { color: var(--bad); min-height: 1.4em; margin: 8px 0 0; }

.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }

.topbar { display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 6px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.tabs { display: flex; gap: 4px; margin-left: 12px; overflow-x: auto; }
.tab { color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 8px; white-space: nowrap; }
.tab:hover { background: var(--surface-2); }
.tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.content { padding: 16px; max-width: 1280px; margin: 0 auto; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 0 16px; }
.empty { text-align: center; color: var(--muted); padding: 28px 0; }
.notice { border: 1px solid var(--border); border-left: 4px solid var(--warn); background: var(--surface); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tile .label { color: var(--muted); font-size: 13px; }
.tile .value { font-size: 26px; font-weight: 650; }
.tile .note { color: var(--muted); font-size: 12px; }

.scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th.num { text-align: right; }
.table td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn + .btn { margin-left: 4px; }
.table tr.link { cursor: pointer; }
.table tr.link:hover { background: var(--surface-2); }
.thumb { width: 40px; height: 40px; object-fit: contain; border-radius: 6px; background: #fff; border: 1px solid var(--border); display: block; }

div.thumb { background: var(--surface-2); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 8px; }
.card:hover { border-color: var(--accent); }
.card .name { font-weight: 650; font-size: 15px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; background: var(--muted); }
.dot.on { background: var(--ok); }
.meter { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--series); border-radius: 999px; }

/* planogram */
.layer { margin-bottom: 10px; }
.layer > .title { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.lanes { display: grid; grid-template-columns: repeat(10, minmax(92px, 1fr)); gap: 6px; }
.lanes-scroll { overflow-x: auto; padding-bottom: 4px; }
.lane { appearance: none; font: inherit; color: inherit; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 3px; min-height: 118px; cursor: pointer; }
.lane:hover { border-color: var(--accent); }
.lane.empty-lane { background: var(--surface-2); color: var(--muted); padding: 6px; text-align: left; }
.lane.sold-out { border-color: var(--bad); background: var(--bad-soft); }
.lane.low { border-color: var(--warn); background: var(--warn-soft); }
.lane.off { opacity: 0.5; }
.lane .no { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }
.lane .title { font-size: 12px; line-height: 1.25; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; flex: 1; overflow-wrap: anywhere; }
.lane .foot { display: flex; justify-content: space-between; font-size: 12px; font-variant-numeric: tabular-nums; }

/* single-series charts */
.chart { position: relative; }
.plot { display: flex; align-items: flex-end; gap: 2px; height: 180px; border-bottom: 1px solid var(--grid); position: relative; padding-top: 18px; }
.col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.col i { display: block; width: 100%; max-width: 24px; background: var(--series); border-radius: 4px 4px 0 0; }
.col:hover i, .col:focus-visible i { filter: brightness(1.2); }
.col .cap { font-size: 11px; color: var(--muted); white-space: nowrap; margin-bottom: 2px; }
.axis { display: flex; gap: 2px; margin-top: 4px; }
.axis span { flex: 1; min-width: 0; text-align: center; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: visible; }
.tip { position: absolute; pointer-events: none; z-index: 4; background: var(--text); color: var(--bg); border-radius: 8px; padding: 6px 10px; font-size: 12px; white-space: nowrap; transform: translate(-50%, -100%); }
.rank { display: grid; grid-template-columns: minmax(120px, 1.2fr) 2fr auto; gap: 6px 10px; align-items: center; }
.rank .bar { height: 12px; }
.rank .bar i { display: block; height: 100%; background: var(--series); border-radius: 0 4px 4px 0; min-width: 2px; }
.rank .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dialog { border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text); width: min(560px, 94vw); max-height: 92vh; box-shadow: 0 20px 60px rgb(0 0 0 / 0.35); }
.dialog.wide { width: min(900px, 96vw); }
.dialog::backdrop { background: rgb(8 12 18 / 0.6); }
.form { padding: 20px; max-height: 92vh; overflow: auto; }
.form h2 { margin-bottom: 14px; font-size: 18px; }
.form .actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.checks { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; max-height: 40vh; overflow: auto; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; max-width: 360px; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.error { background: var(--bad); color: #fff; }

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; position: static; }
  .tabs { order: 3; width: 100%; margin-left: 0; flex-wrap: wrap; overflow: visible; }
  .content { padding: 10px; }
  .two { grid-template-columns: 1fr; }
  .input, select.input { font-size: 16px; min-height: 40px; }
  .btn { min-height: 40px; }
  .btn.small { min-height: 32px; }
  .hide-sm { display: none; }
  .lanes { grid-template-columns: repeat(10, 84px); }
  .rank { grid-template-columns: minmax(100px, 1fr) 1fr auto; }
}
