/* Dashboardz Reports. Dark by default; [data-theme=light] switches every token. */
:root, [data-theme="dark"] {
  --bg: #0b1120; --bg-2: #0f172a; --panel: #131c31; --panel-2: #1a2540; --line: #24314f; --line-2: #2f3f63;
  --text: #e6ebf5; --muted: #8b98b3; --faint: #5b6886;
  --primary: #3b82f6; --primary-2: #2563eb; --accent: #8b5cf6;
  --up: #22c55e; --down: #f87171; --warn: #f59e0b;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --grid: rgba(139,152,179,.14);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #eef2f8; --bg-2: #ffffff; --panel: #ffffff; --panel-2: #f5f7fb; --line: #e2e8f0; --line-2: #cbd5e1;
  --text: #0f172a; --muted: #5b6b85; --faint: #94a3b8;
  --primary: #2563eb; --primary-2: #1d4ed8; --accent: #7c3aed;
  --up: #16a34a; --down: #dc2626; --warn: #d97706;
  --shadow: 0 10px 30px rgba(15,23,42,.08);
  --grid: rgba(15,23,42,.08);
  color-scheme: light;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--text); }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, sans-serif; line-height: 1.45; font-size: 14px; min-height: 100vh; }
a { color: var(--primary); text-decoration: none; } a:hover { text-decoration: underline; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .center { text-align: center; justify-content: center; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; color: var(--text); }
.brand img { width: 28px; height: 28px; border-radius: 7px; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text);
  padding: 9px 16px; border-radius: 10px; font-weight: 650; font-size: 14px; cursor: pointer; transition: .15s; }
.btn:hover { border-color: var(--primary); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; } .btn.primary:hover { background: var(--primary-2); }
.btn.ghost { background: transparent; } .btn.sm { padding: 6px 12px; font-size: 13px; } .btn.full { width: 100%; justify-content: center; margin-top: 20px; padding: 12px; }
.btn:disabled { opacity: .55; cursor: progress; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); cursor: pointer; }
.icon-btn:hover { border-color: var(--primary); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 7px; } .icon-btn.sm svg { width: 15px; height: 15px; }
.icon-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
[data-theme="dark"] .i-moon, [data-theme="light"] .i-sun { display: none; }
.sel { background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 8px; padding: 5px 8px; font-size: 12.5px; }

/* messages */
.msg { padding: 11px 14px; border-radius: 10px; font-size: 13.5px; margin-bottom: 12px; }
.msg.err { background: rgba(248,113,113,.12); color: var(--down); border: 1px solid rgba(248,113,113,.35); }
.msg.ok { background: rgba(34,197,94,.12); color: var(--up); border: 1px solid rgba(34,197,94,.35); }

/* auth */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 16px;
  background: radial-gradient(circle at 15% 0%, rgba(59,130,246,.16), transparent 50%), radial-gradient(circle at 100% 100%, rgba(139,92,246,.14), transparent 50%), var(--bg); }
.auth-card { width: 100%; max-width: 410px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 34px 30px; box-shadow: var(--shadow); }
.auth-card .brand { margin-bottom: 22px; }
.auth-card h1 { font-size: 22px; text-align: center; margin-bottom: 4px; }
.auth-card > p.muted { margin-bottom: 20px; }
.auth-card label { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 6px; }
.auth-card input:not([type=checkbox]) { width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text); font-size: 15px; }
.auth-card input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.25); }
.auth-card .row { margin-top: 14px; } .check { display: flex !important; gap: 8px; align-items: center; font-weight: 500 !important; margin: 0 !important; }
.hint { color: var(--muted); font-size: 12px; margin-top: 5px; } .alt { margin-top: 18px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* app shell */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--bg-2); border-bottom: 1px solid var(--line); }
.top-right { display: flex; align-items: center; gap: 10px; }
.shell { display: flex; min-height: calc(100vh - 55px); }
.side { position: sticky; top: 55px; height: calc(100vh - 55px); width: 232px; flex: none; display: flex; flex-direction: column; justify-content: space-between;
  background: var(--bg-2); border-right: 1px solid var(--line); transition: width .2s; overflow: hidden; }
.side-list { overflow-y: auto; padding: 10px 8px; display: flex; flex-direction: column; gap: 3px; }
.side-item { display: flex; align-items: center; gap: 11px; padding: 7px 8px; border-radius: 10px; color: var(--text); white-space: nowrap; border: 1px solid transparent; }
.side-item:hover { background: var(--panel-2); text-decoration: none; }
.side-item.on { background: var(--panel-2); border-color: var(--primary); }
.side-item img, .side-item .badge { width: 30px; height: 30px; border-radius: 8px; flex: none; object-fit: cover; background: #fff; }
.side-item .badge { display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 12px; }
.side-name { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; }
.side-toggle { margin: 10px; height: 38px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); cursor: pointer; }
.side-closed .side { width: 64px; } .side-closed .side-name { display: none; }
.main { flex: 1; min-width: 0; padding: 22px 22px 60px; }
.site-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 16px; }
.site-head h1 { font-size: 24px; }

/* report area: platform rail + content */
.report { display: flex; gap: 16px; align-items: flex-start; }
.plats { position: sticky; top: 75px; display: flex; flex-direction: column; gap: 8px; width: 132px; flex: none; }
.plat { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); color: var(--text); font-weight: 650; font-size: 13.5px; }
.plat .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--pc); flex: none; }
.plat:hover { border-color: var(--pc); text-decoration: none; }
.plat.on { border-color: var(--pc); box-shadow: inset 3px 0 0 var(--pc); background: var(--panel-2); }
.plat.off { opacity: .45; }
.area { flex: 1; min-width: 0; }
.periods { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.seg { display: flex; gap: 4px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; flex-wrap: wrap; }
.seg-btn { padding: 7px 13px; border-radius: 8px; color: var(--muted); font-weight: 650; font-size: 13px; }
.seg-btn:hover { color: var(--text); text-decoration: none; background: var(--panel-2); }
.seg-btn.on { background: var(--primary); color: #fff; }
.btn.analyze { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; border: 0; }
.btn.analyze svg { fill: currentColor; stroke: none; }

/* cards grid: size follows the card type */
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; grid-auto-flow: row dense; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; min-width: 0; display: flex; flex-direction: column; }
.span-1 { grid-column: span 1; } .span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h3 { font-size: 14px; font-weight: 700; }
.tools { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.kpi { cursor: pointer; transition: .15s; }
.kpi:hover { border-color: var(--line-2); }
.kpi.sel-on { border-color: var(--primary); box-shadow: inset 0 3px 0 var(--primary); }
.kpi .k { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi .v { font-size: 26px; font-weight: 800; margin: 4px 0 2px; letter-spacing: -.02em; }
.kpi .d { font-size: 12.5px; font-weight: 650; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--muted); }
.chart-box { position: relative; height: 270px; } .chart-box.short { height: 220px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.chip { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; }
.chip.on { color: #fff; border-color: transparent; }
.tbl-wrap { overflow: auto; max-height: 360px; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { position: sticky; top: 0; background: var(--panel-2); text-align: left; font-weight: 650; color: var(--muted); padding: 8px 10px; cursor: pointer; white-space: nowrap; user-select: none; }
th.n, td.n { text-align: right; } th:hover { color: var(--text); }
th.sorted::after { content: " \25BE"; } th.sorted.asc::after { content: " \25B4"; }
td { padding: 7px 10px; border-top: 1px solid var(--line); vertical-align: top; }
td.key { width: 100%; max-width: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.n { white-space: nowrap; }
tr:hover td { background: var(--panel-2); }
.filter { background: var(--bg-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 8px; padding: 5px 9px; font-size: 12.5px; width: 150px; }
.tbl-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; color: var(--muted); font-size: 12px; }
.state { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--muted); }
.state.live, .state.published { color: var(--up); border-color: rgba(34,197,94,.4); }
.state.scheduled { color: var(--warn); border-color: rgba(245,158,11,.4); }
.empty-card { grid-column: span 4; text-align: center; padding: 50px 20px; color: var(--muted); border: 2px dashed var(--line-2); border-radius: 14px; }
.empty-card strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 6px; }
.loading { grid-column: span 4; color: var(--muted); padding: 40px; text-align: center; }
.note { grid-column: span 4; color: var(--muted); font-size: 12.5px; }

/* analysis + chat */
.analysis { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 14px; padding: 16px 18px; margin-bottom: 14px; }
.analysis h4 { font-size: 14px; margin: 12px 0 6px; } .analysis ul { padding-left: 20px; } .analysis li { margin: 3px 0; }
.analysis .meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.chat { margin-top: 14px; }
.chat-log { max-height: 380px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 10px; }
.bubble { max-width: 85%; padding: 10px 13px; border-radius: 12px; font-size: 13.5px; white-space: pre-wrap; }
.bubble.me { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.bubble.ai { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; white-space: normal; }
.bubble.ai ul { padding-left: 18px; } .bubble.ai h4 { margin: 8px 0 4px; font-size: 13.5px; }
.bubble.err { align-self: flex-start; color: var(--down); background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.3); }
.chat-form { display: flex; gap: 10px; align-items: flex-end; }
.chat-form textarea { flex: 1; resize: vertical; background: var(--bg-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; font: inherit; }
.chat-form textarea:focus { outline: none; border-color: var(--primary); }

/* modal (expanded card) */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(2,6,23,.7); display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-box { position: relative; width: min(1200px, 100%); max-height: 92vh; overflow: auto; background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px; padding: 18px; }
.modal-x { position: absolute; top: 12px; right: 12px; font-size: 20px; }
.modal .card { border: 0; padding: 0; } .modal .chart-box { height: 60vh; } .modal .tbl-wrap { max-height: 70vh; }

@media (max-width: 1200px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cards > .span-3, .cards > .span-4, .empty-card, .loading, .note { grid-column: span 2; } }
@media (max-width: 860px) {
  .report { flex-direction: column; } .plats { position: static; flex-direction: row; width: 100%; overflow-x: auto; }
  .plat { flex: none; } .side { width: 64px; } .side-name { display: none; }
}
@media (max-width: 560px) {
  .main { padding: 16px 12px 50px; } .cards { grid-template-columns: minmax(0, 1fr); }
  .cards > .span-1, .cards > .span-2, .cards > .span-3, .cards > .span-4, .empty-card, .loading, .note { grid-column: span 1; }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .kpi .v { font-size: 21px; }
  .hide-sm { display: none; } .side { display: none; } .seg-btn { padding: 6px 9px; }
}
