:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #f8fafb;
  --ink: #17202e;
  --muted: #5b6676;
  --line: #e2e7ec;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #e3f3f1;
  --accent: #d97706;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --warn: #b45309;
  --warn-soft: #fff4e0;
  --info-soft: #eaf1fb;
  --side: #17202e;
  --side-ink: #c9d2dd;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e141b;
    --panel: #161e27;
    --panel-2: #1b2530;
    --ink: #e6ebf1;
    --muted: #9aa6b4;
    --line: #26323f;
    --brand: #2dd4bf;
    --brand-ink: #062b27;
    --brand-soft: #123532;
    --accent: #f59e0b;
    --ok: #4ade80;
    --ok-soft: #12301f;
    --bad: #f87171;
    --bad-soft: #3a1717;
    --warn: #fbbf24;
    --warn-soft: #3a2a0c;
    --info-soft: #172537;
    --side: #0a0f15;
    --side-ink: #aeb9c6;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }
code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; background: var(--panel-2); padding: 1px 5px; border-radius: 5px; }

/* Layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 18px; padding: 4px 8px 18px; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a { display: flex; align-items: center; gap: 10px; color: var(--side-ink); text-decoration: none; padding: 9px 10px; border-radius: 8px; font-weight: 500; }
#nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
#nav a.on { background: rgba(45, 212, 191, .14); color: #fff; }
#nav .ico { width: 18px; text-align: center; opacity: .8; }
.count { margin-left: auto; background: var(--accent); color: #111; font-size: 12px; border-radius: 99px; padding: 0 8px; }
.count.ready { background: #2dd4bf; }
.count:empty { display: none; }
.side-foot { margin-top: auto; font-size: 12px; opacity: .7; padding: 0 8px; }
.side-foot code { background: rgba(255, 255, 255, .08); color: inherit; }
main { padding: 28px 32px 60px; max-width: 1180px; width: 100%; outline: none; }

/* Type */
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 6px; }
.lead { color: var(--muted); margin: 0 0 22px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.head .lead { margin: 0; }

/* Panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack > * + * { margin-top: 16px; }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.tile:hover { border-color: var(--brand); }
.tile .n { font-size: 28px; font-weight: 700; line-height: 1.1; }
.tile .l { color: var(--muted); font-size: 13px; }
.tile.needs .n { color: var(--accent); }
.tile.ready .n { color: var(--brand); }
.tile.posted .n { color: var(--ok); }
.tile.error .n { color: var(--bad); }

/* Buttons and inputs */
button, .btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; border-radius: 9px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: var(--brand); }
button.primary, .btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.primary:hover { filter: brightness(1.05); }
button.danger { color: var(--bad); }
button:disabled { opacity: .55; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
input[type=text], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* Status pills */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; border-radius: 99px; padding: 2px 10px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.st-NEEDS_IMAGE { background: var(--warn-soft); color: var(--warn); }
.st-READY { background: var(--brand-soft); color: var(--brand); }
.st-POSTED { background: var(--ok-soft); color: var(--ok); }
.st-ERROR { background: var(--bad-soft); color: var(--bad); }

/* Checks list */
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); align-items: flex-start; }
.checks li:first-child { border-top: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--muted); }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.checks .note { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }

/* Tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button { font-weight: 500; padding: 6px 12px; }
.tabs button.on { background: var(--ink); color: var(--panel); border-color: var(--ink); }

/* Draft cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.card .top { display: grid; grid-template-columns: 96px 1fr; gap: 12px; padding: 14px; border-bottom: 1px solid var(--line); }
.thumb { width: 96px; aspect-ratio: 2 / 3; border-radius: 8px; background: var(--panel-2) center/cover no-repeat; border: 1px dashed var(--line); display: grid; place-items: center; color: var(--muted); font-size: 11px; text-align: center; padding: 4px; }
.thumb.has { border-style: solid; }
.card .meta { min-width: 0; }
.card .product { font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card .facts { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.card .why { font-size: 13px; color: var(--muted); }
.card .body { padding: 14px; }
.card .foot { padding: 12px 14px; border-top: 1px solid var(--line); background: var(--panel-2); margin-top: auto; }
.brief { font-size: 13px; background: var(--info-soft); border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.err { font-size: 13px; background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: 8px 10px; overflow-wrap: anywhere; }
details summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); margin: 6px 0; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .big { font-size: 34px; }

/* Log */
.log { background: #0b1220; color: #cfe3dc; font: 13px/1.55 ui-monospace, Consolas, monospace; border-radius: 10px; padding: 14px 16px; min-height: 160px; max-height: 420px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.log .ok { color: #4ade80; }
.log .bad { color: #f87171; }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Setup groups */
.group-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.copy { display: flex; gap: 6px; align-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 6px 6px 10px; margin: 8px 0 12px; }
.copy code { background: none; padding: 0; overflow-wrap: anywhere; flex: 1; }
.copy button { padding: 4px 10px; font-size: 13px; }
.map-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 8px; }

/* Toasts */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--ink); color: var(--panel); padding: 10px 14px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); max-width: 360px; }
.toast.bad { background: var(--bad); color: #fff; }

/* Phones */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; height: auto; padding: 10px 12px; flex-direction: row; align-items: center; gap: 8px; z-index: 10; overflow-x: auto; }
  .brand { padding: 0 6px 0 0; font-size: 0; }
  .brand img { width: 28px; height: 28px; }
  #nav { flex-direction: row; gap: 2px; }
  #nav a { white-space: nowrap; padding: 7px 9px; font-size: 14px; }
  #nav .ico { display: none; }
  .side-foot { display: none; }
  main { padding: 18px 16px 48px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g2, .g3 { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
}

/* login (hosted mode) */
.login { max-width: 380px; margin: 60px auto; display: grid; gap: 10px; }
.login h1 { margin: 0 0 6px; }
