:root {
    --bg: #0b1120;
    --surface: #111c33;
    --surface-2: #16213d;
    --border: #1e2d4a;
    --text: #e6edf7;
    --muted: #93a4c3;
    --primary: #3b82f6;
    --primary-2: #2563eb;
    --green: #22c55e;
    --amber: #f59e0b;
    --red: #ef4444;
    --radius: 14px;
    --shadow: 0 8px 30px rgba(0,0,0,.25);
}

/* Light theme — overrides the dark defaults above. Higher specificity
   (html[data-theme="light"]) lets these win regardless of source order. */
html[data-theme="light"] {
    --bg: #eef2f7;
    --surface: #ffffff;
    --surface-2: #f3f6fb;
    --border: #dde5ef;
    --text: #0f172a;
    --muted: #5b6b85;
    --shadow: 0 10px 30px rgba(15, 23, 42, .08);
}
/* Translucent bars that hardcoded a dark backdrop. */
html[data-theme="light"] .topbar { background: rgba(255, 255, 255, .85); }
html[data-theme="light"] .lp-nav { background: rgba(238, 242, 247, .8); }
html[data-theme="light"] .legal-top { background: rgba(238, 242, 247, .9); }
html[data-theme="light"] .sidebar.admin { background: #fbfcff; border-right-color: var(--border); }
html[data-theme="light"] body.landing,
html[data-theme="light"].landing { background: radial-gradient(1200px 600px at 50% -200px, rgba(59,130,246,.10), transparent), var(--bg); }
/* Body text that hardcoded a light-grey meant for dark backgrounds. */
html[data-theme="light"] .lp-sub,
html[data-theme="light"] .lp-q,
html[data-theme="light"] .lp-checks li,
html[data-theme="light"] .legal-doc p,
html[data-theme="light"] .legal-doc li,
html[data-theme="light"] .cookie-consent .cc-text,
html[data-theme="light"] .msg.assistant { color: #334155; }
html[data-theme="light"] .lp-demo code { color: #334155; }
/* Flash text contrast on light tints. */
html[data-theme="light"] .flash.success { color: #15803d; }
html[data-theme="light"] .flash.error { color: #b91c1c; }
html[data-theme="light"] .flash.info { color: #1d4ed8; }

/* Theme toggle button */
.theme-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 12.5px; cursor: pointer; font-family: inherit; }
.theme-toggle:hover { border-color: var(--primary); }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14.5px;
    line-height: 1.5;
}
a { color: inherit; text-decoration: none; }

.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 248px; flex-shrink: 0; background: var(--surface);
    border-right: 1px solid var(--border); display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; font-weight: 700; font-size: 16px; }
.brand-mark { color: var(--primary); font-size: 18px; }
.side-nav { flex: 1; overflow-y: auto; padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.side-nav a .ico { width: 20px; text-align: center; }
.side-nav a:hover { background: var(--surface-2); color: var(--text); }
.side-nav a.active { background: linear-gradient(90deg, rgba(59,130,246,.18), rgba(59,130,246,.05)); color: #fff; box-shadow: inset 2px 0 0 var(--primary); }
.side-foot { padding: 14px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-2); display: grid; place-items: center; font-weight: 700; }
.u-name { font-weight: 600; font-size: 13px; }
.u-role { color: var(--muted); font-size: 11.5px; }
.logout { display: block; text-align: center; padding: 8px; border-radius: 9px; background: var(--surface-2); color: var(--muted); font-size: 13px; }
.logout:hover { color: var(--text); }

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 20px 26px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: rgba(11,17,32,.85); backdrop-filter: blur(8px); z-index: 10; }
.topbar h1 { font-size: 20px; margin: 0; }
.topbar .sub { color: var(--muted); margin: 2px 0 0; font-size: 13px; }
.topbar-actions { display: flex; gap: 8px; }
.content { padding: 24px 26px 90px; max-width: 1280px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 15px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-weight: 600; cursor: pointer; font-size: 13.5px; }
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary-2); border-color: var(--primary-2); color: #fff; }
.btn.primary:hover { background: var(--primary); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 12px; font-size: 12.5px; }
.btn.danger { background: transparent; border-color: var(--red); color: #fca5a5; }

/* Cards & grid */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card h3 { margin: 0 0 12px; font-size: 14px; color: var(--muted); font-weight: 600; }
.card.pad-lg { padding: 22px; }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 26px; font-weight: 750; margin-top: 6px; }
.stat .meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.stat.good { box-shadow: inset 3px 0 0 var(--green); }
.stat.warn { box-shadow: inset 3px 0 0 var(--amber); }
.stat.bad { box-shadow: inset 3px 0 0 var(--red); }
.stat.info { box-shadow: inset 3px 0 0 var(--primary); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th { text-align: left; padding: 12px 14px; color: var(--muted); font-weight: 600; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge.green { background: rgba(34,197,94,.15); color: #4ade80; }
.badge.amber { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge.red { background: rgba(239,68,68,.15); color: #f87171; }
.badge.blue { background: rgba(59,130,246,.15); color: #60a5fa; }
.badge.gray { background: rgba(148,163,184,.15); color: #cbd5e1; }

/* Forms */
form .field { margin-bottom: 14px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
input, select, textarea { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 14px; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea { min-height: 110px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 17px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.mt { margin-top: 18px; }
.empty { text-align: center; padding: 40px; color: var(--muted); }

/* Flash */
.flash { margin: 16px 26px 0; padding: 12px 16px; border-radius: 10px; font-weight: 500; }
.flash.success { background: rgba(34,197,94,.12); color: #86efac; border: 1px solid rgba(34,197,94,.3); }
.flash.error { background: rgba(239,68,68,.12); color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }
.flash.info { background: rgba(59,130,246,.12); color: #93c5fd; border: 1px solid rgba(59,130,246,.3); }

/* AI chat */
.chat { display: flex; flex-direction: column; gap: 12px; max-height: 60vh; overflow-y: auto; padding: 4px; }
.msg { max-width: 80%; padding: 12px 15px; border-radius: 14px; }
.msg.user { align-self: flex-end; background: var(--primary-2); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg .disclaimer { margin-top: 8px; font-size: 11px; color: var(--muted); border-top: 1px dashed var(--border); padding-top: 6px; }
.assistant-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.assistant-tabs a { padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border); color: var(--muted); font-weight: 600; }
.assistant-tabs a.active { background: var(--primary-2); border-color: var(--primary-2); color: #fff; }

/* Bottom nav (mobile) */
.bottom-nav { display: none; }

/* Login */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 32px; box-shadow: var(--shadow); }
.auth-card .brand { padding: 0 0 8px; font-size: 22px; }
.auth-card .tagline { color: var(--muted); margin-bottom: 22px; font-size: 13.5px; }
.demo-creds { margin-top: 18px; padding: 12px; background: var(--surface-2); border-radius: 10px; font-size: 12.5px; color: var(--muted); }

/* ---- Landing page ---- */
body.landing { background: radial-gradient(1200px 600px at 50% -200px, rgba(59,130,246,.18), transparent), var(--bg); }
.lp-nav { display: flex; align-items: center; justify-content: space-between; padding: 18px 32px; max-width: 1160px; margin: 0 auto; position: sticky; top: 0; background: rgba(11,17,32,.7); backdrop-filter: blur(10px); z-index: 20; }
.lp-nav .brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.lp-nav-links { display: flex; align-items: center; gap: 22px; }
.lp-nav-links a { color: var(--muted); font-weight: 600; font-size: 14px; }
.lp-nav-links a:hover { color: var(--text); }
.lp-nav-links a.btn { color: #fff; }

.lp-hero { max-width: 900px; margin: 0 auto; padding: 70px 24px 50px; text-align: center; }
.lp-eyebrow { display: inline-block; padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px; color: #93c5fd; font-size: 12.5px; font-weight: 600; letter-spacing: .03em; margin-bottom: 22px; background: rgba(59,130,246,.08); }
.lp-hero h1 { font-size: 52px; line-height: 1.08; margin: 0 0 18px; letter-spacing: -0.02em; }
.lp-hero .grad { background: linear-gradient(90deg, #60a5fa, #a78bfa); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lp-sub { font-size: 18px; color: var(--muted); max-width: 640px; margin: 0 auto 28px; line-height: 1.6; }
.lp-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.lp-cta .btn { padding: 12px 22px; font-size: 15px; }
.lp-demo { margin-top: 20px; font-size: 13px; }
.lp-demo code { background: var(--surface-2); padding: 2px 7px; border-radius: 6px; color: #cbd5e1; }

.lp-questions { max-width: 1000px; margin: 20px auto; padding: 30px 24px; text-align: center; }
.lp-questions h2 { font-size: 22px; margin-bottom: 22px; }
.lp-q-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.lp-q { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; color: #c8d3e6; font-size: 15px; font-style: italic; }

.lp-section { max-width: 1160px; margin: 0 auto; padding: 60px 24px; }
.lp-section-head { text-align: center; max-width: 620px; margin: 0 auto 38px; }
.lp-section-head h2 { font-size: 34px; margin: 0 0 10px; letter-spacing: -0.01em; }
.lp-modules { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.lp-module { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 26px; transition: border-color .2s, transform .2s; }
.lp-module:hover { border-color: var(--primary); transform: translateY(-3px); }
.lp-module-icon { font-size: 30px; margin-bottom: 12px; }
.lp-module h3 { margin: 0 0 8px; font-size: 18px; }
.lp-module p { font-size: 14px; line-height: 1.6; margin: 0; }

.lp-band { background: linear-gradient(180deg, rgba(59,130,246,.06), transparent); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.lp-band-inner { max-width: 1000px; margin: 0 auto; padding: 56px 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: center; }
.lp-band-inner h2 { font-size: 30px; margin: 0 0 14px; }
.lp-checks { list-style: none; padding: 0; margin: 0; }
.lp-checks li { padding: 10px 0 10px 30px; position: relative; border-bottom: 1px solid var(--border); color: #c8d3e6; }
.lp-checks li:before { content: "✓"; position: absolute; left: 0; color: var(--green); font-weight: 700; }

.lp-pricing { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; align-items: stretch; }
.lp-plan { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; position: relative; display: flex; flex-direction: column; }
.lp-plan.featured { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary), 0 20px 50px rgba(59,130,246,.15); }
.lp-plan-tag { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); background: var(--primary-2); color: #fff; font-size: 11.5px; font-weight: 700; padding: 4px 12px; border-radius: 999px; }
.lp-plan h3 { margin: 0 0 8px; font-size: 19px; }
.lp-price { font-size: 26px; font-weight: 750; margin-bottom: 12px; }
.lp-price .muted { font-size: 14px; font-weight: 500; }
.lp-plan-feat { font-size: 13.5px; line-height: 1.6; flex: 1; margin-bottom: 18px; }

.lp-final { text-align: center; max-width: 720px; margin: 0 auto; padding: 70px 24px 90px; }
.lp-final h2 { font-size: 32px; margin: 0 0 12px; }

.lp-footer { border-top: 1px solid var(--border); margin-top: 20px; }
.lp-footer-inner { max-width: 1160px; margin: 0 auto; padding: 40px 24px 24px; display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.lp-footer-inner .brand { font-weight: 700; display: inline-flex; gap: 8px; align-items: center; }
.lp-footer-links { display: flex; gap: 20px; flex-wrap: wrap; align-items: center; }
.lp-footer-links a { color: var(--muted); font-size: 14px; }
.lp-footer-links a:hover { color: var(--text); }
.lp-footer-base { max-width: 1160px; margin: 0 auto; padding: 16px 24px 40px; font-size: 12.5px; border-top: 1px solid var(--border); }

@media (max-width: 880px) {
    .lp-hero h1 { font-size: 36px; }
    .lp-q-grid, .lp-modules, .lp-pricing { grid-template-columns: 1fr; }
    .lp-band-inner { grid-template-columns: 1fr; }
    .lp-nav-links { gap: 14px; }
    .lp-nav-links a:not(.btn) { display: none; }
    .lp-section-head h2 { font-size: 26px; }
}

/* Legal pages (public) */
.legal-top { display: flex; align-items: center; justify-content: space-between; padding: 16px 26px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: rgba(11,17,32,.9); backdrop-filter: blur(8px); z-index: 10; }
.legal-top .brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.legal-shell { display: flex; gap: 30px; max-width: 1080px; margin: 0 auto; padding: 28px 26px 80px; }
.legal-nav { width: 200px; flex-shrink: 0; position: sticky; top: 90px; align-self: flex-start; }
.legal-nav-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; }
.legal-nav a { display: block; padding: 8px 12px; border-radius: 9px; color: var(--muted); font-weight: 500; margin-bottom: 2px; }
.legal-nav a:hover { background: var(--surface-2); color: var(--text); }
.legal-nav a.active { background: var(--surface); color: #fff; box-shadow: inset 2px 0 0 var(--primary); }
.legal-doc { flex: 1; min-width: 0; max-width: 760px; }
.legal-doc h1 { font-size: 28px; margin: 6px 0 4px; }
.legal-doc h2 { font-size: 18px; margin: 28px 0 10px; padding-top: 8px; }
.legal-doc h3 { font-size: 15px; margin: 18px 0 6px; color: var(--text); }
.legal-doc p, .legal-doc li { color: #c8d3e6; line-height: 1.7; }
.legal-doc ul, .legal-doc ol { padding-left: 22px; }
.legal-doc li { margin-bottom: 6px; }
.legal-doc .eff-date { color: var(--muted); font-size: 13px; }
.legal-doc table { margin: 12px 0; }
.legal-pdf-bar { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.legal-banner { background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.3); color: #fcd9a0; padding: 12px 16px; border-radius: 10px; font-size: 13px; margin-bottom: 22px; }
.legal-foot { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.legal-links a { color: var(--muted); }
.legal-links a:hover { color: var(--text); }
.legal-card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 18px; }

@media (max-width: 780px) {
    .legal-nav { display: none; }
    .legal-shell { padding: 18px 16px 70px; }
    .legal-card-grid { grid-template-columns: 1fr; }
}

/* App footer (operational layout) */
.app-footer { margin-top: auto; padding: 18px 26px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 12.5px; }
.app-footer-links { display: flex; gap: 14px; flex-wrap: wrap; }
.app-footer-links a { color: var(--muted); }
.app-footer-links a:hover { color: var(--text); }
.side-foot-links { margin-bottom: 10px; }
.side-foot-links a { display: block; text-align: center; font-size: 12px; color: var(--muted); padding: 4px; }
.side-foot-links a:hover { color: var(--text); }

/* Language toggle (legal header) */
.lang-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lang-toggle a { padding: 5px 10px; font-size: 12px; font-weight: 700; color: var(--muted); }
.lang-toggle a.active { background: var(--primary-2); color: #fff; }

/* Cookie consent banner */
.cookie-consent { position: fixed; bottom: 16px; left: 16px; right: 16px; max-width: 720px; margin: 0 auto; z-index: 200; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 14px 18px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.cookie-consent[hidden] { display: none; }
.cookie-consent .cc-text { flex: 1; min-width: 240px; font-size: 13px; color: #c8d3e6; }
.cookie-consent .cc-text a { color: var(--primary); }
.cookie-consent .cc-actions { display: flex; gap: 8px; }
@media (max-width: 880px) { .cookie-consent { bottom: 76px; } }

/* Admin / Platform console accents */
.admin-theme { --primary: #8b5cf6; --primary-2: #7c3aed; }
.sidebar.admin { background: #0d1326; border-right-color: #241b40; }
.sidebar.admin .side-nav a.active { background: linear-gradient(90deg, rgba(139,92,246,.20), rgba(139,92,246,.05)); box-shadow: inset 2px 0 0 var(--primary); }
.platform-badge { margin: 0 14px 8px; padding: 5px 10px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #c4b5fd; background: rgba(139,92,246,.14); border: 1px solid rgba(139,92,246,.3); border-radius: 8px; text-align: center; }
.avatar.admin { background: var(--primary-2); }
.nav-sep { height: 1px; background: var(--border); margin: 10px 12px; }
.admin-link { display: inline-flex; align-items: center; gap: 6px; }

/* Simple horizontal bar meter for analytics */
.meter { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--primary); }
.kv { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: none; }

@media (max-width: 880px) {
    .sidebar { display: none; }
    .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); justify-content: space-around; padding: 8px 4px env(safe-area-inset-bottom); z-index: 50; }
    .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 10px; }
    .bottom-nav a span { font-size: 19px; }
    .bottom-nav a.active { color: var(--primary); }
    .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .content { padding: 18px 16px 24px; }
    .app-footer { padding-bottom: 90px; flex-direction: column; align-items: flex-start; }
    .topbar { padding: 16px; }
}
@media (min-width: 881px) and (max-width: 1200px) {
    .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
    .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
}
