/* =========================================================================
   SPEAKING AGENT CONSOLE — "green-phosphor CRT meets frosted glass"
   ========================================================================= */
:root {
  --bg: #03110b;
  --bg-2: #061b11;
  --panel: rgba(16, 54, 36, 0.22);
  --panel-2: rgba(10, 40, 26, 0.45);
  --green: #36f9a0;
  --green-bright: #b6ffd9;
  --green-dim: #1c9b62;
  --text: #74ffb4;
  --muted: #2f9e6b;
  --amber: #ffce5a;
  --red: #ff6f6f;
  --border: rgba(54, 249, 160, 0.28);
  --border-soft: rgba(54, 249, 160, 0.14);
  --glow: 0 0 6px rgba(54, 249, 160, 0.55);
  --glow-strong: 0 0 12px rgba(54, 249, 160, 0.75);
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body.crt {
  margin: 0;
  background:
    radial-gradient(ellipse at 50% -10%, #0b3022 0%, var(--bg) 60%, #010907 100%);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.5;
  text-shadow: var(--glow);
  letter-spacing: 0.02em;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  animation: flicker 6s infinite steps(60);
}

@keyframes flicker {
  0%, 97%, 100% { opacity: 1; }
  98% { opacity: 0.96; }
  99% { opacity: 0.99; }
}

/* CRT overlays ---------------------------------------------------------- */
#scanlines {
  position: fixed; inset: 0; z-index: 9000; pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 20, 10, 0.25) 3px,
    rgba(0, 0, 0, 0) 4px
  );
  mix-blend-mode: multiply;
  animation: scan 9s linear infinite;
}
@keyframes scan { from { background-position-y: 0; } to { background-position-y: 100px; } }

#vignette {
  position: fixed; inset: 0; z-index: 8999; pointer-events: none;
  box-shadow: inset 0 0 180px 40px rgba(0, 0, 0, 0.75);
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.35) 100%);
}

/* Links & headings ------------------------------------------------------ */
a { color: var(--green-bright); text-decoration: none; border-bottom: 1px dotted var(--border); }
a:hover { color: #fff; text-shadow: var(--glow-strong); }
h1, h2, h3 { color: var(--green-bright); text-shadow: var(--glow-strong); font-weight: 600; letter-spacing: 0.08em; }
h1 { font-size: 1.4rem; margin: 0; }
h2 { font-size: 1.05rem; text-transform: uppercase; }
h3 { font-size: 0.95rem; text-transform: uppercase; color: var(--green); }
p { margin: 0.4rem 0; }
small, .muted { color: var(--muted); text-shadow: none; }
hr { border: none; border-top: 1px dashed var(--border-soft); margin: 1rem 0; }

/* Layout ---------------------------------------------------------------- */
#app { max-width: 1080px; margin: 0 auto; padding: 1rem 1.25rem 4rem; position: relative; z-index: 1; }

.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 0.6rem 0.9rem; margin-bottom: 1.2rem;
  border: 1px solid var(--border); border-radius: 8px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  backdrop-filter: blur(3px);
  box-shadow: var(--glow), inset 0 0 24px rgba(8, 40, 26, 0.5);
}
.brand { font-weight: 700; letter-spacing: 0.12em; color: var(--green-bright); text-shadow: var(--glow-strong); white-space: nowrap; }
.brand .dot { color: var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.3;} }
.nav { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-left: auto; }
.nav a {
  border: 1px solid var(--border-soft); border-radius: 5px; padding: 0.25rem 0.6rem;
  text-transform: uppercase; font-size: 0.78rem; letter-spacing: 0.1em; color: var(--text);
}
.nav a.active { background: rgba(54,249,160,0.16); color: var(--green-bright); border-color: var(--border); }
.nav a:hover { background: rgba(54,249,160,0.1); color: #fff; }

/* Panels (glass) -------------------------------------------------------- */
.panel {
  border: 1px solid var(--border); border-radius: 8px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  backdrop-filter: blur(3px);
  box-shadow: inset 0 0 30px rgba(8, 40, 26, 0.45), 0 0 10px rgba(0,0,0,0.4);
  padding: 1rem 1.1rem; margin-bottom: 1.1rem;
}
.panel.tight { padding: 0.7rem 0.9rem; }
.panel-title { display:flex; align-items:center; gap:0.5rem; margin-bottom: 0.7rem; }
.panel.error { border-color: var(--red); color: var(--red); text-shadow: 0 0 6px rgba(255,111,111,0.5); }
.panel.warn { border-color: var(--amber); }

.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.row { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Stat tiles ------------------------------------------------------------ */
.stat { text-align: center; padding: 0.8rem; border: 1px solid var(--border-soft); border-radius: 6px; background: rgba(8,36,24,0.4); }
.stat .num { font-size: 1.8rem; color: var(--green-bright); text-shadow: var(--glow-strong); }
.stat .lbl { font-size: 0.72rem; text-transform: uppercase; color: var(--muted); letter-spacing: 0.12em; }

/* Buttons --------------------------------------------------------------- */
button, .btn {
  font-family: var(--mono); font-size: 0.85rem; letter-spacing: 0.08em;
  color: var(--green-bright); background: rgba(54,249,160,0.08);
  border: 1px solid var(--border); border-radius: 5px;
  padding: 0.5rem 0.9rem; cursor: pointer; text-transform: uppercase;
  text-shadow: var(--glow); transition: all 0.12s ease;
}
button:hover, .btn:hover { background: rgba(54,249,160,0.2); color: #fff; box-shadow: var(--glow-strong); }
button:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
button.primary { background: rgba(54,249,160,0.18); border-color: var(--green); }
button.danger { color: var(--red); border-color: var(--red); background: rgba(255,111,111,0.08); text-shadow: 0 0 6px rgba(255,111,111,0.4); }
button.danger:hover { background: rgba(255,111,111,0.2); color: #fff; }
button.ghost { background: transparent; border-color: var(--border-soft); color: var(--text); }
button.big { font-size: 1.05rem; padding: 0.8rem 1.6rem; }

/* Forms ----------------------------------------------------------------- */
label { display: block; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 0.7rem 0 0.25rem; }
input, textarea, select {
  width: 100%; font-family: var(--mono); font-size: 0.9rem;
  color: var(--green-bright); background: rgba(2,14,9,0.7);
  border: 1px solid var(--border); border-radius: 5px; padding: 0.5rem 0.6rem;
  text-shadow: var(--glow);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--green); box-shadow: var(--glow-strong); }
textarea { resize: vertical; min-height: 90px; }
.field-note { font-size: 0.74rem; color: var(--muted); text-shadow: none; margin-top: 0.2rem; }
.field-err { color: var(--red); font-size: 0.76rem; text-shadow: none; margin-top: 0.2rem; }
.switch { display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; text-transform: none; color: var(--text); }
.switch input { width: auto; }

/* Pills / badges -------------------------------------------------------- */
.pill { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.72rem; letter-spacing: 0.06em; border: 1px solid var(--border-soft); text-shadow: none; }
.pill-ok { color: #04130c; background: var(--green); border-color: var(--green); }
.pill-dim { color: var(--muted); }
.pill-warn { color: #1a1404; background: var(--amber); border-color: var(--amber); }
.pill-err { color: #170404; background: var(--red); border-color: var(--red); }
.pill-high { color: #04130c; background: var(--green); }
.pill-medium { color: #1a1404; background: var(--amber); }
.pill-low { color: var(--muted); border-color: var(--border-soft); }

/* Terminal / log feed --------------------------------------------------- */
.terminal {
  background: rgba(1,10,6,0.8); border: 1px solid var(--border); border-radius: 6px;
  padding: 0.8rem 1rem; font-size: 0.85rem; white-space: pre-wrap; word-break: break-word;
  max-height: 420px; overflow-y: auto; box-shadow: inset 0 0 24px rgba(0,0,0,0.6);
}
.logline { display: flex; gap: 0.5rem; }
.logline .ico { width: 1.2rem; flex: none; }
.ok { color: var(--green); }
.run { color: var(--amber); }
.fail { color: var(--red); }
.idle { color: var(--muted); }
.cursor::after { content: "▋"; animation: blink 1s steps(1) infinite; color: var(--green); }
@keyframes blink { 50% { opacity: 0; } }

/* Tables ---------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th, td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
th { color: var(--green); text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.08em; position: sticky; top: 0; background: var(--bg-2); }
tr:hover td { background: rgba(54,249,160,0.06); }

/* Toasts ---------------------------------------------------------------- */
#toast-root { position: fixed; right: 1rem; bottom: 1rem; z-index: 9500; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
  border: 1px solid var(--border); border-radius: 6px; padding: 0.6rem 0.9rem;
  background: var(--bg-2); box-shadow: var(--glow); max-width: 340px; font-size: 0.85rem;
  animation: slidein 0.18s ease;
}
.toast.err { border-color: var(--red); color: var(--red); }
.toast.warn { border-color: var(--amber); color: var(--amber); }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } }

/* Modal ----------------------------------------------------------------- */
.modal-overlay { position: fixed; inset: 0; z-index: 9600; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { max-width: 640px; width: 100%; max-height: 85vh; overflow: auto; }

/* Boot screen ----------------------------------------------------------- */
#boot { max-width: 720px; margin: 8vh auto; padding: 1.5rem; }
#boot .terminal { max-height: none; }

/* Login ----------------------------------------------------------------- */
.login-wrap { max-width: 460px; margin: 12vh auto; }
.center { text-align: center; }

/* Misc ------------------------------------------------------------------ */
.mono-block { white-space: pre-wrap; word-break: break-word; }
.kbd { border:1px solid var(--border-soft); border-radius:3px; padding:0 0.3rem; font-size:0.8rem; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.3); }
::-webkit-scrollbar-thumb { background: rgba(54,249,160,0.3); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: rgba(54,249,160,0.5); }
