/* Kapike Amazon Hub — design system. One stylesheet, no build step.
   Tokens first (light + dark), then layout, then components. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f4f8;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #344054;
  --muted: #667085;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-solid: #4f46e5;
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;
  --ring: rgba(79, 70, 229, .25);
  --high: #d92d20;   --high-bg: #fef3f2;   --high-bd: #fecdca;
  --medium: #b54708; --medium-bg: #fffaeb; --medium-bd: #fedf89;
  --low: #475467;    --low-bg: #f2f4f7;    --low-bd: #e4e7ec;
  --ok: #067647;     --ok-bg: #ecfdf3;     --ok-bd: #abefc6;
  --info: #175cd3;   --info-bg: #eff8ff;   --info-bd: #b2ddff;
  --ins: #d1fadf; --del: #fee4e2;
  --sidebar: #ffffff;
  --logo-ink: #1e1b4b;
  --sidebar-text: #344054;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 24px -6px rgba(16, 24, 40, .12), 0 4px 8px -4px rgba(16, 24, 40, .06);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161616; --surface: #1f1f1f; --surface-2: #242424; --surface-3: #2a2a2a;
    --border: #333333; --border-strong: #454545; --text: #f2f2f2; --text-2: #d0d0d0; --muted: #9a9a9a;
    --primary: #818cf8; --primary-600: #6366f1; --primary-solid: #5b5bd6; --primary-50: rgba(129,140,248,.12); --primary-100: rgba(129,140,248,.2);
    --ring: rgba(129,140,248,.35);
    --high: #f97066; --high-bg: rgba(240,68,56,.12); --high-bd: rgba(240,68,56,.35);
    --medium: #fdb022; --medium-bg: rgba(247,144,9,.12); --medium-bd: rgba(247,144,9,.35);
    --low: #98a2b3; --low-bg: rgba(152,162,179,.12); --low-bd: rgba(152,162,179,.3);
    --ok: #47cd89; --ok-bg: rgba(23,178,106,.12); --ok-bd: rgba(23,178,106,.35);
    --info: #53b1fd; --info-bg: rgba(46,144,250,.12); --info-bd: rgba(46,144,250,.35);
    --ins: rgba(23,178,106,.25); --del: rgba(240,68,56,.25);
    --sidebar: #1b1b1b; --logo-ink: #f2f2f2; --sidebar-text: #cfd4dc;
    --shadow-sm: none; --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 30px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161616; --surface: #1f1f1f; --surface-2: #242424; --surface-3: #2a2a2a;
  --border: #333333; --border-strong: #454545; --text: #f2f2f2; --text-2: #d0d0d0; --muted: #9a9a9a;
  --primary: #818cf8; --primary-600: #6366f1; --primary-solid: #5b5bd6; --primary-50: rgba(129,140,248,.12); --primary-100: rgba(129,140,248,.2);
  --ring: rgba(129,140,248,.35);
  --high: #f97066; --high-bg: rgba(240,68,56,.12); --high-bd: rgba(240,68,56,.35);
  --medium: #fdb022; --medium-bg: rgba(247,144,9,.12); --medium-bd: rgba(247,144,9,.35);
  --low: #98a2b3; --low-bg: rgba(152,162,179,.12); --low-bd: rgba(152,162,179,.3);
  --ok: #47cd89; --ok-bg: rgba(23,178,106,.12); --ok-bd: rgba(23,178,106,.35);
  --info: #53b1fd; --info-bg: rgba(46,144,250,.12); --info-bd: rgba(46,144,250,.35);
  --ins: rgba(23,178,106,.25); --del: rgba(240,68,56,.25);
  --sidebar: #1b1b1b; --logo-ink: #f2f2f2; --sidebar-text: #cfd4dc;
  --shadow-sm: none; --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 30px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -.015em; }
h2 { font-size: 1.08rem; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: .95rem; margin: 0 0 8px; font-weight: 600; }
p { margin: 0 0 10px; }
code, .mono { font-family: var(--mono); font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.xs { font-size: .78rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; }
svg.i.lg { width: 22px; height: 22px; }

/* ---------------------------------------------------------- app shell */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px; overflow-y: auto; z-index: 40; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: var(--text); font-weight: 700; font-size: 1.02rem; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: .82rem;
  background: linear-gradient(135deg, #6366f1, #8b5cf6 60%, #ec4899); box-shadow: 0 4px 12px rgba(99,102,241,.35); }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: .74rem; margin-top: -2px; }
.nav-section { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--sidebar-text); font-weight: 500; }
.nav-item:hover { background: var(--surface-3); text-decoration: none; }
.nav-item.active { background: var(--primary-50); color: var(--primary); }
.nav-item .count { margin-left: auto; }
.nav-group > summary { list-style: none; cursor: pointer; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary .chev { margin-left: auto; transition: transform .15s; color: var(--muted); }
.nav-group[open] > summary .chev { transform: rotate(90deg); }
.nav-sub { margin: 2px 0 4px 19px; padding-left: 10px; border-left: 1px solid var(--border); }
.nav-sub .nav-item { padding: 6px 10px; font-size: .93rem; }
.nav-soon { display: flex; align-items: center; gap: 10px; padding: 7px 10px; color: var(--muted); font-size: .9rem; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 12px; display: flex; align-items: center; gap: 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .8rem;
  background: var(--primary-100); color: var(--primary); flex: none; }
.avatar.sm { width: 24px; height: 24px; font-size: .68rem; }
.who { min-width: 0; flex: 1; }
.who b { display: block; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who span { display: block; font-size: .76rem; color: var(--muted); }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; height: 58px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--border); }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; min-width: 0; overflow: hidden; white-space: nowrap; }
.crumbs a { color: var(--muted); }
.crumbs b { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.search { margin-left: auto; position: relative; width: min(360px, 40vw); }
.search input[type=search] { width: 100%; padding: 8px 40px 8px 36px; border-radius: 10px; background: var(--surface); }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search kbd { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); }
.menu-btn { display: none; }
.content { padding: 26px 28px 64px; max-width: 1400px; width: 100%; }

/* ---------------------------------------------------------- page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.eyebrow { font-size: .78rem; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------- layout helpers */
.grid { display: grid; gap: 16px; }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.mt { margin-top: 16px; } .mt-lg { margin-top: 24px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 10px; }

/* ---------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .sub { color: var(--muted); font-size: .86rem; }
.card.flush .card-head { padding: 16px 20px 0; }
a.card { color: inherit; display: block; }
a.card.tool-card { display: flex; }
a.card:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow); }

.kpi { position: relative; }
.kpi .label { color: var(--muted); font-size: .86rem; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.kpi .value { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; line-height: 1.1; }
.kpi .foot { color: var(--muted); font-size: .82rem; margin-top: 6px; }
.kpi .ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); }
.kpi.high .ico { background: var(--high-bg); color: var(--high); }
.kpi.ok .ico { background: var(--ok-bg); color: var(--ok); }
.kpi.medium .ico { background: var(--medium-bg); color: var(--medium); }
.trend-up { color: var(--high); } .trend-down { color: var(--ok); }

/* ---------------------------------------------------------- buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); cursor: pointer; font: inherit; font-weight: 550;
  line-height: 1.2; white-space: nowrap; box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }
.btn.primary { background: var(--primary-solid); border-color: var(--primary-solid); color: #fff; }
.btn.primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn.danger { color: var(--high); border-color: var(--high-bd); }
.btn.ghost { border-color: transparent; box-shadow: none; background: none; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { padding: 5px 10px; font-size: .86rem; border-radius: 8px; }
.btn.link { border: none; background: none; box-shadow: none; color: var(--primary); padding: 0; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  font: inherit; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); color: var(--text);
  max-width: 100%; box-shadow: var(--shadow-sm); }
select { padding-right: 30px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 15px; }
textarea { width: 100%; min-height: 90px; resize: vertical; line-height: 1.5; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); vertical-align: middle; }
label { font-weight: 550; display: block; margin-bottom: 5px; color: var(--text-2); }
label.inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 450; margin: 0; }
.field { margin-bottom: 16px; }
.hint { color: var(--muted); font-size: .84rem; margin-top: 4px; }
kbd { font-family: var(--mono); font-size: .72rem; padding: 1px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; color: var(--muted); background: var(--surface-2); }

/* ---------------------------------------------------------- toolbar / filters */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { min-width: 240px; }
.seg { display: inline-flex; background: var(--surface-3); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg a { padding: 5px 12px; border-radius: 7px; color: var(--muted); font-weight: 550; font-size: .9rem; white-space: nowrap; }
.seg a:hover { color: var(--text); text-decoration: none; }
.seg a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg a .count { margin-left: 4px; }

/* ---------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; }
table.data th { text-align: left; font-weight: 550; color: var(--muted); font-size: .8rem; padding: 10px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data tr.sel td { background: var(--primary-50); }
table.data td.title-cell { max-width: 460px; }
table.data.compact td { padding: 8px 14px; }
.clip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cell-main { font-weight: 550; color: var(--text); }
.cell-sub { color: var(--muted); font-size: .82rem; }

/* ---------------------------------------------------------- badges, pills, chips */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600;
  white-space: nowrap; border: 1px solid transparent; line-height: 1.5; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.plain::before { display: none; }
.badge.high { background: var(--high-bg); color: var(--high); border-color: var(--high-bd); }
.badge.medium { background: var(--medium-bg); color: var(--medium); border-color: var(--medium-bd); }
.badge.low { background: var(--low-bg); color: var(--low); border-color: var(--low-bd); }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-bd); }
.badge.info { background: var(--info-bg); color: var(--info); border-color: var(--info-bd); }
.badge.neutral { background: var(--surface-3); color: var(--muted); border-color: var(--border); }
.badge.mp { background: var(--text); color: var(--surface); border-radius: 6px; padding: 1px 7px; font-family: var(--mono); font-size: .72rem; }
.badge.mp::before { display: none; }
.count { display: inline-flex; min-width: 20px; height: 20px; align-items: center; justify-content: center; padding: 0 6px; border-radius: 999px;
  font-size: .74rem; font-weight: 700; background: var(--surface-3); color: var(--muted); }
.count.high { background: var(--high); color: #fff; }
.count.medium { background: var(--medium-bg); color: var(--medium); }
.count.low { background: var(--low-bg); color: var(--low); }
.count.primary { background: var(--primary-solid); color: #fff; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 11px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-2); font-size: .84rem; font-weight: 500; }
.chip:hover { text-decoration: none; border-color: var(--border-strong); }
.chip.on { background: var(--primary-solid); color: #fff; border-color: var(--primary-solid); }
.chip b { font-weight: 700; opacity: .85; }

/* ---------------------------------------------------------- health ring */
.ring { --p: 0; --c: var(--ok); width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-3) 0); }
.ring span { width: 30px; height: 30px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: .74rem; font-weight: 700; }
.ring.lg { width: 64px; height: 64px; } .ring.lg span { width: 50px; height: 50px; font-size: 1rem; }
.ring.mid { --c: var(--medium); } .ring.bad { --c: var(--high); }
.bar { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; display: flex; }
.bar > span { display: block; height: 100%; background: var(--ok); }
.bar > span.high { background: var(--high); } .bar > span.medium { background: #f79009; } .bar > span.low { background: #98a2b3; }

/* ---------------------------------------------------------- chart */
.chart { width: 100%; height: 190px; display: block; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.chart .area-high { fill: var(--high); } .chart .area-medium { fill: #f79009; } .chart .area-low { fill: #98a2b3; }
.legend { display: flex; gap: 14px; font-size: .82rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------------------------------------------------------- notices & toasts */
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--medium-bd);
  background: var(--medium-bg); color: var(--text); margin-bottom: 16px; }
.notice svg { color: var(--medium); margin-top: 1px; }
.notice.info { background: var(--info-bg); border-color: var(--info-bd); } .notice.info svg { color: var(--info); }
.notice.ok { background: var(--ok-bg); border-color: var(--ok-bd); } .notice.ok svg { color: var(--ok); }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 40px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); animation: toast-in .25s ease-out; }
.toast.ok svg.i { color: var(--ok); } .toast.error svg.i { color: var(--high); }
.toast.error { border-color: var(--high-bd); }
.toast .x { margin-left: auto; }
.toast.hide { opacity: 0; transform: translateY(8px); transition: all .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------------------------------------------------------- bulk bar */
.bulkbar { position: sticky; bottom: 16px; z-index: 20; margin-top: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 10px 12px; border-radius: 12px; background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg); }
.bulkbar .btn { background: transparent; color: var(--surface); border-color: rgba(255,255,255,.25); box-shadow: none; }
.bulkbar .btn:hover { background: rgba(255,255,255,.12); }
.bulkbar select, .bulkbar input[type=text] { background: transparent; color: var(--surface); border-color: rgba(255,255,255,.25); box-shadow: none; padding-top: 5px; padding-bottom: 5px; }
.bulkbar select option { color: #101828; }
:root[data-theme="dark"] .bulkbar .btn, :root[data-theme="dark"] .bulkbar select, :root[data-theme="dark"] .bulkbar input { border-color: rgba(0,0,0,.25); }
.bulkbar.idle { display: none; }

/* ---------------------------------------------------------- tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 0 0 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 8px; align-items: center; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; } .tab-panel.on { display: block; }

/* ---------------------------------------------------------- compare table */
table.compare { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
table.compare th { text-align: left; color: var(--muted); font-size: .8rem; font-weight: 550; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
table.compare td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; word-wrap: break-word; }
table.compare td.label { width: 180px; font-weight: 600; }
table.compare td.state { width: 150px; }
table.compare tr.mismatch td { background: color-mix(in srgb, var(--high-bg) 70%, transparent); }
table.compare tr.mismatch td.label { box-shadow: inset 3px 0 0 var(--high); }
table.compare tr.group td { background: var(--surface-3); font-weight: 650; color: var(--muted); padding: 7px 14px; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; }
table.compare td.diff-cell { background: color-mix(in srgb, var(--medium-bg) 80%, transparent); }
.val ol { margin: 0; padding-left: 18px; } .val ol li + li { margin-top: 6px; }
.val .empty { color: var(--muted); font-style: italic; }
ins { background: var(--ins); text-decoration: none; border-radius: 3px; padding: 0 1px; }
del { background: var(--del); color: var(--high); border-radius: 3px; padding: 0 1px; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.thumbs img { width: 64px; height: 64px; object-fit: contain; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
details.edit summary { cursor: pointer; color: var(--primary); font-size: .84rem; list-style: none; display: inline-flex; gap: 5px; align-items: center; margin-top: 6px; }
details.edit summary::-webkit-details-marker { display: none; }
details.edit form { margin-top: 8px; }
.meta { color: var(--muted); font-size: .78rem; margin-top: 4px; }

/* ---------------------------------------------------------- listing header */
.listing-hero { display: flex; gap: 20px; align-items: flex-start; }
.listing-hero .img { width: 104px; height: 104px; border-radius: 12px; border: 1px solid var(--border); background: #fff; display: grid; place-items: center; overflow: hidden; flex: none; }
.listing-hero .img img { width: 100%; height: 100%; object-fit: contain; }
.listing-hero .info { flex: 1; min-width: 0; }
.listing-hero h1 { font-size: 1.25rem; font-weight: 650; }
.tagline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; color: var(--muted); font-size: .9rem; }
.tagline .sep { opacity: .4; }
.mp-switch { display: inline-flex; gap: 4px; }
.mp-switch a, .mp-switch span { padding: 2px 8px; border-radius: 6px; border: 1px solid var(--border); font-family: var(--mono); font-size: .76rem; color: var(--muted); }
.mp-switch span.on { background: var(--text); color: var(--surface); border-color: var(--text); }

/* ---------------------------------------------------------- list items */
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: none; }
.list .grow { flex: 1; min-width: 0; }
.finding-msg { color: var(--muted); font-size: .88rem; margin-top: 3px; }

/* ---------------------------------------------------------- tool cards (home) */
.tool-card { display: flex; flex-direction: column; gap: 14px; position: relative; overflow: hidden; }
.tool-card .tool-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); box-shadow: 0 6px 16px rgba(99,102,241,.3); }
.tool-card.soon { border-style: dashed; background: transparent; box-shadow: none; }
.tool-card.soon .tool-ico { background: var(--surface-3); color: var(--muted); box-shadow: none; }
.tool-stats { display: flex; gap: 18px; flex-wrap: wrap; }
.tool-stats div b { display: block; font-size: 1.2rem; }
.tool-stats div span { color: var(--muted); font-size: .8rem; }
.hero { background: linear-gradient(135deg, var(--primary-50), transparent 60%), var(--surface); }

/* ---------------------------------------------------------- empty state, steps */
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .em-ico { width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 12px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.empty h3 { color: var(--text); }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: step; position: relative; padding: 0 0 18px 44px; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 50%; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.steps li.done::before { content: "✓"; background: var(--ok-bg); color: var(--ok); }
.steps li.done b { text-decoration: line-through; color: var(--muted); }

/* ---------------------------------------------------------- pagination */
.pager { display: flex; gap: 6px; justify-content: space-between; align-items: center; padding: 12px 14px; border-top: 1px solid var(--border); }

/* ---------------------------------------------------------- login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1000px 500px at 10% -10%, var(--primary-100), transparent 60%), radial-gradient(800px 400px at 110% 110%, rgba(236,72,153,.12), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; padding: 32px; box-shadow: var(--shadow-lg); }
.auth-card input { width: 100%; }

.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 30px 20px; text-align: center; background: var(--surface-2); cursor: pointer; transition: all .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-50); }
.dropzone input[type=file] { display: none; }
.dropzone .em-ico { width: 46px; height: 46px; border-radius: 12px; margin: 0 auto 10px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); }
.file-list { list-style: none; padding: 0; margin: 10px 0 0; text-align: left; }
.file-list li { display: flex; gap: 8px; align-items: center; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; margin-top: 6px; background: var(--surface); font-size: .88rem; }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.backdrop { display: none; }

@media (max-width: 1100px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-3, .cols-2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35; }
  .menu-btn { display: inline-grid; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .search { width: auto; flex: 1; } .search kbd { display: none; }
  .cols-2, .cols-4 { grid-template-columns: 1fr; }
  table.compare td.label { width: 110px; } table.compare td.state { width: 100px; }
  .listing-hero { flex-direction: column; }
  .crumbs { display: none; }
}

/* ---------- v0.3: rules, families, history, comparison, generator ---------- */
.switch { position: relative; width: 36px; height: 20px; border-radius: 999px; border: 0; padding: 0; cursor: pointer;
  background: var(--border-strong); transition: background .15s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(16px); }
.switch-label { display: inline-flex; align-items: center; cursor: pointer; }
.switch-label input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-ui { position: relative; width: 36px; height: 20px; border-radius: 999px; background: var(--border-strong); transition: background .15s; }
.switch-ui::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch-label input:checked + .switch-ui { background: var(--primary); }
.switch-label input:checked + .switch-ui::after { transform: translateX(16px); }
.switch-label input:focus-visible + .switch-ui { box-shadow: 0 0 0 3px var(--ring); }

.chip-check { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface); cursor: pointer; font-size: .9rem; user-select: none; }
.chip-check:hover { border-color: var(--border-strong); }
.chip-check:has(input:checked) { background: var(--primary-50); border-color: var(--primary); color: var(--primary); font-weight: 550; }
.chip-check input { accent-color: var(--primary); margin: 0; }
code.pill { background: var(--surface-3); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; font-size: .82rem; }

/* parent/child families */
.family { transition: box-shadow .15s, border-color .15s; }
.family.standalone { border-style: dashed; }
.family-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px;
  border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.family-head .grow { flex: 1; min-width: 200px; }
.family table td:first-child { padding-left: 16px; }
.drag-handle { cursor: grab; color: var(--muted); letter-spacing: -2px; font-size: .9rem; user-select: none; }
tr.draggable:hover .drag-handle { color: var(--text); }
tr.dragging { opacity: .45; }
.drop-ok { border-color: var(--primary) !important; box-shadow: 0 0 0 3px var(--ring) !important; }
.saving { opacity: .6; pointer-events: none; }
.odd-title { border-left: 3px solid var(--medium); padding-left: 8px; }
.odd-title ins, .families ins { background: var(--medium-bg); color: inherit; text-decoration: none; border-radius: 3px;
  box-shadow: inset 0 -2px 0 var(--medium); }

/* small popover menus */
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 240px; padding: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  display: grid; gap: 8px; }
.menu-pop select, .menu-pop input[type=text] { width: 100%; }

/* family strip on listing page */
.family-strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 6px; scrollbar-width: thin; }
.fam-chip { display: flex; flex-direction: column; gap: 1px; padding: 7px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text); white-space: nowrap; font-size: .85rem; }
.fam-chip:hover { border-color: var(--primary); text-decoration: none; }
.fam-chip.on { border-color: var(--primary); background: var(--primary-50); box-shadow: inset 0 0 0 1px var(--primary); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.dot.odd { background: var(--medium); }

/* history timeline */
.timeline { position: relative; padding-left: 4px; }
.tl-day { position: sticky; top: 0; z-index: 2; margin: 18px 0 8px; padding: 4px 0; background: var(--surface);
  font-size: .78rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tl-day:first-child { margin-top: 0; }
.tl-item { position: relative; display: grid; grid-template-columns: 30px 1fr; gap: 12px; padding: 0 0 16px; }
.tl-item::before { content: ""; position: absolute; left: 14px; top: 30px; bottom: 0; width: 2px; background: var(--border); }
.tl-dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--muted); position: relative; z-index: 1; }
.tl-item.amazon .tl-dot { color: var(--medium); background: var(--medium-bg); border-color: var(--medium-bd); }
.tl-item.team .tl-dot { color: var(--primary); background: var(--primary-50); border-color: var(--primary-100); }
.tl-item.issue_open .tl-dot { color: var(--high); background: var(--high-bg); border-color: var(--high-bd); }
.tl-item.issue_closed .tl-dot { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-bd); }
.tl-body { min-width: 0; padding-top: 4px; }
.tl-diff { margin-top: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: .9rem; overflow-wrap: anywhere; display: grid; gap: 4px; }
.tl-diff ins { background: var(--ins); text-decoration: none; border-radius: 3px; }
.tl-diff del { background: var(--del); border-radius: 3px; }

/* comparison matrix */
.matrix-wrap { overflow: auto; max-height: calc(100vh - 220px); border-radius: var(--radius); }
table.compare.matrix { border-collapse: separate; border-spacing: 0; }
table.compare.matrix thead th { position: sticky; top: 0; z-index: 3; background: var(--surface-2); vertical-align: top;
  min-width: 260px; border-bottom: 1px solid var(--border); }
table.compare.matrix .sticky-col { position: sticky; left: 0; z-index: 2; background: var(--surface); min-width: 150px;
  box-shadow: 1px 0 0 var(--border); }
table.compare.matrix thead th.sticky-col { z-index: 4; background: var(--surface-2); }
table.compare.matrix tr.group td { background: var(--surface-3); font-size: .75rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); font-weight: 650; }
table.compare.matrix th.ref-col { background: var(--primary-50); box-shadow: inset 0 3px 0 var(--primary); }
table.compare.matrix td.ref-col { background: color-mix(in srgb, var(--primary-50) 60%, transparent); }

/* brand logo */
.brand-logo { width: 34px; height: 34px; flex: none; display: block; }
.login-logo { width: 56px; height: 56px; margin: 0 auto 14px; display: block; }

/* listing generator */
.gen-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.gen-side { position: sticky; top: 76px; display: grid; gap: 16px; }
.gen-field { margin-bottom: 16px; }
.gen-field textarea { width: 100%; resize: vertical; font: inherit; line-height: 1.55; }
.gen-field .lbl { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-weight: 600; }
.counter { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.counter.over { color: var(--high); font-weight: 650; }
.issue-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.issue-list li { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: start; font-size: .88rem; }
.mp-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tool-card .tool-ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: #fff; }
@media (max-width: 1000px) { .gen-grid { grid-template-columns: 1fr; } .gen-side { position: static; } }

/* ---------- v0.4: ideas & notes, weekly reports, internal titles ---------- */
.note-card { margin-bottom: 12px; padding: 16px 18px; }
.note-card.pinned { border-color: var(--primary-100); box-shadow: inset 3px 0 0 var(--primary); }
.note-main { display: flex; gap: 14px; align-items: flex-start; }
.note-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.note-actions select { font-size: .85rem; padding: 4px 8px; }
.vote-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 46px; padding: 8px 0; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); font: inherit; }
.vote-btn:hover { border-color: var(--primary); color: var(--primary); }
.vote-btn.on { background: var(--primary-50); border-color: var(--primary); color: var(--primary); }
.note-body { white-space: pre-wrap; color: var(--text-2); font-size: .93rem; overflow-wrap: anywhere; }
.note-comments { margin-top: 12px; border-left: 2px solid var(--border); padding-left: 12px; display: grid; gap: 8px; }
.note-reply { margin-top: 10px; }
.note-reply summary { cursor: pointer; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.chip-check:has(input[type=radio]:checked) { background: var(--primary-50); border-color: var(--primary); color: var(--primary); font-weight: 550; }
.internal-title { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; color: var(--primary);
  background: var(--primary-50); border-radius: 6px; padding: 1px 7px; margin-bottom: 3px; }
.ean { font-family: var(--mono); font-size: .8rem; }
.ean.bad { color: var(--high); text-decoration: underline wavy; }
.prompt-preview { white-space: pre-wrap; font-family: var(--mono); font-size: .78rem; line-height: 1.5; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; max-height: 420px; overflow: auto; margin: 10px 0 6px; }

/* Kapike logo */
.brand-logo { width: 30px; height: 27px; flex: none; display: block; }
.brand .brand-name { display: block; font-weight: 800; letter-spacing: .14em; font-size: .98rem; color: var(--logo-ink); line-height: 1.1; }
.brand .brand-sub { display: block; font-weight: 650; letter-spacing: .2em; font-size: .62rem; color: var(--primary); margin-top: 3px; }
.logo-full { display: inline-flex; align-items: center; gap: 16px; }
.logo-full-mark { width: 64px; height: 58px; flex: none; }
.logo-words { display: flex; flex-direction: column; align-items: stretch; }
.logo-name { font-weight: 800; letter-spacing: .16em; font-size: 2rem; line-height: 1; color: var(--logo-ink); }
.logo-sub { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: .24em; font-size: .7rem; color: var(--primary); margin-top: 8px; white-space: nowrap; }
.logo-sub i { flex: 1; height: 2px; background: var(--primary); opacity: .8; min-width: 14px; }
.logo-full.sm .logo-full-mark { width: 44px; height: 40px; }
.logo-full.sm .logo-name { font-size: 1.4rem; }
.logo-full.sm .logo-sub { font-size: .58rem; margin-top: 6px; }

/* ---------- v0.6 polish: mobile overflow fixes ---------- */
.gen-grid > * { min-width: 0; }
@media (max-width: 1000px) { .gen-grid { grid-template-columns: minmax(0, 1fr); } }
.seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.page-head .sub, .card-head .sub, .hint { overflow-wrap: anywhere; }
.menu-pop { max-width: min(360px, calc(100vw - 32px)); }
@media (max-width: 700px) {
  .note-main { flex-wrap: wrap; }
  .note-main .grow { flex: 1 1 calc(100% - 60px); }
  .note-actions { flex-direction: row; width: 100%; justify-content: flex-end; }
  .note-actions .menu-pop { right: 0; left: auto; }
}
@media (max-width: 860px) {
  .grid.cols-4:has(> .kpi) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; }
  .kpi .label { font-size: .78rem; gap: 6px; }
  .kpi .ico { width: 28px; height: 28px; }
  .kpi .value { font-size: 1.5rem; }
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { white-space: nowrap; flex: none; }
  .listing-hero { display: grid; grid-template-columns: 72px 1fr auto; gap: 12px; }
  .listing-hero .img { width: 72px; height: 72px; }
  .listing-hero .info { grid-column: 1 / -1; grid-row: 2; }
  .listing-hero > :last-child { grid-column: 3; grid-row: 1; }
  .listing-hero h1 { font-size: 1.1rem; }
  .page-head h1 { font-size: 1.35rem; }
}

.chips .chip.more-hidden { display: none; }
.chips.expanded .chip.more-hidden { display: inline-flex; }
.chip.chip-toggle { border-style: dashed; color: var(--muted); cursor: pointer; background: transparent; font: inherit; font-size: .84rem; }
@media (max-width: 860px) { .tagline .sep { display: none; } .tagline { gap: 6px 10px; } }

/* thin progress bar while a form is being processed (imports, AI, weekly reports…) */
.page-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100; pointer-events: none; overflow: hidden; opacity: 0; transition: opacity .2s; }
.page-progress::after { content: ""; position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; background: linear-gradient(90deg, transparent, var(--primary), transparent); animation: progress 1.1s ease-in-out infinite; }
body.busy .page-progress { opacity: 1; }
body.busy { cursor: progress; }
@keyframes progress { to { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .page-progress::after { animation-duration: 3s; } }

/* ---------- listings tree: variations under their parent ---------- */
.tree-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
table.data.tree tbody + tbody { border-top: 1px solid var(--border); }
table.data.tree tbody.fam { border-top: 2px solid var(--border); }
tr.fam-head td { background: var(--surface-2); }
tr.fam-head .cell-main { font-weight: 700; }
.fam-title { margin: 4px 0 2px 30px; font-weight: 550; color: var(--text); font-size: .9rem; max-width: 640px; }
.tree-caret { width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--muted); cursor: pointer; padding: 0; flex: none; transition: transform .15s; }
.tree-caret:hover { color: var(--text); border-color: var(--border-strong); }
tbody.fam:not(.open) .tree-caret { transform: rotate(-90deg); }
tbody.fam:not(.open) tr.fam-child { display: none; }
tr.fam-child td { border-top-color: transparent; }
tr.fam-child .child-cell { position: relative; padding-left: 42px; }
/* tree connector: vertical line from the parent + short branch to each variation */
tr.fam-child .child-cell::before { content: ""; position: absolute; left: 10px; top: -14px; bottom: -14px; width: 2px; background: var(--border-strong); }
tr.fam-child.last .child-cell::before { bottom: auto; height: calc(14px + 12px); }
tr.fam-child .child-cell::after { content: ""; position: absolute; left: 10px; top: 11px; width: 20px; height: 2px; background: var(--border-strong); }
.var-label { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--primary-50); color: var(--primary); font-weight: 650; font-size: .8rem; white-space: nowrap; }
tr.fam-child .cell-sub.clip { max-width: 560px; }

.brand-words { width: 104px; height: auto; display: block; }
.brand { gap: 11px; }
.logo-full-words { width: 190px; height: auto; display: block; }
.logo-full.sm .logo-full-words { width: 140px; }
table.data.tree .title-cell { max-width: 440px; }
table.data.tree td.nowrap { white-space: nowrap; }

/* ---------- customisable dashboards (Home, Overview) ---------- */
.dash-bar { display: flex; align-items: center; gap: 10px; margin: -6px 0 12px; min-height: 30px; }
.dash-hint, .dash-edit-only { display: none; }
body.dash-editing .dash-hint, body.dash-editing .dash-edit-only { display: inline-flex; }
.dash { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.widget { grid-column: span var(--span, 4); position: relative; min-width: 0; display: flex; flex-direction: column; }
.widget-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.widget-body > .card, .widget-body > a.card { flex: 1; margin: 0; }
.widget.is-hidden { display: none; }
.widget-tools { display: none; align-items: center; gap: 8px; padding: 6px 8px; margin-bottom: 6px; border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); font-size: .8rem; }
.widget-handle { cursor: grab; color: var(--muted); letter-spacing: -2px; user-select: none; padding: 0 2px; }
.widget-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.widget-sizes { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.widget-sizes button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .75rem; padding: 2px 6px; cursor: pointer; }
.widget-sizes button + button { border-left: 1px solid var(--border); }
.widget-sizes button.on { background: var(--primary-solid); color: #fff; }
.widget-hide { border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 6px; padding: 2px 5px; cursor: pointer; display: grid; place-items: center; }
.widget-resize { display: none; position: absolute; top: 40px; bottom: 0; right: -10px; width: 12px; cursor: ew-resize; z-index: 3; }
.widget-resize::after { content: ""; position: absolute; top: 50%; right: 4px; width: 4px; height: 36px; margin-top: -18px; border-radius: 2px; background: var(--primary); opacity: .6; }
body.dash-editing .widget-tools { display: flex; }
body.dash-editing .widget-resize { display: block; }
body.dash-editing .widget.is-hidden { display: flex; opacity: .45; }
body.dash-editing .widget.is-hidden .widget-body { pointer-events: none; }
body.dash-editing .widget-body { pointer-events: none; }
body.dash-editing .widget.is-hidden .widget-hide { color: var(--primary); border-color: var(--primary); }
.widget.dragging { opacity: .4; }
.widget.drop-before { box-shadow: -4px 0 0 var(--primary); }
.widget.drop-after { box-shadow: 4px 0 0 var(--primary); }
.widget.resizing { outline: 2px dashed var(--primary); outline-offset: 4px; }
@media (max-width: 1100px) { .widget { grid-column: span max(6, var(--span, 4)); } .widget[data-span="12"], .widget[data-span="8"] { grid-column: span 12; } }
@media (max-width: 860px) {
  .dash { gap: 10px; }
  .widget { grid-column: span 12; }
  .widget[data-wid^="kpi_"] { grid-column: span 6; }
  .widget-sizes, .widget-resize { display: none !important; }
}

/* What's new */
.wn-release { padding: 10px 0; border-top: 1px solid var(--border); }
.wn-release:first-of-type { border-top: 0; padding-top: 0; }
.wn-date { font-weight: 650; font-size: .85rem; color: var(--text); margin-bottom: 4px; }
.wn-items { margin: 0; padding-left: 18px; display: grid; gap: 5px; font-size: .9rem; color: var(--text-2); }
.wn-items code { font-size: .82em; }
.whats-new .wn-scroll { max-height: 420px; overflow: auto; padding-right: 6px; }

/* guides */
.guide-card:hover { border-color: var(--primary); text-decoration: none; }
.prose { font-size: .95rem; line-height: 1.65; color: var(--text-2); }
.prose h2 { font-size: 1.12rem; margin: 22px 0 8px; color: var(--text); }
.prose h3 { font-size: 1rem; margin: 18px 0 6px; color: var(--text); }
.prose p { margin: 0 0 10px; }
.prose ul, .prose ol { margin: 0 0 12px; padding-left: 22px; display: grid; gap: 4px; }
.prose table { border-collapse: collapse; width: 100%; margin: 6px 0 14px; font-size: .88rem; }
.prose th, .prose td { border: 1px solid var(--border); padding: 6px 9px; text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); color: var(--text); font-weight: 600; }
.prose blockquote { margin: 0 0 12px; padding: 8px 14px; border-left: 3px solid var(--primary); background: var(--primary-50); border-radius: 0 8px 8px 0; }
.prose blockquote p { margin: 0; }
.prose code { background: var(--surface-3); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; font-size: .85em; }
.prose pre { background: var(--surface-3); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow: auto; }
.prose pre code { border: 0; padding: 0; background: none; }
.guide-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-2); background: var(--surface); font-size: .85rem; font-weight: 550; white-space: nowrap; }
.guide-btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
@media (max-width: 860px) { .guide-btn span { display: none; } }

/* ---------- AI assistant ---------- */
.ai-fab { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: inline-flex; align-items: center; gap: 8px; padding: 12px 16px;
  border: 0; border-radius: 999px; cursor: pointer; color: #fff; font: inherit; font-weight: 650;
  background: linear-gradient(135deg, #4f46e5, #8b5cf6); box-shadow: 0 10px 24px -6px rgba(79, 70, 229, .55); transition: transform .15s; }
.ai-fab:hover { transform: translateY(-2px); }
body.ai-open .ai-fab { display: none; }
.ai-panel { position: fixed; right: 20px; bottom: 20px; z-index: 61; width: 420px; height: min(640px, calc(100vh - 40px));
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; }
.ai-panel[hidden] { display: none; }
.ai-panel.wide { width: min(760px, calc(100vw - 40px)); height: calc(100vh - 40px); }
.ai-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.ai-avatar { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #4f46e5, #8b5cf6); }
.ai-log { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.ai-msg { max-width: 92%; font-size: .92rem; line-height: 1.55; overflow-wrap: anywhere; }
.ai-msg.user { align-self: flex-end; background: var(--primary-solid); color: #fff; padding: 8px 12px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; }
.ai-msg.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); padding: 10px 13px; border-radius: 14px 14px 14px 4px; color: var(--text); }
.ai-msg.bot p { margin: 0 0 8px; } .ai-msg.bot p:last-child { margin: 0; }
.ai-msg.bot ul, .ai-msg.bot ol { margin: 0 0 8px; padding-left: 20px; }
.ai-msg.bot table { border-collapse: collapse; font-size: .82rem; margin: 6px 0 8px; display: block; overflow-x: auto; }
.ai-msg.bot th, .ai-msg.bot td { border: 1px solid var(--border); padding: 4px 7px; text-align: left; white-space: nowrap; }
.ai-msg.bot th { background: var(--surface-3); }
.ai-msg.bot code { background: var(--surface-3); border-radius: 4px; padding: 0 4px; font-size: .85em; }
.ai-msg.error { align-self: stretch; background: var(--high-bg); border: 1px solid var(--high-bd); color: var(--high); padding: 8px 12px; border-radius: 10px; font-size: .88rem; }
.ai-used { margin-top: 6px; font-size: .74rem; color: var(--muted); }
.ai-thinking { align-self: flex-start; color: var(--muted); font-size: .86rem; display: inline-flex; gap: 8px; align-items: center; }
.ai-thinking i { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); animation: aidot 1s infinite ease-in-out; }
.ai-thinking i:nth-child(2) { animation-delay: .15s; } .ai-thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes aidot { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
.ai-suggest { display: grid; gap: 6px; }
.ai-suggest button { text-align: left; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 10px; padding: 8px 11px; font: inherit; font-size: .86rem; cursor: pointer; }
.ai-suggest button:hover { border-color: var(--primary); color: var(--primary); }
.ai-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); align-items: flex-end; }
.ai-form textarea { flex: 1; min-height: 40px; max-height: 140px; resize: none; font: inherit; font-size: .92rem; }
.ai-form .btn { height: 40px; }
.ai-foot { padding: 0 14px 10px; }
@media (max-width: 600px) {
  .ai-panel, .ai-panel.wide { right: 0; bottom: 0; width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
  .ai-fab { right: 14px; bottom: 14px; padding: 12px; } .ai-fab span { display: none; }
}
.ai-head > .row:first-child { flex: 1; min-width: 0; flex-wrap: nowrap; }
.ai-head > .row:last-child { flex-wrap: nowrap; flex: none; }
.ai-head .xs { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .guide-btn { margin-left: auto; }
.topbar .guide-btn + .search { margin-left: 10px; }

/* connection info pop-ups */
.info-btn { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; padding: 2px 8px; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface-2); color: var(--primary); font: inherit; font-size: .78rem; font-weight: 550; cursor: pointer; }
.info-btn:hover { border-color: var(--primary); }
.info-dialog { width: min(820px, calc(100vw - 32px)); max-height: calc(100vh - 48px); border: 1px solid var(--border); border-radius: 16px;
  padding: 22px 24px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.info-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.info-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 6px; }
.info-head h2 { margin: 0; font-size: 1.2rem; }
.info-dialog h3 { display: flex; align-items: center; gap: 6px; font-size: .92rem; margin: 14px 0 6px; }
.info-dialog ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: .9rem; color: var(--text-2); }
.info-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.info-api { margin-top: 14px; padding: 10px 14px; border-radius: 10px; background: var(--primary-50); border: 1px solid var(--primary-100); }
.info-api h3 { margin-top: 0; } .info-api p { margin: 0; font-size: .9rem; }
@media (max-width: 700px) { .info-cols { grid-template-columns: 1fr; } }
.kind-tag { display: inline-block; padding: 0 6px; border-radius: 5px; font-size: .68rem; font-weight: 700; letter-spacing: .05em;
  vertical-align: 2px; border: 1px solid; font-family: var(--mono); }
.kind-tag.mcp { color: #7c3aed; border-color: rgba(124, 58, 237, .35); background: rgba(124, 58, 237, .08); }
.kind-tag.api { color: var(--info); border-color: var(--info-bd); background: var(--info-bg); }
.kind-tag.email { color: var(--muted); border-color: var(--border); background: var(--surface-2); }
:root[data-theme="dark"] .kind-tag.mcp { color: #c4b5fd; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .kind-tag.mcp { color: #c4b5fd; } }
.ai-copy { margin-left: 6px; border: 0; background: none; color: var(--primary); font: inherit; font-size: .74rem; cursor: pointer; padding: 0; }
.ask-ai { display: inline-flex; align-items: center; gap: 5px; color: #7c3aed; font-weight: 600; cursor: pointer; background: none; border: 0; font: inherit; font-size: .82rem; padding: 0; }
.ask-ai:hover { text-decoration: underline; }
:root[data-theme="dark"] .ask-ai { color: #c4b5fd; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ask-ai { color: #c4b5fd; } }
.sheet-wrap { max-height: calc(100vh - 300px); overflow: auto; }
table.sheet th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); white-space: nowrap; }
table.sheet td { white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; font-size: .82rem; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; }
.checklist .tick { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: .75rem; margin-top: 1px; }
.checklist li.done .tick { background: var(--ok); border-color: var(--ok); }
.checklist li.partly .tick { background: var(--medium); border-color: var(--medium); }
.checklist li.done .cl-title { color: var(--muted); text-decoration: line-through; }
.checklist .cl-title { color: var(--text); font-weight: 550; font-size: .9rem; }

/* ---------- week in numbers ---------- */
.wk-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.wk-mp { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--surface-2); }
.wk-mp-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.wk-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.wk-kpi { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.wk-kpi .lbl { font-size: .74rem; color: var(--muted); }
.wk-kpi b { font-size: 1.15rem; font-variant-numeric: tabular-nums; color: var(--text); }
.wk-extra { margin-top: 10px; line-height: 1.5; }
.wk-grid.compact .wk-kpi b { font-size: 1rem; }
.chg { font-size: .72rem; font-weight: 650; white-space: nowrap; }
.chg-up { color: var(--ok); } .chg-down { color: var(--high); } .chg-flat { color: var(--muted); }
.wk-alerts { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.wk-alerts li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); }
.wk-alerts li.high { border-color: var(--high-bd); background: var(--high-bg); }
.wk-alerts li.medium { border-color: var(--medium-bd); background: var(--medium-bg); }
.wk-ico { font-size: 1.1rem; line-height: 1.2; }
@media (max-width: 1100px) { .wk-grid { grid-template-columns: 1fr; } }
.perf-kpis { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.perf-kpis > div { display: flex; flex-direction: column; gap: 1px; }
.perf-kpis .lbl { font-size: .74rem; color: var(--muted); }
.perf-kpis b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
@media (max-width: 1100px) { .perf-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 600px) { .perf-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
