/* ============================================================================
   North Lab · AI Manager — custom UI.
   Dark (deep navy + periwinkle #8ca2d5) by default; light = milky blue.
   ========================================================================== */
:root {
  color-scheme: dark;
  --bg: #06080f;
  --bg-2: #0a0d18;
  --surface: #111726;
  --surface-2: #161d30;
  --sheen: rgba(255, 255, 255, .04);
  --border: rgba(140, 162, 213, .15);
  --border-strong: rgba(140, 162, 213, .38);
  --text: #eaf0fb;
  --muted: #9fb0d0;
  --faint: #6b7ba4;
  --accent: #8ca2d5;
  --accent-ink: #b7c7ef;
  --accent-rgb: 140, 162, 213;
  --accent-2-rgb: 120, 147, 218;
  --grad: linear-gradient(135deg, #8ca2d5, #c7d4f2);
  --btn-grad: linear-gradient(135deg, #5a6fd0, #8ca2d5);
  --btn-text: #ffffff;
  --ok: #6ee7b7;
  --warn: #fbbf24;
  --bad: #fb7185;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-sm: 0 6px 20px rgba(0, 0, 0, .4);
  --shadow: 0 26px 60px rgba(3, 6, 18, .7);
  --glow: 0 0 40px rgba(140, 162, 213, .22);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eaf0fb;
  --bg-2: #e3ebf8;
  --surface: #fbfcff;
  --surface-2: #f0f4fd;
  --sheen: rgba(255, 255, 255, .6);
  --border: #dfe7f5;
  --border-strong: rgba(79, 104, 178, .4);
  --text: #101a30;
  --muted: #55638a;
  --faint: #8a97b6;
  --accent: #5b74c4;
  --accent-ink: #3f57ad;
  --accent-rgb: 91, 116, 196;
  --accent-2-rgb: 63, 87, 173;
  --grad: linear-gradient(135deg, #3f57ad, #6d86c4);
  --btn-grad: linear-gradient(135deg, #3f57ad, #5f78c8);
  --btn-text: #ffffff;
  --ok: #059669;
  --warn: #b45309;
  --bad: #e11d48;
  --shadow-sm: 0 6px 20px rgba(31, 51, 102, .1);
  --shadow: 0 26px 55px rgba(31, 51, 102, .16);
  --glow: 0 0 40px rgba(91, 116, 196, .2);
}

* { box-sizing: border-box; }

body {
  margin: 0; min-height: 100vh; font-family: var(--font); font-size: 15px; line-height: 1.6;
  letter-spacing: -.008em; color: var(--text);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  background:
    radial-gradient(900px 520px at 10% -8%, rgba(var(--accent-rgb), .16), transparent 58%),
    radial-gradient(780px 500px at 100% -4%, rgba(var(--accent-2-rgb), .12), transparent 55%),
    radial-gradient(700px 700px at 50% 120%, rgba(var(--accent-rgb), .08), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
  background-attachment: fixed;
  transition: background .4s ease, color .25s ease;
}

#cursor-glow {
  position: fixed; top: 0; left: 0; width: 520px; height: 520px; margin: -260px 0 0 -260px;
  border-radius: 50%; pointer-events: none; z-index: 0; opacity: .95;
  background: radial-gradient(circle, rgba(var(--accent-rgb), .20), rgba(var(--accent-2-rgb), .08) 44%, transparent 70%);
  filter: blur(40px); mix-blend-mode: screen;
}
:root[data-theme="light"] #cursor-glow { mix-blend-mode: multiply; opacity: .45; }

/* ---- Top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 22px;
  padding: 14px 32px; background: color-mix(in srgb, var(--bg) 68%, transparent);
  border-bottom: 1px solid var(--border); backdrop-filter: blur(18px) saturate(160%);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-cat { filter: drop-shadow(0 2px 6px rgba(var(--accent-rgb), .5)); flex: none; }
.brand-name { font-weight: 800; font-size: 15.5px; letter-spacing: -.02em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-name em { font-style: normal; font-weight: 600; opacity: .62; }
.nav { display: flex; gap: 4px; margin-right: auto; margin-left: 8px; flex-wrap: wrap; }
.nav a { padding: 8px 13px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 550; font-size: 14px; transition: color .15s, background .15s; }
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--accent-ink); background: rgba(var(--accent-rgb), .14); }

#theme-toggle {
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 16px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; color: var(--text);
  border: 1px solid var(--border); background: var(--surface-2); transition: transform .25s ease, border-color .2s, box-shadow .2s;
}
#theme-toggle:hover { transform: rotate(-12deg) scale(1.08); border-color: var(--border-strong); box-shadow: var(--glow); }

.demo-banner { text-align: center; font-size: 12.5px; font-weight: 600; letter-spacing: .01em; padding: 7px 24px; color: var(--accent-ink); background: rgba(var(--accent-rgb), .1); border-bottom: 1px solid var(--border); }

.shell { position: relative; z-index: 1; max-width: 1080px; margin: 0 auto; padding: 32px 32px 96px; }

/* ---- Page header ---- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 24px; }
h1 { margin: 0; font-size: 32px; font-weight: 800; letter-spacing: -.04em; }
.sub { margin: 7px 0 0; color: var(--muted); font-size: 14.5px; }
.page-actions { display: flex; gap: 10px; align-items: center; }

/* ---- Buttons & inputs ---- */
.btn {
  font-family: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border: none; border-radius: var(--radius-sm); font-weight: 650; font-size: 14px; cursor: pointer;
  color: var(--btn-text); background: var(--btn-grad);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28), 0 8px 22px rgba(var(--accent-rgb), .32);
  transition: transform .08s ease, box-shadow .2s ease, filter .2s ease;
}
.btn:hover { filter: brightness(1.07); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 12px 30px rgba(var(--accent-rgb), .5); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; box-shadow: none; filter: grayscale(.2); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border-strong); box-shadow: none; }
.btn.ghost:hover { background: var(--surface-2); filter: none; box-shadow: none; }

.select { font-family: inherit; padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 14px; cursor: pointer; }
.link { color: var(--accent-ink); text-decoration: none; font-weight: 600; }
.link:hover { text-decoration: underline; }
.muted { color: var(--muted); }

/* ---- Cards ---- */
.card {
  position: relative; background: linear-gradient(180deg, var(--sheen), transparent 120px), var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 26px; margin: 16px 0;
  box-shadow: var(--shadow-sm); animation: rise .55s cubic-bezier(.2, .7, .2, 1) both;
}
.card > h2 { margin: 0 0 16px; font-size: 11.5px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .14em; }

.status { margin: 14px 0; padding: 12px 15px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--muted); font-size: 14px; }
.status.error { color: var(--bad); border-color: rgba(251, 113, 133, .35); background: rgba(251, 113, 133, .08); }

/* ---- KPI ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(186px, 1fr)); gap: 14px; margin: 16px 0; }
.kpi-card {
  position: relative; background: linear-gradient(180deg, var(--sheen), transparent 90px), var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 18px 16px; box-shadow: var(--shadow-sm);
  overflow: hidden; animation: rise .55s cubic-bezier(.2, .7, .2, 1) both;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.kpi-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: var(--grad); opacity: .9; }
.kpi-card::after { content: ""; position: absolute; inset: 0; background: radial-gradient(130px 90px at 82% -10%, rgba(var(--accent-rgb), .16), transparent 70%); opacity: 0; transition: opacity .2s ease; }
.kpi-card:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.kpi-card:hover::after { opacity: 1; }
.kpi-label { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: capitalize; }
.kpi-value { font-size: 27px; font-weight: 800; margin: 9px 0 4px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kpi-change { font-size: 12.5px; font-weight: 600; }
.kpi-card:nth-child(2) { animation-delay: .04s; } .kpi-card:nth-child(3) { animation-delay: .08s; }
.kpi-card:nth-child(4) { animation-delay: .12s; } .kpi-card:nth-child(5) { animation-delay: .16s; }
.kpi-card:nth-child(6) { animation-delay: .2s; }
.positive { color: var(--ok); }
.negative { color: var(--bad); }

/* ---- Insights ---- */
.insight-list { display: grid; gap: 12px; }
.insight-card { border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius); padding: 16px 18px; background: var(--surface-2); transition: transform .16s ease, box-shadow .16s ease; }
.insight-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.insight-card.critical { border-left-color: #f43f5e; }
.insight-card.high { border-left-color: #fb7185; }
.insight-card.medium { border-left-color: #fbbf24; }
.insight-card.low { border-left-color: #64748b; }
.insight-card h3 { margin: 0 0 7px; font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; }
.insight-card p { margin: 5px 0; color: var(--text); opacity: .82; font-size: 14px; }
.insight-card small { color: var(--faint); font-size: 12px; }
.exposure { font-weight: 700; margin-top: 9px; color: var(--accent-ink); }

/* ---- Capabilities / settings ---- */
.capability-list { display: grid; gap: 4px; }
.capability { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 13px 2px; border-bottom: 1px solid var(--border); }
.capability:last-child { border-bottom: none; }
.badge { padding: 4px 11px; border-radius: 99px; background: rgba(var(--accent-rgb), .16); color: var(--accent-ink); font-size: 11.5px; font-weight: 600; }
.settings-list { margin: 0; }
.settings-list > div { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.settings-list > div:last-child { border-bottom: none; }
.settings-list dt { font-weight: 600; }
.settings-list dd { margin: 0; color: var(--muted); }

/* ---- Ask / export ---- */
.ask-row { display: flex; gap: 10px; margin-bottom: 12px; }
.ask-row input { flex: 1; padding: 12px 15px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; font-family: inherit; outline: none; background: var(--surface-2); color: var(--text); transition: border-color .15s, box-shadow .15s; }
.ask-row input::placeholder { color: var(--faint); }
.ask-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(var(--accent-rgb), .18); }
.export-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }

/* ---- Onboarding ---- */
.onboarding-card { border: 1px solid var(--border-strong); background: linear-gradient(155deg, rgba(var(--accent-rgb), .12), var(--surface) 55%); border-radius: var(--radius); padding: 20px 22px; margin: 14px 0; box-shadow: var(--glow); }
.onboarding-card h3 { margin: 0 0 12px; font-size: 16px; }
.onboarding-steps { margin: 8px 0 16px; padding-left: 18px; display: grid; gap: 9px; font-size: 14px; }
.onboarding-steps li.done { color: var(--ok); }
.onboarding-steps li.pending { color: var(--warn); }

/* ---- Plans ---- */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(238px, 1fr)); gap: 16px; }
.plan-card { position: relative; border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; background: linear-gradient(180deg, var(--sheen), transparent 140px), var(--surface); display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow-sm); transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
.plan-card:hover { transform: translateY(-6px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.plan-card.current { border-color: transparent; box-shadow: inset 0 0 0 1.5px var(--accent), var(--glow); }
.plan-card.current::after { content: "Current"; position: absolute; top: 16px; right: 16px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; padding: 4px 10px; border-radius: 99px; background: var(--btn-grad); color: var(--btn-text); }
.plan-card h3 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.plan-price { font-size: 36px; font-weight: 800; line-height: 1.15; letter-spacing: -.03em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.plan-price span { font-size: 14px; font-weight: 400; color: var(--muted); -webkit-text-fill-color: var(--muted); }
.plan-card ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); display: grid; gap: 6px; }
.plan-card ul li::marker { color: var(--accent); }
.plan-card .btn { margin-top: auto; }

/* ---- Icons ---- */
.ico { flex: none; vertical-align: -.18em; }
.nav a { display: inline-flex; align-items: center; gap: 7px; }
.nav a .ico { opacity: .85; }
#theme-toggle .ico { color: var(--text); }
.btn .ico { margin-right: 2px; }

/* ---- Hero ---- */
.hero { padding: 26px 28px 8px; }
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.hero-label { color: var(--muted); font-size: 13px; font-weight: 500; letter-spacing: .01em; }
.hero-value { font-size: 46px; font-weight: 850; letter-spacing: -.04em; line-height: 1.1; margin: 8px 0 8px; font-variant-numeric: tabular-nums; }
.hero-sub { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.hero-chart { margin: 12px -28px -8px; height: 200px; }
.chart { width: 100%; height: 200px; display: block; }
.chart-line { stroke-dasharray: 2000; stroke-dashoffset: 2000; animation: draw 1.4s cubic-bezier(.4, 0, .2, 1) forwards; filter: drop-shadow(0 4px 10px rgba(var(--accent-rgb), .5)); }
.chart-area { opacity: 0; animation: fade .9s ease .5s forwards; }
.chart-dot { opacity: 0; animation: fade .4s ease 1.3s forwards; filter: drop-shadow(0 0 6px rgba(var(--accent-rgb), .9)); }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade { to { opacity: 1; } }

/* ---- Change pill ---- */
.pill { display: inline-flex; align-items: center; gap: 3px; padding: 3px 9px 3px 6px; border-radius: 99px; font-size: 12.5px; font-weight: 700; }
.pill.up { color: var(--ok); background: color-mix(in srgb, var(--ok) 16%, transparent); }
.pill.down { color: var(--bad); background: color-mix(in srgb, var(--bad) 16%, transparent); }

/* ---- KPI internals ---- */
.kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi-ico { display: inline-flex; width: 30px; height: 30px; align-items: center; justify-content: center; border-radius: 9px; color: var(--accent-ink); background: rgba(var(--accent-rgb), .12); }
.kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; min-height: 22px; }
.spark { width: 96px; height: 30px; opacity: .9; }

/* ---- Insights extras ---- */
.insight-card .do { opacity: 1; color: var(--text); }
.exposure { display: inline-flex; align-items: center; gap: 6px; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 26px; color: var(--muted); text-align: center; }
.empty .ico { color: var(--ok); }
.ai-body { display: flex; gap: 10px; align-items: flex-start; }
.ai-body .ico { color: var(--accent-ink); margin-top: 3px; flex: none; }
.ai-body p { margin: 0; font-size: 15px; }

/* ---- Skeletons ---- */
.skel { border-radius: 8px; background: linear-gradient(100deg, var(--surface-2) 30%, rgba(var(--accent-rgb), .1) 50%, var(--surface-2) 70%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
.skel-sm { height: 13px; width: 38%; margin-bottom: 12px; }
.skel-lg { height: 26px; width: 62%; }
.skel-xl { height: 46px; width: 46%; margin: 8px 0 14px; }
.skel-chart { height: 150px; width: 100%; border-radius: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---- Premium ambient layer ---- */
body::before, body::after {
  content: ""; position: fixed; width: 62vw; height: 62vw; max-width: 880px; max-height: 880px;
  border-radius: 50%; filter: blur(100px); z-index: 0; pointer-events: none; opacity: .55;
  background: radial-gradient(circle, rgba(var(--accent-rgb), .30), transparent 65%);
}
body::before { top: -22vw; left: -12vw; animation: drift1 24s ease-in-out infinite; }
body::after { bottom: -26vw; right: -16vw; background: radial-gradient(circle, rgba(var(--accent-2-rgb), .26), transparent 65%); animation: drift2 30s ease-in-out infinite; }
:root[data-theme="light"] body::before, :root[data-theme="light"] body::after { opacity: .4; }
@keyframes drift1 { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(7vw, 5vw) scale(1.08); } }
@keyframes drift2 { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(-6vw, -7vw) scale(1.1); } }

#grain {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .045; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.topbar::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: var(--grad); opacity: .7; }

.card { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05), var(--shadow-sm); }
.kpi-card:hover, .plan-card:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 0 0 1px var(--border-strong), var(--shadow), 0 0 36px rgba(var(--accent-rgb), .16); }

.hero { position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; top: 0; left: -60%; width: 45%; height: 100%; pointer-events: none; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .07), transparent); transform: skewX(-18deg); animation: sheen 2.8s ease .4s 1; }
@keyframes sheen { to { left: 135%; } }
.hero-value { text-shadow: 0 0 42px rgba(var(--accent-rgb), .28); }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent-ink); margin-right: 7px; vertical-align: middle; animation: pulse 2s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), .5); } 70% { box-shadow: 0 0 0 8px rgba(var(--accent-rgb), 0); } 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); } }

.btn { position: relative; overflow: hidden; }
.btn::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(100deg, transparent 32%, rgba(255, 255, 255, .28), transparent 68%); transform: translateX(-120%); transition: transform .6s ease; }
.btn:hover::after { transform: translateX(120%); }

.chart-grid { stroke: rgba(255, 255, 255, .06); stroke-width: 1; }
:root[data-theme="light"] .chart-grid { stroke: rgba(16, 24, 48, .07); }

@media (max-width: 640px) {
  .topbar { padding: 12px 16px; gap: 12px; }
  .brand-name em { display: none; }
  .shell { padding: 22px 16px 68px; }
  h1 { font-size: 26px; }
  .settings-list > div { grid-template-columns: 1fr; gap: 4px; }
  .plan-grid { grid-template-columns: 1fr; }
  .ask-row { flex-direction: column; }
  #cursor-glow { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  #cursor-glow { display: none; }
}

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.section-head h2 { margin: 0; }
.insight-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.insight-actions .btn { padding: 7px 12px; font-size: 12px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
td:first-child { white-space: normal; min-width: 220px; }
.settings-form { display: grid; gap: 12px; max-width: 560px; }
.settings-form > label:not(.check-row) { color: var(--muted); font-size: 13px; font-weight: 650; }
.settings-form input[type="email"] { padding: 12px 15px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font: inherit; }
.check-row { display: flex; align-items: center; gap: 10px; }
