/* EcomKings CRM — design system */
:root {
  --bg: #05050a;
  --bg-2: #0b0b13;
  --surface: rgba(255, 255, 255, .035);
  --surface-2: rgba(255, 255, 255, .06);
  --surface-solid: #10101a;
  --border: rgba(255, 255, 255, .07);
  --border-2: rgba(255, 255, 255, .12);
  --text: #f5f5fa;
  --text-2: #b4b4c6;
  --muted: #7d7d93;
  --a1: #8b5cf6;
  --a2: #22d3ee;
  --a3: #f472b6;
  --grad: linear-gradient(135deg, #8b5cf6 0%, #6366f1 45%, #22d3ee 100%);
  --pos: #34d399;
  --pos-bg: rgba(52, 211, 153, .12);
  --neg: #fb7185;
  --neg-bg: rgba(251, 113, 133, .12);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, .12);
  --info-bg: rgba(139, 92, 246, .14);
  --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 20px 50px -20px rgba(0, 0, 0, .6);
  --glow: 0 0 0 1px rgba(139, 92, 246, .35), 0 10px 40px -10px rgba(139, 92, 246, .45);
  --r: 20px;
  --r-sm: 12px;
  --sidebar: 248px;
  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --mesh-1: rgba(139, 92, 246, .22);
  --mesh-2: rgba(34, 211, 238, .14);
  --mesh-3: rgba(244, 114, 182, .10);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f4fa;
  --bg-2: #ffffff;
  --surface: rgba(255, 255, 255, .72);
  --surface-2: rgba(15, 15, 40, .045);
  --surface-solid: #ffffff;
  --border: rgba(20, 20, 50, .08);
  --border-2: rgba(20, 20, 50, .14);
  --text: #0f0f1a;
  --text-2: #3e3e55;
  --muted: #74748a;
  --pos: #059669;
  --pos-bg: rgba(5, 150, 105, .1);
  --neg: #e11d48;
  --neg-bg: rgba(225, 29, 72, .08);
  --warn: #d97706;
  --warn-bg: rgba(217, 119, 6, .1);
  --info-bg: rgba(139, 92, 246, .1);
  --shadow: 0 1px 2px rgba(20, 20, 50, .04), 0 12px 40px -18px rgba(20, 20, 60, .18);
  --mesh-1: rgba(139, 92, 246, .16);
  --mesh-2: rgba(34, 211, 238, .14);
  --mesh-3: rgba(244, 114, 182, .10);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
.num, .mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- background mesh ---------- */
.mesh { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.mesh i {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: 1;
  animation: float 22s ease-in-out infinite alternate;
}
.mesh i:nth-child(1) { width: 620px; height: 620px; background: var(--mesh-1); top: -220px; left: 10%; }
.mesh i:nth-child(2) { width: 520px; height: 520px; background: var(--mesh-2); top: 30%; right: -160px; animation-delay: -7s; }
.mesh i:nth-child(3) { width: 480px; height: 480px; background: var(--mesh-3); bottom: -200px; left: 35%; animation-delay: -14s; }
.mesh::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(to bottom, black, transparent 70%);
}
:root[data-theme="light"] .mesh::after { background-image: radial-gradient(rgba(20,20,60,.06) 1px, transparent 1px); }
@keyframes float { to { transform: translate3d(60px, 40px, 0) scale(1.12); } }

/* ---------- layout ---------- */
.app { position: relative; z-index: 1; display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 6px;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(24px) saturate(1.4); -webkit-backdrop-filter: blur(24px) saturate(1.4);
  z-index: 20;
}
.logo { display: flex; align-items: center; gap: 11px; padding: 4px 10px 22px; }
.logo-mark {
  width: 36px; height: 36px; border-radius: 11px; background: var(--grad);
  display: grid; place-items: center; box-shadow: 0 8px 24px -6px rgba(139,92,246,.7);
}
.logo-mark svg { width: 20px; height: 20px; color: #fff; }
.logo b { font-size: 16px; letter-spacing: -.02em; display: block; line-height: 1.1; }
.logo small { color: var(--muted); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.nav-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
  text-decoration: none; color: var(--text-2); font-weight: 500; position: relative;
  transition: background .2s, color .2s;
}
.nav a svg { width: 18px; height: 18px; opacity: .85; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--surface-2); color: var(--text); }
.nav a.active::before {
  content: ""; position: absolute; left: -16px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--grad);
}
.nav a .badge { margin-left: auto; }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--grad); display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; flex: none; }
.side-foot .who { flex: 1; min-width: 0; }
.side-foot .who b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.side-foot .who small { color: var(--muted); font-size: 11px; }

.main { flex: 1; margin-left: var(--sidebar); min-width: 0; padding: 0 32px 48px; }
.topbar {
  position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 18px 0 16px; margin: 0 -32px; padding-left: 32px; padding-right: 32px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(20px) saturate(1.3); -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.page-title h1 { margin: 0; font-size: 22px; letter-spacing: -.03em; font-weight: 700; }
.page-title p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- controls ---------- */
.seg {
  display: inline-flex; padding: 4px; gap: 2px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); position: relative;
}
.seg button {
  border: 0; background: transparent; padding: 7px 13px; border-radius: 10px; cursor: pointer;
  color: var(--text-2); font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  transition: color .2s, background .2s;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface-solid); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.06) inset, 0 4px 14px -4px rgba(0,0,0,.4); }
:root[data-theme="light"] .seg button.on { box-shadow: 0 1px 3px rgba(20,20,50,.12); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
  padding: 9px 14px; border-radius: 12px; cursor: pointer; font-weight: 600; font-size: 13px;
  transition: transform .15s, background .2s, border-color .2s, box-shadow .2s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-2); }
.btn:active { transform: scale(.97); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 8px 24px -8px rgba(139,92,246,.7); }
.btn.primary:hover { box-shadow: var(--glow); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--neg); }
.btn.icon { padding: 9px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.date-btn { position: relative; }
.popover {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 280px;
  background: var(--surface-solid); border: 1px solid var(--border-2); border-radius: 16px; padding: 8px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.6); display: none; animation: pop .18s ease-out;
}
.popover.open { display: block; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.popover .opt { display: flex; justify-content: space-between; width: 100%; border: 0; background: transparent; padding: 9px 12px; border-radius: 10px; cursor: pointer; text-align: left; font-weight: 500; }
.popover .opt:hover, .popover .opt.on { background: var(--surface-2); }
.popover .opt small { color: var(--muted); }
.popover .custom { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 6px 4px; border-top: 1px solid var(--border); margin-top: 6px; }
.popover .custom .btn { grid-column: span 2; }

.input, select.input {
  width: 100%; padding: 10px 13px; border-radius: 12px; border: 1px solid var(--border-2);
  background: var(--surface); outline: none; transition: border-color .2s, box-shadow .2s;
}
.input:focus { border-color: var(--a1); box-shadow: 0 0 0 4px rgba(139,92,246,.18); }
label.f { display: block; }
label.f span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
label.f em { font-style: normal; color: var(--muted); font-weight: 400; font-size: 11.5px; display: block; margin-top: 5px; }

.sync-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); font-size: 12px; color: var(--text-2); cursor: pointer;
}
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--pos); position: relative; }
.pulse::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--pos); opacity: 0; animation: ping 2s infinite; }
.pulse.err { background: var(--neg); } .pulse.err::after { border-color: var(--neg); }
.pulse.run { background: var(--warn); } .pulse.run::after { border-color: var(--warn); }
.pulse.off { background: var(--muted); } .pulse.off::after { display: none; }
@keyframes ping { 0% { transform: scale(.6); opacity: .8; } 100% { transform: scale(1.6); opacity: 0; } }

/* ---------- cards & grid ---------- */
.view { animation: rise .45s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 20px; box-shadow: var(--shadow);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-h h3 { margin: 0; font-size: 14.5px; font-weight: 700; letter-spacing: -.01em; }
.card-h p { margin: 0; color: var(--muted); font-size: 12px; }
.card-h .r { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.hero { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr) minmax(0, 1fr); margin-top: 8px; }
.hero-main { overflow: hidden; padding: 24px; }
.hero-main::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(135deg, rgba(139,92,246,.6), transparent 40%, rgba(34,211,238,.45));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none;
}
.hero-main .glow-orb { position: absolute; width: 300px; height: 300px; border-radius: 50%; right: -90px; top: -120px; background: radial-gradient(circle, rgba(139,92,246,.35), transparent 65%); pointer-events: none; }
.eyebrow { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .02em; display: flex; align-items: center; gap: 8px; }
.big { font-size: 44px; font-weight: 800; letter-spacing: -.045em; line-height: 1.05; margin: 10px 0 6px; }
.big .cur { font-size: .6em; color: var(--text-2); margin-right: 2px; vertical-align: .18em; font-weight: 700; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { display: flex; gap: 22px; margin-top: 18px; flex-wrap: wrap; }
.hero-sub div small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.hero-sub div b { font-size: 17px; letter-spacing: -.02em; }

.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 700; padding: 3px 7px; border-radius: 999px; }
.delta.up { color: var(--pos); background: var(--pos-bg); }
.delta.down { color: var(--neg); background: var(--neg-bg); }
.delta.flat { color: var(--muted); background: var(--surface-2); }
.delta svg { width: 11px; height: 11px; }

.gauge-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.gauge { position: relative; width: 168px; height: 168px; margin: 4px auto 6px; }
.gauge svg { width: 100%; height: 100%; transform: rotate(135deg); }
.gauge .track { stroke: var(--surface-2); }
.gauge .val { transition: stroke-dashoffset 1.2s cubic-bezier(.2,.8,.2,1); }
.gauge .center { position: absolute; inset: 0; display: grid; place-content: center; }
.gauge .center b { font-size: 34px; font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.gauge .center small { color: var(--muted); font-size: 11.5px; margin-top: 4px; font-weight: 600; }
.legend-row { display: flex; gap: 14px; justify-content: center; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }

.profit-card { display: flex; flex-direction: column; }
.profit-card .big { font-size: 34px; }
.profit-bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 14px 0 10px; display: flex; }
.profit-bar i { display: block; height: 100%; transition: width 1s cubic-bezier(.2,.8,.2,1); }
.kv { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-2); padding: 4px 0; }
.kv b { color: var(--text); }

.kpis { grid-template-columns: repeat(4, 1fr); margin-top: 16px; }
.kpi { padding: 18px 18px 14px; overflow: hidden; transition: transform .25s, border-color .25s; }
.kpi:hover { transform: translateY(-2px); border-color: var(--border-2); }
.kpi .top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.kpi .lbl { color: var(--muted); font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.kpi .lbl .ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.kpi .lbl .ic svg { width: 14px; height: 14px; }
.kpi .v { font-size: 25px; font-weight: 800; letter-spacing: -.035em; margin: 10px 0 2px; }
.kpi .spark { height: 38px; margin: 6px -18px -14px; }
.kpi .spark svg { width: 100%; height: 100%; display: block; }

.row2 { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); margin-top: 16px; }
.chart-box { position: relative; height: 300px; }

.funnel { display: flex; flex-direction: column; gap: 10px; }
.f-step { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.f-step .name { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.f-step .val { font-size: 13px; font-weight: 700; text-align: right; }
.f-bar { grid-column: span 2; height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.f-bar i { display: block; height: 100%; border-radius: 99px; background: var(--grad); transition: width 1s cubic-bezier(.2,.8,.2,1); }
.f-rate { grid-column: span 2; font-size: 11px; color: var(--muted); margin-top: -2px; }
.f-rate b { color: var(--text-2); }

.brand-split { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.bs { padding: 16px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); }
.bs h4 { margin: 0 0 12px; display: flex; align-items: center; gap: 8px; font-size: 14px; }
.bs .m { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bs .m small { display: block; color: var(--muted); font-size: 11px; font-weight: 600; }
.bs .m b { font-size: 15px; letter-spacing: -.02em; }
.share { height: 6px; border-radius: 9px; background: var(--surface-2); margin-top: 12px; overflow: hidden; }
.share i { display: block; height: 100%; border-radius: 9px; }

/* ---------- creatives ---------- */
.cr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.cr { padding: 0; overflow: hidden; transition: transform .25s, border-color .25s; }
.cr:hover { transform: translateY(-3px); border-color: var(--border-2); }
.cr .thumb { aspect-ratio: 1 / 1; position: relative; background: var(--surface-2); overflow: hidden; }
.cr .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s; }
.cr:hover .thumb img { transform: scale(1.05); }
.cr .thumb .ph { position: absolute; inset: 0; display: grid; place-items: center; font-size: 34px; font-weight: 800; color: rgba(255,255,255,.85); }
.cr .thumb .tags { position: absolute; left: 10px; right: 10px; top: 10px; display: flex; justify-content: space-between; gap: 6px; }
.cr .thumb .roas-badge { position: absolute; right: 10px; bottom: 10px; padding: 6px 10px; border-radius: 10px; font-weight: 800; font-size: 13px; backdrop-filter: blur(10px); background: rgba(0,0,0,.55); color: #fff; }
.cr .thumb .roas-badge.good { background: rgba(16,185,129,.85); }
.cr .thumb .roas-badge.bad { background: rgba(225,29,72,.85); }
.cr .body { padding: 14px 14px 12px; }
.cr .body .t { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr .body .s { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.cr .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.cr .stats small { display: block; font-size: 10.5px; color: var(--muted); font-weight: 600; }
.cr .stats b { font-size: 13px; }
.strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(190px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; scrollbar-width: thin; }
.strip > * { scroll-snap-align: start; }

/* ---------- status chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .01em; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.chip.active { color: var(--pos); background: var(--pos-bg); }
.chip.paused { color: var(--muted); }
.chip.issue { color: var(--neg); background: var(--neg-bg); }
.chip.glass { background: rgba(0,0,0,.5); color: #fff; backdrop-filter: blur(8px); }
.chip .dot { width: 6px; height: 6px; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--neg); color: #fff; font-size: 11px; font-weight: 800; display: inline-grid; place-items: center; }

/* ---------- table ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0 16px; }
.search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.search input { padding-left: 38px; }
.tbl-wrap { overflow-x: auto; margin: -4px -20px -20px; }
table.tbl { width: 100%; border-collapse: collapse; min-width: 980px; }
.tbl th { text-align: right; font-size: 11.5px; color: var(--muted); font-weight: 700; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; user-select: none; white-space: nowrap; position: sticky; top: 0; }
.tbl th:first-child, .tbl td:first-child { text-align: left; padding-left: 20px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 20px; }
.tbl th.sorted { color: var(--text); }
.tbl th .arr { display: inline-block; margin-left: 4px; opacity: .8; }
.tbl td { padding: 13px 14px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; font-size: 13px; }
.tbl tr { transition: background .15s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .nm { display: flex; align-items: center; gap: 12px; max-width: 380px; }
.tbl .nm img, .tbl .nm .mini-ph { width: 38px; height: 38px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); }
.tbl .nm .txt { min-width: 0; }
.tbl .nm .txt b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.tbl .nm .txt small { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; }
.tbl tfoot td { font-weight: 800; border-top: 1px solid var(--border-2); border-bottom: 0; }
.roas-cell { font-weight: 700; }
.good { color: var(--pos); } .bad { color: var(--neg); } .meh { color: var(--warn); }
.mcards { display: none; }

/* ---------- actions ---------- */
.act-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.act { display: flex; gap: 14px; padding: 16px; align-items: flex-start; }
.act .thumb { width: 64px; height: 64px; border-radius: 14px; overflow: hidden; flex: none; background: var(--surface-2); }
.act .thumb img, .act .thumb > div { width: 100%; height: 100%; object-fit: cover; }
.act .ttl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.act .ttl b { font-size: 13.5px; }
.act p { margin: 6px 0 8px; color: var(--text-2); font-size: 12.5px; }
.act .meta { font-size: 11.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.act .nm { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.act.leak { border-left: 3px solid var(--neg); }
.act.loss { border-left: 3px solid var(--neg); }
.act.fatigue { border-left: 3px solid var(--warn); }
.act.hook { border-left: 3px solid var(--warn); }
.act.scale { border-left: 3px solid var(--pos); }
.tag { font-size: 10.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; }
.tag.leak, .tag.loss { color: var(--neg); background: var(--neg-bg); }
.tag.fatigue, .tag.hook { color: var(--warn); background: var(--warn-bg); }
.tag.scale { color: var(--pos); background: var(--pos-bg); }

/* ---------- settings ---------- */
.set-grid { grid-template-columns: 1fr 1fr; }
.brand-card .head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.brand-card .head .sw { width: 40px; height: 40px; border-radius: 12px; flex: none; position: relative; overflow: hidden; border: 1px solid var(--border-2); }
.brand-card .head .sw input { position: absolute; inset: -10px; width: 60px; height: 60px; border: 0; padding: 0; cursor: pointer; background: none; }
.brand-card .head input.name { font-size: 16px; font-weight: 700; background: transparent; border: 1px solid transparent; padding: 6px 8px; border-radius: 10px; flex: 1; min-width: 0; }
.brand-card .head input.name:hover, .brand-card .head input.name:focus { border-color: var(--border-2); outline: none; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.status-line { margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 12.5px; display: flex; gap: 8px; align-items: center; }
.status-line.err { background: var(--neg-bg); color: var(--neg); }
.status-line.ok { background: var(--pos-bg); color: var(--pos); }
.steps { counter-reset: s; margin: 0; padding: 0; list-style: none; }
.steps li { counter-increment: s; position: relative; padding: 0 0 14px 40px; color: var(--text-2); font-size: 13px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: -2px; width: 26px; height: 26px; border-radius: 8px; background: var(--info-bg); color: var(--a1); font-weight: 800; display: grid; place-items: center; font-size: 12px; }
.steps li b { color: var(--text); }
code.k { font-family: var(--mono); font-size: 11.5px; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }

/* ---------- empty / skeleton / toast ---------- */
.empty { text-align: center; padding: 56px 24px; }
.empty .ic { width: 64px; height: 64px; border-radius: 20px; background: var(--grad); display: grid; place-items: center; margin: 0 auto 18px; box-shadow: 0 16px 40px -10px rgba(139,92,246,.7); }
.empty .ic svg { width: 28px; height: 28px; color: #fff; }
.empty h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.03em; }
.empty p { margin: 0 auto 20px; color: var(--muted); max-width: 440px; }
.sk { background: linear-gradient(90deg, var(--surface-2) 0%, rgba(255,255,255,.09) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: sh 1.3s infinite; border-radius: 10px; }
:root[data-theme="light"] .sk { background: linear-gradient(90deg, rgba(0,0,0,.04), rgba(0,0,0,.08), rgba(0,0,0,.04)); background-size: 200% 100%; }
@keyframes sh { to { background-position: -200% 0; } }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 12px 16px; border-radius: 14px; background: var(--surface-solid); border: 1px solid var(--border-2); box-shadow: 0 20px 50px -15px rgba(0,0,0,.6); font-size: 13px; font-weight: 600; display: flex; gap: 10px; align-items: center; animation: pop .25s ease-out; max-width: 360px; }
.toast.err { border-color: rgba(251,113,133,.4); }
.toast.ok svg { color: var(--pos); } .toast.err svg { color: var(--neg); }
.toast svg { width: 18px; height: 18px; flex: none; }

.bottomnav { display: none; }
.mobile-only { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .hero { grid-template-columns: 1fr 1fr; }
  .hero-main { grid-column: span 2; }
  .row2 { grid-template-columns: 1fr; }
}
@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .set-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
  .topbar { margin: 0 -16px; padding: 14px 16px 12px; gap: 10px; }
  .page-title h1 { font-size: 20px; }
  .top-actions { margin-left: 0; width: 100%; }
  .top-actions .brand-seg { flex: 1 1 100%; overflow-x: auto; scrollbar-width: none; }
  .top-actions .brand-seg button { flex: 1 0 auto; justify-content: center; }
  .top-actions .date-btn { flex: 1; }
  .top-actions .date-btn > .btn { width: 100%; justify-content: space-between; }
  .top-actions .brand-seg::-webkit-scrollbar { display: none; }
  .mobile-only { display: inline-flex; }
  .desktop-only { display: none !important; }
  .hero { grid-template-columns: 1fr; }
  .hero-main { grid-column: auto; }
  .big { font-size: 38px; }
  .kpis { gap: 10px; }
  .kpi { padding: 14px 14px 10px; }
  .kpi .v { font-size: 20px; }
  .kpi .spark { margin: 6px -14px -10px; height: 30px; }
  .kpi .lbl .ic { display: none; }
  .card { padding: 16px; border-radius: 18px; }
  .chart-box { height: 240px; }
  .tbl-wrap { display: none; }
  .mcards { display: grid; gap: 10px; }
  .mcard { padding: 14px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); }
  .mcard .h { display: flex; gap: 10px; align-items: center; }
  .mcard .h img, .mcard .h .mini-ph { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; flex: none; background: var(--surface-2); }
  .mcard .h .t { min-width: 0; flex: 1; }
  .mcard .h .t b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mcard .h .t small { color: var(--muted); font-size: 11.5px; display: flex; gap: 6px; align-items: center; }
  .mcard .g { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
  .mcard .g small { display: block; color: var(--muted); font-size: 10.5px; font-weight: 600; }
  .mcard .g b { font-size: 14px; }
  .cr-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cr .body { padding: 10px; }
  .cr .stats { grid-template-columns: repeat(2, 1fr); }
  .cr .stats div:nth-child(3) { display: none; }
  .act-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .toasts { left: 16px; right: 16px; bottom: calc(90px + env(safe-area-inset-bottom)); }
  .popover { position: fixed; left: 16px; right: 16px; top: auto; bottom: calc(90px + env(safe-area-inset-bottom)); min-width: 0; }

  .bottomnav {
    display: flex; position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 30;
    justify-content: space-around; padding: 8px; border-radius: 22px;
    background: color-mix(in srgb, var(--bg-2) 80%, transparent); border: 1px solid var(--border-2);
    backdrop-filter: blur(24px) saturate(1.5); -webkit-backdrop-filter: blur(24px) saturate(1.5);
    box-shadow: 0 20px 50px -10px rgba(0,0,0,.5);
  }
  .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 4px; border-radius: 14px; text-decoration: none; color: var(--muted); font-size: 10.5px; font-weight: 700; position: relative; }
  .bottomnav a svg { width: 21px; height: 21px; }
  .bottomnav a.active { color: var(--text); background: var(--surface-2); }
  .bottomnav a.active svg { color: var(--a1); }
  .bottomnav a .badge { position: absolute; top: 2px; right: calc(50% - 22px); min-width: 16px; height: 16px; font-size: 9.5px; padding: 0 4px; }
}
@media (max-width: 380px) {
  .big { font-size: 32px; }
  .kpi .v { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* default sizing for inline icons that have no explicit size */
.status-line svg { width: 16px; height: 16px; flex: none; }
.empty .ic svg { flex: none; }
