/* ============ Reporting Hub – bright, professional theme ============ */
:root {
  color-scheme: light;
  --bg: #f5f7fb; --panel: #ffffff; --panel-2: #f9fafc; --ink: #0f172a; --ink-2: #334155; --muted: #64748b; --faint: #94a3b8;
  --line: #e6eaf1; --line-2: #eef1f6;
  --brand: #4f46e5; --brand-2: #0ea5e9; --brand-soft: #eef2ff; --brand-ink: #3730a3;
  --good: #059669; --good-soft: #ecfdf5; --bad: #dc2626; --bad-soft: #fef2f2; --warn: #d97706; --warn-soft: #fffbeb;
  --th: #f1f5f9; --total: #f8fafc;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow: 0 4px 16px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, .18);
  --r: 12px; --r-sm: 8px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 16px; font-weight: 600; letter-spacing: -.01em; margin: 0; }
h3 { font-size: 14px; font-weight: 600; margin: 0; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12px; }
.ico { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 16px; }

/* ---------- shell ---------- */
#shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
body.bare #shell { grid-template-columns: 1fr; } body.bare #side { display: none; }
#side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 700; font-size: 15px; color: var(--ink); letter-spacing: -.01em; }
.logo-mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); display: grid; place-items: center; color: #fff; box-shadow: 0 6px 16px rgba(79, 70, 229, .35); }
.logo-mark .ico { width: 18px; height: 18px; }
.logo small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: 0; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--panel-2); color: var(--ink); }
.nav a.on { background: var(--brand-soft); color: var(--brand-ink); }
.nav a.on .ico { color: var(--brand); }
.nav a .avatar { width: 20px; height: 20px; font-size: 10px; border-radius: 6px; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: flex; align-items: center; gap: 10px; }
.side-foot .who { min-width: 0; flex: 1; } .side-foot .who b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#main { min-width: 0; }
main#app { padding: 28px 32px 60px; max-width: 1480px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.crumb { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.crumb:hover { color: var(--brand); }

/* ---------- controls ---------- */
button, .btn { font: inherit; font-weight: 500; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2);
  border-radius: var(--r-sm); padding: 7px 12px; cursor: pointer; box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s, color .12s; white-space: nowrap; }
button:hover, .btn:hover { border-color: #cfd6e2; color: var(--ink); background: var(--panel-2); }
button.primary, .btn.primary { background: linear-gradient(180deg, #5b52ee, var(--brand)); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(79, 70, 229, .3), inset 0 1px 0 rgba(255, 255, 255, .15); }
button.primary:hover, .btn.primary:hover { background: var(--brand); color: #fff; }
button.ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--muted); padding: 6px 8px; }
button.ghost:hover { background: var(--panel-2); color: var(--ink); border-color: transparent; }
button.danger { color: var(--bad); } button.danger:hover { background: var(--bad-soft); border-color: #fecaca; }
button.sm { padding: 5px 9px; font-size: 12px; }
button:disabled { opacity: .55; cursor: default; }
input, select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); color: var(--ink); outline: none; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .14); }
select { padding-right: 28px; }
label.f { display: block; font-size: 12px; font-weight: 500; color: var(--ink-2); margin: 12px 0 5px; }
.field input, .field select { width: 100%; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.search { position: relative; } .search .ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search input { padding-left: 32px; }
.seg { display: inline-flex; background: var(--th); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.seg button { box-shadow: none; border: 0; background: transparent; padding: 5px 10px; font-size: 12.5px; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow-sm); }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.chk { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 99px; font-size: 12.5px; cursor: pointer; background: var(--panel); color: var(--ink-2); user-select: none; }
.chk:has(input:checked) { border-color: #c7d2fe; background: var(--brand-soft); color: var(--brand-ink); }
.chk input { margin: 0; accent-color: var(--brand); }
.grid-form { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

/* ---------- surfaces ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); }
.card.pad { padding: 20px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.card-head .sub { color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 2px; }
.card-body { padding: 18px; }
.section-title { display: flex; align-items: center; gap: 8px; margin: 30px 0 12px; }
.section-title .num { width: 22px; height: 22px; border-radius: 6px; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 500; background: var(--th); color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--good-soft); color: var(--good); } .badge.error { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); } .badge.run { background: var(--brand-soft); color: var(--brand); }
.badge.run::before { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .2; } }
.avatar { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; flex: none; letter-spacing: -.02em; }

/* clients grid */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { padding: 16px 18px; } .stat .l { font-size: 12px; color: var(--muted); font-weight: 500; } .stat .v { font-size: 24px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }
.clients { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.client-card { padding: 18px; display: flex; flex-direction: column; gap: 14px; color: inherit; transition: box-shadow .15s, border-color .15s, transform .15s; }
.client-card:hover { box-shadow: var(--shadow); border-color: #d5dbf5; transform: translateY(-1px); }
.client-card .top { display: flex; gap: 12px; align-items: center; }
.client-card .name { font-weight: 600; font-size: 15px; } .client-card .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.client-card .links { display: flex; gap: 6px; border-top: 1px solid var(--line-2); padding-top: 12px; }
.client-card .links span { font-size: 12px; color: var(--muted); padding: 4px 8px; border-radius: 6px; background: var(--panel-2); }
.client-card .links span:hover { color: var(--brand); background: var(--brand-soft); }
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty .ico { width: 36px; height: 36px; color: var(--faint); stroke-width: 1.5; margin-bottom: 8px; }

/* client header */
.client-head { padding: 18px 20px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.client-head .avatar { width: 48px; height: 48px; font-size: 17px; border-radius: 13px; }
.client-head .info { flex: 1; min-width: 220px; }
.client-head .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 4px; margin: 18px 0 22px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 10px 12px 11px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--brand); border-color: var(--brand); }

/* KPIs */
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 18px; }
.kpi { padding: 16px 18px; position: relative; overflow: hidden; }
.kpi .l { font-size: 12px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .v { font-size: 26px; font-weight: 700; margin-top: 8px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; gap: 8px; align-items: center; }
.delta { font-weight: 600; font-size: 12px; padding: 1px 6px; border-radius: 6px; }
.delta.up { color: var(--good); background: var(--good-soft); } .delta.down { color: var(--bad); background: var(--bad-soft); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }

/* chart */
.chart { width: 100%; height: 190px; display: block; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); } .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- data tables ---------- */
.tw { overflow: auto; max-height: 72vh; }
table.dt { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; font-size: 13px; }
table.dt th, table.dt td { padding: 8px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line-2); }
table.dt thead th { background: var(--th); color: var(--ink-2); font-weight: 600; font-size: 12px; position: sticky; top: 0; z-index: 2; border-bottom: 1px solid var(--line); }
table.dt thead tr + tr th { top: 33px; }
table.dt thead th.grp { text-align: center; border-left: 1px solid var(--line); color: var(--ink); }
table.dt th.gs, table.dt td.gs { border-left: 1px solid var(--line); }
table.dt th.sortable { cursor: pointer; user-select: none; } table.dt th.sortable:hover { color: var(--brand); }
table.dt th .arr { display: inline-block; width: 10px; color: var(--brand); font-size: 10px; margin-left: 3px; }
table.dt th .rng { display: block; font-weight: 400; color: var(--faint); font-size: 10.5px; }
table.dt td:first-child, table.dt th:first-child { text-align: left; position: sticky; left: 0; background: var(--panel); z-index: 1; box-shadow: 1px 0 0 var(--line); }
table.dt thead th:first-child { background: var(--th); z-index: 3; }
table.dt tbody tr:hover td { background: #f8faff; }
table.dt tbody tr:hover td:first-child { background: #f8faff; }
table.dt tr.total td { font-weight: 700; background: var(--total); border-top: 1px solid var(--line); position: sticky; bottom: 0; z-index: 1; }
table.dt td.mt, table.dt th.mt { background: #f8fafc; font-weight: 600; }
table.dt thead th.mt { background: #e9eef5; }
table.dt td.lbl { max-width: 460px; overflow: hidden; text-overflow: ellipsis; }
table.dt td.lbl .hide-row { visibility: hidden; margin-right: 6px; padding: 0; border: 0; background: none; box-shadow: none; color: var(--faint); vertical-align: -2px; }
table.dt tr:hover td.lbl .hide-row { visibility: visible; } table.dt td.lbl .hide-row:hover { color: var(--bad); }
table.dt tr.sec td { background: var(--panel-2); font-weight: 600; text-align: left; color: var(--brand-ink); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.heat { border-radius: 5px; padding: 2px 7px; font-weight: 600; display: inline-block; min-width: 38px; text-align: center; }
.databar { position: relative; } .databar > span { position: relative; z-index: 1; }
.databar::before { content: ""; position: absolute; right: 6px; top: 6px; bottom: 6px; width: calc(var(--w, 0) * (100% - 12px)); background: linear-gradient(90deg, rgba(79, 70, 229, .08), rgba(79, 70, 229, .22)); border-radius: 4px; }
.dt-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip-hidden { font-size: 12px; color: var(--warn); background: var(--warn-soft); border: 1px solid #fde68a; padding: 4px 10px; border-radius: 99px; cursor: pointer; box-shadow: none; }
.chip-hidden:hover { background: #fef3c7; color: var(--warn); border-color: #fcd34d; }
.dt-foot { padding: 10px 18px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line-2); display: flex; gap: 12px; }

/* popover / modal */
.pop { position: absolute; z-index: 40; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 10px; min-width: 260px; max-height: 420px; overflow: auto; }
.pop .grp { padding: 6px 4px; border-bottom: 1px solid var(--line-2); } .pop .grp:last-child { border: 0; }
.pop label { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.pop label:hover { background: var(--panel-2); } .pop label.g { font-weight: 600; } .pop label.c { padding-left: 26px; color: var(--ink-2); }
.pop input { accent-color: var(--brand); margin: 0; }
.pop .pop-foot { display: flex; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line-2); margin-top: 6px; }
.backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .38); backdrop-filter: blur(3px); z-index: 50; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; background: var(--panel); border-radius: 16px; box-shadow: var(--shadow-lg); animation: rise .18s; }
.modal.wide { max-width: 720px; }
.modal-head { padding: 20px 22px 6px; display: flex; gap: 12px; align-items: flex-start; }
.modal-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.modal-body { padding: 8px 22px 6px; } .modal-foot { padding: 16px 22px 20px; display: flex; gap: 8px; justify-content: flex-end; }
@keyframes fade { from { opacity: 0; } } @keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* integrations */
.int-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.int-card { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.int-logo { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; color: #fff; }
.int-logo .ico { width: 22px; height: 22px; }
.int-logo.meta { background: linear-gradient(135deg, #2563eb, #7c3aed); } .int-logo.shop { background: linear-gradient(135deg, #16a34a, #65a30d); } .int-logo.demo { background: linear-gradient(135deg, #64748b, #94a3b8); }
.conn-row { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.conn-row:last-child { border: 0; } .conn-row .int-logo { width: 34px; height: 34px; border-radius: 9px; } .conn-row .int-logo .ico { width: 17px; height: 17px; }
.conn-row .info { flex: 1; min-width: 200px; } .conn-row .err { margin-top: 4px; }
.steps { counter-reset: s; margin: 6px 0 4px; padding: 0; list-style: none; }
.steps li { counter-increment: s; position: relative; padding: 0 0 14px 34px; color: var(--ink-2); font-size: 13px; line-height: 1.55; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink); font-weight: 700; font-size: 11.5px; display: grid; place-items: center; }
.copy { display: flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; padding: 4px 4px 4px 10px; margin: 6px 0; }
.copy code { flex: 1; font-family: "JetBrains Mono", monospace; font-size: 12px; overflow-x: auto; white-space: nowrap; color: var(--ink); }
.callout { background: var(--brand-soft); border: 1px solid #e0e7ff; color: var(--brand-ink); border-radius: var(--r-sm); padding: 10px 12px; font-size: 12.5px; line-height: 1.5; }
.callout.warn { background: var(--warn-soft); border-color: #fde68a; color: #92400e; }
.err { color: var(--bad); font-size: 12px; white-space: pre-wrap; }
code { font-family: "JetBrains Mono", monospace; font-size: 11.5px; background: var(--th); padding: 1px 5px; border-radius: 4px; }

/* auth */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { background: radial-gradient(1200px 600px at 0% 0%, #6366f1 0%, transparent 60%), radial-gradient(900px 600px at 100% 100%, #0ea5e9 0%, transparent 55%), #312e81;
  color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255, 255, 255, .06) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .06) 1px, transparent 1px); background-size: 36px 36px; mask-image: linear-gradient(180deg, #000 30%, transparent); }
.auth-art > * { position: relative; z-index: 1; }
.auth-art h2 { font-size: 32px; line-height: 1.15; letter-spacing: -.03em; font-weight: 700; max-width: 440px; }
.auth-art p { color: rgba(255, 255, 255, .78); max-width: 420px; line-height: 1.6; }
.auth-art .feat { display: flex; gap: 10px; align-items: center; margin: 10px 0; color: rgba(255, 255, 255, .9); }
.auth-art .feat .ico { color: #a5f3fc; }
.auth-art .logo { color: #fff; padding: 0; } .auth-art .logo small { color: rgba(255, 255, 255, .7); }
.auth-form { display: grid; place-items: center; padding: 32px; background: var(--panel); }
.auth-form form { width: 100%; max-width: 360px; }
.auth-form h1 { font-size: 24px; } .auth-form p.sub { color: var(--muted); margin: 6px 0 18px; }
.auth-form input { width: 100%; padding: 10px 12px; }
.auth-form button.primary { width: 100%; justify-content: center; padding: 10px; margin-top: 20px; }

/* share header */
.share-bar { display: flex; align-items: center; gap: 14px; padding: 14px 32px; background: var(--panel); border-bottom: 1px solid var(--line); }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 10px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; pointer-events: none; z-index: 60; font-size: 13px; box-shadow: var(--shadow-lg); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.loading { display: grid; place-items: center; padding: 80px; }
.spin { width: 22px; height: 22px; border: 2.5px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  #shell { grid-template-columns: 1fr; }
  #side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  #side .logo { padding: 0 8px 0 0; } .nav-label { display: none; } .nav { display: flex; gap: 2px; flex-wrap: wrap; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; } .side-foot .who { display: none; }
  main#app { padding: 18px 16px 40px; }
  .auth-wrap { grid-template-columns: 1fr; } .auth-art { display: none; }
  .share-bar { padding: 12px 16px; }
}
@media print { #side, .tabs, button, .noprint, .dt-tools { display: none !important; } #shell { display: block; } main#app { padding: 0; max-width: none; } .tw { max-height: none; overflow: visible; } }

/* team-wide alert banner */
#alerts { position: sticky; top: 0; z-index: 30; }
.alert { display: flex; align-items: center; gap: 10px; padding: 10px 32px; font-size: 13px; font-weight: 500; border-bottom: 1px solid; flex-wrap: wrap; }
.alert.warn { background: var(--warn-soft); color: #92400e; border-color: #fde68a; }
.alert.error { background: var(--bad-soft); color: #991b1b; border-color: #fecaca; }
.alert .ico { flex: none; }
@media (max-width: 900px) { .alert { padding: 10px 16px; } }
