/* HRBR Redesign — design tokens and shell styles */

:root {
  /* Clinical palette (default) */
  --bg: oklch(0.98 0.005 95);
  --bg-elev: oklch(1 0 0);
  --bg-sunken: oklch(0.96 0.006 95);
  --ink: oklch(0.2 0.015 260);
  --ink-2: oklch(0.4 0.012 260);
  --ink-3: oklch(0.55 0.01 260);
  --ink-4: oklch(0.72 0.008 260);
  --line: oklch(0.92 0.006 260);
  --line-2: oklch(0.88 0.008 260);
  --accent: oklch(0.55 0.12 265);
  --accent-soft: oklch(0.93 0.04 265);
  --accent-ink: oklch(0.35 0.12 265);

  /* Stage colors (consistent across themes) */
  --stage-awake: oklch(0.72 0.14 50);
  --stage-rem: oklch(0.62 0.16 320);
  --stage-light: oklch(0.72 0.1 240);
  --stage-deep: oklch(0.42 0.12 260);

  /* Vital colors */
  --hr-color: oklch(0.58 0.17 25);
  --br-color: oklch(0.58 0.12 200);

  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 22px;

  --shadow-sm: 0 1px 2px oklch(0.2 0.02 260 / 0.04), 0 0 0 1px oklch(0.2 0.02 260 / 0.04);
  --shadow: 0 2px 8px oklch(0.2 0.02 260 / 0.06), 0 0 0 1px oklch(0.2 0.02 260 / 0.04);

  --font-sans: 'Inter Tight', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="editorial"] {
  --bg: oklch(0.16 0.015 260);
  --bg-elev: oklch(0.2 0.018 260);
  --bg-sunken: oklch(0.13 0.013 260);
  --ink: oklch(0.97 0.005 95);
  --ink-2: oklch(0.82 0.01 260);
  --ink-3: oklch(0.65 0.012 260);
  --ink-4: oklch(0.48 0.012 260);
  --line: oklch(0.28 0.015 260);
  --line-2: oklch(0.35 0.018 260);
  --accent: oklch(0.78 0.16 85);
  --accent-soft: oklch(0.28 0.06 85);
  --accent-ink: oklch(0.85 0.17 85);
  --stage-awake: oklch(0.78 0.16 65);
  --stage-rem: oklch(0.72 0.18 330);
  --stage-light: oklch(0.72 0.12 230);
  --stage-deep: oklch(0.55 0.13 260);
  --hr-color: oklch(0.72 0.19 25);
  --br-color: oklch(0.72 0.14 200);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

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

/* Sidebar */
.sidebar {
  border-right: 1px solid var(--line);
  background: var(--bg-elev);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  padding: 6px 10px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
  letter-spacing: -0.02em;
}
.brand-name {
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 15px;
}
.brand-sub {
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.nav-group-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-4);
  padding: 16px 10px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 14px;
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
}
.nav-item:hover { background: var(--bg-sunken); color: var(--ink); }
.nav-item.active {
  background: var(--ink);
  color: var(--bg);
}
.nav-icon {
  width: 16px; height: 16px;
  display: grid; place-items: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 10px;
  font-size: 11px;
  color: var(--ink-3);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}
.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: oklch(0.65 0.17 145);
  box-shadow: 0 0 0 3px oklch(0.65 0.17 145 / 0.2);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Main */
.main {
  min-width: 0;
  padding: 40px 56px 80px;
  max-width: 1280px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 32px;
  gap: 24px;
  flex-wrap: wrap;
}
.page-header > :first-child {
  flex: 1;
  min-width: 0;
}
.page-title {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0;
}
.page-subtitle {
  color: var(--ink-3);
  font-size: 14px;
  margin-top: 4px;
}
.page-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  font-weight: 600;
  margin-bottom: 6px;
}

/* Cards */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}
.card-flat {
  background: var(--bg-sunken);
  border-radius: var(--radius);
  padding: 20px;
}
.card-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  font-weight: 600;
  margin: 0 0 16px;
  white-space: nowrap;
}

/* Numerics */
.num {
  font-family: var(--font-sans);
  font-feature-settings: 'tnum', 'ss01';
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Stage chips */
.stage-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
}
.stage-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}
.stage-awake .stage-dot, .dot-awake { background: var(--stage-awake); }
.stage-rem .stage-dot, .dot-rem { background: var(--stage-rem); }
.stage-light .stage-dot, .dot-light { background: var(--stage-light); }
.stage-deep .stage-dot, .dot-deep { background: var(--stage-deep); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--bg-elev);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s;
}
.btn:hover { background: var(--bg-sunken); }
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary:hover { background: var(--ink-2); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg-sunken); }
.btn-danger { color: oklch(0.55 0.2 25); }

.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Segmented */
.segment {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-sunken);
  border-radius: 8px;
  gap: 2px;
}
.segment button {
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
}
.segment button.active {
  background: var(--bg-elev);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* Utility */
.row { display: flex; }
.col { display: flex; flex-direction: column; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.gap-32 { gap: 32px; }
.items-center { align-items: center; }
.items-baseline { align-items: baseline; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; min-width: 0; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-ink-3 { color: var(--ink-3); }
.text-ink-2 { color: var(--ink-2); }

/* Grids */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* Tweaks panel */
.tweaks {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 12px 40px oklch(0.2 0.02 260 / 0.12);
  min-width: 220px;
  display: none;
}
.tweaks.open { display: block; }
.tweaks h3 {
  margin: 0 0 12px;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.tweak-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 12px;
  font-size: 13px;
}
.tweak-row:last-child { margin-bottom: 0; }

/* Mobile adjustments */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 24px 20px 100px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
  .mobile-tabs { display: flex; }
}

/* Mobile bottom tabs */
.mobile-tabs {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-elev);
  border-top: 1px solid var(--line);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 50;
  justify-content: space-around;
}
.mobile-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px;
  border: none;
  background: transparent;
  font-size: 10px;
  color: var(--ink-3);
}
.mobile-tab.active { color: var(--ink); }
