/* TIMxAI Security Modules Sandbox — labs UI */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #0b0d12;
  --bg-elev: #11141b;
  --bg-elev-2: #161a23;
  --line: #232836;
  --line-strong: #2f3547;
  --text: #e9edf6;
  --text-dim: #a3aabb;
  --text-faint: #6e7589;
  --accent: #56f0c5;
  --accent-2: #7aa8ff;
  --warn: #ffb05a;
  --bad: #ff6e7f;
  --good: #56f0c5;
  --shadow: 0 10px 40px rgba(0,0,0,0.45);
  --radius: 14px;
  --radius-sm: 9px;
  --t-fast: 140ms;
  --t-mid: 240ms;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

[data-theme="light"] {
  --bg: #f6f7fb;
  --bg-elev: #ffffff;
  --bg-elev-2: #f0f2f8;
  --line: #e3e6ef;
  --line-strong: #cdd2e1;
  --text: #14171f;
  --text-dim: #4d5365;
  --text-faint: #7a8095;
  --accent: #0c9c7c;
  --accent-2: #2563eb;
  --warn: #c2701f;
  --bad: #c8364a;
  --good: #0c9c7c;
  --shadow: 0 10px 36px rgba(20, 30, 60, 0.10);
}

html, body { margin: 0; padding: 0; }
html { color-scheme: dark light; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent-2); }

.skip {
  position: absolute; left: -9999px; top: auto;
  background: var(--accent); color: #000; padding: 8px 12px; border-radius: 8px;
  z-index: 1000;
}
.skip:focus { left: 12px; top: 12px; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: color-mix(in oklab, var(--bg) 80%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px; color: var(--text);
  font-weight: 600; letter-spacing: 0.2px;
}
.brand-mark { color: var(--accent); display: inline-flex; }
.brand-text { display: inline-flex; gap: 6px; align-items: baseline; }
.brand-org { color: var(--text); }
.brand-sep { color: var(--text-faint); }
.brand-product { color: var(--text-dim); font-weight: 500; }

.tabs {
  display: flex; gap: 4px; justify-self: center;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px; padding: 4px;
}
.tabs button {
  appearance: none; border: 0; background: transparent;
  color: var(--text-dim);
  padding: 8px 14px; border-radius: 999px;
  font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] {
  background: var(--bg-elev-2); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.tabs button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.topbar-actions { display: inline-flex; align-items: center; gap: 8px; }
.prod-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 11px; letter-spacing: 1px; font-weight: 600;
  color: var(--text-dim);
  background: var(--bg-elev);
}
.prod-pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--warn); box-shadow: 0 0 8px var(--warn);
}
body[data-promoted="true"] .prod-pill { color: var(--good); border-color: color-mix(in oklab, var(--good) 50%, var(--line-strong)); }
body[data-promoted="true"] .prod-pill .dot { background: var(--good); box-shadow: 0 0 8px var(--good); }
body[data-promoted="true"] .prod-pill-text::before { content: "PROD "; }

.icon-btn {
  appearance: none; border: 1px solid var(--line);
  background: var(--bg-elev); color: var(--text);
  width: 34px; height: 34px; border-radius: 10px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
.icon-btn:hover { border-color: var(--line-strong); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Main / panels */
main {
  flex: 1;
  max-width: 1240px; width: 100%;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.panel { animation: fadeUp var(--t-mid) ease both; }
.panel[hidden] { display: none; }

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

.panel-head { margin: 4px 0 18px; }
.panel-head h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.01em; }
.panel-head p  { margin: 0; color: var(--text-dim); max-width: 64ch; }

.section-title { margin: 32px 0 4px; font-size: 17px; letter-spacing: -0.005em; }
.section-sub { margin: 0 0 14px; color: var(--text-dim); font-size: 14px; }

/* Buttons */
.btn {
  appearance: none; border: 1px solid var(--line-strong);
  background: var(--bg-elev);
  color: var(--text);
  padding: 8px 14px; border-radius: 10px;
  font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.btn:hover { border-color: color-mix(in oklab, var(--accent) 50%, var(--line-strong)); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary {
  background: linear-gradient(180deg, color-mix(in oklab, var(--accent) 22%, var(--bg-elev)), var(--bg-elev));
  border-color: color-mix(in oklab, var(--accent) 50%, var(--line-strong));
  color: var(--text);
}
.btn.primary:hover { border-color: var(--accent); }
.btn.ghost { background: transparent; }

/* Hero */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 32px;
  align-items: center;
  padding: 20px 0 8px;
}
.hero-copy .eyebrow {
  color: var(--accent); text-transform: uppercase;
  font-size: 11px; letter-spacing: 2px; margin: 0 0 10px;
}
.hero-copy h1 {
  margin: 0 0 12px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05; letter-spacing: -0.02em;
}
.hero-copy .lede {
  font-size: 16px; line-height: 1.55; color: var(--text-dim); max-width: 56ch;
}
.hero-actions { display: inline-flex; gap: 10px; margin: 18px 0 12px; flex-wrap: wrap; }
.hero-bullets { padding: 0; margin: 14px 0 0; list-style: none; color: var(--text-dim); font-size: 14px; line-height: 1.7; }
.hero-bullets span { color: var(--accent); margin-right: 8px; }

.hero-stage {
  position: relative;
  min-height: 320px;
  border-radius: var(--radius);
  background: radial-gradient(120% 90% at 60% 40%, color-mix(in oklab, var(--accent) 12%, transparent), transparent 60%), var(--bg-elev);
  border: 1px solid var(--line);
  overflow: hidden;
}
.stage-glow {
  position: absolute; inset: -20%;
  background:
    radial-gradient(40% 30% at 20% 30%, color-mix(in oklab, var(--accent) 22%, transparent), transparent 60%),
    radial-gradient(40% 30% at 80% 70%, color-mix(in oklab, var(--accent-2) 18%, transparent), transparent 60%);
  filter: blur(20px);
  animation: drift 16s linear infinite alternate;
  pointer-events: none;
}
@keyframes drift {
  from { transform: translate3d(-2%, 0, 0) scale(1); }
  to   { transform: translate3d(4%, -2%, 0) scale(1.05); }
}
.hero-svg { position: relative; display: block; width: 100%; height: 100%; }
.hero-nodes circle { fill: var(--bg-elev-2); stroke: var(--accent); stroke-width: 1.5; }
.hero-nodes text { fill: var(--text-dim); font-size: 10px; font-family: var(--mono); letter-spacing: 1px; }

/* Roster */
.roster {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.module-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color var(--t-fast), transform var(--t-fast);
  position: relative;
  overflow: hidden;
}
.module-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.module-card .mc-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px;
}
.module-card .mc-name {
  font-family: var(--mono); font-size: 13px; letter-spacing: 2px; color: var(--text);
}
.module-card .mc-tag {
  font-size: 10px; padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--text-dim); background: var(--bg-elev-2);
}
.module-card .mc-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: color-mix(in oklab, var(--accent) 18%, var(--bg-elev-2));
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--accent);
  margin-bottom: 12px;
}
.module-card .mc-purpose { color: var(--text-dim); font-size: 14px; line-height: 1.5; margin: 0 0 10px; }
.module-card .mc-hook { font-family: var(--mono); font-size: 11px; color: var(--text-faint); }

/* Flow list */
.flow { padding-left: 18px; color: var(--text-dim); line-height: 1.7; }
.flow b { color: var(--text); letter-spacing: 1.5px; font-family: var(--mono); font-size: 13px; }

/* Wire */
.wire-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.wire-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.wire-card h3 {
  margin: 0 0 4px; font-family: var(--mono); font-size: 13px; letter-spacing: 2px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.wire-card .wc-purpose { color: var(--text-dim); font-size: 13px; margin: 0 0 14px; line-height: 1.5; }
.wire-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; font-size: 13px; color: var(--text-dim); }
.wire-row input[type="range"] { flex: 1; }
.wire-row input[type="number"] { width: 64px; }
.wire-foot { display: flex; align-items: center; gap: 12px; margin-top: 16px; color: var(--text-dim); font-size: 13px; }
.wire-status { color: var(--text-dim); }

/* Switch */
.switch {
  position: relative; display: inline-block; width: 38px; height: 22px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--bg-elev-2); border: 1px solid var(--line-strong);
  border-radius: 999px; transition: background var(--t-fast), border-color var(--t-fast);
}
.switch span::before {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: var(--text-faint);
  transition: transform var(--t-fast), background var(--t-fast);
}
.switch input:checked + span { background: color-mix(in oklab, var(--accent) 30%, var(--bg-elev-2)); border-color: var(--accent); }
.switch input:checked + span::before { transform: translateX(16px); background: var(--accent); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.scope-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: var(--bg-elev-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px;
  max-height: 180px; overflow: auto;
}
.scope-grid label {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-dim);
  padding: 4px 6px; border-radius: 6px;
}
.scope-grid label:hover { background: var(--bg-elev); color: var(--text); }
.scope-grid input { accent-color: var(--accent); }

/* Theater */
.theater {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}
.theater-controls {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 10px;
}
.theater-controls .speed,
.theater-controls .rate,
.theater-controls .mix {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-dim); font-size: 12px;
}
.theater-controls select, .theater-controls input[type="range"] {
  appearance: none;
  background: var(--bg-elev-2); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 6px 8px; font: inherit; font-size: 12px;
}
.theater-controls input[type="range"] { padding: 0; width: 120px; }
#stage {
  display: block; width: 100%; height: auto; aspect-ratio: 1200 / 360;
  background:
    linear-gradient(180deg, color-mix(in oklab, var(--accent) 4%, var(--bg-elev-2)), var(--bg-elev-2));
  border-radius: 10px; border: 1px solid var(--line);
  cursor: crosshair;
}
.theater-meters {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px; margin-top: 10px;
}
.meter {
  background: var(--bg-elev-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px;
}
.meter .m-name { font-family: var(--mono); font-size: 10px; letter-spacing: 2px; color: var(--text-faint); }
.meter .m-val  { font-size: 20px; font-variant-numeric: tabular-nums; font-weight: 600; }
.meter .m-sub  { font-size: 11px; color: var(--text-dim); }

.legend {
  margin-top: 10px; display: flex; gap: 14px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-dim);
}
.legend i.dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  margin-right: 6px; vertical-align: -1px;
}
.legend i.ok    { background: #9bd6ff; }
.legend i.bite  { background: #ffb05a; }
.legend i.hunt  { background: #c08bff; }
.legend i.mole  { background: #f088c2; }
.legend i.dry   { background: #7ce6c4; }
.legend i.block { background: #ff6e7f; }

.inspector {
  margin-top: 18px; background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.inspector h3 { margin: 0 0 6px; font-size: 15px; }
.inspector .muted { color: var(--text-dim); margin: 0; font-size: 13px; }
.inspector .insp-trace {
  margin-top: 12px; display: flex; gap: 6px; flex-wrap: wrap;
}
.insp-trace .step {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 8px;
  background: var(--bg-elev-2); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; letter-spacing: 1.5px; color: var(--text-dim);
}
.insp-trace .step.ok    { border-color: color-mix(in oklab, #9bd6ff 40%, var(--line)); color: #9bd6ff; }
.insp-trace .step.flag  { border-color: color-mix(in oklab, var(--warn) 40%, var(--line)); color: var(--warn); }
.insp-trace .step.block { border-color: color-mix(in oklab, var(--bad) 40%, var(--line)); color: var(--bad); }
.insp-trace .step.dry   { border-color: color-mix(in oklab, var(--good) 40%, var(--line)); color: var(--good); }

.insp-payload {
  margin-top: 12px;
  background: var(--bg-elev-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px;
  font-family: var(--mono); font-size: 12px; color: var(--text-dim); white-space: pre-wrap;
}

/* Red team */
.rt-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px;
}
.rt-card {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.rt-card h3 { margin: 0; font-family: var(--mono); font-size: 13px; letter-spacing: 2px; }
.rt-card p  { margin: 0; color: var(--text-dim); font-size: 13px; line-height: 1.55; }
.rt-card .rt-meta {
  display: flex; gap: 8px; flex-wrap: wrap; color: var(--text-faint);
  font-family: var(--mono); font-size: 11px;
}
.rt-card .rt-meta span {
  padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--bg-elev-2);
}
.rt-result {
  margin-top: 14px; padding: 12px 14px; min-height: 44px;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text-dim); font-size: 13px;
}
.rt-streak {
  display: inline-flex; gap: 4px; margin-left: 10px; vertical-align: middle;
}
.rt-streak span { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.rt-streak span.win { background: var(--good); box-shadow: 0 0 8px var(--good); }
.promotion {
  margin-top: 18px;
  background: linear-gradient(135deg, color-mix(in oklab, var(--accent) 14%, var(--bg-elev)), var(--bg-elev));
  border: 1px solid color-mix(in oklab, var(--accent) 35%, var(--line-strong));
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}

/* Audit */
.audit-tools { display: flex; gap: 8px; margin: 10px 0 12px; flex-wrap: wrap; }
.audit-tools input, .audit-tools select {
  flex: 1; min-width: 180px;
  background: var(--bg-elev); border: 1px solid var(--line-strong);
  color: var(--text); padding: 8px 10px; border-radius: 10px; font: inherit; font-size: 13px;
}
.audit-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.audit-item {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px;
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
}
.audit-item .verdict {
  font-family: var(--mono); font-size: 11px; letter-spacing: 2px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--text-dim); background: var(--bg-elev-2);
}
.audit-item.block .verdict   { color: var(--bad);  border-color: color-mix(in oklab, var(--bad) 50%, var(--line)); }
.audit-item.throttle .verdict{ color: var(--warn); border-color: color-mix(in oklab, var(--warn) 50%, var(--line)); }
.audit-item.allow .verdict   { color: var(--good); border-color: color-mix(in oklab, var(--good) 50%, var(--line)); }
.audit-item .audit-body { display: grid; gap: 4px; }
.audit-item .audit-eid { font-family: var(--mono); font-size: 11px; color: var(--text-faint); }
.audit-item .audit-reason { font-size: 13px; color: var(--text); }
.audit-item .audit-meta { font-size: 11px; color: var(--text-dim); }
.audit-item .audit-actions { display: flex; gap: 8px; align-items: center; }
.audit-item .appeal-state {
  font-family: var(--mono); font-size: 10px; letter-spacing: 2px; color: var(--text-faint);
}
.audit-item .appeal-state.appealed { color: var(--accent); }

/* About */
.about-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.about-grid article {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.about-grid h3 { margin: 0 0 6px; font-size: 15px; }
.about-grid p  { margin: 0; color: var(--text-dim); font-size: 14px; line-height: 1.55; }

/* Modal */
.modal-root {
  position: fixed; inset: 0; z-index: 100;
  background: color-mix(in oklab, #000 60%, transparent);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn var(--t-mid) ease;
}
.modal-root[hidden] { display: none; }
.modal {
  background: var(--bg-elev); border: 1px solid var(--line-strong);
  border-radius: var(--radius); width: min(520px, 100%);
  box-shadow: var(--shadow);
  display: grid; grid-template-rows: auto 1fr auto;
}
.modal > header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.modal > header h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 16px; display: grid; gap: 12px; }
.modal-body label { display: grid; gap: 6px; font-size: 13px; color: var(--text-dim); }
.modal-body textarea, .modal-body input[type="text"] {
  background: var(--bg-elev-2); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 8px 10px; font: inherit; font-size: 13px; resize: vertical;
}
.modal-body textarea:focus, .modal-body input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.modal > footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 12px 16px; border-top: 1px solid var(--line);
}

@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}

/* Footer */
.footer {
  border-top: 1px solid var(--line);
  padding: 14px 20px;
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between;
  color: var(--text-faint); font-size: 12px;
  background: var(--bg-elev);
}

/* Responsiveness */
@media (max-width: 880px) {
  .hero { grid-template-columns: 1fr; }
  .hero-stage { min-height: 220px; }
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .tabs::-webkit-scrollbar { display: none; }
  .topbar { grid-template-columns: 1fr auto; }
  .tabs { grid-column: 1 / -1; justify-self: stretch; border-radius: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
  .stage-glow { animation: none; }
}
