:root {
  --bg: #0b0f14;
  --surface: #131a22;
  --surface-2: #1a2430;
  --surface-3: #22303d;
  --border: #24313f;
  --border-strong: #33475a;
  --text: #eaf2fb;
  --muted: #8fa3b8;
  --brand: #37e0c9;
  --brand-2: #1f9dff;
  --danger: #ff5b6e;
  --ok: #31c56a;
  --warn: #ffb020;
  --radius: 16px;
  --shadow: 0 18px 44px -18px rgba(0, 0, 0, .7);
  --f: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--f);
  background: radial-gradient(1200px 600px at 80% -10%, #16303a 0%, transparent 60%), var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
}
a { color: var(--brand); }

.wrap { max-width: 1080px; margin: 0 auto; padding: 22px clamp(14px, 4vw, 32px) 60px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px clamp(14px, 4vw, 32px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
  background: rgba(11, 15, 20, .82); backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: .3px; }
.brand .heart {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #04121a;
  animation: heartbeat 1.6s ease-in-out infinite; will-change: transform;
}
/* double-thump like a real heartbeat */
@keyframes heartbeat {
  0%, 40%, 100% { transform: scale(1); }
  10% { transform: scale(1.22); }
  20% { transform: scale(1); }
  30% { transform: scale(1.13); }
}
.tag { font-size: 12px; color: var(--muted); font-weight: 600; }

/* animated ECG pulse next to the Cardea logo — traces on, glows, then fades.
   The glow is a static drop-shadow: animating `filter` forces a repaint every
   frame, which stuttered/froze the trace on desktop GPUs. Opacity pulses on the
   wrapper give the same heartbeat feel and stay on the compositor. */
.brand-ecg { display: inline-block; width: 120px; height: 30px; margin-left: 8px; vertical-align: middle; animation: ecgBeat 1.1s ease-in-out infinite; will-change: opacity; }
.brand-ecg svg { display: block; width: 100%; height: 100%; overflow: visible; }
.ecg-line {
  fill: none; stroke: var(--brand); stroke-width: 2.5;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1000 1000;
  stroke-dashoffset: 1000;
  filter: drop-shadow(0 0 5px rgba(55, 224, 201, .8));
  animation: ecgTrace 4s ease-in-out infinite;
  will-change: stroke-dashoffset, opacity;
}
@keyframes ecgTrace {
  0%   { stroke-dashoffset: 1000; opacity: 0; }
  8%   { opacity: 1; }
  55%  { stroke-dashoffset: 0; opacity: 1; }
  80%  { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}
/* the pulsating glow (cheap: opacity only) */
@keyframes ecgBeat {
  0%, 100% { opacity: .75; }
  50%      { opacity: 1; }
}
/* Many laptops/desktops have "reduce animations" enabled system-wide, which
   used to switch these off entirely (the "frozen on laptop" bug). Honor the
   setting by dropping movement, but keep a gentle motion-free pulse alive. */
@media (prefers-reduced-motion: reduce) {
  .brand .heart { animation: softPulse 2.4s ease-in-out infinite; }
  .brand-ecg { animation: none; }
  .ecg-line { animation: softPulse 2.4s ease-in-out infinite; stroke-dashoffset: 0; }
}
@keyframes softPulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

h1 { font-size: clamp(24px, 4vw, 34px); margin: 6px 0 4px; letter-spacing: -.5px; }
h2 { font-size: 20px; margin: 0 0 14px; }
.sub { color: var(--muted); margin: 0 0 22px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); font-weight: 700; margin: 26px 0 12px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 14px; }
.grid.cols { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.avatar {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  font-weight: 800; color: #04121a; font-size: 18px; flex: 0 0 auto;
}

.doc-card { display: flex; gap: 14px; cursor: pointer; transition: transform .12s ease, border-color .12s ease; }
.doc-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.doc-card .name { font-weight: 700; font-size: 16px; }
.doc-card .role { color: var(--brand); font-size: 13px; font-weight: 600; }
.doc-card .meta { color: var(--muted); font-size: 13px; margin-top: 6px; display: flex; gap: 14px; flex-wrap: wrap; }

.btn {
  appearance: none; border: none; cursor: pointer; font-family: var(--f);
  font-weight: 700; font-size: 14px; padding: 11px 18px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #04121a;
  transition: filter .12s ease, transform .05s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); }
.btn.danger { background: linear-gradient(135deg, #ff6b7e, var(--danger)); color: #fff; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
input, textarea, select {
  width: 100%; font-family: var(--f); font-size: 15px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 11px; padding: 11px 13px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--brand); }
textarea { resize: vertical; min-height: 76px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 9px 14px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 14px; cursor: pointer;
}
.chip.on { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #04121a; border-color: transparent; }
.chip.off { opacity: .55; }
.chip:disabled { opacity: .3; cursor: not-allowed; text-decoration: line-through; }

.badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 20px; }
.badge.upcoming { background: rgba(31, 157, 255, .16); color: #6fc0ff; }
.badge.completed { background: rgba(49, 197, 106, .16); color: #57d98a; }
.badge.cancelled { background: rgba(255, 91, 110, .16); color: #ff8a97; }

.appt { display: flex; align-items: center; gap: 14px; }
.appt .when { font-weight: 700; }
.appt .who { color: var(--muted); font-size: 13px; }
.appt .spacer { flex: 1; }

.tabs { display: flex; gap: 8px; margin: 8px 0 20px; flex-wrap: wrap; }
.tab { padding: 9px 16px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); font-weight: 700; cursor: pointer; }
.tab.on { color: var(--text); border-color: var(--brand); background: var(--surface-3); }

.stat { text-align: center; padding: 18px; }
.stat .v { font-size: 28px; font-weight: 800; }
.stat .k { color: var(--muted); font-size: 13px; margin-top: 4px; }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

.toast-wrap { position: fixed; bottom: 22px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; z-index: 200; pointer-events: none; }
.toast { background: var(--surface-3); border: 1px solid var(--border-strong); padding: 12px 20px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow); animation: toastIn .3s ease; }
.toast.err { border-color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.modal-bg { position: fixed; inset: 0; background: rgba(3, 7, 12, .62); backdrop-filter: blur(4px); z-index: 100; display: grid; place-items: center; padding: 20px; animation: toastIn .2s ease; }
.modal { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 20px; padding: 26px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal h2 { display: flex; justify-content: space-between; align-items: center; }
.x { cursor: pointer; color: var(--muted); font-size: 22px; line-height: 1; background: none; border: none; }

.hide { display: none !important; }
.pill-live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.pill-live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(49,197,106,.6); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(49,197,106,.5); } 70% { box-shadow: 0 0 0 8px rgba(49,197,106,0); } 100% { box-shadow: 0 0 0 0 rgba(49,197,106,0); } }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
