/* Sovors Ops — UI */
:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 14px; --radius-sm: 9px;
  --bg: #f4f6f8; --surface: #ffffff; --surface-2: #f7f9fb; --surface-3: #eef1f4;
  --border: #e4e8ed; --border-strong: #cfd6de;
  --text: #0e1218; --text-2: #4e5a68; --text-3: #8a95a3;
  --accent: #0ca779; --accent-ink: #ffffff; --accent-soft: rgba(12,167,121,.12);
  --series-1: #2a78d6; --series-2: #1baf7a; --series-3: #eb6834;
  --good: #0ca30c; --warn: #d98c00; --serious: #ec835a; --crit: #d03b3b;
  --st-new: #2a78d6; --st-sourced: #6250d6; --st-purchased: #c98500; --st-shipped: #1baf7a; --st-delivered: #008300; --st-cancelled: #8a95a3; --st-refunded: #e34948;
  --shadow: 0 1px 2px rgba(10,20,30,.05), 0 8px 24px -12px rgba(10,20,30,.18);
  --grid: #e9edf1;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0f14; --surface: #121821; --surface-2: #161d27; --surface-3: #1b2330;
  --border: rgba(255,255,255,.07); --border-strong: rgba(255,255,255,.14);
  --text: #e9eef4; --text-2: #9aa7b5; --text-3: #5f6c7a;
  --accent: #10b981; --accent-ink: #06130e; --accent-soft: rgba(16,185,129,.14);
  --series-1: #3987e5; --series-2: #1fb880; --series-3: #d95926;
  --good: #22c55e; --warn: #fab219; --serious: #ec835a; --crit: #e66767;
  --st-new: #3987e5; --st-sourced: #9085e9; --st-purchased: #e0a21c; --st-shipped: #1fb880; --st-delivered: #22c55e; --st-cancelled: #6b7785; --st-refunded: #e66767;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 12px 32px -16px rgba(0,0,0,.6);
  --grid: #1e2733;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
svg:not(.chart) { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }

/* layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex: none; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 14px; background: var(--surface); border-right: 1px solid var(--border); z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 22px; font-size: 17px; letter-spacing: -.01em; }
.brand b { color: var(--accent); font-weight: 800; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), #0a8f68); color: #fff; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; color: var(--text-2); font-weight: 500; transition: .15s; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a.active svg { stroke: var(--accent); }
.nav-badge { margin-left: auto; background: var(--st-new); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; }
.sidebar-foot { margin-top: auto; display: flex; gap: 6px; }
.sidebar-foot .btn { flex: 1; justify-content: center; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 16px 28px; position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.content { padding: 4px 28px 48px; max-width: 1400px; width: 100%; }
#menuBtn { display: none; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: var(--text-3); background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--crit); border-color: color-mix(in srgb, var(--crit) 40%, transparent); }
.btn.danger:hover { background: color-mix(in srgb, var(--crit) 12%, transparent); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.icon { padding: 8px; }
.btn.block { width: 100%; justify-content: center; }
.input, select.input, textarea.input { width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); outline: none; transition: .15s; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { min-height: 80px; resize: vertical; font-family: var(--font); }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-2); font-weight: 600; }
label.field .input { font-weight: 400; font-size: 14px; color: var(--text); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; color: var(--text-2); font-weight: 600; cursor: pointer; font-size: 13px; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 11px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 12.5px; font-weight: 600; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.chip:hover { border-color: var(--border-strong); }
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--text-3)); }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 16px 18px 0; }
.card-h h3 { margin: 0; font-size: 14px; font-weight: 700; }
.card-h .sub { color: var(--text-3); font-size: 12px; font-weight: 500; }
.card-h .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-b { padding: 16px 18px 18px; }
.grid { display: grid; gap: 16px; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: 1.6fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.section { margin-top: 18px; }

/* KPI tiles */
.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi .label { font-size: 12px; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 26px; font-weight: 800; letter-spacing: -.03em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi.hero .value { font-size: 40px; }
.kpi .delta { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.kpi .delta b { color: var(--text-2); }
.kpi.hero { grid-column: span 2; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, var(--surface)), var(--surface) 70%); }
.kpi.hero .value.neg, .neg { color: var(--crit); }
.kpi.hero .value.pos { color: var(--accent); }
.kpi .spark { position: absolute; right: 14px; bottom: 12px; width: 120px; height: 36px; opacity: .9; }
.cc { display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .04em; padding: 1px 5px; border-radius: 5px; background: var(--surface-3); color: var(--text-2); vertical-align: 1px; margin-right: 5px; }

/* status pill */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); text-transform: capitalize; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.st-new { --c: var(--st-new); } .st-sourced { --c: var(--st-sourced); } .st-purchased { --c: var(--st-purchased); }
.st-shipped { --c: var(--st-shipped); } .st-delivered { --c: var(--st-delivered); } .st-cancelled { --c: var(--st-cancelled); } .st-refunded { --c: var(--st-refunded); }

/* table */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 12px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; transition: background .12s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .muted { color: var(--text-3); }
.tbl .strong { font-weight: 700; }
.tbl td.prod { max-width: 280px; } .tbl td.prod > span:first-child, .tbl td.prod > .sub { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbl .sub { display: block; color: var(--text-3); font-size: 12px; margin-top: 2px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 36px; text-align: center; color: var(--text-3); }
.empty b { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 4px; }

/* queue cards */
.queue { display: grid; gap: 10px; }
.q-item { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; transition: .12s; }
.q-item:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.q-step { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c); }
.q-title { font-weight: 700; }
.q-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.q-body { min-width: 0; }
.q-next { font-size: 12px; font-weight: 700; color: var(--accent); margin-top: 6px; }
.q-next small { display: block; color: var(--text-3); font-weight: 500; }

/* chart */
.chart-box { position: relative; }
svg.chart { display: block; overflow: visible; max-width: 100%; }
.chart-box { min-height: 260px; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-text { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .bar { transition: opacity .12s; }
.chart .bar.dim { opacity: .35; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); font-weight: 600; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tooltip { position: absolute; pointer-events: none; background: var(--text); color: var(--bg); padding: 8px 10px; border-radius: 9px; font-size: 12px; box-shadow: var(--shadow); white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); z-index: 5; }
.tooltip b { font-weight: 700; }
.tooltip .row { display: flex; justify-content: space-between; gap: 14px; }

/* bars list */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13px; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.bar-row .val { color: var(--text-2); font-variant-numeric: tabular-nums; }
.bar-row .track { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 3px; background: var(--series-1); }

/* drawer */
.drawer-bg { position: fixed; inset: 0; background: rgba(5,8,12,.55); backdrop-filter: blur(3px); z-index: 40; animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(720px, 100vw); background: var(--bg); border-left: 1px solid var(--border); z-index: 41; display: flex; flex-direction: column; animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.drawer-h { display: flex; align-items: center; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--border); background: var(--surface); }
.drawer-h h2 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; }
.drawer-h .right { margin-left: auto; display: flex; gap: 6px; }
.drawer-b { flex: 1; overflow-y: auto; padding: 18px 22px 40px; display: grid; gap: 14px; align-content: start; }
.drawer-b .card-b { padding-top: 12px; }
.steps { display: flex; gap: 4px; }
.step { flex: 1; text-align: center; font-size: 11.5px; font-weight: 700; padding: 8px 4px; border-radius: 8px; background: var(--surface-3); color: var(--text-3); position: relative; cursor: pointer; }
.step.done { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.step.current { background: var(--accent); color: var(--accent-ink); }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 13.5px; }
.kv dt { color: var(--text-3); font-weight: 600; }
.kv dd { margin: 0; word-break: break-word; }
.addr { background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 10px; padding: 12px 14px; white-space: pre-line; font-size: 13.5px; line-height: 1.5; position: relative; }
.items { display: grid; gap: 8px; }
.item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.item .t { font-weight: 600; flex: 1; }
.item .v { color: var(--text-3); font-size: 12px; display: block; }
.cost-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.profit-line { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); margin-top: 12px; font-weight: 600; }
.profit-line .big { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.activity { display: grid; gap: 8px; font-size: 13px; }
.act { display: grid; grid-template-columns: 70px 1fr; gap: 10px; }
.act .when { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.act .who { font-weight: 700; margin-right: 6px; }
.who-claude { color: var(--st-sourced); } .who-you { color: var(--accent); } .who-shopify { color: var(--st-new); }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(5,8,12,.6); z-index: 50; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; width: min(640px, 100%); max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal-h { padding: 18px 22px 0; display: flex; align-items: center; }
.modal-h h2 { margin: 0; font-size: 18px; font-weight: 800; }
.modal-b { padding: 16px 22px 22px; display: grid; gap: 14px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 0 22px 20px; }

/* auth */
.auth { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: radial-gradient(1200px 600px at 20% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%), var(--bg); padding: 16px; }
.auth .card { width: min(400px, 100%); padding: 30px; display: grid; gap: 14px; }
.auth h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.auth p { margin: 0; color: var(--text-2); }
.err { color: var(--crit); font-size: 13px; font-weight: 600; }

/* toasts */
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 200; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 13px; box-shadow: var(--shadow); animation: up .2s; }
.toast.err { background: var(--crit); color: #fff; }
@keyframes up { from { transform: translateY(10px); opacity: 0; } }

.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 6px 0 16px; }
.filters .input { width: auto; }
.help { font-size: 12px; color: var(--text-3); }
code.k { background: var(--surface-3); padding: 2px 6px; border-radius: 6px; font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.flag { font-size: 16px; margin-right: 4px; }
.spin { width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: rot .7s linear infinite; display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }

/* responsive */
@media (max-width: 1000px) { .grid.two, .grid.three { grid-template-columns: 1fr; } .kpi.hero { grid-column: 1 / -1; } }
@media (max-width: 760px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .sidebar.open { transform: none; }
  #menuBtn { display: inline-flex; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .page-title { font-size: 19px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; } .kv dt { margin-top: 6px; }
  .drawer-b { padding: 14px 14px 40px; }
  .tbl .hide-m { display: none; }
}