:root {
  --ink: #1d1b2e;
  --muted: #6a6880;
  --paper: #f3f3f7;
  --surface: #ffffff;
  --line: #e2e1ea;
  --side: #25213d;
  --accent: #4b3fd1;
  --accent-soft: #ecebfb;

  --apple: #fa2d48;
  --spotify: #1db954;
  --amazon: #1fb5c1;
  --mapping: #8b5cf6;

  --pending: #a86208;   --pending-bg: #fdf1dc;
  --progress: #1f5fae;  --progress-bg: #e3eefb;
  --hold: #5b5f6e;      --hold-bg: #ececf1;
  --done: #217a4b;      --done-bg: #e0f3e8;
  --rejected: #b42331;  --rejected-bg: #fbe4e6;

  --r-sm: 6px;
  --r-md: 10px;
  font-family: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; margin: 0; line-height: 1.2; }
h2 { font-size: 1rem; font-weight: 700; margin: 0 0 0.9rem; }
.muted { color: var(--muted); }
.mono, code { font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace; font-size: 0.86em; }
.strong { font-weight: 700; color: var(--ink); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--side); color: #d9d6ee; padding: 1.4rem 1rem; display: flex; flex-direction: column; gap: 1.6rem; position: sticky; top: 0; height: 100vh; }
.brand { color: #fff; font-weight: 800; font-size: 1.15rem; display: flex; align-items: center; gap: 0.6rem; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 50%; background:
  radial-gradient(circle, var(--side) 0 3px, #fff 3.5px 5px, transparent 5.5px),
  repeating-radial-gradient(circle, #8f86ff 0 1px, #3a3462 1.5px 3px); }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { color: #cfcbe8; padding: 0.5rem 0.7rem; border-radius: var(--r-sm); font-weight: 600; }
.side nav a:hover { background: rgba(255,255,255,0.06); text-decoration: none; }
.side nav a.on { background: rgba(255,255,255,0.12); color: #fff; }
.me { margin-top: auto; font-size: 0.85rem; }
.me a { color: #a9a3d6; }
.main { padding: 2rem 2.2rem 4rem; min-width: 0; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.page-head p { margin: 0.3rem 0 0; }
.crumb { margin: 0 0 0.6rem; font-size: 0.9rem; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 1.3rem 1.4rem; margin-bottom: 1.2rem; }
.panel.empty { text-align: center; padding: 2.5rem; color: var(--muted); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; align-items: start; }
.two-col > .panel, .two-col > div > .panel { margin-bottom: 1.2rem; }
.narrow { max-width: 420px; margin: 4rem auto; }
.narrow h1 { margin-bottom: 1rem; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.8rem; margin-bottom: 1.2rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 1rem 1.1rem; color: var(--ink); display: flex; flex-direction: column; }
.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat strong { font-size: 1.9rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 0.88rem; margin-top: 0.35rem; }
.stat.warn strong { color: var(--rejected); }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; gap: 0.4rem; font: inherit; font-weight: 700; font-size: 0.9rem; padding: 0.5rem 0.9rem;
  border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #bdbacd; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #3d32b8; }
.btn.danger { color: var(--rejected); }
.btn.small { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
input, select, textarea { font: inherit; font-weight: 400; font-size: 0.92rem; padding: 0.5rem 0.65rem; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form { display: flex; flex-direction: column; gap: 0.9rem; }
.form label { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; font-size: 0.88rem; }
.form label small { font-weight: 400; color: var(--muted); }
.form label.check { flex-direction: row; align-items: center; gap: 0.5rem; font-weight: 500; }
.form label.check input { width: auto; }
.form .btn { align-self: flex-start; }
.form.inline { flex-direction: row; align-items: flex-end; flex-wrap: wrap; }
.form.inline label { flex: 1 1 220px; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

.flash { padding: 0.7rem 1rem; border-radius: var(--r-sm); margin-bottom: 1rem; font-weight: 600; font-size: 0.92rem; }
.flash-ok { background: var(--done-bg); color: var(--done); }
.flash-err { background: var(--rejected-bg); color: var(--rejected); }

/* platform tabs */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--line); margin-bottom: 0.4rem; overflow-x: auto; }
.tabs a { padding: 0.6rem 1rem 0.55rem; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--ink); }
.tabs a.t-apple_profile.on { border-bottom-color: var(--apple); }
.tabs a.t-spotify_profile.on { border-bottom-color: var(--spotify); }
.tabs a.t-amazon_profile.on { border-bottom-color: var(--amazon); }
.tabs a.t-mapping.on { border-bottom-color: var(--mapping); }
.tabs em { font-style: normal; font-weight: 600; font-size: 0.78rem; background: var(--line); color: var(--ink); border-radius: 999px; padding: 0.05rem 0.45rem; margin-left: 0.25rem; }
.hint { font-size: 0.8rem; color: var(--muted); margin: 0 0 1rem; }

.tdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 0.45rem; vertical-align: 0.05em; background: var(--muted); }
.tdot.t-apple_profile { background: var(--apple); }
.tdot.t-spotify_profile { background: var(--spotify); }
.tdot.t-amazon_profile { background: var(--amazon); }
.tdot.t-mapping { background: var(--mapping); }

.filters { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters input[type=search] { flex: 1 1 260px; width: auto; }
.filters select { width: auto; }
.bulkbar { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.6rem; font-size: 0.88rem; color: var(--muted); }
.bulkbar select, .bulkbar input { width: auto; padding: 0.35rem 0.55rem; }
.bulkbar input { min-width: 260px; }

/* tables */
.scroll { overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.grid th { text-align: left; font-weight: 700; font-size: 0.8rem; color: var(--muted); padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid td { padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid tr:last-child td { border-bottom: 0; }
.grid tr.dim td { opacity: 0.55; }

.sheet-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.sheet { font-size: 0.86rem; }
.sheet thead th { position: sticky; top: 0; background: #faf9fd; z-index: 1; }
.sheet td { padding: 0.35rem 0.6rem; border-right: 1px solid #efeef4; white-space: nowrap; }
.sheet td:last-child { border-right: 0; }
.sheet tbody tr:hover td { background: #faf9ff; }
.sheet .chk { width: 34px; text-align: center; }
.sheet .notes { max-width: 180px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 0.82rem; }
.cell-input { padding: 0.3rem 0.45rem; font-size: 0.84rem; min-width: 130px; }
.cell-input.wide { min-width: 200px; }
.st-select { padding: 0.3rem 0.45rem; font-size: 0.82rem; font-weight: 700; width: auto; border-width: 1px; }
.row-cancelled td { color: var(--muted); }

/* badges */
.badge { display: inline-block; font-size: 0.76rem; font-weight: 700; padding: 0.15rem 0.55rem; border-radius: 999px; white-space: nowrap; background: var(--hold-bg); color: var(--hold); }
.st-pending { background: var(--pending-bg); color: var(--pending); }
.st-in_progress { background: var(--progress-bg); color: var(--progress); }
.st-on_hold { background: var(--hold-bg); color: var(--hold); }
.st-completed { background: var(--done-bg); color: var(--done); }
.st-rejected { background: var(--rejected-bg); color: var(--rejected); }
.st-cancelled { background: #f0f0f3; color: #8b8a99; }
.wh-delivered { background: var(--done-bg); color: var(--done); }
.wh-pending { background: var(--pending-bg); color: var(--pending); }
.wh-failed { background: var(--rejected-bg); color: var(--rejected); }

/* detail */
.facts { display: grid; grid-template-columns: 150px 1fr; gap: 0.5rem 1rem; margin: 0; font-size: 0.92rem; }
.facts dt { color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; word-break: break-word; }
.feed { list-style: none; padding: 0; margin: 0; }
.feed li { display: grid; grid-template-columns: 120px 1fr; gap: 1rem; padding: 0.55rem 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.feed li:last-child { border-bottom: 0; }
.feed time { color: var(--muted); font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.feed q { display: block; color: var(--muted); margin-top: 0.2rem; quotes: none; }

.reveal { border: 2px solid var(--accent); background: var(--accent-soft); }
.keybox { display: flex; align-items: center; gap: 0.6rem; background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0.55rem 0.7rem; }
.keybox code { flex: 1; word-break: break-all; font-size: 0.9rem; }
.keybox.small code { font-size: 0.78rem; }

.pager { display: flex; gap: 1rem; align-items: center; justify-content: flex-end; margin-top: 0.9rem; font-size: 0.9rem; color: var(--muted); }
.pager span:first-child { margin-right: auto; }

.plain { margin: 0; padding-left: 1.1rem; color: var(--muted); font-size: 0.92rem; }
.plain li { margin-bottom: 0.4rem; }
td.ex { font-size: 0.82rem; max-width: 420px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 0.8rem 1rem; gap: 1rem; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .me { margin-top: 0; margin-left: auto; }
  .main { padding: 1.2rem 1rem 3rem; }
  .two-col { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr; gap: 0.1rem; }
  .facts dd { margin-bottom: 0.5rem; }
  .feed li { grid-template-columns: 1fr; gap: 0.1rem; }
}
