/* eMark Portal. One stylesheet for every page.
   Palette from the DOUzzle brand: chocolate sidebar, sugar-white page, magenta for strength and actions, gold for gaps. */
:root {
  --bg: #f6f4f5;
  --panel: #ffffff;
  --sunk: #faf8f9;
  --ink: #241a1c;
  --muted: #6e6266;
  --faint: #9a8f92;
  --line: #e7e1e3;
  --line-strong: #d6cdd0;
  --side: #2a1c1a;
  --side-ink: #f3e9e4;
  --side-muted: #b9a69f;
  --side-hover: #3a2825;
  --accent: #c2185b;
  --accent-ink: #ffffff;
  --accent-soft: #fbe8f0;
  --gold: #b5832b;
  --gold-soft: #fbf1de;
  --brown: #654a43;
  --ok: #1d7a4e; --ok-soft: #e2f3ea;
  --warn: #8a5a00; --warn-soft: #fbf0d9;
  --dim: #7a7073; --dim-soft: #efebec;
  --heat1: rgba(194, 24, 91, .08);
  --heat2: rgba(194, 24, 91, .16);
  --heat3: rgba(194, 24, 91, .28);
  --heat4: rgba(194, 24, 91, .44);
  --shadow: 0 1px 2px rgba(36, 26, 28, .06), 0 8px 24px rgba(36, 26, 28, .06);
  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171213; --panel: #1f191a; --sunk: #1b1617; --ink: #f1eaec; --muted: #a99ca0; --faint: #7f7376;
    --line: #342b2d; --line-strong: #463b3e; --side: #120d0c; --side-ink: #f3e9e4; --side-muted: #a08e88; --side-hover: #24191a;
    --accent: #f0679a; --accent-ink: #1f0b12; --accent-soft: #3a1b29; --gold: #e0b25e; --gold-soft: #33280f; --brown: #c9a79d;
    --ok: #6fd3a0; --ok-soft: #173326; --warn: #f0c060; --warn-soft: #362a12; --dim: #a99ca0; --dim-soft: #2a2325;
    --heat1: rgba(240, 103, 154, .10); --heat2: rgba(240, 103, 154, .20); --heat3: rgba(240, 103, 154, .33); --heat4: rgba(240, 103, 154, .50);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
mark { background: var(--gold-soft); color: inherit; border-bottom: 1.5px solid var(--gold); border-radius: 2px; padding: 0 2px; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.side .brand img { width: 28px; height: 28px; }
.side .brand span { color: var(--side-muted); font-weight: 500; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow: auto; }
.nav h2 { font-size: 12px; font-weight: 500; color: var(--side-muted); margin: 16px 8px 6px; }
.nav a { color: var(--side-ink); text-decoration: none; padding: 7px 10px; border-radius: 8px; display: flex; justify-content: space-between; gap: 8px; }
.nav a:hover { background: var(--side-hover); }
.nav a[aria-current="page"] { background: var(--accent); color: #fff; font-weight: 600; }
.nav a small { color: var(--side-muted); font-size: 12px; }
.nav a[aria-current="page"] small { color: rgba(255, 255, 255, .8); }
.side-foot { margin-top: auto; font-size: 12px; color: var(--side-muted); padding: 12px 8px 0; border-top: 1px solid rgba(255, 255, 255, .08); line-height: 1.6; }
.side-foot b { color: var(--side-ink); font-weight: 500; }
.side-foot button { background: none; border: 0; color: var(--side-ink); padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.menu-btn { display: none; }

.main { min-width: 0; padding: 18px 28px 48px; }
.topbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.topbar .spacer { flex: 1; }

/* ---------- item picker ---------- */
.picker { position: relative; }
.pick-btn { display: grid; grid-template-columns: 1fr auto; column-gap: 14px; text-align: left; width: min(460px, calc(100vw - 64px)); border: 1px solid var(--line-strong); background: var(--panel); border-radius: 10px; padding: 7px 12px; cursor: pointer; box-shadow: 0 1px 0 rgba(36, 26, 28, .03); }
.pick-btn:hover, .pick-btn[aria-expanded="true"] { border-color: var(--accent); }
.pick-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-sub { grid-row: 2; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { grid-row: 1 / 3; grid-column: 2; align-self: center; color: var(--muted); font-size: 12px; }
.kbd { font-size: 11px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--muted); }
.pick-panel { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: min(660px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 10px; }
.pick-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.pick-tools input { flex: 1 1 240px; border: 1px solid var(--line); background: var(--sunk); border-radius: 8px; padding: 8px 10px; }
.pick-tools select { border: 1px solid var(--line); background: var(--sunk); border-radius: 8px; padding: 8px; max-width: 100%; }
.pick-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: min(440px, 60vh); overflow: auto; }
.pick-list li { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.pick-list li.active { background: var(--accent-soft); }
.pick-list li[aria-selected="true"] .o-name { color: var(--accent); }
.pick-list li.no-sales { opacity: .55; }
.o-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.o-num { font-size: 12px; color: var(--muted); text-align: right; }
.o-meta { grid-column: 1 / 3; font-size: 12px; color: var(--muted); }
.pick-foot { font-size: 12px; color: var(--muted); padding: 8px 4px 0; border-top: 1px solid var(--line); margin-top: 6px; }

/* ---------- segmented control ---------- */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; background: var(--panel); }
.seg button { border: 0; background: none; padding: 7px 12px; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.custom { display: none; gap: 6px; align-items: center; }
.custom.on { display: inline-flex; }
.custom input { border: 1px solid var(--line-strong); background: var(--panel); border-radius: 8px; padding: 6px 8px; }
.who { color: var(--muted); font-size: 13px; display: flex; gap: 12px; align-items: center; }
.link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; }

/* ---------- item header ---------- */
.ihead { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 420px); gap: 20px 32px; align-items: end; padding: 4px 0 18px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.ihead h1 { font-size: clamp(24px, 3vw, 34px); line-height: 1.1; letter-spacing: -.02em; margin: 0 0 8px; font-weight: 700; text-wrap: balance; }
.ihead .meta { color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.packs { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.pack { text-decoration: none; border: 1px solid var(--line-strong); border-radius: 6px; padding: 0 6px; font-size: 12px; color: var(--ink); background: var(--panel); }
.stats { display: flex; gap: 26px; flex-wrap: wrap; margin-top: 14px; }
.stat b { display: block; font-size: 22px; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; }
.stat span { color: var(--muted); font-size: 12px; }
.up { color: var(--ok); } .down { color: var(--accent); }

.mchart { width: 100%; height: 118px; display: block; }
.mchart rect.bar { fill: var(--brown); opacity: .35; }
.mchart rect.bar.in { fill: var(--accent); opacity: .9; }
.mchart rect.hit { fill: transparent; cursor: default; }
.mchart text { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.mchart text.val { fill: var(--ink); font-weight: 600; }
.mchart-cap { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }

/* ---------- panels and grids ---------- */
.grid2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.panel h2 { font-size: 16px; margin: 0 0 4px; font-weight: 700; letter-spacing: -.01em; }
.panel > p.lead { color: var(--muted); margin: 0 0 14px; font-size: 13px; }
.lede { color: var(--muted); max-width: 72ch; margin: 0 0 16px; }

/* listing x-ray */
.xr-packs { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 14px; }
.chip { border: 1px solid var(--line-strong); background: var(--panel); border-radius: 999px; padding: 3px 11px; cursor: pointer; font-size: 13px; color: var(--muted); }
.chip:hover { color: var(--ink); border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--panel); }
.chip .n { opacity: .7; margin-left: 4px; }
.xr-field { padding: 12px 0; border-top: 1px solid var(--line); }
.xr-field:first-of-type { border-top: 0; padding-top: 4px; }
.xr-label { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.xr-label b { color: var(--ink); font-size: 13px; font-weight: 600; }
.xr-text { line-height: 1.85; }
.xr-text.title { font-size: 17px; font-weight: 600; line-height: 1.7; letter-spacing: -.005em; }
.xr-text ul { margin: 0; padding-left: 18px; }
.xr-text li + li { margin-top: 4px; }
.w { border-radius: 4px; padding: 1px 1px; }
.w.h1 { background: var(--heat1); } .w.h2 { background: var(--heat2); } .w.h3 { background: var(--heat3); } .w.h4 { background: var(--heat4); }
.gap-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; font-size: 12px; color: var(--muted); }
.gap { border: 1px dashed var(--gold); background: var(--gold-soft); color: var(--ink); border-radius: 6px; padding: 1px 8px; font-size: 13px; font-weight: 500; }
.gap small { color: var(--gold); font-weight: 600; margin-left: 4px; }
.meter { display: inline-flex; align-items: center; gap: 6px; }
.meter i { display: inline-block; width: 64px; height: 5px; border-radius: 3px; background: var(--line); position: relative; overflow: hidden; }
.meter i::after { content: ""; position: absolute; inset: 0; width: var(--fill, 0%); background: var(--ok); border-radius: 3px; }
.meter.over i::after { background: var(--accent); }
.meter.over { color: var(--accent); font-weight: 600; }
.legend { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend .w { padding: 0 6px; color: var(--ink); }
details.desc summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details.desc[open] summary { margin-bottom: 6px; }

/* to-do list */
.todo h3 { font-size: 14px; margin: 16px 0 6px; display: flex; justify-content: space-between; align-items: baseline; }
.todo h3:first-of-type { margin-top: 4px; }
.todo h3 small { color: var(--muted); font-weight: 400; font-size: 12px; }
.todo ul { list-style: none; margin: 0; padding: 0; }
.todo li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.todo li .what { overflow-wrap: anywhere; }
.todo li .what mark { background: var(--gold-soft); color: var(--ink); border-bottom: 1.5px solid var(--gold); padding: 0 2px; border-radius: 2px; }
.todo li .num { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; }
.todo li .why { grid-column: 1 / 3; color: var(--muted); font-size: 12px; }
.todo .more { margin-top: 8px; }
.empty-note { color: var(--muted); font-size: 13px; padding: 6px 0; }

/* ---------- tables ---------- */
.tools { display: flex; gap: 10px; align-items: center; margin: 0 0 10px; flex-wrap: wrap; }
.tools input[type="search"] { border: 1px solid var(--line-strong); background: var(--panel); border-radius: 9px; padding: 7px 11px; width: min(300px, 70vw); }
.tools select { border: 1px solid var(--line-strong); background: var(--panel); border-radius: 9px; padding: 7px 9px; }
.tools .count { color: var(--muted); font-size: 13px; }
.tools .spacer { flex: 1; }
.btn { border: 1px solid var(--line-strong); background: var(--panel); border-radius: 9px; padding: 7px 13px; cursor: pointer; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.05); color: var(--accent-ink); }
.tablewrap { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: auto; max-height: calc(100vh - 230px); }
table { border-collapse: separate; border-spacing: 0; width: 100%; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; vertical-align: middle; }
th { position: sticky; top: 0; background: var(--panel); font-size: 12px; color: var(--muted); font-weight: 600; cursor: pointer; user-select: none; z-index: 2; }
th:hover { color: var(--ink); }
th[aria-sort="ascending"]::after { content: " \25B2"; font-size: 9px; }
th[aria-sort="descending"]::after { content: " \25BC"; font-size: 9px; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 240px; color: var(--muted); }
td.term { font-weight: 500; white-space: normal; min-width: 220px; }
tbody tr:hover td { background: var(--sunk); }
tbody tr.click { cursor: pointer; }
tbody tr:last-child td { border-bottom: 0; }
td.bar { position: relative; }
td.bar i { position: absolute; right: 8px; top: 7px; bottom: 7px; background: var(--accent-soft); border-radius: 3px; z-index: 0; }
td.bar span { position: relative; z-index: 1; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.p-proven { background: var(--ok-soft); color: var(--ok); }
.p-one { background: var(--warn-soft); color: var(--warn); }
.p-click { background: var(--accent-soft); color: var(--accent); }
.p-seen, .p-none { background: var(--dim-soft); color: var(--dim); }
.p-sister { background: var(--gold-soft); color: var(--gold); }
.p-season { background: var(--gold-soft); color: var(--brown); }
.act { font-weight: 600; color: var(--accent); }
.act.backend { color: var(--brown); }
.lvl { color: var(--muted); }
.lvl.Title { color: var(--ink); font-weight: 600; }
.lvl.Missing { color: var(--gold); font-weight: 600; }
.spark { vertical-align: middle; }
.spark rect { fill: var(--accent); }
.spark rect.z { fill: var(--line-strong); }
.trend { font-size: 12px; font-weight: 600; }
.ours { font-size: 11px; font-weight: 700; color: var(--ok); margin-left: 4px; }
.showall { display: block; margin: 10px auto 2px; }
.state { padding: 46px 20px; text-align: center; color: var(--muted); }
.note { color: var(--muted); font-size: 12px; margin: 12px 2px; max-width: 90ch; }

/* backend */
.be-line { font-size: 15px; line-height: 1.8; background: var(--sunk); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; overflow-wrap: anywhere; }
.be-line .new { background: var(--gold-soft); border-bottom: 1.5px solid var(--gold); }
.be-cmp td { white-space: normal; }

/* toast */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--panel); padding: 9px 16px; border-radius: 10px; font-size: 13px; z-index: 50; box-shadow: var(--shadow); }

/* ---------- login ---------- */
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--side); }
.card { background: var(--panel); border-radius: 16px; padding: 30px; width: min(400px, 100%); display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.card .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.card .brand img { width: 28px; height: 28px; }
.card h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.card p { margin: 0; color: var(--muted); }
.card input { border: 1px solid var(--line-strong); background: var(--sunk); border-radius: 9px; padding: 10px 12px; }
.card .primary { background: var(--accent); color: #fff; border: 0; border-radius: 9px; padding: 11px; cursor: pointer; font-weight: 600; }
.msg { font-size: 13px; color: var(--muted); min-height: 1.2em; }

/* ---------- small screens ---------- */
@media (max-width: 980px) {
  .grid2, .ihead { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; }
  .side.open { transform: none; box-shadow: var(--shadow); }
  .menu-btn { display: inline-flex; border: 1px solid var(--line-strong); background: var(--panel); border-radius: 9px; padding: 7px 11px; cursor: pointer; }
  .main { padding: 14px 16px 40px; }
  .tablewrap { max-height: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
