/* ProAI Analytics - handcrafted design system. Light + dark, responsive. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --elevated: #ffffff;
  --border: #e7eaee;
  --border-strong: #d6dbe2;
  --text: #0f1720;
  --text-2: #55606e;
  --text-3: #8a94a2;
  --brand: #2f8199;
  --brand-2: #4aa6bf;
  --brand-ink: #0f4a5a;
  --brand-tint: #e9f4f7;
  --good: #1f9d68;
  --good-tint: #e5f5ee;
  --warn: #d9932b;
  --warn-tint: #fbf1df;
  --bad: #d9534f;
  --bad-tint: #fbeceb;
  --info: #3f6fd1;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -12px rgba(16, 24, 40, .16);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar: 244px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

:root[data-theme="dark"],
:root[data-theme="dark"] * { color-scheme: dark; }

.dark-tokens,
:root[data-theme="dark"] {
  --bg: #0c1013;
  --surface: #141a1f;
  --surface-2: #10161a;
  --elevated: #182027;
  --border: #232c34;
  --border-strong: #2d3843;
  --text: #eef2f5;
  --text-2: #a3afba;
  --text-3: #6c7884;
  --brand: #4aa6bf;
  --brand-2: #6fc0d5;
  --brand-ink: #bfe4ee;
  --brand-tint: #12262d;
  --good-tint: #10241b;
  --warn-tint: #241d10;
  --bad-tint: #24110f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 8px 30px -12px rgba(0, 0, 0, .6);
}

/* Follow the OS setting when the user has not chosen an explicit theme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1013;
    --surface: #141a1f;
    --surface-2: #10161a;
    --elevated: #182027;
    --border: #232c34;
    --border-strong: #2d3843;
    --text: #eef2f5;
    --text-2: #a3afba;
    --text-3: #6c7884;
    --brand: #4aa6bf;
    --brand-2: #6fc0d5;
    --brand-ink: #bfe4ee;
    --brand-tint: #12262d;
    --good-tint: #10241b;
    --warn-tint: #241d10;
    --bad-tint: #24110f;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 8px 30px -12px rgba(0, 0, 0, .6);
  }
}

* { 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;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 3px solid var(--bg); }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; color: #fff; box-shadow: var(--shadow-sm);
}
.brand-name { font-weight: 700; letter-spacing: -.02em; font-size: 15px; }
.brand-name span { color: var(--text-3); font-weight: 500; }
.nav { flex: 1; overflow-y: auto; padding: 6px 12px 16px; }
.nav-group { margin-top: 14px; }
.nav-group > .label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); padding: 6px 10px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px;
  color: var(--text-2); font-weight: 500; font-size: 13.5px; position: relative; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--brand-tint); color: var(--brand-ink); }
.nav-item.active .ic { color: var(--brand); }
.nav-item .ic { width: 17px; height: 17px; flex: none; color: var(--text-3); }
.nav-item .dot { margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); }
.nav-item.active .dot { background: var(--brand); }

.side-foot { padding: 12px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; }
.user-chip .meta { min-width: 0; }
.user-chip .nm { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .rl { font-size: 11px; color: var(--text-3); }

/* ---------- Main ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.scrim { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px; padding: 12px 22px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(140%) blur(10px); border-bottom: 1px solid var(--border);
}
.topbar .page-title { font-size: 16px; font-weight: 650; }
.topbar .site-pill { font-size: 12px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); padding: 3px 9px; border-radius: 999px; }
.spacer { flex: 1; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 7px 11px; color: var(--text-3); width: 230px; max-width: 34vw; }
.search input { border: 0; background: transparent; outline: none; color: var(--text); font: inherit; width: 100%; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn .badge-count { position: absolute; top: -5px; right: -5px; background: var(--bad); color: #fff; font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 5px; }

.content { padding: 22px; max-width: 1360px; width: 100%; margin: 0 auto; }

/* toolbar (date range etc.) */
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; box-shadow: var(--shadow-sm); }
.seg a { padding: 6px 11px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.seg a.on { background: var(--brand); color: #fff; }
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 600; font-size: 13px; cursor: pointer; }
.btn:hover { border-color: var(--brand); color: var(--brand-ink); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); color: #fff; }

/* ---------- Cards & grid ---------- */
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(4, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.span-2 { grid-column: span 2; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card.pad { padding: 18px; }
.card-h { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.card-h h3 { font-size: 13.5px; font-weight: 650; }
.card-h .sub { font-size: 12px; color: var(--text-3); font-weight: 500; }
.card-b { padding: 16px 18px; }

.kpi { padding: 16px 18px; }
.kpi .lab { font-size: 12px; color: var(--text-3); font-weight: 600; display: flex; align-items: center; gap: 7px; }
.kpi .val { font-size: 27px; font-weight: 700; letter-spacing: -.02em; margin-top: 8px; }
.kpi .sub { margin-top: 6px; font-size: 12px; color: var(--text-3); }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.delta.up { color: var(--good); background: var(--good-tint); }
.delta.down { color: var(--bad); background: var(--bad-tint); }
.delta.flat { color: var(--text-3); background: var(--surface-2); }

/* ---------- Bars / lists ---------- */
.bars { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.bar-row .nm { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .vv { font-size: 12.5px; color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-track { grid-column: 1 / -1; height: 6px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }

.empty { text-align: center; padding: 30px 18px; color: var(--text-3); }
.empty .ic { width: 26px; height: 26px; margin: 0 auto 8px; color: var(--border-strong); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 480px; }
.tbl thead th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.tbl tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.badge.good { color: var(--good); background: var(--good-tint); }
.badge.warn { color: var(--warn); background: var(--warn-tint); }
.badge.bad { color: var(--bad); background: var(--bad-tint); }
.badge.muted { color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); }

/* CWV pill */
.cwv { display: flex; align-items: center; justify-content: space-between; padding: 13px 15px; border: 1px solid var(--border); border-radius: 12px; }
.cwv .m { font-size: 12px; color: var(--text-3); font-weight: 600; }
.cwv .v { font-size: 20px; font-weight: 700; margin-top: 3px; }
.cwv .r { width: 9px; height: 9px; border-radius: 50%; }
.r.good { background: var(--good); } .r.needs-improvement { background: var(--warn); } .r.poor { background: var(--bad); } .r.none { background: var(--border-strong); }

/* ---------- Realtime ---------- */
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 rgba(31, 157, 104, .5); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(31,157,104,.45); } 70% { box-shadow: 0 0 0 8px rgba(31,157,104,0); } 100% { box-shadow: 0 0 0 0 rgba(31,157,104,0); } }
.big-num { font-size: 54px; font-weight: 750; letter-spacing: -.03em; line-height: 1; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 70% -10%, var(--brand-tint), var(--bg)); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 30px; }
.auth-card h1 { font-size: 20px; }
.field { margin-top: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field input { width: 100%; padding: 11px 13px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface-2); color: var(--text); font: inherit; outline: none; }
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.auth-err { margin-top: 12px; font-size: 13px; color: var(--bad); background: var(--bad-tint); padding: 9px 12px; border-radius: 9px; }

/* ---------- Section (staged) ---------- */
.section-hero { text-align: center; padding: 26px; }
.section-hero .ic { width: 46px; height: 46px; margin: 0 auto 14px; color: var(--brand); background: var(--brand-tint); border-radius: 14px; display: grid; place-items: center; }
.section-hero h2 { font-size: 20px; }
.section-hero p { color: var(--text-2); max-width: 560px; margin: 10px auto 0; }
.integrations { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
.integ { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.integ .nm { font-weight: 600; }
.integ .st { margin-left: auto; }

/* ---------- Utilities ---------- */
.muted { color: var(--text-3); }
.hint { font-size: 12.5px; color: var(--text-3); }
.mt { margin-top: 16px; } .mt-lg { margin-top: 24px; }
.row { display: flex; align-items: center; gap: 10px; }
.hamburger { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) { .kpis { grid-template-columns: repeat(2, 1fr); } .cols-3 { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .scrim { position: fixed; inset: 0; background: rgba(8,12,16,.4); z-index: 35; }
  .scrim.show { display: block; }
  .hamburger { display: grid; }
  .cols-2 { grid-template-columns: 1fr; } .span-2 { grid-column: auto; }
  .search { display: none; }
  .integrations { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .content { padding: 16px; }
  .big-num { font-size: 44px; }
}
