/* =========================================================================
   Content System — design system
   Aesthetic: dark glass / holographic (deep navy + cyan + backdrop blur)
   ========================================================================= */

:root {
  /* The design system is dark glass regardless of OS preference. Declaring
     it stops the browser from painting native UI (select popups, scrollbars,
     date pickers) with the OS light theme — without this, dropdowns open as
     glaring white panels for anyone whose OS is in light mode. */
  color-scheme: dark;

  /* Palette ---------------------------------------------------------------- */
  --ink-0:  #02030a;
  --ink-1:  #05070f;
  --ink-2:  #0a0f1f;
  --ink-3:  #111932;
  --ink-4:  #1a2447;

  --fog-1:  rgba(18, 26, 54, 0.55);
  --fog-2:  rgba(22, 32, 68, 0.45);
  --fog-3:  rgba(40, 56, 110, 0.30);

  --edge-1: rgba(120, 180, 255, 0.10);
  --edge-2: rgba(120, 180, 255, 0.22);
  --edge-3: rgba(120, 180, 255, 0.40);

  --text-1: #e7ecf5;
  --text-2: #a7b3cd;
  --text-3: #6b7897;
  --text-4: #3f4a66;

  --cyan:       #4fd1ff;
  --cyan-soft:  #8fe4ff;
  --cyan-glow:  rgba(79, 209, 255, 0.45);
  --cyan-haze:  rgba(79, 209, 255, 0.12);

  --violet:     #9a7cff;
  --violet-glow: rgba(154, 124, 255, 0.35);

  --mint:       #3ddc97;
  --amber:      #ffc56d;
  --rose:       #ff5d8f;

  /* Typography ------------------------------------------------------------- */
  --font-sans: 'Inter', 'SF Pro Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', ui-monospace, 'Cascadia Mono', Menlo, monospace;

  /* Spacing / radii -------------------------------------------------------- */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 22px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Shadows ---------------------------------------------------------------- */
  --shadow-panel:
    0 1px 0 rgba(255, 255, 255, 0.03) inset,
    0 24px 60px -20px rgba(0, 0, 0, 0.75),
    0 0 0 1px var(--edge-1);

  --shadow-glow:
    0 0 0 1px var(--edge-2),
    0 0 24px -4px var(--cyan-glow);

  --shadow-inset-hair: 0 1px 0 rgba(255, 255, 255, 0.04) inset;

  /* Motion ----------------------------------------------------------------- */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

/* Reset ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-1);
  background: var(--ink-0);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
}
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; letter-spacing: -0.01em; color: var(--text-1); }
h1 { font-size: 28px; letter-spacing: -0.02em; }
h2 { font-size: 20px; letter-spacing: -0.015em; }
h3 { font-size: 16px; }
p  { margin: 0; }
a  { color: var(--cyan); text-decoration: none; }
a:hover { color: var(--cyan-soft); text-shadow: 0 0 12px var(--cyan-glow); }
hr { border: 0; height: 1px; background: var(--edge-1); margin: var(--space-5) 0; }
code, pre, kbd { font-family: var(--font-mono); }
svg { display: inline-block; vertical-align: middle; }

::selection { background: var(--cyan-haze); color: var(--cyan-soft); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--ink-3);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); background-clip: padding-box; }

/* =========================================================================
   Global background — aurora + grid
   ========================================================================= */

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(1200px 800px at 85% -10%, rgba(79, 209, 255, 0.18), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(154, 124, 255, 0.20), transparent 60%),
    radial-gradient(600px 400px at 50% 50%,  rgba(79, 209, 255, 0.06), transparent 60%),
    linear-gradient(180deg, var(--ink-0) 0%, var(--ink-1) 40%, var(--ink-0) 100%);
  filter: saturate(110%);
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(to right, rgba(120, 180, 255, 0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(120, 180, 255, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, rgba(0,0,0,0.8), transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at center, rgba(0,0,0,0.8), transparent 75%);
  pointer-events: none;
}

/* =========================================================================
   Utility primitives
   ========================================================================= */

.muted  { color: var(--text-3); }
.dim    { color: var(--text-2); }
.mono   { font-family: var(--font-mono); }
.caps   {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
}
.tabular { font-variant-numeric: tabular-nums; }

.row { display: flex; align-items: center; gap: var(--space-3); }
.row--between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.stack-lg { gap: var(--space-5); }
.grid { display: grid; gap: var(--space-5); }

/* =========================================================================
   Glass panel — the core design primitive
   ========================================================================= */

.panel {
  position: relative;
  background: linear-gradient(180deg, var(--fog-1), var(--fog-2));
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-panel);
  padding: var(--space-5);
  isolation: isolate;
}

.panel::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    135deg,
    rgba(120, 180, 255, 0.35),
    rgba(120, 180, 255, 0.02) 30%,
    rgba(120, 180, 255, 0.02) 70%,
    rgba(154, 124, 255, 0.25)
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
}

/* Corner reticles — little L-brackets at each corner for the holographic feel */
.panel--reticle::after {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: calc(var(--r-lg) - 4px);
  background:
    linear-gradient(var(--cyan), var(--cyan)) top left     / 12px 1px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) top left     / 1px 12px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) top right    / 12px 1px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) top right    / 1px 12px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) bottom left  / 12px 1px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) bottom left  / 1px 12px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) bottom right / 12px 1px no-repeat,
    linear-gradient(var(--cyan), var(--cyan)) bottom right / 1px 12px no-repeat;
  opacity: 0.35;
  pointer-events: none;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--edge-1);
}
.panel-title { font-size: 14px; font-weight: 600; letter-spacing: 0.02em; }

/* =========================================================================
   Forms
   ========================================================================= */

.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field > label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.02em;
}

.input, .textarea, .select {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  color: var(--text-1);
  background-color: rgba(5, 7, 15, 0.55);
  border: 1px solid var(--edge-1);
  border-radius: var(--r-sm);
  outline: none;
  transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out), background 160ms var(--ease-out);
  box-shadow: var(--shadow-inset-hair);
}
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--edge-2); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--edge-3);
  background-color: rgba(5, 7, 15, 0.75);
  box-shadow:
    var(--shadow-inset-hair),
    0 0 0 3px var(--cyan-haze),
    0 0 22px -2px var(--cyan-glow);
}

.textarea { resize: vertical; min-height: 96px; }

/* Native select chrome can't be glass-styled, so replace it: flat
   appearance + our own chevron, and explicit option colors so the open
   list matches the palette in browsers that honor option styling.
   (The popup itself renders dark via :root color-scheme.) */
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23a7b3cd' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}
.select option,
.select optgroup {
  background: var(--ink-2);
  color: var(--text-1);
}
.select option:disabled { color: var(--text-4); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 18px;
  font: inherit;
  font-weight: 500;
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--edge-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all 160ms var(--ease-out);
  letter-spacing: 0.01em;
}
.btn:hover {
  border-color: var(--edge-3);
  background: rgba(120, 180, 255, 0.06);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn--primary {
  color: #021822;
  background:
    linear-gradient(180deg, #9be7ff 0%, var(--cyan) 60%, #37b8e8 100%);
  border-color: transparent;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 10px 30px -8px var(--cyan-glow),
    0 0 0 1px rgba(79, 209, 255, 0.5);
  font-weight: 600;
}
.btn--primary:hover {
  background:
    linear-gradient(180deg, #b5efff 0%, #74dbff 60%, #4ac7ec 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 14px 36px -6px var(--cyan-glow),
    0 0 0 1px rgba(79, 209, 255, 0.7);
}

.btn--ghost { background: transparent; border-color: var(--edge-1); color: var(--text-2); }
.btn--ghost:hover { color: var(--text-1); border-color: var(--edge-2); background: rgba(255,255,255,0.02); }

.btn--danger { color: var(--rose); border-color: rgba(255, 93, 143, 0.4); }
.btn--danger:hover { background: rgba(255, 93, 143, 0.08); border-color: rgba(255, 93, 143, 0.7); }

.btn-block { width: 100%; }

/* =========================================================================
   Badges / status pills
   ========================================================================= */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  border-radius: 999px;
  border: 1px solid var(--edge-1);
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.02);
  text-transform: uppercase;
}
.pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}
.pill--ok      { color: var(--mint);   border-color: rgba(61, 220, 151, 0.35); }
.pill--warn    { color: var(--amber);  border-color: rgba(255, 197, 109, 0.35); }
.pill--danger  { color: var(--rose);   border-color: rgba(255, 93, 143, 0.35); }
.pill--info    { color: var(--cyan);   border-color: rgba(79, 209, 255, 0.40); }
.pill--muted   { color: var(--text-3); border-color: var(--edge-1); }

/* =========================================================================
   Boot / splash screen (used by HomeController placeholder)
   ========================================================================= */

.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
}
.boot-screen { text-align: center; max-width: 520px; }
.boot-screen h1 {
  font-size: 36px;
  letter-spacing: -0.025em;
  background: linear-gradient(180deg, #ffffff 0%, #bcd3ec 100%);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  margin-bottom: var(--space-2);
}
.boot-screen .muted { font-size: 14px; }

.boot-orb {
  width: 128px;
  height: 128px;
  margin: 0 auto var(--space-6);
  border-radius: 50%;
  position: relative;
  background:
    radial-gradient(circle at 35% 35%, rgba(255,255,255,0.9), rgba(79, 209, 255, 0.6) 30%, rgba(79, 209, 255, 0.1) 60%, transparent 70%);
  filter: blur(0.3px);
  box-shadow:
    0 0 80px 10px var(--cyan-glow),
    0 0 160px 20px rgba(154, 124, 255, 0.25);
  animation: orb-pulse 4s var(--ease-in-out) infinite;
}
.boot-orb::after {
  content: '';
  position: absolute;
  inset: -40px;
  border-radius: 50%;
  border: 1px dashed rgba(120, 180, 255, 0.25);
  animation: orb-ring 20s linear infinite;
}

@keyframes orb-pulse {
  0%, 100% { transform: scale(1);   filter: blur(0.3px) brightness(1); }
  50%      { transform: scale(1.03); filter: blur(0.3px) brightness(1.15); }
}
@keyframes orb-ring {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* =========================================================================
   Auth layout (login screen)
   ========================================================================= */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
}
.auth .panel { width: 100%; max-width: 420px; padding: var(--space-6); }
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.auth-brand .brand-mark {
  width: 44px; height: 44px; border-radius: 12px;
  background:
    radial-gradient(circle at 35% 35%, #ffffff 0%, var(--cyan) 35%, #1a4d6b 80%);
  box-shadow:
    0 0 0 1px var(--edge-3),
    0 0 24px -4px var(--cyan-glow);
}
.auth-brand .brand-name {
  font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-2);
}
.auth-title { text-align: center; margin-bottom: var(--space-5); }
.auth-title h1 { font-size: 22px; }
.auth-title p  { color: var(--text-3); margin-top: 4px; }
.auth-footer   { text-align: center; margin-top: var(--space-5); font-size: 12px; color: var(--text-4); }
.auth-error {
  background: rgba(255, 93, 143, 0.08);
  border: 1px solid rgba(255, 93, 143, 0.35);
  color: var(--rose);
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 13px;
  margin-bottom: var(--space-4);
}

/* =========================================================================
   App shell — sidebar + main
   ========================================================================= */

.shell {
  display: grid;
  grid-template-columns: 264px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: var(--space-5);
  border-right: 1px solid var(--edge-1);
  background: linear-gradient(180deg, rgba(5, 7, 15, 0.85), rgba(5, 7, 15, 0.65));
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 4px 8px;
}
.sidebar-brand .brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background:
    radial-gradient(circle at 35% 35%, #ffffff 0%, var(--cyan) 35%, #1a4d6b 80%);
  box-shadow: 0 0 0 1px var(--edge-3), 0 0 18px -4px var(--cyan-glow);
}
.sidebar-brand .brand-name {
  font-size: 12px;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--text-2);
}

/* Workspace switcher */
.ws-switcher {
  position: relative;
  background: rgba(5, 7, 15, 0.5);
  border: 1px solid var(--edge-1);
  border-radius: var(--r-md);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: border-color 160ms var(--ease-out), background 160ms var(--ease-out);
}
.ws-switcher:hover { border-color: var(--edge-2); background: rgba(5, 7, 15, 0.7); }
.ws-switcher .ws-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan-glow);
  flex: 0 0 auto;
}
.ws-switcher .ws-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.ws-switcher .ws-chev {
  color: var(--text-3);
  font-size: 10px;
}

/* Sidebar nav */
.nav-section {
  display: flex; flex-direction: column; gap: 2px;
}
.nav-heading {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-4);
  padding: 0 8px;
  margin-bottom: 6px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  color: var(--text-2);
  border-radius: var(--r-sm);
  font-size: 13px;
  position: relative;
  transition: color 120ms, background 120ms;
}
.nav-link:hover { color: var(--text-1); background: rgba(120, 180, 255, 0.05); }
.nav-link[aria-current='page'] {
  color: var(--text-1);
  background:
    linear-gradient(90deg, rgba(79, 209, 255, 0.14), rgba(79, 209, 255, 0) 80%);
}
.nav-link[aria-current='page']::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan-glow);
}
.nav-link .nav-icon {
  width: 16px; height: 16px; opacity: 0.8;
}

/* Small leading glyph for top-level rows (standalone links + group triggers) */
.nav-glyph {
  flex: 0 0 auto;
  width: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  opacity: 0.9;
}

/* ── Grouped flyout navigation ────────────────────────────────────────── */
.nav-group { position: relative; }

.nav-group-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  color: var(--text-2);
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  position: relative;
  transition: color 120ms, background 120ms;
}
.nav-group-trigger:hover { color: var(--text-1); background: rgba(120, 180, 255, 0.05); }
.nav-group-label { flex: 1; min-width: 0; }
.nav-group-chev {
  flex: 0 0 auto;
  color: var(--text-4);
  font-size: 14px;
  transition: transform 160ms var(--ease-out), color 120ms;
}
.nav-group:hover .nav-group-chev,
.nav-group.is-open .nav-group-chev { transform: translateX(2px); color: var(--text-2); }

/* Active group (contains the current page): same cyan accent as a live link */
.nav-group-trigger.is-active { color: var(--text-1); }
.nav-group-trigger.is-active .nav-glyph { color: var(--cyan); opacity: 1; }
.nav-group-trigger.is-active::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan-glow);
}

/* The frosted-glass flyout panel.
   app.js relocates each panel to <body> (so the sidebar's backdrop-filter +
   overflow can't make it the containing block and clip it), sets its top/left
   relative to the trigger, and toggles .is-shown for hover / click-pin /
   keyboard reveal. */
.nav-flyout {
  position: fixed;
  top: 0;
  left: 0;
  min-width: 208px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: rgba(12, 18, 38, 0.55);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  backdrop-filter: blur(22px) saturate(150%);
  border: 1px solid var(--edge-2);
  border-radius: var(--r-md);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 24px 60px -20px rgba(0, 0, 0, 0.8);
  opacity: 0;
  visibility: hidden;
  transform: translateX(-6px);
  transition: opacity 140ms var(--ease-out), transform 140ms var(--ease-out), visibility 140ms;
  z-index: 200;
  pointer-events: none;
}
/* Invisible hover bridge across the gap so the pointer can reach the panel */
.nav-flyout::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 0;
  bottom: 0;
  width: 14px;
}
.nav-flyout.is-shown {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  pointer-events: auto;
}
.nav-flyout-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-4);
  padding: 2px 8px 6px;
}
.nav-flyout .nav-link[aria-current='page']::before { left: -8px; }

.sidebar-footer {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--edge-1);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-3);
}
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b4b80, #1a2447);
  border: 1px solid var(--edge-2);
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-1);
  letter-spacing: 0.05em;
}

/* Main area */
.main { padding: var(--space-6); max-width: 1400px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-6);
}
.topbar h1 {
  font-size: 24px;
  background: linear-gradient(180deg, #ffffff 0%, #c9d6ec 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.topbar .sub { color: var(--text-3); font-size: 13px; margin-top: 2px; }

/* Dashboard grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-5);
}

.metric {
  padding: var(--space-5);
}
.metric .metric-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.14em; }
.metric .metric-value {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 4px;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
}
.metric .metric-value .unit { color: var(--text-3); font-size: 14px; font-weight: 400; margin-left: 6px; }
.metric .metric-trend { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.metric .metric-trend .up   { color: var(--mint); }
.metric .metric-trend .down { color: var(--rose); }

/* Simple table */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.table th, .table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--edge-1);
}
.table th {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-4);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.015);
}
.table tbody tr:hover td { background: rgba(120, 180, 255, 0.03); }
.table tbody tr:last-child td { border-bottom: 0; }

.empty {
  padding: var(--space-7) var(--space-5);
  text-align: center;
  color: var(--text-3);
  border: 1px dashed var(--edge-1);
  border-radius: var(--r-md);
}

/* =========================================================================
   Small helpers — keep last so they can override earlier specificity
   ========================================================================= */

.hide { display: none !important; }

.thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  border: 1px solid var(--edge-1);
  object-fit: cover;
  display: block;
}
.thumb--empty { background: var(--ink-3); }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--edge-1);
  }
  .main { padding: var(--space-5); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* =========================================================================
   Toasts — overlay stack, top-right
   ========================================================================= */

.toast-stack {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 1000;
  pointer-events: none;
  max-width: calc(100vw - 2 * var(--space-5));
  width: 360px;
}

.toast {
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 12px 14px 12px 16px;
  color: var(--text-1);
  background: linear-gradient(180deg, rgba(18, 26, 54, 0.9), rgba(10, 15, 31, 0.9));
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--edge-2);
  border-left-width: 3px;
  border-radius: var(--r-md);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 14px 40px -12px rgba(0, 0, 0, 0.8),
    0 0 0 1px var(--edge-1);
  font-size: 13px;
  line-height: 1.45;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
}
.toast--in  { opacity: 1; transform: translateY(0); }
.toast--out { opacity: 0; transform: translateY(-8px); }

.toast__body {
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
}
.toast__close {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: -2px;
  padding: 0;
  font: inherit;
  font-size: 18px;
  line-height: 1;
  color: var(--text-3);
  background: transparent;
  border: 0;
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: color 120ms, background 120ms;
}
.toast__close:hover { color: var(--text-1); background: rgba(255,255,255,0.06); }

.toast--ok    { border-left-color: var(--mint);  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 14px 40px -12px rgba(0,0,0,0.8), 0 0 0 1px rgba(61,220,151,0.25); }
.toast--error { border-left-color: var(--rose);  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 14px 40px -12px rgba(0,0,0,0.8), 0 0 0 1px rgba(255,93,143,0.28); }
.toast--info  { border-left-color: var(--cyan);  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 14px 40px -12px rgba(0,0,0,0.8), 0 0 0 1px rgba(79,209,255,0.28); }
.toast--warn  { border-left-color: var(--amber); box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 14px 40px -12px rgba(0,0,0,0.8), 0 0 0 1px rgba(255,197,109,0.28); }

/* =========================================================================
   Modals — dark-glass dialogs
   ========================================================================= */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 900;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}
.modal.modal--open { display: flex; }
body.modal-open { overflow: hidden; }

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 3, 10, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal__panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: linear-gradient(180deg, var(--fog-1), var(--fog-2)), var(--ink-2);
  border: 1px solid var(--edge-2);
  border-radius: var(--r-lg);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 32px 80px -20px rgba(0, 0, 0, 0.85),
    0 0 0 1px var(--edge-1);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  animation: modal-pop 180ms var(--ease-out);
}

@keyframes modal-pop {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.modal__title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text-1);
}
.modal__body {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-2);
}
.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin: 0;
}

.modal__panel--wide { max-width: 620px; }

/* =========================================================================
   Dropdown menu — split-button companion
   ========================================================================= */

.menu { position: relative; display: inline-block; }

.menu__chev {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  line-height: 1;
  transform: translateY(-1px);
  opacity: 0.85;
}

.menu__panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 800;
  min-width: 280px;
  background: linear-gradient(180deg, var(--fog-1), var(--fog-2)), var(--ink-2);
  border: 1px solid var(--edge-2);
  border-radius: var(--r-lg);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 24px 60px -16px rgba(0, 0, 0, 0.85),
    0 0 0 1px var(--edge-1);
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: modal-pop 160ms var(--ease-out);
}

.menu__panel[hidden] { display: none; }

.menu__item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--text-1);
  text-align: left;
  cursor: pointer;
  transition: background 120ms var(--ease-out), border-color 120ms var(--ease-out);
  font: inherit;
}

.menu__item:hover,
.menu__item:focus-visible {
  background: rgba(120, 180, 255, 0.06);
  border-color: var(--edge-1);
  outline: none;
}

.menu__item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
}

.menu__item-sub {
  font-size: 11px;
  color: var(--text-3, var(--text-2));
  line-height: 1.35;
}

/* =====================================================================
   Calendar grid — equal-sized day cells, compact entry cards,
   network filter pills, hover preview popover.
   ===================================================================== */

.cal-day {
  min-height: 160px;
  display: flex;
  flex-direction: column;
}

.cal-day__entries {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.cal-entry {
  display: block;
  padding: 4px 6px;
  background: rgba(120, 180, 255, 0.05);
  border-left: 2px solid var(--cyan);
  border-radius: 3px;
  font-size: 11px;
  color: var(--text-1);
  text-decoration: none;
  overflow: hidden;
  transition: background 0.12s ease;
}
.cal-entry:hover {
  background: rgba(120, 180, 255, 0.12);
  color: var(--text-1);
  text-shadow: none;
}
.cal-entry__row {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
}
.cal-entry__time {
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.cal-entry__title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-entry__net-extra {
  color: var(--text-3);
  font-size: 9px;
  font-weight: 600;
  flex-shrink: 0;
}
.cal-entry--green  { border-left-color: #4ade80; }
.cal-entry--amber  { border-left-color: #f59e0b; }
.cal-entry--red    { border-left-color: #ef4444; }
.cal-entry--gray   { border-left-color: var(--text-3); background: rgba(107, 120, 151, 0.06); }
.cal-entry--muted  { border-left-color: var(--text-3); opacity: 0.55; }
.cal-entry[draggable="true"] { cursor: grab; }
.cal-entry[hidden] { display: none !important; }

.cal-more {
  margin-top: 2px;
  padding: 2px 6px;
  background: transparent;
  border: 1px solid var(--edge-1);
  border-radius: 3px;
  font-size: 10px;
  color: var(--text-3);
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: inherit;
}
.cal-more:hover { color: var(--cyan); border-color: var(--edge-3); }

/* Compact circular network badge (renders <span class="net-icon">). */
.net-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-family: var(--font-sans, system-ui, sans-serif);
  letter-spacing: -0.04em;
  flex-shrink: 0;
  line-height: 1;
}
.net-icon[data-len="1"] { font-size: 10px; }
.net-icon[data-len="2"] { font-size: 8px; }
.net-icon--lg { width: 18px; height: 18px; }
.net-icon--lg[data-len="1"] { font-size: 12px; }
.net-icon--lg[data-len="2"] { font-size: 10px; }

/* Network filter pill row. */
.cal-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--space-3);
  align-items: center;
}
.cal-filters__label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-right: 4px;
}
.cal-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--edge-1);
  border-radius: 999px;
  background: rgba(5, 7, 15, 0.55);
  color: var(--text-2);
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.cal-filter-pill:hover { border-color: var(--edge-3); color: var(--text-1); }
.cal-filter-pill[aria-pressed="true"] {
  border-color: var(--cyan);
  color: var(--cyan-soft);
  background: var(--cyan-haze);
  box-shadow: 0 0 12px -4px var(--cyan-glow);
}

/* Custom hover preview card (rendered by calendar-hover.js into <body>). */
.cal-hover-card {
  position: fixed;
  z-index: 1000;
  width: 320px;
  max-width: calc(100vw - 24px);
  padding: var(--space-4);
  background: rgba(5, 7, 15, 0.94);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--edge-3);
  border-radius: var(--r-md);
  box-shadow: 0 0 32px -4px var(--cyan-glow), 0 12px 32px rgba(0, 0, 0, 0.5);
  font-size: 12px;
  color: var(--text-1);
  pointer-events: none;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.cal-hover-card[data-visible="true"] {
  opacity: 1;
  transform: translateY(0);
}
.cal-hover-card__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 4px;
  line-height: 1.35;
}
.cal-hover-card__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.cal-hover-card__meta .tabular { color: var(--cyan); }
.cal-hover-card__excerpt {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-2);
  margin: 8px 0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 7.5em;
  overflow: hidden;
  position: relative;
}
.cal-hover-card__excerpt::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 2em;
  background: linear-gradient(to bottom, rgba(5, 7, 15, 0), rgba(5, 7, 15, 0.94));
  pointer-events: none;
}
.cal-hover-card__networks {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--edge-1);
}
.cal-hover-card__net-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-2);
}
.cal-hover-card__net-row .net-icon { width: 12px; height: 12px; }
.cal-hover-card__net-row .net-icon[data-len="1"] { font-size: 8px; }
.cal-hover-card__net-row .net-icon[data-len="2"] { font-size: 7px; }
.cal-hover-card__notes {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--edge-1);
  font-size: 11px;
  color: var(--text-3);
  font-style: italic;
}
.cal-hover-card__open {
  margin-top: 10px;
  font-size: 11px;
  color: var(--cyan);
  letter-spacing: 0.04em;
}

/* =========================================================================
   Confirm dialog — [data-confirm] forms (see app.js)
   Reuses the .modal__* panel/backdrop visual language; own root class so
   the generic [data-modal] machinery never touches it.
   ========================================================================= */

.confirm-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 950; /* above .modal (900) so it can stack over an open modal */
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}
.confirm-modal.confirm-modal--open { display: flex; }
.confirm-modal .modal__panel { max-width: 440px; }
.confirm-modal .modal__body { white-space: pre-line; }

/* =========================================================================
   LinkedIn formatting toolbar (post body) — see linkedin-format.js
   ========================================================================= */
.lf-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}
.lf-btn {
  padding: 4px 11px;
  font-size: 13px;
  line-height: 1.2;
  min-width: 34px;
}
.lf-btn strong { font-weight: 800; }
.lf-emoji-wrap { position: relative; display: inline-flex; }
/* The panel uses display:grid, which overrides the `hidden` attribute's
   UA display:none — restore it so the picker stays closed until toggled. */
.lf-emoji-panel[hidden] { display: none; }
.lf-emoji-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 8px;
  background: var(--ink-2);
  border: 1px solid var(--edge-2);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-panel);
}
.lf-emoji {
  background: transparent;
  border: 0;
  font-size: 20px;
  line-height: 1;
  padding: 6px;
  border-radius: var(--r-xs);
  cursor: pointer;
}
.lf-emoji:hover { background: rgba(120, 180, 255, 0.12); }
.lf-hint { color: var(--text-3); font-size: 11px; margin-left: auto; }
