/* ═══════════════════════════════════════════════════════════════════════════
   ARGOS VAULT — Design System
   Trimmed, faithful subset of Argos Service's app.css (Argos Page Standard v2).
   Tokens and rules below are copied from the real deployed stylesheet, not
   reinvented — see the argos-page-standard skill before touching this file.
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,600;0,9..144,700;1,9..144,400&family=Manrope:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

[x-cloak] { display: none !important; }

/* ─── CSS Custom Properties ──────────────────────────────────────────────── */

:root {
  --bg-primary:     #030912;
  --bg-secondary:   #06101e;
  --bg-card:        #0a1628;
  --bg-elevated:    #0e2040;

  --blue:           #0070f3;
  --blue-mid:       #0090f0;
  --blue-lite:      #3db8ff;
  --blue-dim:       #0050c8;
  --purple:         #7c3aed;
  --purple-mid:     #9f67ff;
  --purple-lite:    #c4b5fd;
  --cyan:           #00d4ff;
  --green:          #4ade80;
  --red:            #f87171;
  --orange:         #fb923c;
  --yellow:         #fbbf24;

  --glass-bg:       rgba(10, 22, 40, 0.90);
  --glass-bg-hover: rgba(14, 32, 64, 0.95);
  --glass-border:   rgba(0, 112, 243, 0.14);
  --glass-border-h: rgba(0, 112, 243, 0.24);
  --glass-blur:     12px;

  --font-heading: 'Fraunces', Georgia, serif;
  --font-body:    'Manrope', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  --r-xl: 12px;
  --r-lg: 8px;
  --r-md: 6px;
  --r-sm: 4px;
  --r-xs: 2px;

  --glow-blue:   0 0 0 1px rgba(0, 112, 243, 0.4);
  --shadow-card: 0 1px 0 rgba(255,255,255,0.04) inset, 0 2px 8px rgba(0,0,0,0.24);

  --z-dropdown: 100;
  --z-modal:    200;
  --z-toast:    300;
  --z-sidebar:  50;
  --z-topbar:   60;

  --danger:  #f87171;
  --warning: #fbbf24;
  --success: #4ade80;

  /* Page width cap — single source of truth for "fill the screen, no dead
     space" (Argos Page Standard v2 §1). */
  --page-max: 1680px;
}

/* ─── Reset & Base ───────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: #D4D4D8;
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}
h1, h2, h3, h4, h5 { font-family: var(--font-heading); font-weight: 700; line-height: 1.2; color: #F4F4F5; }
a { color: var(--blue-lite); text-decoration: none; }
a:hover { color: #93C5FD; }
code, pre, .mono { font-family: var(--font-mono); }

/* ─── App shell ──────────────────────────────────────────────────────────── */

.app-shell { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* ─── Rail (icon-only, 68px, hover/click flyouts — Page Standard v2 §2) ───── */

.rail {
  width: 68px;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--glass-border);
  z-index: var(--z-sidebar);
  overflow-y: auto;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }

.rail-mark { width: 40px; height: 40px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-bottom: 8px; }
.rail-mark img { width: 34px; height: 34px; display: block; }

.rail-btn {
  position: relative;
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: var(--r-md);
  background: transparent;
  border: 1px solid transparent;
  color: #B4BAC7;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
  text-decoration: none;
}
/* Hover and selected are deliberately DIFFERENT rules — collapsing them means
   the rail can't tell you where you are. Hover = neutral lift; selected =
   blue + the inset bar, so it survives even if colour alone is missed. */
.rail-btn:hover { color: #F4F4F5; background: rgba(255, 255, 255, 0.04); }
.rail-btn.on,
.rail-btn[aria-expanded="true"] {
  color: var(--blue-lite);
  background: rgba(0, 112, 243, 0.1);
  box-shadow: inset 2px 0 0 var(--blue);
}
.rail-btn svg { flex-shrink: 0; opacity: 0.95; width: 20px; height: 20px; }
.rail-btn:hover svg, .rail-btn.on svg, .rail-btn[aria-expanded="true"] svg { opacity: 1; }
.rail-spacer { flex: 1; }

.rail-tip {
  position: fixed;
  left: 78px;
  top: auto;
  white-space: nowrap;
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border-h);
  color: #F4F4F5;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, visibility 0.12s;
  transition-delay: 0.35s;
  z-index: var(--z-dropdown);
}
.rail-btn:hover .rail-tip { opacity: 1; visibility: visible; }

/* ─── Topbar ─────────────────────────────────────────────────────────────── */

.topbar {
  height: 60px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: var(--glass-bg);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
}
.topbar-title { font-family: var(--font-heading); font-size: 1.05rem; font-weight: 700; color: #F4F4F5; }

/* ─── Page shell — centred, fluid, capped by ONE token ─────────────────────
   A width cap with no auto margin IS the dead-space defect (Page Standard v2
   §1). Full-bleed is fine; a cap without centring is not. */

.page {
  padding: clamp(16px, 3vw, 28px);
  width: 100%;
  min-width: 0;
  max-width: var(--page-max);
  margin-inline: auto;
}

.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-header > div:last-child { display: flex; gap: 8px; flex-wrap: wrap; }
.page-title { font-size: 1.625rem; font-weight: 700; color: #F4F4F5; }
.page-subtitle { font-size: 0.875rem; color: #9AA8C0; margin-top: 3px; }

/* ─── Cards ──────────────────────────────────────────────────────────────── */

.card { background: var(--bg-card); border: 1px solid var(--glass-border); border-radius: var(--r-lg); box-shadow: var(--shadow-card); transition: border-color 0.15s; }
.card:hover { border-color: var(--glass-border-h); }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 14px; border-bottom: 1px solid var(--glass-border); }
.card-title { font-size: 0.875rem; font-weight: 600; color: #E4E4E7; }
.card-body { padding: 18px 20px; }

/* ─── Stat cards — dashboard drill-down (Page Standard v2 §6) ──────────────
   Wire drilldown ONLY when a predicate reproduces the exact count shown.
   Inert is a legitimate answer for rates/sums/timestamps. */

.stat-grid { display: grid; gap: clamp(10px, 2vw, 16px); grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); margin-bottom: 24px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--glass-border); border-radius: var(--r-lg); padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; transition: border-color 0.15s; box-shadow: var(--shadow-card); }
.stat-card:hover { border-color: var(--glass-border-h); }
.stat-card[data-drilled] { cursor: pointer; }
.stat-card[data-drilled]:hover { border-color: var(--blue); }

.stat-icon { width: 40px; height: 40px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.stat-icon.blue   { background: rgba(0, 112, 243,0.12); color: var(--blue-lite); }
.stat-icon.purple { background: rgba(124,58,237,0.12); color: var(--purple-lite); }
.stat-icon.cyan   { background: rgba(0, 212, 255,0.12); color: var(--cyan); }
.stat-icon.green  { background: rgba(74,222,128,0.12); color: var(--green); }
.stat-icon.red    { background: rgba(248,113,113,0.12); color: var(--red); }
.stat-icon.orange { background: rgba(251,146,60,0.12); color: var(--orange); }

.stat-value { font-family: var(--font-heading); font-size: 1.875rem; font-weight: 700; color: #F4F4F5; line-height: 1; }
.stat-label { font-size: 0.78rem; color: #9AA8C0; font-weight: 500; }

/* ─── Buttons — clear, bright, visible (Page Standard v2 §5) ────────────────
   font-weight 600 is the "bright" part; labels stay muted in COLOUR not weight. */

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 18px; border-radius: var(--r-md);
  font-family: var(--font-body); font-size: 0.875rem; font-weight: 600;
  cursor: pointer; transition: background 0.12s, border-color 0.12s, color 0.12s;
  border: 1px solid var(--glass-border); white-space: nowrap; text-decoration: none;
  background: rgba(255, 255, 255, 0.05); color: #E4E4E7;
  -webkit-appearance: none; appearance: none;
}
.btn:hover { background: rgba(255, 255, 255, 0.09); border-color: var(--glass-border-h); color: #E4E4E7; }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--blue); color: #fff; border-color: transparent; }
.btn-primary:hover { background: var(--blue-dim); color: #fff; }
.btn-secondary { background: rgba(255, 255, 255, 0.04); color: #D4D4D8; }
form.htmx-request button[type="submit"],
button[type="submit"].htmx-request { opacity: .65; pointer-events: none; }

/* ─── Data entry (Page Standard v2 §3) ──────────────────────────────────── */

.form-label { display: block; font-size: 0.78rem; font-weight: 600; color: #A1A1AA; margin-bottom: 6px; letter-spacing: 0.01em; }
.form-control, .form-input {
  width: 100%; padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-sm);
  color: #E4E4E7; font-family: var(--font-body); font-size: 0.875rem;
  transition: border-color 0.12s, box-shadow 0.12s;
  outline: none;
}
.form-control:focus, .form-input:focus {
  border-color: rgba(0, 112, 243, 0.5);
  box-shadow: 0 0 0 3px rgba(0, 112, 243, 0.12);
  background: rgba(255, 255, 255, 0.06);
}
.form-control::placeholder, .form-input::placeholder { color: #52525B; }
.form-control:invalid:not(:placeholder-shown):not(:focus) { border-color: var(--red); background: rgba(248,113,113,0.06); }
.form-error { color: var(--red); font-size: .75rem; margin-top: 4px; }
.form-help  { color: rgba(162,184,220,0.5); font-size: .75rem; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid--lg { grid-template-columns: 1fr 1fr 1fr; }

select.form-control {
  cursor: pointer; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%2352525b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 10px;
  padding-right: 34px;
}

/* ─── Search / filter bars (Page Standard v2 §4) ────────────────────────────
   CSS-only sizing — flex-basis, never a hardcoded inline pixel width. */

.search-wrap { position: relative; display: flex; align-items: center; }
.search-wrap svg { position: absolute; left: 11px; width: 14px; height: 14px; color: #52525B; pointer-events: none; }
.search-wrap .form-control { padding-left: 34px; }

.topbar .search-wrap svg { width: 16px; height: 16px; left: 13px; color: #B4BAC7; }
.topbar .search-wrap .form-control {
  padding: 10px 14px 10px 40px; font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.16);
}
.topbar .search-wrap .form-control::placeholder { color: #93939c; }
.topbar .search-wrap .form-control:focus { background: rgba(255, 255, 255, 0.11); }

.filters-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters-bar .search-wrap { flex: 1 1 240px; min-width: 0; }
@media (max-width: 479px) {
  .filters-bar .search-wrap { width: 100% !important; }
  .filters-bar > .filter-chip { font-size: 0.72rem; padding: 5px 10px; }
}

/* Filter chips — hover and .active are DELIBERATELY different rules. Service's
   own chip rule conflates them (fixed known-defect, per the design skill —
   do not copy that rule verbatim); this is the corrected version. */
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 20px;
  font-size: 0.78rem; font-weight: 500;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  color: #71717A;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.filter-chip:hover { background: rgba(255, 255, 255, 0.06); color: #D4D4D8; }
.filter-chip.active { background: rgba(0, 112, 243, 0.1); border-color: rgba(0, 112, 243, 0.25); color: var(--blue-lite); }

/* ─── Modals — standardize on .modal-shell, not the older .modal system ──── */

.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: var(--z-modal); padding: 16px; }
.modal-shell {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--r-xl);
  box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.04) inset;
  display: flex; flex-direction: column;
  max-height: calc(100vh - clamp(16px, 6vh, 96px));
  overflow: hidden;
}
.modal-shell--sm   { max-width: 420px; }
.modal-shell--md   { max-width: min(95vw, 560px); }
.modal-shell--lg   { max-width: min(95vw, 760px); }
.modal-shell--xl   { max-width: min(95vw, 1100px); }
.modal-shell--full { max-width: 95vw; min-height: min(90vh, 720px); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: clamp(14px, 2vw, 20px) clamp(16px, 3vw, 24px); border-bottom: 1px solid var(--glass-border); flex-shrink: 0; }
.modal-title { font-family: var(--font-heading); font-size: clamp(0.95rem, 0.875rem + 0.35vw, 1.125rem); font-weight: 700; color: #F4F4F5; }
.modal-close { background: none; border: none; cursor: pointer; color: #71717A; }
.modal-body { padding: clamp(14px, 2vw, 20px) clamp(16px, 3vw, 24px); overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: clamp(14px, 2vw, 20px) clamp(16px, 3vw, 24px); border-top: 1px solid var(--glass-border); flex-shrink: 0; }

/* ─── Badges ─────────────────────────────────────────────────────────────── */

.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; }
.badge-critical { background: rgba(248,113,113,0.14); color: var(--red); }
.badge-success  { background: rgba(74,222,128,0.14); color: var(--green); }
.badge-warning  { background: rgba(251,146,60,0.14); color: var(--orange); }
.badge-neutral  { background: rgba(255,255,255,0.06); color: #A1A1AA; }

/* ─── Empty states ───────────────────────────────────────────────────────── */

.empty-state { text-align: center; padding: 48px 24px; color: #71717A; }
.empty-state h3 { color: #E4E4E7; margin-bottom: 6px; }

/* ─── Focus rings, reduced motion ────────────────────────────────────────── */

:focus-visible { outline: 2px solid var(--blue-lite); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ─── Mobile — rail becomes a slide-in drawer ───────────────────────────────
   (identical breakpoint/mechanism to Service; wire the same body.sidebar-open
   toggle when the nav-toggle button is built). */
@media (max-width: 640px) {
  .rail { position: fixed; left: 0; top: 0; width: min(84vw, 280px); transform: translateX(-100%); transition: transform 0.2s; z-index: calc(var(--z-modal) + 1); }
  body.sidebar-open .rail { transform: translateX(0); }
  .page { padding: 16px; }
}
