/* Design tokens copied verbatim from alysium-site apps/frontend/src/styles/tokens.css (see docs/04). */
:root {
  /* Backgrounds */
  --bg-void: #020810;
  --bg-deep: #06101a;
  --bg-surface: rgba(6, 14, 30, 0.96);
  --bg-card: rgba(10, 22, 44, 0.45);
  --bg-card-hover: rgba(14, 30, 58, 0.60);

  /* Accents */
  --accent-cyan: #08a8c5;
  --accent-glow: rgba(39, 251, 255, 0.85);
  --accent-glow-dim: rgba(39, 251, 255, 0.50);
  --accent-glow-subtle: rgba(39, 251, 255, 0.15);
  --accent-blue: rgba(3, 75, 148, 0.75);
  --accent-magenta: #c850c0;
  --accent-amber: #f5a623;
  --accent-green: #34d399;
  --accent-red: #ef4444;

  /* Text */
  --text-primary: #e8f4ff;
  --text-secondary: rgba(200, 215, 230, 0.88);
  --text-muted: rgba(160, 200, 220, 0.75);

  /* Borders */
  --border: rgba(8, 168, 197, 0.15);
  --border-strong: rgba(8, 168, 197, 0.35);

  /* Effects / glow */
  --glow-spread: 0 0 20px rgba(39, 251, 255, 0.3);
  --glow-text: 0 0 10px rgba(39, 251, 255, 0.5);
  --glow-online: 0 0 12px rgba(52, 211, 153, 0.5);
  --glow-offline: 0 0 12px rgba(239, 68, 68, 0.3);

  /* Spacing scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 2rem;
  --space-xl: 4rem;
  --space-2xl: 8rem;

  /* Typography */
  --font-display: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-body: 'Outfit', sans-serif;

  /* Layout */
  --max-width: 1200px;

  /* Radii */
  --radius-sm: 0.4em;
  --radius-md: 0.7em;
  --radius-lg: 1em;
}

/* ---- status → color mapping (docs/04) ---- */
.s-operational, .s-up { --s: var(--accent-green); }
.s-degraded { --s: var(--accent-amber); }
.s-down { --s: var(--accent-red); }
.s-partial { --s: var(--accent-magenta); }
.s-unknown { --s: var(--text-muted); }
.s-maintenance { --s: var(--accent-cyan); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--accent-cyan); text-decoration: none; }
a:hover { text-shadow: var(--glow-text); }
:focus-visible { outline: 1px solid var(--accent-glow-dim); outline-offset: 2px; }

.wrap { max-width: var(--max-width); margin: 0 auto; padding: 0 var(--space-md); }

/* ---- header ---- */
.top {
  position: sticky; top: 0; z-index: 10;
  background: rgba(6, 14, 30, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.top .wrap { display: flex; align-items: center; justify-content: space-between; height: 3.5rem; gap: var(--space-md); }
.brand { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; color: var(--text-primary); letter-spacing: 0.02em; }
.brand span { color: var(--accent-cyan); }
.top nav { display: flex; gap: var(--space-md); }

.label {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.75rem;
  color: var(--accent-cyan);
  opacity: 0.75;
}
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }

main { padding: var(--space-lg) 0 var(--space-xl); }

/* ---- glass card ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: background 0.2s ease;
}
.card:hover { background: var(--bg-card-hover); }

/* ---- aggregate banner ---- */
.banner {
  display: flex; align-items: center; gap: var(--space-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  border-color: color-mix(in srgb, var(--s) 45%, transparent);
}
.banner.s-operational { box-shadow: var(--glow-online); }
.banner.s-down { box-shadow: var(--glow-offline); }
.banner h1 { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: clamp(1.3rem, 4vw, 1.9rem); }
.banner p { margin: var(--space-xs) 0 0; color: var(--text-secondary); }
.banner .big-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--s); flex: none; }
.banner.s-operational .big-dot { box-shadow: 0 0 10px var(--accent-green); animation: pulse-dot 2s ease-in-out infinite; }

/* ---- status dot (docs/04) ---- */
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--s); flex: none; }
.status-dot.operational, .status-dot.up {
  background: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
  animation: pulse-dot 2s ease-in-out infinite;
}
.status-dot.down { background: var(--accent-red); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 4px var(--accent-glow-subtle); }
  50% { box-shadow: 0 0 12px var(--accent-glow-dim); }
}
@media (prefers-reduced-motion: reduce) {
  .status-dot, .banner .big-dot, .live { animation: none !important; }
}

/* ---- sections ---- */
.section { margin-bottom: var(--space-lg); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-md); flex-wrap: wrap; margin-bottom: var(--space-sm); }
.section-note { font-size: 0.85rem; color: var(--text-muted); margin: 0 0 var(--space-sm); }
.section .card { padding: var(--space-xs) var(--space-md); }

.svc { padding: var(--space-md) 0; border-bottom: 1px solid var(--border); }
.svc:last-child { border-bottom: 0; }
.svc-head { display: flex; align-items: center; gap: var(--space-sm); margin-bottom: var(--space-sm); flex-wrap: wrap; }
.svc-name { font-weight: 500; }
.svc-meta { margin-left: auto; font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-muted); display: flex; gap: var(--space-md); }
.svc-meta .now { color: var(--s); }
.svc-detail { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); margin: calc(-1 * var(--space-xs)) 0 var(--space-sm); word-break: break-word; }

/* ---- 90-day bar ---- */
.bar { display: flex; gap: 2px; height: 30px; }
.cell {
  position: relative;
  flex: 1 1 0; min-width: 0;
  padding: 0; border: 0; margin: 0;
  border-radius: 2px;
  background: var(--s);
  opacity: 0.85;
  cursor: default;
  font: inherit; color: inherit;
}
.cell.s-unknown { opacity: 0.25; }
.cell:hover, .cell:focus { opacity: 1; outline: none; }
.cell:focus-visible { outline: 1px solid var(--accent-glow); outline-offset: 1px; }
.tip {
  display: none;
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%);
  width: max-content; max-width: 15rem;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--glow-spread);
  text-align: left; font-size: 0.8rem; line-height: 1.4;
  z-index: 5; cursor: auto;
}
.cell.edge-l .tip { left: 0; transform: none; }
.cell.edge-r .tip { left: auto; right: 0; transform: none; }
.cell:hover .tip, .cell:focus .tip, .cell:focus-within .tip { display: block; }
.tip strong { display: block; font-weight: 500; margin-bottom: 2px; }
.tip .mono { font-size: 0.75rem; }
.tip .tsum { color: var(--s); text-transform: capitalize; }
.tip ul { margin: var(--space-xs) 0 0; padding-left: 1rem; }
.bar-legend { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-muted); margin-top: var(--space-xs); }

/* ---- legend ---- */
.legend { display: flex; flex-wrap: wrap; gap: var(--space-md); font-size: 0.8rem; color: var(--text-muted); margin: 0 0 var(--space-lg); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; background: var(--s); display: inline-block; }

/* ---- incidents ---- */
.incident { padding: var(--space-md); margin-bottom: var(--space-md); }
.incident h3 { margin: 0 0 var(--space-xs); font-family: var(--font-display); font-weight: 500; font-size: 1.1rem; }
.incident .when { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); }
.pill {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-family: var(--font-mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em;
  border: 1px solid currentColor;
}
.pill.investigating { color: var(--accent-red); }
.pill.identified { color: var(--accent-amber); }
.pill.monitoring { color: var(--accent-cyan); }
.pill.resolved { color: var(--accent-green); }
.timeline { list-style: none; margin: var(--space-md) 0 0; padding: 0 0 0 var(--space-md); border-left: 1px solid var(--border-strong); }
.timeline li { margin-bottom: var(--space-md); }
.timeline li:last-child { margin-bottom: 0; }
.timeline .body { color: var(--text-secondary); margin-top: var(--space-xs); }
.timeline .body p { margin: 0 0 var(--space-xs); }
.empty { color: var(--text-muted); padding: var(--space-md); }

.maint { padding: var(--space-md); margin-bottom: var(--space-lg); border-color: color-mix(in srgb, var(--accent-cyan) 45%, transparent); }
.maint h3 { margin: 0 0 var(--space-xs); font-weight: 500; }

footer { border-top: 1px solid var(--border); padding: var(--space-lg) 0; font-size: 0.8rem; color: var(--text-muted); }
footer .wrap { display: flex; justify-content: space-between; gap: var(--space-md); flex-wrap: wrap; }
.live { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-cyan); margin-right: 6px; animation: pulse-glow 2s ease-in-out infinite; vertical-align: middle; }

/* ---- admin ---- */
.admin h1 { font-family: var(--font-display); font-weight: 600; }
.admin .card { padding: var(--space-md); margin-bottom: var(--space-md); }
.admin table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.admin th, .admin td { text-align: left; padding: var(--space-sm); border-bottom: 1px solid var(--border); vertical-align: top; }
.admin th { font-family: var(--font-mono); font-weight: 400; text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.7rem; color: var(--text-muted); }
.table-scroll { overflow-x: auto; }
form.stack { display: grid; gap: var(--space-sm); }
label.f { display: grid; gap: var(--space-xs); font-size: 0.85rem; color: var(--text-secondary); }
input, select, textarea, button.btn {
  font: inherit; color: var(--text-primary);
  background: var(--bg-void);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-sm);
  width: 100%;
}
textarea { min-height: 6rem; resize: vertical; }
input[type='checkbox'] { width: auto; }
.checks { display: flex; flex-wrap: wrap; gap: var(--space-sm) var(--space-md); }
.checks label { display: inline-flex; gap: 6px; align-items: center; font-size: 0.85rem; }
button.btn { width: auto; cursor: pointer; border-color: var(--accent-cyan); color: var(--accent-cyan); padding: var(--space-sm) var(--space-md); }
button.btn:hover { background: var(--accent-glow-subtle); box-shadow: var(--glow-spread); }
.flash { padding: var(--space-sm) var(--space-md); border-radius: var(--radius-sm); border: 1px solid var(--accent-red); color: var(--accent-red); margin-bottom: var(--space-md); }
.hint { border-color: var(--accent-amber); color: var(--accent-amber); }
.grid2 { display: grid; gap: var(--space-md); grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); }
.login { max-width: 22rem; margin: var(--space-xl) auto; }

@media (max-width: 600px) {
  /* 90 cells are ~2px wide on a phone; show the most recent 30 days instead. */
  .bar { height: 28px; gap: 2px; }
  .bar .cell:nth-child(-n+60) { display: none; }
  .bar .cell.edge-r-m .tip { left: auto; right: 0; transform: none; }
  .bar .cell.edge-l-m .tip { left: 0; transform: none; }
  .range-90 { display: none; }
  .range-30 { display: inline !important; }
  .svc-meta { margin-left: 0; width: 100%; }
  .banner { padding: var(--space-md); }
}
