/* ============================================================
   SAFESHIFT — NICU Handover HUD
   Design System & Layout
   ============================================================ */

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

/* ── Design Tokens ───────────────────────────────────────── */
:root {
  /* ── Design Tokens (Default: Dark Theme) ───────────────── */
  --bg-deep:       #080c18;
  --bg-surface:    #0f1729;
  --bg-card:       #141e33;
  --bg-card-hi:    #1a2640;
  --bg-glass:      rgba(20, 30, 51, 0.7);
  --bg-topbar:     rgba(8, 12, 24, 0.85);
  --bg-overlay:    rgba(8, 12, 24, 0.75);

  --primary:       #4f8ef7;
  --primary-dim:   rgba(79, 142, 247, 0.18);
  --primary-glow:  rgba(79, 142, 247, 0.35);

  --accent:        #34d399;   /* green — on time */
  --amber:         #fbbf24;   /* amber — warning */
  --danger:        #f87171;   /* red — overrun */

  --text:          #f1f5f9;
  --text-sub:      #94a3b8;
  --text-dim:      #475569;
  --border:        rgba(255,255,255,0.07);
  --border-hi:     rgba(255,255,255,0.14);

  --radial-glow-1: rgba(79, 142, 247, 0.07);
  --radial-glow-2: rgba(52, 211, 153, 0.05);

  --sec-col-0: #3b82f6;
  --sec-col-1: #8b5cf6;
  --sec-col-2: #ec4899;
  --sec-col-3: #f43f5e;
  --sec-col-4: #f59e0b;
  --sec-col-5: #10b981;
  --sec-col-6: #06b6d4;
  --sec-col-7: #64748b;

  --radius-sm:     6px;
  --radius-md:     12px;
  --radius-lg:     20px;
  --radius-xl:     28px;

  --shadow-card:   0 4px 24px rgba(0,0,0,0.5);
  --shadow-glow:   0 0 32px rgba(79, 142, 247, 0.2);

  --transition:    all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --theme-transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, background-image 0.3s ease;
}

:root[data-theme="light"] {
  /* ── Design Tokens (Light Theme Override) ──────────────── */
  --bg-deep:       #f8fafc;
  --bg-surface:    #ffffff;
  --bg-card:       #ffffff;
  --bg-card-hi:    #f1f5f9;
  --bg-glass:      rgba(255, 255, 255, 0.8);
  --bg-topbar:     rgba(248, 250, 252, 0.85);
  --bg-overlay:    rgba(248, 250, 252, 0.75);

  --primary:       #2563eb;
  --primary-dim:   rgba(37, 99, 235, 0.08);
  --primary-glow:  rgba(37, 99, 235, 0.15);

  --accent:        #10b981;   /* Rich green */
  --amber:         #d97706;   /* Dark gold/orange for clear light-mode contrast */
  --danger:        #dc2626;   /* Clinical red */

  --text:          #0f172a;   /* Slate 900 */
  --text-sub:      #475569;   /* Slate 600 */
  --text-dim:      #94a3b8;   /* Slate 400 */
  --border:        rgba(15, 23, 42, 0.08);
  --border-hi:     rgba(15, 23, 42, 0.15);

  --radial-glow-1: rgba(37, 99, 235, 0.03);
  --radial-glow-2: rgba(16, 185, 129, 0.03);

  --shadow-card:   0 4px 20px rgba(15, 23, 42, 0.05);
  --shadow-glow:   0 0 24px rgba(37, 99, 235, 0.08);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--bg-deep);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.5;
  transition: var(--theme-transition);
  background-image:
    radial-gradient(ellipse 70% 60% at 15% 50%, var(--radial-glow-1) 0%, transparent 65%),
    radial-gradient(ellipse 50% 50% at 85% 20%, var(--radial-glow-2) 0%, transparent 55%);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── Screens ──────────────────────────────────────────────── */
.screen {
  display: none;
  min-height: 100dvh;
  flex-direction: column;
}
.screen.active { display: flex; }

/* ── Top Bar (shared) ─────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-topbar);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
  transition: var(--theme-transition);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(79,142,247,0.4);
}
.brand-name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: linear-gradient(90deg, var(--text), var(--text-sub));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.brand-sub {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ============================================================
   SETUP SCREEN
   ============================================================ */

#setup-screen {
  padding-bottom: 40px;
}

.setup-content {
  max-width: 640px;
  margin: 0 auto;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.setup-hero {
  text-align: center;
  padding: 8px 0 16px;
}
.setup-hero h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}
.setup-hero p {
  font-size: 0.875rem;
  color: var(--text-sub);
}

/* ── Shift Toggle ─────────────────────────────────────────── */
.setup-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.setup-card-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.shift-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--bg-deep);
  border-radius: var(--radius-md);
  padding: 4px;
}

.shift-btn {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.925rem;
  font-weight: 600;
  color: var(--text-sub);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.shift-btn.active {
  background: linear-gradient(135deg, var(--primary), #3a7ce8);
  color: white;
  box-shadow: 0 2px 12px var(--primary-glow);
}

.date-display {
  margin-top: 14px;
  font-size: 0.875rem;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  gap: 8px;
}
.date-display input[type="date"] {
  background: var(--bg-deep);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 6px 10px;
  font-family: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}
.date-display input[type="date"]:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Room Selectors ──────────────────────────────────────── */
.rooms-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.room-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition);
}
.room-row:hover { border-color: var(--border-hi); }

.room-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.room-name {
  font-size: 0.925rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
.room-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  transition: var(--transition);
}
.dot.empty {
  background: transparent;
  border: 1.5px solid var(--text-dim);
}

.room-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.count-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-sub);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: var(--transition);
  line-height: 1;
}
.count-btn:hover:not(:disabled) {
  background: var(--primary-dim);
  border-color: var(--primary);
  color: var(--primary);
}
.count-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.count-display {
  width: 40px;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
}

.no-patients-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-style: italic;
}

/* ── Begin Button ─────────────────────────────────────────── */
.begin-btn {
  width: 100%;
  padding: 18px 24px;
  border-radius: var(--radius-lg);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: white;
  box-shadow: 0 4px 24px rgba(79,142,247,0.4), 0 1px 0 rgba(255,255,255,0.1) inset;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.begin-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(79,142,247,0.5), 0 1px 0 rgba(255,255,255,0.1) inset;
}
.begin-btn:active { transform: translateY(0); }

/* ── Previous Sessions ──────────────────────────────────── */
.prev-sessions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.prev-sessions-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-sub);
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  gap: 10px;
}
.session-item-info { color: var(--text-sub); }
.session-item-time { font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; color: var(--accent); }
.session-export-btn {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 600;
  padding: 4px 10px;
  border: 1px solid var(--primary-dim);
  border-radius: 20px;
  background: var(--primary-dim);
  transition: var(--transition);
  white-space: nowrap;
}
.session-export-btn:hover { background: rgba(79,142,247,0.3); }

.no-sessions {
  font-size: 0.82rem;
  color: var(--text-dim);
  text-align: center;
  padding: 16px 0;
}

/* ============================================================
   HUD SCREEN
   ============================================================ */

#hud-screen {
  display: none;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}
#hud-screen.active { display: flex; }

.hud-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-topbar);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
  transition: var(--theme-transition);
}

.hud-brand { display: flex; align-items: center; gap: 8px; margin-right: 4px; }
.hud-brand .brand-icon { width: 26px; height: 26px; font-size: 13px; }
.hud-brand .brand-name { font-size: 0.85rem; }

.hud-shift-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--primary-dim);
  color: var(--primary);
  border: 1px solid rgba(79,142,247,0.25);
}

.hud-live-clock {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  margin-left: 10px;
  padding: 2px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-variant-numeric: tabular-nums;
  box-shadow: 0 0 10px rgba(0,0,0,0.1) inset;
}

.hud-total-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-sub);
  margin-left: auto;
}
.hud-total-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-left: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.hud-btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  border: 1px solid transparent;
}
.hud-btn-pause {
  background: var(--bg-card);
  border-color: var(--border-hi);
  color: var(--text-sub);
}
.hud-btn-pause:hover { background: var(--bg-card-hi); color: var(--text); }
.hud-btn-pause.paused {
  background: rgba(251,191,36,0.15);
  border-color: rgba(251,191,36,0.3);
  color: var(--amber);
}
.hud-btn-end {
  background: rgba(248,113,113,0.12);
  border-color: rgba(248,113,113,0.25);
  color: var(--danger);
}
.hud-btn-end:hover { background: rgba(248,113,113,0.22); }

/* Interrupt pill in topbar (compact) */
.hud-interrupt-btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(251,191,36,0.1);
  border: 1px solid rgba(251,191,36,0.2);
  color: var(--amber);
  display: flex;
  align-items: center;
  gap: 5px;
  transition: var(--transition);
}
.hud-interrupt-btn:hover { background: rgba(251,191,36,0.2); }

/* ── HUD Main Layout ──────────────────────────────────────── */
.hud-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-deep);
}

/* Tiles Grid (Left) */
.tiles-panel {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  align-content: start;
}

.section-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.section-tile:hover {
  border-color: var(--border-hi);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.section-tile.active {
  background: var(--primary-dim);
  border-color: rgba(79,142,247,0.4);
  box-shadow: 0 0 0 1px rgba(79,142,247,0.4), var(--shadow-card);
}
.section-tile.active.amber {
  background: rgba(251,191,36,0.1);
  border-color: rgba(251,191,36,0.4);
  box-shadow: 0 0 0 1px rgba(251,191,36,0.4), var(--shadow-card);
}
.section-tile.active.danger {
  background: rgba(248,113,113,0.1);
  border-color: rgba(248,113,113,0.4);
  box-shadow: 0 0 0 1px rgba(248,113,113,0.4), var(--shadow-card);
}

.section-tile.pristine {
  opacity: 0.6;
}
.section-tile.pristine:hover {
  opacity: 1;
}

.tile-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}
.tile-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.tile-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tile-visit-badge {
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--bg-deep);
  color: var(--text-dim);
  padding: 2px 6px;
  border-radius: 10px;
}
.tile-active-pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary-glow);
  animation: pulse-ring 1.8s ease-out infinite;
}
.section-tile.amber .tile-active-pip { background: var(--amber); box-shadow: 0 0 8px rgba(251,191,36,0.6); }
.section-tile.danger .tile-active-pip { background: var(--danger); box-shadow: 0 0 8px rgba(248,113,113,0.6); }

.tile-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  margin-top: auto;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tile-time.amber { color: var(--amber); }
.tile-time.danger { color: var(--danger); }

.tile-perpt {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-sub);
  margin-top: 4px;
  height: 16px;
}

/* Tile Cot Dots */
.tile-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}
.tile-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  transition: all 0.15s ease;
  position: relative;
}
.tile-dot.filled {
  background: var(--accent);
  box-shadow: 0 0 6px rgba(52,211,153,0.3);
}
.tile-dot.empty {
  background: transparent;
  border: 1.5px solid var(--text-dim);
}
.tile-dot.hover-preview.empty {
  background: rgba(52,211,153,0.3);
  border-color: var(--accent);
}
.tile-dot.hover-preview.filled {
  background: rgba(248,113,113,0.5); /* previewing decrement */
}

/* Analogue Clock Panel (Center) */
.hud-clock-panel {
  display: none; /* hidden by default, shown on large screens */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  border-left: 1px solid var(--border);
  background: var(--bg-card-hi);
  flex-shrink: 0;
}

.clock-container {
  width: 100%;
  max-width: 380px;
  aspect-ratio: 1;
  position: relative;
  border-radius: 50%;
  background: var(--bg-deep);
  box-shadow: 
    0 10px 40px rgba(0,0,0,0.3),
    0 0 0 10px var(--bg-card) inset,
    0 0 0 1px var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.clock-svg {
  width: 90%;
  height: 90%;
  transform: rotate(-90deg); /* 12 o'clock at top */
  overflow: visible;
}

.clock-face {
  fill: transparent;
}

.clock-mark-hour {
  stroke: var(--text-dim);
  stroke-width: 3;
  stroke-linecap: round;
}

.clock-mark-minute {
  stroke: var(--text-dim);
  stroke-width: 1;
  opacity: 0.4;
}

.clock-slice {
  fill: transparent;
  stroke-width: 32; /* Width of the pie slice */
  opacity: 0.8;
  transition: stroke-dasharray 0.5s ease;
}

.clock-hand-hour {
  stroke: var(--text);
  stroke-width: 5;
  stroke-linecap: round;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.clock-hand-minute {
  stroke: var(--primary);
  stroke-width: 3;
  stroke-linecap: round;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.clock-center-dot {
  fill: var(--text);
  stroke: var(--bg-card);
  stroke-width: 2;
}

/* Section Colors for the Pie Chart and Tiles */
.clock-slice-color-0 { stroke: var(--sec-col-0); }
.clock-slice-color-1 { stroke: var(--sec-col-1); }
.clock-slice-color-2 { stroke: var(--sec-col-2); }
.clock-slice-color-3 { stroke: var(--sec-col-3); }
.clock-slice-color-4 { stroke: var(--sec-col-4); }
.clock-slice-color-5 { stroke: var(--sec-col-5); }
.clock-slice-color-6 { stroke: var(--sec-col-6); }
.clock-slice-color-7 { stroke: var(--sec-col-7); }

.section-tile[data-color-idx="0"] { border-left: 4px solid var(--sec-col-0); }
.section-tile[data-color-idx="1"] { border-left: 4px solid var(--sec-col-1); }
.section-tile[data-color-idx="2"] { border-left: 4px solid var(--sec-col-2); }
.section-tile[data-color-idx="3"] { border-left: 4px solid var(--sec-col-3); }
.section-tile[data-color-idx="4"] { border-left: 4px solid var(--sec-col-4); }
.section-tile[data-color-idx="5"] { border-left: 4px solid var(--sec-col-5); }
.section-tile[data-color-idx="6"] { border-left: 4px solid var(--sec-col-6); }
.section-tile[data-color-idx="7"] { border-left: 4px solid var(--sec-col-7); }

/* HUD Right Panel */
.hud-right-panel {
  width: 320px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
}

.detail-panel {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: 220px;
  justify-content: center;
}
.detail-placeholder {
  color: var(--text-dim);
}
.detail-placeholder-icon {
  font-size: 2rem;
  margin-bottom: 10px;
  opacity: 0.5;
}

.detail-section-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}
.detail-timer {
  font-family: 'JetBrains Mono', monospace;
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
  transition: color 0.3s;
}
.detail-timer.amber { color: var(--amber); }
.detail-timer.danger { color: var(--danger); }

.detail-per-patient {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--text-sub);
  height: 20px;
  margin-bottom: 20px;
}

/* Tips Panel */
.tips-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tips-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tips-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.tips-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.tips-framework {
  font-size: 0.65rem;
  color: var(--primary);
  font-weight: 600;
  padding: 2px 7px;
  background: var(--primary-dim);
  border-radius: 20px;
  letter-spacing: 0.05em;
}
.tips-section-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-sub);
}

.tips-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tip-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.tip-icon { font-size: 1rem; flex-shrink: 0; margin-top: -2px; }
.tip-text {
  font-size: 0.82rem;
  color: var(--text-sub);
  line-height: 1.45;
}
.tip-text strong { color: var(--text); font-weight: 600; }
.tip-item.highlight {
  background: rgba(79,142,247,0.06);
  border-color: rgba(79,142,247,0.2);
}
.tip-item.highlight .tip-text { color: var(--text); }

/* Pause overlay */
.paused-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, background-color 0.3s ease;
}
.paused-overlay.visible {
  opacity: 1;
  pointer-events: all;
}
.paused-overlay .paused-label {
  font-size: 2rem;
  font-weight: 800;
  color: var(--amber);
  letter-spacing: -0.02em;
}
.paused-overlay .paused-sub {
  font-size: 0.95rem;
  color: var(--text-sub);
}
.paused-resume-btn {
  padding: 14px 32px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 12px;
  transition: var(--transition);
}
.paused-resume-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px var(--primary-glow); }

/* ============================================================
   SUMMARY SCREEN
   ============================================================ */

#summary-screen {
  overflow-y: auto;
  padding-bottom: 60px;
}

.summary-content {
  max-width: 700px;
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Hero stats */
.summary-hero {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--primary-dim) 100%);
  border: 1px solid var(--primary-glow);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-glow);
  transition: var(--theme-transition);
}
.summary-hero-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.summary-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
}
.summary-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.summary-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1;
}
.summary-stat-label {
  font-size: 0.72rem;
  color: var(--text-sub);
  font-weight: 500;
}

/* Section breakdown table */
.section-table {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.section-table-header {
  display: grid;
  grid-template-columns: 1fr 80px 80px 80px;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
}
.section-table-header span {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.section-table-header span:not(:first-child) { text-align: right; }

.section-row {
  display: grid;
  grid-template-columns: 1fr 80px 80px 80px;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  transition: var(--transition);
}
.section-row:last-child { border-bottom: none; }
.section-row:hover { background: var(--bg-card-hi); }

.section-row-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-row-pts {
  font-size: 0.72rem;
  color: var(--text-dim);
  background: var(--bg-deep);
  padding: 2px 6px;
  border-radius: 20px;
}
.section-row-time, .section-row-perpt, .section-row-pct {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--text-sub);
  text-align: right;
}
.section-row-time { color: var(--text); font-weight: 700; }
.section-row-pct { color: var(--text-dim); font-size: 0.75rem; }

/* Closing safety pause */
.safety-pause-card {
  background: rgba(248,113,113,0.06);
  border: 1px solid rgba(248,113,113,0.2);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.safety-pause-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--danger);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.safety-checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.safety-check-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 0.85rem;
  color: var(--text-sub);
  padding: 6px 0;
  border-bottom: 1px solid rgba(248,113,113,0.1);
  line-height: 1.4;
}
.safety-check-item:last-child { border-bottom: none; }
.safety-check-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }

/* Export section */
.export-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}
.export-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.export-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.export-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  transition: var(--transition);
  border: 1px solid transparent;
  flex: 1;
  min-width: 150px;
  justify-content: center;
}
.export-btn-email {
  background: var(--primary-dim);
  border-color: rgba(79,142,247,0.3);
  color: var(--primary);
}
.export-btn-email:hover { background: rgba(79,142,247,0.25); transform: translateY(-1px); }
.export-btn-copy {
  background: rgba(52,211,153,0.1);
  border-color: rgba(52,211,153,0.25);
  color: var(--accent);
}
.export-btn-copy:hover { background: rgba(52,211,153,0.2); transform: translateY(-1px); }
.export-btn-csv {
  background: rgba(251,191,36,0.1);
  border-color: rgba(251,191,36,0.25);
  color: var(--amber);
}
.export-btn-csv:hover { background: rgba(251,191,36,0.2); transform: translateY(-1px); }
.export-btn-json {
  background: var(--bg-deep);
  border-color: var(--border-hi);
  color: var(--text-sub);
}
.export-btn-json:hover { background: var(--bg-card-hi); color: var(--text); }
.export-success {
  font-size: 0.78rem;
  color: var(--accent);
  text-align: center;
  margin-top: 8px;
  min-height: 20px;
  transition: opacity 0.3s;
}

.new-session-btn {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-lg);
  font-size: 1rem;
  font-weight: 700;
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  color: var(--text-sub);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.new-session-btn:hover {
  background: var(--bg-card-hi);
  color: var(--text);
  border-color: var(--primary);
}

/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-lg);
  padding: 12px 20px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  box-shadow: var(--shadow-card);
  z-index: 1000;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.visible { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: rgba(52,211,153,0.4); }
.toast.warning { border-color: rgba(251,191,36,0.4); }

/* ============================================================
   RESPONSIVE
   ============================================================ */



/* Responsive adjustments */
@media (min-width: 1100px) {
  .hud-clock-panel {
    display: flex;
    width: 400px;
  }
}

@media (max-width: 900px) {
  .hud-right-panel { display: none; }
  .tiles-panel { grid-template-columns: 1fr; padding-bottom: 100px; }
  .hud-total-label { display: none; }
  .hud-btn-pause .btn-label, .hud-btn-end .btn-label, .hud-interrupt-btn .btn-label { display: none; }
  
  .section-table-header,
  .section-row { grid-template-columns: 1fr 70px 70px; }
  .section-table-header span:last-child,
  .section-row-perpt { display: none; }
  .summary-stats-row { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
  .export-btns { flex-direction: column; }
}

@media (max-width: 600px) {
  .tiles-panel {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 10px;
    padding-bottom: 104px; /* Ensure scrolled tiles clear the sticky bottom bar */
  }
  .section-tile {
    padding: 12px 10px;
    border-radius: var(--radius-md);
    min-height: 98px;
  }
  .tile-header {
    margin-bottom: 6px;
  }
  .tile-name {
    font-size: 0.8rem;
  }
  .tile-time {
    font-size: 1.35rem;
    margin-top: 4px;
  }
  .tile-perpt {
    font-size: 0.65rem;
    height: auto;
    margin-top: 2px;
  }
  .tile-dots {
    gap: 3px;
    margin-bottom: 6px;
  }
  .tile-dot {
    width: 10px;
    height: 10px;
    border-width: 1px;
  }
  .tile-visit-badge {
    font-size: 0.6rem;
    padding: 1px 4px;
  }
}

@media (max-width: 480px) {
  .hud-topbar { padding: 8px 12px; gap: 8px; }
  .hud-shift-badge { display: none; }
  
  /* Setup screen responsiveness & overflow fixes */
  .setup-content {
    padding: 16px 12px;
    gap: 14px;
  }
  .setup-hero h1 {
    font-size: 1.4rem;
  }
  .setup-card {
    padding: 14px;
    border-radius: var(--radius-md);
  }
  .room-row {
    padding: 10px 8px;
    gap: 8px;
  }
  .room-name {
    white-space: normal; /* Allow word wrapping for long NICU room titles */
    font-size: 0.82rem;
  }
  .no-patients-label {
    font-size: 0.72rem;
  }
  .room-dots {
    gap: 3px;
  }
  .dot {
    width: 7px;
    height: 7px;
  }
  .room-controls {
    gap: 2px;
  }
  .count-btn {
    width: 28px;
    height: 28px;
    font-size: 0.95rem;
  }
  .count-display {
    width: 28px;
    font-size: 0.95rem;
  }
  .begin-btn {
    padding: 14px 20px;
    font-size: 1rem;
    border-radius: var(--radius-md);
  }
}

@media (max-width: 350px) {
  /* Extremely narrow devices (e.g., iPhone SE first gen) */
  .tiles-panel {
    grid-template-columns: 1fr;
    padding-bottom: 110px;
  }
}

/* ── Sticky HUD Active Bar for Mobile ─────────────────────── */
.mobile-active-bar {
  display: none;
}

@media (max-width: 900px) {
  .mobile-active-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-hi);
    padding: 12px 16px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
    z-index: 150;
    align-items: center;
    gap: 14px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.3s ease;
  }
  
  .mobile-active-bar.visible {
    transform: translateY(0);
  }
  
  .mobile-active-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  
  .mobile-active-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .mobile-active-progress-track {
    height: 4px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
    overflow: hidden;
    border: 0.5px solid var(--border);
  }
  
  .mobile-active-progress-bar {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.4s ease, background-color 0.4s ease;
  }
  .mobile-active-progress-bar.amber { background: var(--amber); }
  .mobile-active-progress-bar.danger { background: var(--danger); }
  
  .mobile-active-target {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    color: var(--text-sub);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .mobile-active-timer-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
  }
  
  .mobile-active-timer {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
    font-variant-numeric: tabular-nums;
  }
  .mobile-active-timer.amber { color: var(--amber); }
  .mobile-active-timer.danger { color: var(--danger); }
  
  .mobile-active-perpt {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    color: var(--text-dim);
    margin-top: 2px;
  }
}

/* ── Utilities ────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.tag {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 2px 8px;
  border-radius: 20px;
}
.tag-am { background: rgba(251,191,36,0.15); color: var(--amber); }
.tag-pm { background: rgba(79,142,247,0.15); color: var(--primary); }

/* Section transition animation */
.section-name.fade-enter { animation: fadeIn 0.25s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Progress Bar & Target Label ─────────────────────────── */
.timer-target-row {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.timer-progress-track {
  height: 5px;
  background: var(--bg-card);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.timer-progress-bar {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  width: 0%;
  transition: width 0.6s ease, background-color 0.5s ease;
}
.timer-progress-bar.amber {
  background: var(--amber);
}
.timer-progress-bar.danger {
  background: var(--danger);
  animation: bar-pulse 1.2s ease-in-out infinite;
}
@keyframes bar-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.timer-target-label {
  font-size: 0.72rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  color: var(--text-dim);
  text-align: right;
  min-height: 18px;
  transition: color 0.3s ease;
}

/* ============================================================
   EDIT START TIME MODAL
   ============================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 24, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modal-fade-in 0.18s ease;
}
.modal-backdrop[hidden] { display: none; }

@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-xl);
  padding: 28px 24px 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), var(--shadow-glow);
  animation: modal-slide-up 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-slide-up {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}
.modal-icon { font-size: 2rem; line-height: 1; flex-shrink: 0; }
.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.modal-subtitle {
  font-size: 0.8rem;
  color: var(--text-sub);
  margin-top: 2px;
}
.modal-body { margin-bottom: 20px; }
.modal-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.modal-time-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-deep);
  border: 1.5px solid var(--border-hi);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  -webkit-appearance: none;
}
.modal-time-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}
.modal-hint {
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--text-dim);
  text-align: center;
  min-height: 20px;
  font-family: 'JetBrains Mono', monospace;
}
.modal-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.modal-btn {
  padding: 13px 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  transition: var(--transition);
  text-align: center;
}
.modal-btn-cancel {
  background: var(--bg-deep);
  border: 1px solid var(--border-hi);
  color: var(--text-sub);
}
.modal-btn-cancel:hover { background: var(--bg-card-hi); color: var(--text); }
.modal-btn-confirm {
  background: linear-gradient(135deg, var(--primary), #3a7ce8);
  color: white;
  box-shadow: 0 2px 12px var(--primary-glow);
}
.modal-btn-confirm:hover {
  box-shadow: 0 4px 20px var(--primary-glow);
  transform: translateY(-1px);
}
.modal-btn-confirm:active { transform: translateY(0); }

/* Long-press hint on non-pristine tiles */
.tile-edit-hint {
  position: absolute;
  bottom: 7px;
  right: 10px;
  font-size: 0.58rem;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.01em;
  user-select: none;
}
.section-tile:not(.pristine):hover .tile-edit-hint,
.section-tile:not(.pristine):focus .tile-edit-hint {
  opacity: 1;
}
