/* ================================================================
   CortexAI — design system
   Dark operations console. Built mobile-first.
   ================================================================ */

:root {
  --bg:            #070a14;
  --bg-2:          #0b1020;
  --surface:       rgba(19, 26, 48, 0.72);
  --surface-solid: #131a30;
  --surface-hi:    rgba(30, 40, 70, 0.85);
  --line:          rgba(126, 150, 220, 0.16);
  --line-hi:       rgba(126, 150, 220, 0.32);

  --text:          #e8ecf8;
  --text-dim:      #9aa6c8;
  --text-faint:    #6b779b;

  --accent:        #5eead4;
  --accent-2:      #818cf8;
  --accent-3:      #c084fc;

  --critical:      #f87171;
  --high:          #fb923c;
  --medium:        #fbbf24;
  --low:           #60a5fa;
  --info:          #94a3b8;
  --ok:            #34d399;

  --radius:   16px;
  --radius-s: 10px;
  --shadow:   0 18px 48px rgba(0, 0, 0, 0.45);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

/* An author `display` rule beats the UA stylesheet's [hidden] rule, so any
   element given display:grid/flex would stay visible when hidden. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(1100px 620px at 82% -8%, rgba(129, 140, 248, 0.20), transparent 62%),
    radial-gradient(900px 560px at 8% 4%, rgba(94, 234, 212, 0.13), transparent 58%),
    radial-gradient(800px 700px at 50% 100%, rgba(192, 132, 252, 0.10), transparent 62%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4 { line-height: 1.18; letter-spacing: -0.02em; margin: 0 0 .5em; font-weight: 650; }
h1 { font-size: clamp(2rem, 6.4vw, 3.6rem); letter-spacing: -0.035em; }
h2 { font-size: clamp(1.5rem, 4.4vw, 2.3rem); letter-spacing: -0.028em; }
h3 { font-size: clamp(1.08rem, 2.6vw, 1.32rem); }
p  { margin: 0 0 1em; }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 820px; }

.muted  { color: var(--text-dim); }
.faint  { color: var(--text-faint); }
.mono   { font-family: var(--mono); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

/* ---------- Header ---------- */
.site-head {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  background: rgba(7, 10, 20, 0.78);
  border-bottom: 1px solid var(--line);
}
.site-head .wrap { display: flex; align-items: center; gap: 16px; height: 62px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 680; letter-spacing: -0.02em; color: var(--text); font-size: 1.06rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 9px; flex: none;
  background: linear-gradient(140deg, var(--accent), var(--accent-2) 55%, var(--accent-3));
  display: grid; place-items: center; color: #061018; font-weight: 800; font-size: 13px;
  box-shadow: 0 0 22px rgba(94, 234, 212, 0.35);
}
.nav-links { display: none; gap: 26px; margin-left: auto; }
.nav-links a { color: var(--text-dim); font-size: .93rem; font-weight: 500; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.head-cta { margin-left: auto; display: flex; gap: 10px; align-items: center; }
@media (min-width: 900px) {
  .nav-links { display: flex; }
  .head-cta { margin-left: 26px; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 11px; border: 1px solid var(--line-hi);
  background: var(--surface-hi); color: var(--text);
  font: inherit; font-size: .93rem; font-weight: 560; cursor: pointer;
  transition: transform .12s ease, border-color .18s ease, background .18s ease, opacity .18s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #05131a; border-color: transparent; font-weight: 660;
  box-shadow: 0 10px 30px rgba(94, 234, 212, 0.22);
}
.btn-primary:hover { border-color: transparent; box-shadow: 0 14px 38px rgba(94, 234, 212, 0.32); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 7px 13px; font-size: .84rem; border-radius: 9px; }
.btn-danger { border-color: rgba(248, 113, 113, .4); color: #fca5a5; }
.btn-danger:hover { border-color: var(--critical); }
.btn-block { width: 100%; }

/* ---------- Cards / panels ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.card-hover { transition: border-color .2s, transform .2s; }
.card-hover:hover { border-color: var(--line-hi); transform: translateY(-2px); }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr; }
.g3 { grid-template-columns: 1fr; }
.g4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) { .g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); } }

/* ---------- Landing ---------- */
.hero { padding: 68px 0 40px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .76rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); font-weight: 640;
  border: 1px solid rgba(94, 234, 212, .28); background: rgba(94, 234, 212, .07);
  padding: 6px 13px; border-radius: 999px; margin-bottom: 22px;
}
.hero h1 span.grad {
  background: linear-gradient(120deg, var(--accent), var(--accent-2) 48%, var(--accent-3));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lede { font-size: clamp(1.02rem, 2.4vw, 1.22rem); color: var(--text-dim); max-width: 62ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.hero-note { margin-top: 16px; font-size: .86rem; color: var(--text-faint); }

.section { padding: 56px 0; }
.section-head { max-width: 68ch; margin-bottom: 34px; }

/* Terminal-style demo block */
.terminal {
  background: rgba(4, 7, 16, 0.88); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden; font-family: var(--mono);
  font-size: .8rem; line-height: 1.72; box-shadow: var(--shadow);
}
.terminal-bar {
  display: flex; align-items: center; gap: 7px; padding: 10px 14px;
  border-bottom: 1px solid var(--line); background: rgba(255,255,255,.02);
}
.tdot { width: 10px; height: 10px; border-radius: 50%; }
.terminal-title { margin-left: 8px; font-size: .74rem; color: var(--text-faint); letter-spacing: .04em; }
.terminal-body { padding: 16px; overflow-x: auto; white-space: pre; color: var(--text-dim); }
.terminal-body .t-ok   { color: var(--ok); }
.terminal-body .t-crit { color: var(--critical); }
.terminal-body .t-warn { color: var(--medium); }
.terminal-body .t-acc  { color: var(--accent); }
.terminal-body .t-dim  { color: var(--text-faint); }

/* Detector catalogue chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-size: .78rem; padding: 6px 11px; border-radius: 8px;
  border: 1px solid var(--line); background: rgba(255,255,255,.03);
  color: var(--text-dim); font-family: var(--mono);
}
.chip-crit { border-color: rgba(248,113,113,.3); color: #fca5a5; }
.chip-high { border-color: rgba(251,146,60,.3); color: #fdba74; }

/* Autonomy ladder */
.ladder { display: grid; gap: 12px; counter-reset: rung; }
.rung {
  display: grid; grid-template-columns: 38px 1fr; gap: 14px; align-items: start;
  padding: 18px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface);
}
.rung-n {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  font-family: var(--mono); font-size: .82rem; font-weight: 700;
  background: rgba(129,140,248,.14); color: var(--accent-2); border: 1px solid rgba(129,140,248,.3);
}
.rung.is-featured { border-color: rgba(94,234,212,.4); background: rgba(94,234,212,.05); }
.rung h3 { margin-bottom: 4px; }
.rung p { margin: 0; font-size: .92rem; color: var(--text-dim); }

/* Pricing */
.price-card { display: flex; flex-direction: column; }
.price-card.featured { border-color: rgba(94,234,212,.42); box-shadow: 0 0 0 1px rgba(94,234,212,.16), var(--shadow); }
.price-tag { font-size: 2.4rem; font-weight: 700; letter-spacing: -0.04em; margin: 6px 0 2px; }
.price-tag small { font-size: .92rem; font-weight: 500; color: var(--text-faint); letter-spacing: 0; }
.feature-list { list-style: none; padding: 0; margin: 18px 0 22px; display: grid; gap: 9px; font-size: .9rem; }
.feature-list li { display: flex; gap: 9px; align-items: flex-start; color: var(--text-dim); }
.feature-list li::before { content: "✓"; color: var(--accent); font-weight: 700; flex: none; }
.feature-list li.off { color: var(--text-faint); }
.feature-list li.off::before { content: "—"; color: var(--text-faint); }
.price-card .btn { margin-top: auto; }

/* FAQ */
details.faq {
  border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 16px 18px; background: var(--surface); margin-bottom: 10px;
}
details.faq summary { cursor: pointer; font-weight: 580; list-style: none; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after { content: "+"; float: right; color: var(--accent); font-weight: 700; }
details.faq[open] summary::after { content: "−"; }
details.faq p { margin: 12px 0 0; color: var(--text-dim); font-size: .93rem; }

/* Footer */
.site-foot { border-top: 1px solid var(--line); padding: 34px 0; margin-top: 40px; font-size: .87rem; color: var(--text-faint); }
.foot-row { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; justify-content: space-between; }
.foot-links { display: flex; flex-wrap: wrap; gap: 16px; }
.site-foot a { color: var(--text-dim); }

/* ================================================================
   Console
   ================================================================ */
.app-shell { padding: 22px 0 80px; }

.stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
@media (min-width: 860px) { .stat-row { grid-template-columns: repeat(4, 1fr); } }
.stat {
  padding: 16px; border-radius: var(--radius-s); border: 1px solid var(--line);
  background: var(--surface);
}
.stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-faint); margin-bottom: 6px; }
.stat-value { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.stat-sub { font-size: .8rem; color: var(--text-faint); margin-top: 3px; }

/* Health ring */
.ring { position: relative; width: 76px; height: 76px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring-val {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 1.28rem; font-weight: 700; letter-spacing: -0.03em;
}

.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 20px; padding-bottom: 0; }
.tab {
  padding: 10px 15px; border: 0; background: transparent; color: var(--text-dim);
  font: inherit; font-size: .9rem; font-weight: 540; cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab .count { font-family: var(--mono); font-size: .74rem; opacity: .75; margin-left: 5px; }

.panel { display: none; }
.panel.active { display: block; }

/* Severity */
.sev {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .7rem; text-transform: uppercase; letter-spacing: .09em; font-weight: 680;
  padding: 3px 8px; border-radius: 6px; border: 1px solid currentColor;
}
.sev-critical { color: var(--critical); background: rgba(248,113,113,.09); }
.sev-high     { color: var(--high);     background: rgba(251,146,60,.09); }
.sev-medium   { color: var(--medium);   background: rgba(251,191,36,.09); }
.sev-low      { color: var(--low);      background: rgba(96,165,250,.09); }
.sev-info     { color: var(--info);     background: rgba(148,163,184,.09); }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.dot-ok { background: var(--ok); box-shadow: 0 0 8px rgba(52,211,153,.6); }
.dot-warn { background: var(--medium); box-shadow: 0 0 8px rgba(251,191,36,.6); }
.dot-bad { background: var(--critical); box-shadow: 0 0 8px rgba(248,113,113,.6); }
.dot-idle { background: var(--text-faint); }

/* List rows */
.row-list { display: grid; gap: 10px; }
.row {
  display: grid; gap: 10px; padding: 15px 16px;
  border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface);
  transition: border-color .18s;
}
.row:hover { border-color: var(--line-hi); }
.row-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-title { font-weight: 590; font-size: .97rem; }
.row-sub { font-size: .82rem; color: var(--text-faint); font-family: var(--mono); word-break: break-all; }
.row-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: .8rem; color: var(--text-dim); }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.row-body { font-size: .9rem; color: var(--text-dim); }
.spacer { flex: 1 1 auto; }

/* Forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .82rem; color: var(--text-dim); margin-bottom: 6px; font-weight: 540; }
input[type=text], input[type=url], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 10px 13px; border-radius: var(--radius-s);
  border: 1px solid var(--line); background: rgba(4,8,18,.62); color: var(--text);
  font: inherit; font-size: .93rem;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(94,234,212,.12); }
textarea { min-height: 120px; resize: vertical; font-family: var(--mono); font-size: .85rem; line-height: 1.6; }
.field-row { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .field-row { grid-template-columns: 1fr 1fr; } }
.hint { font-size: .78rem; color: var(--text-faint); margin-top: 5px; }

/* Code block */
pre.code {
  background: rgba(4,7,16,.9); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 14px; overflow-x: auto; font-family: var(--mono); font-size: .8rem;
  line-height: 1.65; color: #cbd5f5; margin: 0; white-space: pre;
}

/* Modal */
.modal-back {
  position: fixed; inset: 0; z-index: 200; background: rgba(3,6,14,.78);
  backdrop-filter: blur(6px); display: none; align-items: flex-start; justify-content: center;
  padding: 20px; overflow-y: auto;
}
.modal-back.open { display: flex; }
.modal {
  background: var(--surface-solid); border: 1px solid var(--line-hi);
  border-radius: var(--radius); width: 100%; max-width: 660px; padding: 24px;
  box-shadow: var(--shadow); margin: auto;
}
.modal-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.modal-head h3 { margin: 0; flex: 1; }
.modal-close { background: none; border: 0; color: var(--text-faint); font-size: 1.5rem; cursor: pointer; line-height: 1; padding: 0 4px; }

/* Toast */
.toast-stack { position: fixed; bottom: 20px; left: 20px; right: 20px; z-index: 300; display: grid; gap: 8px; pointer-events: none; }
@media (min-width: 640px) { .toast-stack { left: auto; width: 380px; } }
.toast {
  background: var(--surface-solid); border: 1px solid var(--line-hi); border-left: 3px solid var(--accent);
  border-radius: var(--radius-s); padding: 13px 15px; font-size: .9rem; box-shadow: var(--shadow);
  animation: toast-in .22s ease;
}
.toast.err { border-left-color: var(--critical); }
.toast.ok  { border-left-color: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.empty { text-align: center; padding: 44px 20px; color: var(--text-faint); }
.empty h3 { color: var(--text-dim); }

.loading { display: inline-block; width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.16); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Sparkline */
.spark { display: block; width: 100%; height: 38px; }

/* Auth screen */
.auth-wrap { min-height: 82vh; display: grid; place-items: center; padding: 30px 20px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-toggle { display: flex; gap: 4px; background: rgba(4,8,18,.6); padding: 4px; border-radius: var(--radius-s); margin-bottom: 20px; }
.auth-toggle button { flex: 1; padding: 8px; border: 0; background: transparent; color: var(--text-dim); font: inherit; font-size: .9rem; border-radius: 7px; cursor: pointer; }
.auth-toggle button.active { background: var(--surface-hi); color: var(--text); }

.badge-owner { font-size: .68rem; padding: 2px 7px; border-radius: 5px; background: rgba(192,132,252,.16); color: var(--accent-3); border: 1px solid rgba(192,132,252,.3); text-transform: uppercase; letter-spacing: .08em; font-weight: 680; }
.badge-plan  { font-size: .68rem; padding: 2px 7px; border-radius: 5px; background: rgba(94,234,212,.13); color: var(--accent); border: 1px solid rgba(94,234,212,.28); text-transform: uppercase; letter-spacing: .08em; font-weight: 680; }

.legal { padding: 40px 0 70px; }
.legal h2 { margin-top: 34px; }
.legal p, .legal li { color: var(--text-dim); font-size: .95rem; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
