/* KPI cards, badges, charts, modals, command palette, empty states, theme picker */

/* ─── Cards / panels (base, theme-aware via vars) ────────────────── */
.card {
  background: var(--card-bg);
  border: var(--card-border-w) solid var(--border);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--sp-3);
}
.card-header h2 { font-size: 14px; font-weight: 600; }
.card-header .icon-chip {
  width: 28px; height: 28px; border-radius: var(--r-md);
  background: var(--tint-blue); color: var(--brand-600);
  display: grid; place-items: center;
}
.card-header .icon-chip svg { width: 14px; height: 14px; }
.card-header .meta { color: var(--fg-muted); font-size: 12px; margin-left: auto; font-family: var(--f-num); font-feature-settings: var(--num-feat); }
.card-body { padding: 20px; }
.card-link { color: var(--brand-600); font-size: 12px; font-weight: 500; margin-left: auto; }

[data-theme="editorial"] .card-header h2 { font-family: var(--f-display); font-weight: 500; font-size: 16px; }
[data-theme="midnight"] .card-header { border-bottom-color: var(--border); }
[data-theme="midnight"] .card { background: linear-gradient(180deg, var(--bg-elevated), var(--bg-soft)); }

/* ─── KPI cards ──────────────────────────────────────────────────── */
.kpi-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .kpi-grid { grid-template-columns: 1fr; } }

.kpi {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 18px;
  position: relative;
  overflow: hidden;
  transition: transform var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease), border-color var(--t-med) var(--ease);
  box-shadow: var(--card-shadow);
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.kpi .kpi-icon {
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  margin-bottom: 14px;
}
.kpi .kpi-icon svg { width: 18px; height: 18px; }
.kpi .kpi-label { font-size: 12px; color: var(--fg-muted); margin-bottom: 6px; font-weight: 500; }
.kpi .kpi-value {
  font-family: var(--f-num);
  font-size: 32px;
  font-weight: var(--num-weight);
  letter-spacing: var(--num-tracking);
  line-height: 1.05;
  color: var(--fg);
  font-feature-settings: var(--num-feat);
}
.kpi .kpi-sub { font-size: 12px; color: var(--fg-subtle); margin-top: 4px; }
.kpi .kpi-trend {
  position: absolute; right: 14px; top: 14px;
  width: 64px; height: 24px;
  opacity: 0.6;
}
.kpi:hover .kpi-trend { opacity: 1; }

.kpi.tone-blue    .kpi-icon { background: var(--tint-blue);    color: var(--brand-600); }
.kpi.tone-amber   .kpi-icon { background: var(--tint-amber);   color: var(--accent-amber); }
.kpi.tone-rose    .kpi-icon { background: var(--tint-rose);    color: var(--accent-rose); }
.kpi.tone-emerald .kpi-icon { background: var(--tint-emerald); color: var(--accent-emerald); }
.kpi.tone-violet  .kpi-icon { background: var(--tint-violet);  color: var(--accent-violet); }
.kpi.tone-cyan    .kpi-icon { background: var(--tint-cyan);    color: var(--accent-cyan); }
.kpi.tone-slate   .kpi-icon { background: var(--tint-slate);   color: var(--fg-muted); }

.kpi.is-critical {
  background: linear-gradient(135deg, var(--card-bg) 60%, color-mix(in srgb, var(--accent-rose) 8%, transparent));
  border-color: color-mix(in srgb, var(--accent-rose) 25%, transparent);
}

/* Slate Pro: kpis are dense, mono number, no icon-coloured background */
[data-theme="slate-pro"] .kpi { padding: 16px; }
[data-theme="slate-pro"] .kpi .kpi-icon { width: 28px; height: 28px; border-radius: 4px; margin-bottom: 10px; }
[data-theme="slate-pro"] .kpi .kpi-value { font-size: 28px; }

/* Editorial: large serif number, label below number */
[data-theme="editorial"] .kpi {
  display: flex; flex-direction: column;
  padding: 22px;
}
[data-theme="editorial"] .kpi .kpi-icon { display: none; }
[data-theme="editorial"] .kpi .kpi-value {
  font-size: 48px;
  font-weight: 400;
  letter-spacing: -0.04em;
  margin-bottom: 8px;
  order: 1;
}
[data-theme="editorial"] .kpi .kpi-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 10px;
  font-weight: 600;
  margin-bottom: 0;
  order: 2;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
[data-theme="editorial"] .kpi .kpi-sub { order: 3; font-style: italic; }
[data-theme="editorial"] .kpi .kpi-trend { display: none; }

/* Midnight: glow on big numbers, neon outline on critical */
[data-theme="midnight"] .kpi .kpi-value {
  color: var(--fg);
  text-shadow: 0 0 12px color-mix(in srgb, var(--brand-500) 35%, transparent);
}
[data-theme="midnight"] .kpi.is-critical {
  border-color: rgba(251,113,133,0.4);
  box-shadow: 0 0 0 1px rgba(251,113,133,0.18), 0 0 28px rgba(251,113,133,0.10);
}
[data-theme="midnight"] .kpi.is-critical .kpi-value {
  text-shadow: 0 0 14px rgba(251,113,133,0.45);
}

/* ─── Badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 11px; font-weight: 500;
  border: 1px solid transparent;
  letter-spacing: 0.01em;
}
[data-theme="slate-pro"] .badge { border-radius: 3px; font-weight: 600; }
.badge.b-blue    { background: var(--tint-blue);    color: var(--brand-700); }
.badge.b-amber   { background: var(--tint-amber);   color: #92400e; }
.badge.b-rose    { background: var(--tint-rose);    color: #9f1239; }
.badge.b-emerald { background: var(--tint-emerald); color: #047857; }
.badge.b-violet  { background: var(--tint-violet);  color: #6d28d9; }
.badge.b-cyan    { background: var(--tint-cyan);    color: #0e7490; }
.badge.b-slate   { background: var(--tint-slate);   color: var(--fg-muted); }
[data-theme="aurora-dark"] .badge.b-amber { color: #fbbf24; }
[data-theme="aurora-dark"] .badge.b-rose  { color: #fb7185; }
[data-theme="aurora-dark"] .badge.b-emerald { color: #34d399; }
[data-theme="aurora-dark"] .badge.b-violet  { color: #a78bfa; }
[data-theme="aurora-dark"] .badge.b-blue    { color: #93c5fd; }
[data-theme="aurora-dark"] .badge.b-cyan    { color: #67e8f9; }
[data-theme="midnight"] .badge.b-amber { color: #fbbf24; }
[data-theme="midnight"] .badge.b-rose  { color: #fb7185; }
[data-theme="midnight"] .badge.b-emerald { color: #34d399; }
[data-theme="midnight"] .badge.b-violet  { color: #c084fc; }
[data-theme="midnight"] .badge.b-blue    { color: #67e8f9; }
[data-theme="midnight"] .badge.b-cyan    { color: #67e8f9; }

.critical-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: var(--tint-rose);
  color: var(--accent-rose);
  border: 1px solid color-mix(in srgb, var(--accent-rose) 30%, transparent);
  border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600;
  animation: pulse-rose 2.4s var(--ease) infinite;
}
@keyframes pulse-rose { 0%,100% { box-shadow: 0 0 0 0 rgba(244,63,94,0.0); } 50% { box-shadow: 0 0 0 6px rgba(244,63,94,0.10); } }

/* ─── Quick access tiles ─────────────────────────────────────────── */
.quick-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(6, 1fr); margin-top: 10px; }
@media (max-width: 1100px) { .quick-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px)  { .quick-grid { grid-template-columns: repeat(2, 1fr); } }
.quick-tile {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 16px;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-decoration: none; color: var(--fg);
  transition: transform var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease), border-color var(--t-med) var(--ease);
}
.quick-tile:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow-md); text-decoration: none; }
.quick-tile .tile-icon {
  width: 44px; height: 44px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  transition: transform var(--t-med) var(--ease);
}
.quick-tile:hover .tile-icon { transform: scale(1.08); }
.quick-tile .tile-icon svg { width: 20px; height: 20px; }
.quick-tile span { font-size: 12px; font-weight: 500; color: var(--fg-muted); }

.quick-tile.t-rose    .tile-icon { background: var(--tint-rose);    color: var(--accent-rose); }
.quick-tile.t-blue    .tile-icon { background: var(--tint-blue);    color: var(--brand-600); }
.quick-tile.t-cyan    .tile-icon { background: var(--tint-cyan);    color: var(--accent-cyan); }
.quick-tile.t-emerald .tile-icon { background: var(--tint-emerald); color: var(--accent-emerald); }
.quick-tile.t-amber   .tile-icon { background: var(--tint-amber);   color: var(--accent-amber); }
.quick-tile.t-violet  .tile-icon { background: var(--tint-violet);  color: var(--accent-violet); }

/* ─── Section headers ────────────────────────────────────────────── */
.section-heading {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--fg-subtle);
  font-weight: 700;
  margin: 28px 0 10px;
}
[data-theme="editorial"] .section-heading {
  font-family: var(--f-display);
  text-transform: none;
  letter-spacing: 0;
  font-style: italic;
  font-weight: 500;
  font-size: 16px;
  color: var(--fg-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

/* ─── Empty state ────────────────────────────────────────────────── */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--fg-muted);
}
.empty .ill {
  width: 64px; height: 64px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--bg-soft);
  display: grid; place-items: center;
  color: var(--fg-subtle);
  position: relative;
}
.empty .ill::after {
  content: '';
  position: absolute; inset: -6px;
  border-radius: 50%;
  border: 1px dashed var(--border-strong);
  opacity: 0.6;
}
.empty .ill svg { width: 26px; height: 26px; position: relative; z-index: 1; }
.empty h3 { font-size: 14px; color: var(--fg); margin-bottom: 4px; font-family: var(--f-display); }
.empty p { font-size: 12px; max-width: 36ch; margin: 0 auto; }
[data-theme="editorial"] .empty h3 { font-size: 18px; font-weight: 500; }

/* ─── Forms / detail panels ──────────────────────────────────────── */
.form-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(2, 1fr); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }

/* ─── Login ──────────────────────────────────────────────────────── */
.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
@media (max-width: 900px) { .login-shell { grid-template-columns: 1fr; } .login-brand { display: none; } }
.login-brand {
  background: linear-gradient(135deg, #0b1220, #050912 60%, #1a1247);
  color: #e2e8f0;
  padding: 60px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-brand::before, .login-brand::after {
  content: ''; position: absolute; border-radius: 50%; filter: blur(60px); opacity: 0.4;
}
.login-brand::before { width: 360px; height: 360px; background: var(--brand-500); top: -120px; right: -120px; }
.login-brand::after  { width: 320px; height: 320px; background: var(--accent-violet); bottom: -100px; left: -100px; opacity: 0.3; }
.login-brand .lb-mark { display: flex; align-items: center; gap: 12px; position: relative; z-index: 2; }
.login-brand .lb-mark .brand-mark { width: 38px; height: 38px; }
.login-brand .lb-mark span { font-weight: 600; color: #fff; font-size: 17px; font-family: var(--f-display); }
.login-brand .lb-hero { position: relative; z-index: 2; max-width: 480px; }
.login-brand .lb-hero h1 {
  color: #fff; font-size: 38px; line-height: 1.1; letter-spacing: -0.025em; margin-bottom: 20px;
  font-family: var(--f-display);
}
.login-brand .lb-hero p { color: #cbd5e1; font-size: 15px; line-height: 1.6; }
.login-brand .lb-foot { position: relative; z-index: 2; font-size: 12px; color: #64748b; }

.login-form { padding: 60px; display: flex; align-items: center; }
@media (max-width: 760px) { .login-form { padding: 28px 20px; min-height: 100vh; } }
.login-form-inner { max-width: 380px; width: 100%; margin: 0 auto; }
.login-form h2 { font-size: 24px; margin-bottom: 6px; letter-spacing: -0.02em; font-family: var(--f-display); }
.login-form .lead { color: var(--fg-muted); font-size: 13px; margin-bottom: 28px; }
.login-form .btn-primary { width: 100%; justify-content: center; padding: 11px 16px; font-size: 14px; }
.login-form .demo-hint {
  margin-top: 22px; padding: 12px 14px;
  background: var(--bg-soft); border: 1px dashed var(--border-strong);
  border-radius: var(--r-md); font-size: 12px; color: var(--fg-muted); line-height: 1.6;
}
.login-form .demo-hint code {
  background: var(--bg-elevated); padding: 1px 6px; border-radius: 4px;
  font-family: var(--f-mono); font-size: 11px; color: var(--fg);
}

/* Editorial login: cream brand panel, serif headline */
[data-theme="editorial"] .login-brand {
  background: linear-gradient(135deg, #1a1410, #2d1f15 50%, #4a2d1a);
}
[data-theme="editorial"] .login-brand::before,
[data-theme="editorial"] .login-brand::after { background: var(--brand-500); }

/* Slate Pro login: tighter, no gradients */
[data-theme="slate-pro"] .login-brand {
  background: var(--fg);
}
[data-theme="slate-pro"] .login-brand::before { background: var(--brand-500); opacity: 0.20; }
[data-theme="slate-pro"] .login-brand::after { display: none; }

/* Midnight login: full neon */
[data-theme="midnight"] .login-brand { background: linear-gradient(135deg, #050810, #0b1c2c 60%, #1a0a26); }
[data-theme="midnight"] .login-brand::before { background: #22d3ee; opacity: 0.25; }
[data-theme="midnight"] .login-brand::after { background: #d946ef; opacity: 0.18; }

/* ─── Command palette ────────────────────────────────────────────── */
.cmdk-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(8,12,24,0.55);
  backdrop-filter: blur(6px);
  display: none;
  align-items: flex-start; justify-content: center;
  padding-top: 12vh;
}
.cmdk-backdrop.show { display: flex; animation: fade-in var(--t-med) var(--ease); }
.cmdk {
  width: min(580px, 92vw);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.cmdk-input {
  width: 100%; padding: 16px 18px;
  border: 0; outline: 0;
  background: transparent;
  font-size: 15px; color: var(--fg);
  border-bottom: 1px solid var(--border);
  font-family: var(--f-body);
}
.cmdk-results { max-height: 50vh; overflow-y: auto; padding: 6px; }
.cmdk-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  cursor: pointer; color: var(--fg); font-size: 13px;
  text-decoration: none;
}
.cmdk-item:hover, .cmdk-item.active { background: var(--bg-soft); text-decoration: none; }
.cmdk-item .group { color: var(--fg-subtle); font-size: 11px; margin-left: auto; text-transform: uppercase; letter-spacing: 0.06em; }
.cmdk-item svg { width: 16px; height: 16px; color: var(--fg-muted); }
.cmdk-empty { padding: 24px; text-align: center; color: var(--fg-muted); font-size: 13px; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ─── Charts wrapper ─────────────────────────────────────────────── */
.chart-host { height: 260px; position: relative; }

/* ─── Page action bar ────────────────────────────────────────────── */
.action-bar { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.action-bar .filters { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.action-bar .filters select { padding: 7px 10px; font-size: 12px; }

/* ─── Detail page ────────────────────────────────────────────────── */
.detail-head { display: flex; align-items: center; gap: var(--sp-4); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.detail-head .back { color: var(--fg-muted); }
.detail-head h1 { font-size: 22px; }

/* ─── Theme picker (topbar dropdown) ─────────────────────────────── */
.theme-picker { position: relative; }
.theme-picker > button {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  height: 36px;
  padding: 0 12px;
  border-radius: var(--r-md);
  display: flex; align-items: center; gap: 8px;
  color: var(--fg-muted);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.theme-picker > button:hover { color: var(--fg); border-color: var(--border-strong); background: var(--bg-elevated); }
.theme-picker .swatch {
  width: 16px; height: 16px; border-radius: 4px;
  background: linear-gradient(135deg, var(--brand-grad-from), var(--brand-grad-to));
  flex: 0 0 auto;
}
.theme-picker .menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 240px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 50;
  display: none;
}
.theme-picker.open .menu { display: block; animation: fade-in var(--t-fast) var(--ease); }
.theme-picker .menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  cursor: pointer; color: var(--fg); font-size: 13px;
  width: 100%; background: transparent; border: 0; text-align: left;
}
.theme-picker .menu-item:hover { background: var(--bg-soft); }
.theme-picker .menu-item.active { background: var(--bg-soft); font-weight: 600; }
.theme-picker .menu-item .preview {
  width: 24px; height: 24px; border-radius: 6px;
  flex: 0 0 auto;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}
.theme-picker .menu-item .preview::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 8px;
}
.theme-picker .menu-item small { color: var(--fg-subtle); font-size: 11px; margin-top: 2px; display: block; }
.theme-picker .menu-item .text { display: flex; flex-direction: column; flex: 1; }

/* Per-theme swatch previews */
.tp-aurora-light .preview { background: #f7f8fb; }
.tp-aurora-light .preview::before { background: linear-gradient(180deg, #0b1220, #050912); }
.tp-aurora-dark  .preview { background: #0a0e1a; }
.tp-aurora-dark  .preview::before { background: linear-gradient(180deg, #0b1220, #050912); }
.tp-slate-pro    .preview { background: #ffffff; }
.tp-slate-pro    .preview::before { background: #f8fafc; border-right: 1px solid #cbd5e1; }
.tp-editorial    .preview { background: #faf7f2; }
.tp-editorial    .preview::before { background: #ede4d3; }
.tp-midnight     .preview { background: #050810; }
.tp-midnight     .preview::before { background: #02050c; box-shadow: 1px 0 8px #22d3ee; }

/* ─── Severity chips ─────────────────────────────────────────────── */
.sev-low      { color: var(--accent-emerald); }
.sev-medium   { color: var(--accent-amber); }
.sev-high     { color: var(--accent-rose); }
.sev-critical { color: var(--accent-rose); font-weight: 700; }

/* ─── Misc small helpers ─────────────────────────────────────────── */
.dot-status { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-open      { background: var(--accent-amber); }
.dot-closed    { background: var(--fg-subtle); }
.dot-progress  { background: var(--brand-500); }
.dot-resolved  { background: var(--accent-emerald); }

/* Detail head: theme variants for breadcrumb-y feel */
[data-theme="editorial"] .detail-head h1 { font-size: 28px; }

/* ─── List toolbar (search + filter row above tables) ────────────── */
.list-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 14px;
}
.list-toolbar input[type="search"],
.list-toolbar select { margin: 0; }

/* ─── Detail-head action group on the right ──────────────────────── */
.detail-head form { margin: 0; }

/* ─── Flash auto-dismiss ─────────────────────────────────────────── */
.flash-stack { position: fixed; top: 16px; right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.flash {
  padding: 10px 14px; border-radius: 8px; font-size: 13px; line-height: 1.45;
  background: var(--card); border: 1px solid var(--border); color: var(--fg);
  box-shadow: 0 6px 24px rgba(0,0,0,.18); animation: flash-in .18s ease-out, flash-out .3s ease-in 4.5s forwards;
}
.flash.success { border-left: 3px solid var(--accent-emerald); }
.flash.error   { border-left: 3px solid var(--accent-rose); }
.flash.warn    { border-left: 3px solid var(--accent-amber); }
@keyframes flash-in { from { transform: translateX(8px); opacity: 0 } to { transform: none; opacity: 1 } }
@keyframes flash-out { to { transform: translateX(8px); opacity: 0; visibility: hidden } }

/* ─── Dashboard module tabs ──────────────────────────────────────── */
.module-tabs {
  display: flex; gap: 8px; flex-wrap: nowrap; overflow-x: auto;
  padding-bottom: 6px; margin-bottom: 18px; scrollbar-width: thin;
}
.module-tab {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--card); border: 1px solid var(--border); color: var(--fg);
}
.module-tab:hover {
  border-color: var(--border-strong); box-shadow: var(--shadow-md);
  text-decoration: none; transform: translateY(-1px);
}

/* ─── CoreM8 theme — component tweaks (mirrors marketingm8 app.css) ── */
[data-theme="corem8"] body {
  background-image:
    radial-gradient(1200px 700px at 78% -8%, rgba(124,108,255,.10), transparent 60%),
    radial-gradient(900px 600px at 5% 0%, rgba(34,211,238,.05), transparent 55%);
  background-attachment: fixed;
}
[data-theme="corem8-light"] body {
  background-image: radial-gradient(1100px 600px at 80% -10%, rgba(124,108,255,.10), transparent 60%);
  background-attachment: fixed;
}

[data-theme="corem8"] .topbar,
[data-theme="corem8-light"] .topbar {
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}
@media (max-width: 760px) {
  /* keep the iOS-Safari solid-bg fix from layout.css */
  [data-theme="corem8"] .topbar,
  [data-theme="corem8-light"] .topbar {
    background: var(--bg-elevated);
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
}

/* the full CoreM8 3-stop gradient on brand + primary actions */
[data-theme="corem8"] .brand-mark,
[data-theme="corem8-light"] .brand-mark {
  background: linear-gradient(135deg, #7c6cff, #b06cff 60%, #ff6cab);
  box-shadow: 0 4px 16px -4px rgba(124,108,255,.7), inset 0 1px 0 rgba(255,255,255,.25);
  border-radius: 10px;
}
[data-theme="corem8"] .btn-primary,
[data-theme="corem8-light"] .btn-primary {
  background: linear-gradient(135deg, #7c6cff, #b06cff 60%, #ff6cab);
  box-shadow: 0 6px 18px -6px rgba(124,108,255,.7), inset 0 1px 0 rgba(255,255,255,.2);
}
[data-theme="corem8"] .btn-primary:hover,
[data-theme="corem8-light"] .btn-primary:hover { filter: brightness(1.07); }

[data-theme="corem8"] .brand-name { color: #f3f3f7; }
[data-theme="corem8-light"] .brand-name { color: var(--fg); }

/* inputs sit on the raised surface like CoreM8 (surface-2) */
[data-theme="corem8"] input:not([type="checkbox"]):not([type="radio"]),
[data-theme="corem8"] select,
[data-theme="corem8"] textarea {
  background: var(--bg-soft);
  border-color: var(--border-strong);
}
[data-theme="corem8"] input:focus,
[data-theme="corem8"] select:focus,
[data-theme="corem8"] textarea:focus {
  background: var(--bg-elevated);
  border-color: rgba(124,108,255,.40);
  box-shadow: 0 0 0 3px rgba(124,108,255,.14);
}

/* badges readable on dark */
[data-theme="corem8"] .badge.b-amber   { color: #fbbf24; }
[data-theme="corem8"] .badge.b-rose    { color: #fb7185; }
[data-theme="corem8"] .badge.b-emerald { color: #34d399; }
[data-theme="corem8"] .badge.b-violet  { color: #b79dff; }
[data-theme="corem8"] .badge.b-blue    { color: #a99dff; }
[data-theme="corem8"] .badge.b-cyan    { color: #67e8f9; }

/* avatar: CoreM8 violet gradient instead of cyan/indigo */
[data-theme="corem8"] .avatar,
[data-theme="corem8-light"] .avatar {
  background: linear-gradient(135deg, #7c6cff, #b06cff);
}

/* login brand panel */
[data-theme="corem8"] .login-brand,
[data-theme="corem8-light"] .login-brand {
  background: linear-gradient(135deg, #08080c, #101018 55%, #1d1440);
}
[data-theme="corem8"] .login-brand::before,
[data-theme="corem8-light"] .login-brand::before { background: #7c6cff; }
[data-theme="corem8"] .login-brand::after,
[data-theme="corem8-light"] .login-brand::after { background: #ff6cab; }

/* module tabs pick up the accent on hover */
[data-theme="corem8"] .module-tab:hover,
[data-theme="corem8-light"] .module-tab:hover {
  border-color: rgba(124,108,255,.40);
  color: var(--fg);
}

/* theme-picker swatches */
.tp-corem8       .preview { background: #08080c; }
.tp-corem8       .preview::before { background: linear-gradient(180deg, #7c6cff, #b06cff 60%, #ff6cab); }
.tp-corem8-light .preview { background: #f6f6f9; }
.tp-corem8-light .preview::before { background: linear-gradient(180deg, #7c6cff, #b06cff 60%, #ff6cab); }

/* ─── Notifications bell ─────────────────────────────────────────── */
.notif-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 99px; font-size: 10px; font-weight: 700; line-height: 17px;
  text-align: center; color: #fff;
  background: linear-gradient(135deg, #7c6cff, #ff6cab);
  box-shadow: 0 0 0 2px var(--bg-elevated);
}
#notif-bell .menu-item { text-decoration: none; }
#notif-bell .menu-item .badge { margin-left: auto; }

/* ═══ ResponseM8 theme — component tweaks ═════════════════════════ */
[data-theme="responsem8"] body {
  background-image:
    radial-gradient(1200px 700px at 78% -8%, rgba(20,184,166,.09), transparent 60%),
    radial-gradient(900px 600px at 4% 0%, rgba(34,211,238,.05), transparent 55%);
  background-attachment: fixed;
}
[data-theme="responsem8-light"] body {
  background-image: radial-gradient(1100px 600px at 80% -10%, rgba(20,184,166,.10), transparent 60%);
  background-attachment: fixed;
}
[data-theme="responsem8"] .topbar,
[data-theme="responsem8-light"] .topbar {
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}
@media (max-width: 760px) {
  [data-theme="responsem8"] .topbar,
  [data-theme="responsem8-light"] .topbar {
    background: var(--bg-elevated);
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
}
[data-theme="responsem8"] .brand-mark,
[data-theme="responsem8-light"] .brand-mark {
  background: linear-gradient(135deg, #0d9488, #14b8a6 55%, #22d3ee);
  box-shadow: 0 4px 16px -4px rgba(20,184,166,.7), inset 0 1px 0 rgba(255,255,255,.25);
  border-radius: 10px;
}
[data-theme="responsem8"] .btn-primary,
[data-theme="responsem8-light"] .btn-primary {
  background: linear-gradient(135deg, #0d9488, #14b8a6 55%, #22d3ee);
  box-shadow: 0 6px 18px -6px rgba(20,184,166,.7), inset 0 1px 0 rgba(255,255,255,.2);
}
[data-theme="responsem8"] .btn-primary:hover,
[data-theme="responsem8-light"] .btn-primary:hover { filter: brightness(1.07); }
[data-theme="responsem8"] .brand-name { color: #ecf4f4; }
[data-theme="responsem8"] input:not([type="checkbox"]):not([type="radio"]),
[data-theme="responsem8"] select,
[data-theme="responsem8"] textarea {
  background: var(--bg-soft);
  border-color: var(--border-strong);
}
[data-theme="responsem8"] input:focus,
[data-theme="responsem8"] select:focus,
[data-theme="responsem8"] textarea:focus {
  background: var(--bg-elevated);
  border-color: rgba(45,212,191,.45);
  box-shadow: 0 0 0 3px rgba(45,212,191,.15);
}
[data-theme="responsem8"] .badge.b-amber   { color: #fbbf24; }
[data-theme="responsem8"] .badge.b-rose    { color: #fb7185; }
[data-theme="responsem8"] .badge.b-emerald { color: #34d399; }
[data-theme="responsem8"] .badge.b-violet  { color: #c4b5fd; }
[data-theme="responsem8"] .badge.b-blue    { color: #5eead4; }
[data-theme="responsem8"] .badge.b-cyan    { color: #67e8f9; }
[data-theme="responsem8"] .avatar,
[data-theme="responsem8-light"] .avatar {
  background: linear-gradient(135deg, #14b8a6, #22d3ee);
}
[data-theme="responsem8"] .login-brand,
[data-theme="responsem8-light"] .login-brand {
  background: linear-gradient(135deg, #060a0d, #0d1519 55%, #0b2b2c);
}
[data-theme="responsem8"] .login-brand::before,
[data-theme="responsem8-light"] .login-brand::before { background: #14b8a6; }
[data-theme="responsem8"] .login-brand::after,
[data-theme="responsem8-light"] .login-brand::after { background: #22d3ee; }
[data-theme="responsem8"] .notif-badge,
[data-theme="responsem8-light"] .notif-badge {
  background: linear-gradient(135deg, #14b8a6, #22d3ee);
}
[data-theme="responsem8"] .kpi .kpi-value {
  text-shadow: 0 0 14px color-mix(in srgb, var(--brand-500) 22%, transparent);
}
.tp-responsem8       .preview { background: #070b0e; }
.tp-responsem8       .preview::before { background: linear-gradient(180deg, #0d9488, #14b8a6 55%, #22d3ee); }
.tp-responsem8-light .preview { background: #f4f7f7; }
.tp-responsem8-light .preview::before { background: linear-gradient(180deg, #0d9488, #14b8a6 55%, #22d3ee); }

/* ═══ Shared primitives (all themes) ══════════════════════════════ */
.mono { font-family: var(--f-mono); font-feature-settings: 'tnum','zero'; }
.row-muted td { opacity: 0.5; }
.row-muted td:first-child { text-decoration: line-through; text-decoration-color: var(--fg-subtle); }

/* Segmented control */
.seg { display: inline-flex; background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--r-pill); padding: 3px; gap: 2px; }
.seg-btn { padding: 6px 14px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; color: var(--fg-muted); text-decoration: none; }
.seg-btn:hover { color: var(--fg); text-decoration: none; }
.seg-btn.active { background: var(--bg-elevated); color: var(--fg); box-shadow: var(--shadow-sm); }

/* Live pill + dot */
.live-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--accent-rose) 14%, transparent);
  color: var(--accent-rose);
  border: 1px solid color-mix(in srgb, var(--accent-rose) 35%, transparent);
  font-size: 10px; font-weight: 800; letter-spacing: 0.1em;
}
.live-pill.big { font-size: 12px; padding: 5px 14px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-rose); animation: live-blink 1.6s ease-in-out infinite; }
@keyframes live-blink { 0%,100% { opacity: 1; box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-rose) 45%, transparent); } 50% { opacity: 0.55; box-shadow: 0 0 0 5px transparent; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* Event cards */
.event-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
@media (max-width: 640px) { .event-grid { grid-template-columns: 1fr; } }
.event-card {
  display: flex; gap: 16px; align-items: stretch;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--card-radius); padding: 16px;
  box-shadow: var(--card-shadow); color: var(--fg); text-decoration: none;
  transition: transform var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease), border-color var(--t-med) var(--ease);
}
.event-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); text-decoration: none; }
.event-card.is-live { border-color: color-mix(in srgb, var(--accent-rose) 35%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent-rose) 18%, transparent), var(--card-shadow); }
.event-when {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 62px; padding: 8px 10px; border-radius: var(--r-md);
  background: var(--bg-soft); border: 1px solid var(--border);
}
.event-when .ew-day { font-family: var(--f-num); font-size: 24px; font-weight: 700; line-height: 1; }
.event-when .ew-mon { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--fg-muted); margin-top: 2px; }
.event-when .ew-time { font-family: var(--f-mono); font-size: 11px; color: var(--fg-subtle); margin-top: 4px; }
.event-main { flex: 1; min-width: 0; }
.event-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.event-title-row strong { font-size: 15px; }
.event-sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--fg-muted); font-size: 12px; margin-top: 5px; }
.event-sub svg { display: inline-block; vertical-align: -2px; }
.event-cover-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.event-go { display: grid; place-items: center; color: var(--fg-subtle); }
.event-go svg { transform: rotate(180deg); }

/* Coverage chips */
.cover-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; font-family: var(--f-num); font-feature-settings: 'tnum';
  background: var(--tint-slate); color: var(--fg-muted);
  border: 1px solid transparent;
}
.cover-chip.ok    { background: var(--tint-emerald); color: var(--accent-emerald); }
.cover-chip.short { background: var(--tint-amber); color: var(--accent-amber); border-color: color-mix(in srgb, var(--accent-amber) 30%, transparent); }
.cover-chip.live  { background: var(--tint-rose); color: var(--accent-rose); }
.cover-chip.pcr   { background: var(--tint-cyan); color: var(--accent-cyan); }

/* Coverage bars */
.cover-bars { display: flex; flex-direction: column; gap: 8px; }
.cover-bar { display: grid; grid-template-columns: 150px 1fr 52px; align-items: center; gap: 10px; }
.cover-bar .cb-label { font-size: 12px; font-weight: 600; color: var(--fg-muted); display: flex; align-items: center; gap: 6px; }
.cover-bar .cb-track { height: 8px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
.cover-bar .cb-fill { height: 100%; border-radius: 99px; transition: width var(--t-slow) var(--ease); }
.cover-bar .cb-fill.ok    { background: linear-gradient(90deg, var(--accent-emerald), color-mix(in srgb, var(--accent-emerald) 70%, var(--accent-cyan))); }
.cover-bar .cb-fill.short { background: linear-gradient(90deg, var(--accent-amber), color-mix(in srgb, var(--accent-amber) 60%, var(--accent-rose))); }
.cover-bar .cb-fill.over  { background: var(--accent-cyan); }
.cover-bar .cb-count { font-family: var(--f-num); font-size: 12px; font-weight: 700; text-align: right; font-feature-settings: 'tnum'; }
.cover-bar .cb-count.ok { color: var(--accent-emerald); }
.cover-bar .cb-count.short { color: var(--accent-amber); }
@media (max-width: 560px) { .cover-bar { grid-template-columns: 110px 1fr 48px; } }

/* Ring gauges (conic) */
.cmd-gauges { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.gauge {
  --pct: 0; --ring: var(--accent-emerald);
  width: 92px; height: 92px; border-radius: 50%;
  background:
    radial-gradient(closest-side, var(--card-bg) 78%, transparent 79% 100%),
    conic-gradient(var(--ring) calc(var(--pct) * 1%), var(--bg-soft) 0);
  display: grid; place-items: center;
  border: 1px solid var(--border);
}
.gauge.short  { --ring: var(--accent-amber); }
.gauge.ok     { --ring: var(--accent-emerald); }
.gauge.sec    { --ring: var(--accent-violet); }
.gauge.sec.short { --ring: var(--accent-amber); }
.gauge.neutral { --ring: var(--accent-cyan); }
.gauge-in { text-align: center; line-height: 1.1; }
.gauge-in strong { display: block; font-family: var(--f-num); font-size: 20px; font-feature-settings: 'tnum'; }
.gauge-in strong small { font-size: 12px; color: var(--fg-muted); font-weight: 600; }
.gauge-in span { font-size: 9px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--fg-subtle); font-weight: 700; }

/* Event command layout */
.cmd-head.is-live { border-color: color-mix(in srgb, var(--accent-rose) 35%, transparent); }
.cmd-head-body { display: flex; gap: 24px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.cmd-title h1 { font-size: 24px; }
.cmd-meta { display: flex; gap: 16px; flex-wrap: wrap; color: var(--fg-muted); font-size: 12.5px; margin-top: 10px; }
.cmd-meta span { display: inline-flex; align-items: center; gap: 6px; }
.cmd-grid { display: grid; gap: var(--sp-4); grid-template-columns: 1.25fr 1fr; margin-top: 16px; align-items: start; }
@media (max-width: 1100px) { .cmd-grid { grid-template-columns: 1fr; } }
.briefing .card-body { background: color-mix(in srgb, var(--tint-amber) 55%, transparent); border-radius: 0 0 var(--card-radius) var(--card-radius); }

/* Add-to-team disclosure */
.add-assign { margin-top: 16px; border-top: 1px dashed var(--border-strong); padding-top: 12px; }
.add-assign summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--brand-600); display: flex; align-items: center; gap: 8px; list-style: none; }
.add-assign summary::-webkit-details-marker { display: none; }

/* On-the-clock list */
.onclock-list { display: flex; flex-direction: column; gap: 8px; }
.onclock-list.cols { flex-direction: row; flex-wrap: wrap; gap: 8px 22px; }
.onclock-list li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.onclock-list li .muted { font-size: 12px; }
.oc-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.oc-dot.on { background: var(--accent-emerald); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-emerald) 20%, transparent); }
.oc-dot.break { background: var(--accent-amber); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-amber) 20%, transparent); }
.oc-dot.off { background: var(--fg-subtle); }

.log-form input[name="body"] { flex: 1; }

/* Control-log feed */
.feed { display: flex; flex-direction: column; gap: 0; margin-top: 14px; max-height: 420px; overflow-y: auto; scrollbar-width: thin; }
.feed-item {
  display: flex; align-items: baseline; gap: 10px;
  padding: 9px 2px; border-bottom: 1px solid var(--border);
  font-size: 13px; line-height: 1.45;
}
.feed-item:last-child { border-bottom: 0; }
.feed-item .fi-time { font-size: 11px; color: var(--fg-subtle); flex: 0 0 auto; }
.feed-item .fi-type { flex: 0 0 auto; font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; }
.feed-item .fi-body { min-width: 0; }
.feed-item .fi-body small { font-size: 11px; }

/* Requirement steppers (event form) */
.req-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.req-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg-soft);
}
.req-item label { margin: 0; flex: 1; text-transform: none; font-size: 13px; letter-spacing: 0; color: var(--fg); font-weight: 600; }
.req-item input[type="number"] { width: 72px; text-align: center; font-family: var(--f-num); font-weight: 700; padding: 8px 6px; }
.req-ico { width: 32px; height: 32px; border-radius: var(--r-md); display: grid; place-items: center; flex: 0 0 auto; }
.req-ico.med { background: var(--tint-emerald); color: var(--accent-emerald); }
.req-ico.sec { background: var(--tint-violet); color: var(--accent-violet); }
.req-item.sec { border-color: color-mix(in srgb, var(--accent-violet) 30%, transparent); }

/* Assignment list (time clock page) */
.assign-list { display: flex; flex-direction: column; gap: 12px; }
.assign-list li { display: flex; gap: 12px; align-items: center; }
.assign-list .al-when {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 46px; padding: 6px; border-radius: var(--r-md);
  background: var(--bg-soft); border: 1px solid var(--border);
  font-family: var(--f-num); line-height: 1.1;
}
.assign-list .al-when span { font-size: 17px; font-weight: 700; }
.assign-list .al-when small { font-size: 10px; text-transform: uppercase; color: var(--fg-muted); }

/* Clock hero (time clock page) */
.clock-hero.is-in { border-color: color-mix(in srgb, var(--accent-emerald) 35%, transparent); }
.clock-hero-body { display: flex; gap: 24px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.clock-big { font-size: 56px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.05; margin: 10px 0 6px; font-feature-settings: 'tnum','zero'; }
@media (max-width: 560px) { .clock-big { font-size: 42px; } }
.clock-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.clockin-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.break-banner {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 10px;
  padding: 8px 14px; border-radius: var(--r-md);
  background: var(--tint-amber); color: var(--accent-amber);
  border: 1px solid color-mix(in srgb, var(--accent-amber) 35%, transparent);
  font-size: 13px; font-weight: 600;
}

/* Big touch-target action buttons */
.big-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 58px; padding: 12px 26px; border-radius: 14px;
  font-size: 16px; font-weight: 700; letter-spacing: 0.01em;
  border: 1px solid transparent; cursor: pointer; font-family: var(--f-body);
  transition: transform var(--t-fast) var(--ease), filter var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  color: #fff;
}
.big-btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
.big-btn:active { transform: translateY(0); }
.big-btn.emerald { background: linear-gradient(135deg, #059669, #10b981); box-shadow: 0 8px 22px -8px rgba(16,185,129,.65), inset 0 1px 0 rgba(255,255,255,.2); }
.big-btn.rose    { background: linear-gradient(135deg, #e11d48, #f43f5e); box-shadow: 0 8px 22px -8px rgba(244,63,94,.65), inset 0 1px 0 rgba(255,255,255,.2); }
.big-btn.amber   { background: linear-gradient(135deg, #d97706, #f59e0b); box-shadow: 0 8px 22px -8px rgba(245,158,11,.6), inset 0 1px 0 rgba(255,255,255,.2); }
.big-btn.ghost   { background: var(--bg-soft); color: var(--fg); border-color: var(--border-strong); }
.big-btn.ghost:hover { background: var(--bg-elevated); }

/* ═══ Field mode ══════════════════════════════════════════════════ */
.fm-strip {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 18px; margin-bottom: 14px;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--card-radius); box-shadow: var(--card-shadow);
  overflow: hidden; position: relative;
}
.fm-clock-now { font-size: 30px; font-weight: 700; font-feature-settings: 'tnum','zero'; letter-spacing: -0.01em; }
.fm-who { font-size: 13px; color: var(--fg-muted); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fm-who strong { color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fm-duty { display: inline-flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 800; letter-spacing: 0.1em; }
.fm-duty.on { color: var(--accent-emerald); }
.fm-duty.off { color: var(--fg-subtle); }
.fm-ecg { margin-left: auto; width: 130px; color: var(--brand-600); opacity: 0.9; }
.fm-ecg svg { width: 100%; height: 26px; }
.fm-ecg path { stroke-dasharray: 200; stroke-dashoffset: 0; animation: ecg-run 3s linear infinite; }
@keyframes ecg-run { from { stroke-dashoffset: 400; } to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .fm-ecg path { animation: none; } }
@media (max-width: 560px) { .fm-ecg { display: none; } .fm-clock-now { font-size: 24px; } }

.fm-clockcard {
  display: flex; gap: 18px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 18px 20px; margin-bottom: 14px;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--card-radius); box-shadow: var(--card-shadow);
}
.fm-clockcard.is-in { border-color: color-mix(in srgb, var(--accent-emerald) 40%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent-emerald) 15%, transparent), var(--card-shadow); }
.fm-clock-left { min-width: 0; flex: 1; }
.fm-elapsed { font-size: 44px; font-weight: 700; line-height: 1.05; margin: 8px 0 4px; font-feature-settings: 'tnum','zero'; }
.fm-clock-sub { font-size: 12.5px; color: var(--fg-muted); }
.fm-event-pick { margin-top: 10px; max-width: 320px; }
.fm-clock-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.fm-clock-actions .big-btn { min-width: 150px; }
@media (max-width: 560px) {
  .fm-elapsed { font-size: 36px; }
  .fm-clock-actions { width: 100%; }
  .fm-clock-actions form { flex: 1; }
  .fm-clock-actions .big-btn { width: 100%; min-width: 0; }
}

.fm-sect {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--fg-subtle); font-weight: 700; margin: 18px 0 10px;
}
.fm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.fm-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 122px; padding: 16px 10px; border-radius: 16px; text-align: center;
  background: var(--card); border: 1px solid var(--border); color: var(--fg);
  font-size: 14px; font-weight: 650; box-shadow: var(--card-shadow);
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.fm-btn:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.fm-btn:active { transform: translateY(0); }
.fm-btn small { font-weight: 400; font-size: 11px; color: var(--fg-subtle); }
.fm-btn .ico { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; }
.fm-btn .ico svg { width: 22px; height: 22px; }
.fm-btn.hero-rose { border-color: color-mix(in srgb, var(--accent-rose) 35%, transparent); }
.fm-btn.hero-rose .ico { background: linear-gradient(135deg, #e11d48, #f43f5e); color: #fff; box-shadow: 0 6px 16px -6px rgba(244,63,94,.7); }
.fm-status { border: 1px solid var(--border); width: 100%; cursor: pointer; font-family: inherit; }
.fm-banner {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap;
  font-size: 13px;
}
details.fm-tools { margin-top: 22px; }
details.fm-tools summary { cursor: pointer; font-size: 13px; color: var(--fg-muted); }

/* Cards flagged live */
.card.is-live { border-color: color-mix(in srgb, var(--accent-rose) 35%, transparent); }

/* Login ECG line (brand panel) — static when reduced motion */
.lb-ecg { position: relative; z-index: 2; margin: 26px 0 0; color: #2dd4bf; opacity: 0.85; }
.lb-ecg svg { width: min(420px, 100%); height: 44px; }
.lb-ecg path { stroke-dasharray: 340; animation: ecg-run 4s linear infinite; }
@media (prefers-reduced-motion: reduce) { .lb-ecg path { animation: none; } }
.lb-feats { position: relative; z-index: 2; display: flex; flex-direction: column; gap: 10px; margin-top: 26px; }
.lb-feats li { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: #b7cbcd; }
.lb-feats li svg { color: #2dd4bf; flex: 0 0 auto; }

/* ═══ Mobile & touch ergonomics ═══════════════════════════════════
   Tables were forcing grid items wider than the viewport (grid items
   default to min-width:auto, and a table's min-content width punches
   through overflow wrappers). Cap every grid/flex track at the
   viewport and let the scroll containers do their job. */
.grid > *, .cmd-grid > *, .cmd-side > *, .kpi-grid > *, .event-grid > * { min-width: 0; }
.form-grid > .field, .form-grid > .field .row { min-width: 0; }
.field input[type="datetime-local"], .field input[type="date"] { min-width: 0; }
.card, .table-wrap { max-width: 100%; }
.card-body { min-width: 0; }

@media (max-width: 760px) {
  /* Tables: compact, nowrap, and always scrollable inside their card */
  .card-body, .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.data th, table.data td { padding: 10px 12px; font-size: 12.5px; white-space: nowrap; }
  table.data td .subtle { white-space: nowrap; }

  /* Page never scrolls sideways — scroll happens inside cards only */
  .page { overflow-x: clip; }
}

/* Bigger, easier controls on touch devices (also stops iOS input zoom) */
@media (pointer: coarse) {
  .btn { min-height: 44px; padding: 10px 16px; font-size: 14px; }
  .btn-sm { min-height: 40px; padding: 8px 14px; font-size: 13px; }
  .icon-btn, .theme-toggle, .theme-picker > button { min-width: 40px; min-height: 40px; }
  input:not([type="checkbox"]):not([type="radio"]), select, textarea {
    min-height: 48px; font-size: 16px;
  }
  .seg-btn { padding: 10px 18px; font-size: 13px; }
  .nav-link { padding: 12px; }
  .theme-picker .menu-item, .cmdk-item { padding: 12px; }
  .add-assign summary { padding: 10px 0; }
  .req-item input[type="number"] { width: 84px; }
  table.data td a { display: inline-block; padding: 4px 0; }
}

/* Event command page on phones */
@media (max-width: 560px) {
  .cmd-head-body { gap: 16px; }
  .cmd-title h1 { font-size: 20px; }
  .cmd-gauges { width: 100%; justify-content: space-between; gap: 8px; }
  .gauge { width: 72px; height: 72px; }
  .gauge-in strong { font-size: 15px; }
  .gauge-in strong small { font-size: 10px; }
  .gauge-in span { font-size: 8px; letter-spacing: 0.08em; }
  .cmd-meta { gap: 8px 14px; font-size: 12px; }
  .detail-head { gap: 8px; }
  .detail-head .spacer { flex-basis: 100%; order: -1; display: none; }
  .detail-head form { flex: 1; }
  .detail-head form .btn, .detail-head > .btn { width: 100%; justify-content: center; }
  .detail-head > .btn:first-child { width: auto; }

  /* Control-log form: message first and full width, then type + Log */
  .log-form .row { flex-wrap: wrap; }
  .log-form input[name="body"] { flex: 1 1 100%; order: -1; width: 100%; }
  .log-form select { flex: 1; max-width: none !important; }

  /* Quick-action row under the header becomes a 2-col grid of fat buttons */
  .cmd-actions { display: grid !important; grid-template-columns: 1fr 1fr; }
  .cmd-actions .btn { width: 100%; justify-content: center; }

  /* Feed stays readable */
  .feed-item { flex-wrap: wrap; row-gap: 2px; }
  .feed-item .fi-body { flex-basis: 100%; }

  /* Cover bars: tighter label column */
  .cover-bar { grid-template-columns: 96px 1fr 44px; gap: 8px; }
  .cover-bar .cb-label { font-size: 11px; }

  /* Timesheets filter bar stacks cleanly */
  .list-toolbar > input, .list-toolbar > select { flex: 1 1 45%; min-width: 0 !important; max-width: none !important; }
  .clock-hero-body { justify-content: center; text-align: center; }
  .clock-actions, .clockin-form { width: 100%; }
  .clockin-form select { width: 100%; }
  .clock-actions form { flex: 1; }
  .clock-actions .big-btn, .clockin-form .big-btn { width: 100%; }
  .assign-list li { flex-wrap: wrap; }
}

/* ═══ Wheel time picker (touch bottom sheet) ══════════════════════ */
.wheel-backdrop {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(0,0,0,.5);
  opacity: 0; pointer-events: none; transition: opacity .2s var(--ease);
}
.wheel-backdrop.show { opacity: 1; pointer-events: auto; }
.wheel-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 121;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-strong);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-lg);
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .25s var(--ease);
  max-width: 560px; margin: 0 auto;
}
.wheel-sheet.show { transform: none; }
@media (prefers-reduced-motion: reduce) {
  .wheel-sheet, .wheel-backdrop { transition: none; }
}
.wheel-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.wheel-head strong { font-size: 15px; margin-right: 6px; }
.wheel-cols { position: relative; display: flex; gap: 8px; }
.wheel-col {
  flex: 1; height: 220px; overflow-y: auto;
  scroll-snap-type: y mandatory; scrollbar-width: none;
  text-align: center; overscroll-behavior: contain;
}
.wheel-col::-webkit-scrollbar { display: none; }
.wheel-col:first-child { flex: 1.6; }
.wheel-pad { height: 88px; }
.wheel-item {
  height: 44px; line-height: 44px;
  scroll-snap-align: center;
  font-family: var(--f-num); font-feature-settings: 'tnum';
  font-size: 17px; color: var(--fg-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wheel-hl {
  position: absolute; left: 0; right: 0; top: 88px; height: 44px;
  border-top: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--brand-500) 9%, transparent);
  border-radius: 10px; pointer-events: none;
}
