/* HIPAA Phase 1 demo — Tokyo Night (Night variant).
   Palette locked to the canonical 16-token Altius PDF/dark theme.
   Aesthetic: refined engineering console — dark cockpit, monospace for
   data/audit surfaces, a precise stage-pipeline rail as the centerpiece. */

@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=JetBrains+Mono:wght@400;500;600&family=Inter:wght@400;500;600&display=swap");

:root {
  --bg-base: #1a1b26;
  --bg-elevated: #24283b;
  --bg-highlight: #292e42;
  --fg-primary: #c0caf5;
  --fg-muted: #a9b1d6;
  --fg-subtle: #565f89;
  --border: #3b4261;
  --accent-primary: #7aa2f7;
  --accent-secondary: #bb9af7;
  --accent-tertiary: #7dcfff;
  --success: #9ece6a;
  --warning: #e0af68;
  --danger: #f7768e;
  --info: #2ac3de;
  --teal: #73daca;

  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 18px 48px -24px rgba(0, 0, 0, 0.75);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-base);
  color: var(--fg-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

/* Atmospheric gradient mesh behind everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60rem 40rem at 85% -10%, rgba(122, 162, 247, 0.10), transparent 60%),
    radial-gradient(50rem 38rem at 5% 8%, rgba(187, 154, 247, 0.08), transparent 55%),
    radial-gradient(40rem 40rem at 50% 120%, rgba(115, 218, 202, 0.06), transparent 60%);
  pointer-events: none;
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-highlight);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.05em 0.4em;
  color: var(--accent-tertiary);
}

h1, h2 { font-family: var(--font-display); letter-spacing: -0.01em; }

/* ---------------------------------------------------------------- */
/* Topbar                                                            */
/* ---------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.6rem;
  background: rgba(36, 40, 59, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 0.85rem; }
.brand-logo { height: 30px; width: auto; display: block; filter: drop-shadow(0 0 14px rgba(122,162,247,0.25)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-title { font-family: var(--font-display); font-weight: 700; font-size: 1.04rem; }
.brand-env {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--fg-subtle);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topbar-right { display: flex; align-items: center; gap: 0.75rem; }

/* User menu (native <details> dropdown) */
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-summary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.32rem 0.7rem 0.32rem 0.34rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.user-summary:hover { border-color: var(--accent-primary); background: var(--bg-highlight); }
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}
.user-avatar--fallback {
  display: grid; place-items: center;
  background: var(--accent-secondary);
  color: var(--bg-base);
  font-weight: 700;
  font-family: var(--font-display);
}
.user-email { font-family: var(--font-mono); font-size: 0.82rem; color: var(--fg-muted); }
.user-caret { color: var(--fg-subtle); font-size: 0.7rem; }

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  min-width: 230px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 0.9rem;
  z-index: 30;
}
.user-dropdown-name { font-weight: 600; }
.user-dropdown-email { font-family: var(--font-mono); font-size: 0.78rem; color: var(--fg-muted); margin-bottom: 0.7rem; }
.user-logout { width: 100%; justify-content: center; }

/* ---------------------------------------------------------------- */
/* Buttons                                                           */
/* ---------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.84rem;
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--accent-primary), #6a92e7);
  color: var(--bg-base);
  box-shadow: 0 8px 20px -10px rgba(122, 162, 247, 0.7);
}
.btn-primary:hover { box-shadow: 0 10px 26px -10px rgba(122, 162, 247, 0.9); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn-ghost {
  background: transparent;
  color: var(--fg-muted);
  border-color: var(--border);
}
.btn-ghost:hover { color: var(--fg-primary); border-color: var(--accent-primary); }

/* ---------------------------------------------------------------- */
/* Sign-in / unconfigured                                            */
/* ---------------------------------------------------------------- */
.signin-stage, .unconfigured {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 120px);
  padding: 2rem;
}
.signin-card, .unconfigured-card {
  max-width: 520px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.2rem;
  box-shadow: var(--shadow);
  text-align: center;
}
.signin-card h1, .unconfigured-card h1 { margin-top: 0; }
.signin-card p, .unconfigured-card p { color: var(--fg-muted); }
.unconfigured { min-height: 100vh; }
.unconfigured-glyph {
  font-size: 2.6rem;
  color: var(--warning);
  line-height: 1;
  margin-bottom: 0.6rem;
}
.unconfigured-card { border-color: rgba(224, 175, 104, 0.4); }
.unconfigured-hint { font-size: 0.86rem; color: var(--fg-subtle); }

/* ---------------------------------------------------------------- */
/* Console layout                                                    */
/* ---------------------------------------------------------------- */
.console {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.8rem 1.6rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem 1.4rem;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.panel-head h2 { margin: 0; font-size: 1.06rem; }
.panel-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-subtle);
  background: var(--bg-highlight);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.18rem 0.6rem;
}
.panel-tag--live.is-live { color: var(--success); border-color: rgba(158, 206, 106, 0.5); }
.panel-tag--live.is-error { color: var(--danger); border-color: rgba(247, 118, 142, 0.5); }

/* Instructions */
.steps { list-style: none; margin: 0 0 1.3rem; padding: 0; display: grid; gap: 0.7rem; }
.steps li { display: flex; gap: 0.8rem; align-items: flex-start; }
.steps strong { color: var(--fg-primary); }
.steps div { color: var(--fg-muted); }
.step-n {
  flex: none;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--accent-tertiary);
  background: var(--bg-highlight);
  border: 1px solid var(--border);
}

.run-controls { border-top: 1px dashed var(--border); padding-top: 1.1rem; display: grid; gap: 0.9rem; }
.sample-list { display: grid; gap: 0.55rem; }
.sample-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--bg-highlight);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
}
.sample-meta { display: flex; flex-direction: column; gap: 0.1rem; }
.sample-label { font-weight: 600; }
.sample-desc { font-size: 0.8rem; color: var(--fg-subtle); }
.sample-actions { display: flex; gap: 0.5rem; flex: none; }

.run-note { margin: 0; font-size: 0.8rem; color: var(--fg-subtle); min-height: 1.1rem; font-family: var(--font-mono); }
.run-note.is-error { color: var(--danger); }

.push-script {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px dashed var(--border);
}
.push-script-text { display: flex; flex-direction: column; gap: 0.2rem; }
.push-script-text strong { font-weight: 600; }
.push-script-text span { font-size: 0.8rem; color: var(--fg-subtle); }
.push-script .btn { flex: none; }

/* ---------------------------------------------------------------- */
/* Stage rail                                                        */
/* ---------------------------------------------------------------- */
.stage-rail { display: grid; gap: 0.6rem; }
.stage-card {
  position: relative;
  display: grid;
  grid-template-columns: 40px 1fr 36px;
  align-items: center;
  gap: 0.9rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-highlight);
  transition: border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}
/* connecting line down the rail */
.stage-card:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 30px;
  top: 100%;
  height: 0.6rem;
  width: 2px;
  background: var(--border);
}
.stage-index {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-weight: 600;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--fg-subtle);
  transition: all 0.25s ease;
}
.stage-title { font-weight: 600; }
.stage-subtitle { font-size: 0.8rem; color: var(--fg-subtle); }
.stage-counts {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--accent-tertiary);
  margin-top: 0.25rem;
  min-height: 0;
}
.stage-state { display: grid; place-items: center; }
.state-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--fg-subtle);
  box-shadow: 0 0 0 0 transparent;
  transition: all 0.25s ease;
}
.state-spinner {
  display: none;
  width: 14px; height: 14px;
  border: 2px solid rgba(122,162,247,0.25);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
}
.stage-elapsed {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--fg-subtle);
  margin-top: 0.2rem;
}
.stage-elapsed:empty { display: none; }

/* running */
.stage-card.is-running { border-color: var(--accent-primary); background: #232a44; box-shadow: 0 0 0 1px rgba(122,162,247,0.25) inset; }
.stage-card.is-running .stage-index { color: var(--accent-primary); border-color: var(--accent-primary); }
.stage-card.is-running .state-dot { display: none; }
.stage-card.is-running .state-spinner { display: block; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* done */
.stage-card.is-done { border-color: rgba(158,206,106,0.45); }
.stage-card.is-done .stage-index { color: var(--success); border-color: rgba(158,206,106,0.55); background: rgba(158,206,106,0.08); }
.stage-card.is-done .state-dot { background: var(--success); box-shadow: 0 0 10px 0 rgba(158,206,106,0.5); }

/* error */
.stage-card.is-error { border-color: rgba(247,118,142,0.55); }
.stage-card.is-error .stage-index { color: var(--danger); border-color: rgba(247,118,142,0.55); }
.stage-card.is-error .state-dot { background: var(--danger); }

/* ---------------------------------------------------------------- */
/* Lower grid: audit + schedule                                      */
/* ---------------------------------------------------------------- */
.lower-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; align-items: start; }
@media (max-width: 940px) { .lower-grid { grid-template-columns: 1fr; } }

.audit-stream {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem;
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.audit-empty { color: var(--fg-subtle); }
.audit-line {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.25rem 0.35rem;
  border-radius: 5px;
  border-left: 2px solid transparent;
  animation: fadein 0.3s ease;
}
@keyframes fadein { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.audit-line .ts { color: var(--fg-subtle); }
.audit-line .stage-badge {
  color: var(--accent-secondary);
  font-weight: 600;
}
.audit-line .msg { color: var(--fg-muted); }
.audit-line.s-running { border-left-color: var(--accent-primary); }
.audit-line.s-done { border-left-color: var(--success); }
.audit-line.s-done .msg { color: var(--fg-primary); }
.audit-line.s-error { border-left-color: var(--danger); background: rgba(247,118,142,0.06); }
.audit-line.s-error .msg { color: var(--danger); }
.audit-line.s-complete { border-left-color: var(--teal); }
.audit-line.s-complete .msg { color: var(--teal); }

/* Schedule table */
.schedule-table-wrap { overflow-x: auto; max-height: 360px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.schedule-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.schedule-table thead th {
  position: sticky;
  top: 0;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  background: var(--bg-highlight);
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0.7rem;
}
.schedule-table tbody td { padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--border); }
.schedule-table tbody tr:hover { background: var(--bg-highlight); }
.schedule-table tbody tr:last-child td { border-bottom: none; }
.disc-pill {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.disc-pill.PT { color: var(--accent-tertiary); border-color: rgba(125,207,255,0.4); }
.disc-pill.OT { color: var(--teal); border-color: rgba(115,218,202,0.4); }

/* ---------------------------------------------------------------- */
/* Footer                                                            */
/* ---------------------------------------------------------------- */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.6rem;
  border-top: 1px solid var(--border);
  color: var(--fg-subtle);
  font-size: 0.78rem;
  font-family: var(--font-mono);
}
.footer-warn { color: var(--warning); }
