/* ==========================================================================
   MEDICAL TRACKER UI
   ========================================================================== */

:root {
  --bg: #050505;
  --bg-elev: #111111;
  --bg-elev-2: #18181b;
  --panel: rgba(11, 11, 14, 0.92);
  --panel-soft: rgba(20, 20, 24, 0.72);
  --text: #ededed;
  --muted: #a1a1aa;
  --line: rgba(255,255,255,0.08);
  --line-strong: rgba(255,255,255,0.14);
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-glow: rgba(59, 130, 246, 0.18);
  --shadow-lg: 0 24px 60px rgba(0,0,0,0.32);
  --shadow-md: 0 10px 30px rgba(0,0,0,0.22);

  --c-sleep: #818cf8;
  --c-med: #34d399;
  --c-sym: #f87171;
  --c-note: #a78bfa;
  --c-appt: #3b82f6;
  --c-call: #06b6d4;

  --radius: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --max: 1280px;
  --header: 72px;
}

:root[data-theme="light"] {
  --bg: #f5f7fb;
  --bg-elev: #ffffff;
  --bg-elev-2: #eef3f9;
  --panel: rgba(255,255,255,0.88);
  --panel-soft: rgba(248,250,252,0.78);
  --text: #171717;
  --muted: #5f6470;
  --line: rgba(15,23,42,0.08);
  --line-strong: rgba(15,23,42,0.13);
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-glow: rgba(37, 99, 235, 0.12);
  --shadow-lg: 0 20px 44px rgba(15,23,42,0.08);
  --shadow-md: 0 12px 26px rgba(15,23,42,0.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: dark; }
:root[data-theme="light"] html,
:root[data-theme="light"] { color-scheme: light; }

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #03101d url("cloud-procurement-framework-artwork-01.jpg") center center / cover fixed no-repeat;
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  position: relative;
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(2, 10, 18, 0.76) 0%, rgba(2, 8, 14, 0.90) 100%),
    radial-gradient(circle at top, rgba(59,130,246,0.18), transparent 28%);
  pointer-events: none;
  z-index: -1;
}

:root[data-theme="light"] body::before {
  background:
    linear-gradient(180deg, rgba(2, 10, 18, 0.70) 0%, rgba(2, 8, 14, 0.84) 100%),
    radial-gradient(circle at top, rgba(96, 165, 250, 0.14), transparent 30%);
}

a { color: inherit; text-decoration: none; transition: color 0.2s ease; }
button, input, select, textarea { font: inherit; }

h1 { font-size: clamp(2rem, 3vw, 2.75rem); font-weight: 700; letter-spacing: -0.04em; line-height: 1.05; margin-bottom: 0.5rem; }
h2 { font-size: 1.2rem; font-weight: 650; letter-spacing: -0.025em; }
h3 { font-size: 1rem; font-weight: 650; }

.lead { font-size: 1.02rem; color: var(--muted); max-width: 64ch; margin-bottom: 2rem; }
.muted { color: var(--muted); }
.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; }

/* ==========================================================================
   HEADER
   ========================================================================== */

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: var(--header);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  min-height: var(--header);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.025em;
}

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 18%, transparent);
}

.nav {
  display: flex;
  gap: 0.35rem;
  padding: 0.3rem;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.nav a {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.58rem 0.95rem;
  border-radius: 999px;
  transition: all 0.2s ease;
}

.nav a.active,
.nav a:hover {
  color: var(--text);
  background: var(--bg-elev-2);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toggle {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.74rem 1.15rem;
  min-width: 132px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.16);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.toggle:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255,255,255,0.28);
  box-shadow: 0 16px 36px rgba(0,0,0,0.2);
}

:root[data-theme="light"] .toggle {
  background: rgba(255,255,255,0.74);
  color: #0f172a;
  border-color: rgba(15,23,42,0.10);
  box-shadow: 0 14px 32px rgba(15,23,42,0.10);
}

:root[data-theme="light"] .toggle:hover {
  background: rgba(255,255,255,0.88);
  border-color: rgba(37,99,235,0.22);
}

.toggle:focus-visible,
.btn:focus-visible,
.icon-btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.day:focus-within {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ==========================================================================
   BUTTONS & INPUTS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.74rem 1.15rem;
  font-size: 0.9rem;
  font-weight: 650;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  text-decoration: none;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 26px rgba(0,0,0,0.14);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255,255,255,0.28);
  box-shadow: 0 14px 30px rgba(0,0,0,0.18);
}

.btn.primary {
  background: #0f172a;
  border-color: #38bdf8;
  color: #38bdf8;
  box-shadow: 0 0 0 rgba(56, 189, 248, 0);
}

.btn.primary:hover {
  background: #38bdf8;
  color: #0f172a;
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.6);
}

.btn.danger {
  background: rgba(127, 29, 29, 0.36);
  color: #fecaca;
  border-color: rgba(248,113,113,0.34);
}

.btn.danger:hover {
  background: rgba(153, 27, 27, 0.52);
  border-color: rgba(252,165,165,0.5);
  color: #fff1f2;
}

:root[data-theme="light"] .btn {
  background: rgba(255,255,255,0.76);
  color: #0f172a;
  border-color: rgba(15,23,42,0.10);
  box-shadow: 0 12px 28px rgba(15,23,42,0.10);
}

:root[data-theme="light"] .btn:hover {
  background: rgba(255,255,255,0.90);
  border-color: rgba(15,23,42,0.18);
}

:root[data-theme="light"] .btn.primary {
  background: #0f172a;
  border-color: #38bdf8;
  color: #38bdf8;
}

:root[data-theme="light"] .btn.primary:hover {
  background: #38bdf8;
  color: #0f172a;
  box-shadow: 0 0 12px rgba(56,189,248,0.45);
}

input, select, textarea {
  width: 100%;
  background: color-mix(in srgb, var(--bg-elev) 94%, transparent);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line-strong));
  background: var(--bg-elev);
}

textarea { min-height: 180px; resize: vertical; }

label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.84rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: var(--muted);
}

/* ==========================================================================
   LAYOUT & PANELS
   ========================================================================== */

.page {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2.25rem 2rem 5rem;
  min-height: calc(100vh - var(--header));
}

.grid { display: grid; gap: 1.5rem; }
.grid.two { grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr); align-items: start; }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.panel,
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.hero-banner {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding: 1.3rem 1.45rem;
  background: rgba(4, 17, 31, 0.58);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.hero-banner h1,
.hero-banner .lead {
  color: #f8fafc;
}

.hero-banner .lead {
  max-width: 60ch;
  margin-bottom: 0;
  color: rgba(241,245,249,0.82);
}

:root[data-theme="light"] .hero-banner {
  background: rgba(255,255,255,0.78);
  border-color: rgba(15,23,42,0.10);
  box-shadow: 0 18px 40px rgba(15,23,42,0.10);
}

:root[data-theme="light"] .hero-banner h1,
:root[data-theme="light"] .hero-banner .lead {
  color: #0f172a;
}

:root[data-theme="light"] .hero-banner .lead {
  color: #475569;
}

.panel { overflow: hidden; }

.panel-head {
  padding: 1.35rem 1.45rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.panel-sub { font-size: 0.9rem; color: var(--muted); margin-top: 0.3rem; max-width: 58ch; }
.panel-body { padding: 1.45rem; }

.stat-card {
  padding: 1.15rem 1.2rem;
  min-height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-label { font-size: 0.82rem; font-weight: 650; color: var(--muted); margin-bottom: 0.55rem; }
.stat-value { font-size: clamp(1.5rem, 3vw, 2.15rem); font-weight: 750; color: var(--text); letter-spacing: -0.05em; line-height: 1; }

.stack { display: flex; flex-direction: column; gap: 1.5rem; }
.inline-actions, .actions { display: flex; flex-wrap: wrap; gap: 0.65rem; align-items: center; }


/* ==========================================================================
   PAGE LOADING / TRANSITIONS
   ========================================================================== */

#app {
  position: relative;
  z-index: 1;
}

html.page-loading #app {
  visibility: hidden;
}

html.page-loading body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(3, 10, 18, 0.68) 0%, rgba(2, 8, 14, 0.82) 100%),
    linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.10) 38%, rgba(255,255,255,0.04) 50%) 0 0 / 220% 100%,
    #03101d;
  animation: medtrackShimmer 1.3s linear infinite;
}

html.page-loading body::before {
  z-index: 9998;
}

html.page-loading body {
  overflow: hidden;
}

html.page-loading .app-header,
html.page-loading .page,
html.page-loading .app-footer {
  visibility: hidden;
}

@keyframes medtrackShimmer {
  0% { background-position: 0 0, 120% 0, 0 0; }
  100% { background-position: 0 0, -120% 0, 0 0; }
}

/* ==========================================================================
   RECORDS / ITEMS
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 28px;
  padding: 0.28rem 0.7rem;
  font-size: 0.74rem;
  font-weight: 700;
  background: color-mix(in srgb, var(--bg-elev-2) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
}

:root[data-theme="light"] .badge {
  background: rgba(255,255,255,0.82);
  border-color: rgba(15,23,42,0.08);
  color: #334155;
}

.empty {
  padding: 2.5rem 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  background: color-mix(in srgb, var(--bg-elev) 95%, transparent);
  border-radius: 14px;
  border: 1px dashed var(--line-strong);
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.item {
  background: color-mix(in srgb, var(--panel-soft) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem 1rem 1rem 1.1rem;
  position: relative;
}

.item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 16px;
  bottom: 16px;
  width: 4px;
  border-radius: 999px;
  background: var(--line-strong);
}
.item.sleep::before { background: var(--c-sleep); }
.item.medication::before { background: var(--c-med); }
.item.symptom::before { background: var(--c-sym); }
.item.note::before { background: var(--c-note); }
.item.appointment::before { background: var(--c-appt); }
.item.call::before { background: var(--c-call); }

.item-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.item-title { font-size: 1rem; font-weight: 700; letter-spacing: -0.02em; }
.item-meta {
  margin-top: 0.35rem;
  font-size: 0.84rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.item-desc {
  margin-top: 0.9rem;
  color: color-mix(in srgb, var(--text) 88%, var(--muted));
  white-space: pre-wrap;
}

.icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 10px;
  min-width: 36px;
  min-height: 36px;
  cursor: pointer;
}

.records-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 1.35rem;
}

.filter-panel {
  position: sticky;
  top: calc(var(--header) + 1rem);
}

.filter-stack,
.record-summary {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.records-results {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.result-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 0.25rem;
}

.searchbar,
.form-grid,
.form-grid.compact,
.form-grid.three,
.form-grid.two,
.form-grid.auto {
  display: grid;
  gap: 1rem;
}

.searchbar { grid-template-columns: 1.25fr 0.85fr 0.9fr; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.auto { grid-template-columns: repeat( auto-fit, minmax(220px, 1fr)); }
.form-grid.compact { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field.span-3 { grid-column: span 3; }
.field.span-4 { grid-column: span 4; }
.field.span-5 { grid-column: span 5; }
.field.span-6 { grid-column: span 6; }
.field.span-7 { grid-column: span 7; }
.field.span-8 { grid-column: span 8; }
.field.span-12 { grid-column: 1 / -1; }

.meta-card {
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.95rem 1rem;
}

.meta-kicker {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.meta-value {
  font-size: 0.96rem;
  font-weight: 650;
}



.entry-panel .panel-head {
  align-items: flex-start;
}

.entry-shell {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
}

.entry-form {
  width: 100%;
}

.entry-meta-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.entry-meta-card {
  padding: 0.8rem 0.95rem;
  border-radius: 16px;
}

.entry-panel .form-grid.compact {
  gap: 0.85rem 0.9rem;
}

.entry-panel .field label {
  margin-bottom: 0.42rem;
}

.entry-panel input,
.entry-panel select,
.entry-panel textarea {
  background: color-mix(in srgb, var(--bg-elev) 96%, transparent);
}

.entry-panel textarea {
  min-height: 220px;
}

.entry-panel .actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

@media (min-width: 1100px) {
  .entry-panel .panel-head,
  .entry-panel .panel-body {
    padding-left: 1.35rem;
    padding-right: 1.35rem;
  }
}

@media (max-width: 900px) {
  .entry-meta-row,
  .entry-panel .form-grid.compact {
    grid-template-columns: 1fr;
  }

  .entry-panel .field.span-3,
  .entry-panel .field.span-4,
  .entry-panel .field.span-5,
  .entry-panel .field.span-6,
  .entry-panel .field.span-7,
  .entry-panel .field.span-8,
  .entry-panel .field.span-12 {
    grid-column: auto;
  }
}

/* ==========================================================================
   TABLES
   ========================================================================== */

table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 0.95rem 0.45rem; border-bottom: 1px solid var(--line); }
th { font-size: 0.73rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
td { font-size: 0.93rem; }
tr:last-child td { border-bottom: none; }

/* ==========================================================================
   CALENDAR
   ========================================================================== */

.calendar-toolbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.9rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
}

.calendar-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--bg-elev-2);
  color: var(--text);
  cursor: pointer;
}

.calendar-title {
  text-align: center;
}

.calendar-title h3 {
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.calendar-title p {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.15rem;
}


.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 0.95rem;
  padding: 0.2rem 0 0.1rem;
}

.legend-chip,
.mini-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.legend-chip {
  padding: 0.4rem 0.68rem;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
}

.day-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: center;
  margin-top: 0.35rem;
}

.mini-pill {
  padding: 0.22rem 0.45rem;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-chip.sleep, .mini-pill.sleep { background: color-mix(in srgb, var(--c-sleep) 16%, transparent); color: #c7d2fe; border-color: color-mix(in srgb, var(--c-sleep) 35%, transparent); }
.legend-chip.medication, .mini-pill.medication { background: color-mix(in srgb, var(--c-med) 16%, transparent); color: #bbf7d0; border-color: color-mix(in srgb, var(--c-med) 35%, transparent); }
.legend-chip.symptom, .mini-pill.symptom { background: color-mix(in srgb, var(--c-sym) 16%, transparent); color: #fecaca; border-color: color-mix(in srgb, var(--c-sym) 35%, transparent); }
.legend-chip.note, .mini-pill.note { background: color-mix(in srgb, var(--c-note) 16%, transparent); color: #ddd6fe; border-color: color-mix(in srgb, var(--c-note) 35%, transparent); }
.legend-chip.appointment, .mini-pill.appointment { background: color-mix(in srgb, var(--c-appt) 16%, transparent); color: #bfdbfe; border-color: color-mix(in srgb, var(--c-appt) 35%, transparent); }
.legend-chip.call, .mini-pill.call { background: color-mix(in srgb, var(--c-call) 16%, transparent); color: #a5f3fc; border-color: color-mix(in srgb, var(--c-call) 35%, transparent); }

.calendar {
  width: 100%;
  padding: 0.35rem 0;
}

.calendar-head {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.8rem;
}

.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.55rem; }
.day {
  background: color-mix(in srgb, var(--bg-elev) 95%, transparent);
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 96px;
  padding: 0.65rem 0.45rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease, background 0.18s ease;
}
.day:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--accent) 35%, var(--line-strong)); }
.day.other { opacity: 0.38; background: transparent; }
.day.today { border-color: color-mix(in srgb, var(--accent) 60%, var(--line-strong)); }
.day.selected {
  background: color-mix(in srgb, var(--bg-elev-2) 98%, transparent);
  border-color: color-mix(in srgb, var(--text) 18%, var(--line-strong));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 10%, transparent);
}
.day button {
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 700;
  width: 100%;
  cursor: pointer;
}
.inline-note {
  font-size: 0.73rem;
  color: var(--muted);
  margin-top: 0.35rem;
  text-align: center;
  min-height: 2.1em;
}
.day-dots { display: flex; gap: 4px; margin-top: auto; justify-content: center; flex-wrap: wrap; }
.dot { width: 6px; height: 6px; border-radius: 50%; }
.dot.sleep { background: var(--c-sleep); }
.dot.medication { background: var(--c-med); }
.dot.symptom { background: var(--c-sym); }
.dot.note { background: var(--c-note); }
.dot.appointment { background: var(--c-appt); }
.dot.call { background: var(--c-call); }

/* ==========================================================================
   FOOTER
   ========================================================================== */

.app-footer { margin-top: auto; }
.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.5rem 2rem 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.875rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

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

@media (max-width: 1100px) {
  .records-shell,
  .grid.two { grid-template-columns: 1fr; }
  .filter-panel { position: static; }
  .searchbar { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.three,
  .form-grid,
  .form-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field.span-3,
  .field.span-4,
  .field.span-5,
  .field.span-6,
  .field.span-7,
  .field.span-8 { grid-column: span 1; }
  .field.full,
  .field.span-12 { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .header-inner {
    padding: 0.85rem 1rem;
    min-height: auto;
    flex-wrap: wrap;
  }
  .app-header { height: auto; }
  .nav {
    width: 100%;
    order: 3;
    justify-content: space-between;
    overflow-x: auto;
    padding: 0.28rem;
  }
  .nav a { flex: 1 0 auto; text-align: center; }
  .page { padding: 1.3rem 1rem 4rem; }
  .panel-head,
  .panel-body { padding-left: 1rem; padding-right: 1rem; }
  .calendar-toolbar { grid-template-columns: 44px 1fr 44px; padding: 0.65rem; }
}

@media (max-width: 640px) {
  .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; }
  .calendar-legend { gap: 0.4rem; }
  .legend-chip { padding: 0.32rem 0.55rem; font-size: 0.67rem; }
  .day-pills { display: none; }
  .stat-card {
    min-height: 78px;
    padding: 0.85rem 0.9rem;
    border-radius: 14px;
  }
  .stat-label { font-size: 0.72rem; margin-bottom: 0.35rem; }
  .stat-value { font-size: 1.32rem; }
  .panel-head { flex-direction: column; }
  .footer-inner { padding-left: 1rem; padding-right: 1rem; }
  .day {
    min-height: 78px;
    padding: 0.5rem 0.3rem;
    border-radius: 12px;
  }
  .inline-note { font-size: 0.68rem; min-height: 1.9em; }
  .form-grid.three,
  .form-grid,
  .form-grid.compact,
  .searchbar { grid-template-columns: 1fr; }
}


:root[data-theme="light"] .legend-chip.sleep, :root[data-theme="light"] .mini-pill.sleep { background: rgba(129,140,248,0.18); color: #4338ca; border-color: rgba(99,102,241,0.28); }
:root[data-theme="light"] .legend-chip.medication, :root[data-theme="light"] .mini-pill.medication { background: rgba(52,211,153,0.18); color: #047857; border-color: rgba(16,185,129,0.26); }
:root[data-theme="light"] .legend-chip.symptom, :root[data-theme="light"] .mini-pill.symptom { background: rgba(248,113,113,0.18); color: #b91c1c; border-color: rgba(239,68,68,0.28); }
:root[data-theme="light"] .legend-chip.note, :root[data-theme="light"] .mini-pill.note { background: rgba(167,139,250,0.18); color: #6d28d9; border-color: rgba(139,92,246,0.26); }
:root[data-theme="light"] .legend-chip.appointment, :root[data-theme="light"] .mini-pill.appointment { background: rgba(59,130,246,0.18); color: #1d4ed8; border-color: rgba(37,99,235,0.28); }
:root[data-theme="light"] .legend-chip.call, :root[data-theme="light"] .mini-pill.call { background: rgba(6,182,212,0.18); color: #0f766e; border-color: rgba(8,145,178,0.28); }

.calendar-nav {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

:root[data-theme="light"] .calendar-nav {
  background: rgba(255,255,255,0.76);
  border-color: rgba(15,23,42,0.10);
  color: #0f172a;
}

:root[data-theme="light"] .day {
  background: rgba(255,255,255,0.82);
}

:root[data-theme="light"] .day.selected {
  background: rgba(241,245,249,0.94);
}

:root[data-theme="light"] .icon-btn {
  background: rgba(255,255,255,0.76);
  border-color: rgba(15,23,42,0.08);
  color: #0f172a;
}

@media (max-width: 760px) {
  .hero-banner {
    padding: 1rem;
    align-items: stretch;
  }

  .hero-banner .inline-actions {
    width: 100%;
  }

  .hero-banner .inline-actions .btn {
    flex: 1 1 0;
  }
}

/* Medical records archive */
.glass-panel {
  background: linear-gradient(180deg, rgba(4, 15, 28, 0.86), rgba(6, 17, 30, 0.74));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(126, 200, 255, 0.12);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

.medical-records-page {
  display: grid;
  gap: 1.35rem;
}

.records-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto;
  gap: 1.25rem;
  align-items: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.76rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.8rem;
}

.records-hero h1,
.record-detail-head h1 {
  margin: 0;
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1.05;
}

.records-hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(100px, 1fr));
  gap: 0.8rem;
}

.hero-stat,
.record-summary-box {
  border-radius: 18px;
  padding: 0.95rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.hero-stat span {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
}

.hero-stat small,
.record-summary-box .meta-kicker {
  color: var(--muted);
}

.records-layout,
.record-detail-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 1.25rem;
}

.records-sidebar,
.record-series-panel {
  position: sticky;
  top: 88px;
  align-self: start;
}

.panel-head.compact {
  padding-bottom: 0;
}

.records-helper-block {
  padding: 1rem;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(61, 195, 255, 0.08), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(126, 200, 255, 0.12);
}

.archive-mini-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.6rem;
}

.archive-mini-stats span,
.record-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 0.78rem;
}

.records-main,
.record-view-main {
  min-width: 0;
}

.records-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.record-card {
  display: grid;
  overflow: hidden;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: inherit;
  text-decoration: none;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.record-card:hover {
  transform: translateY(-3px);
  border-color: rgba(126, 200, 255, 0.28);
  box-shadow: 0 22px 45px rgba(3, 8, 15, 0.32);
}

.record-card-media {
  aspect-ratio: 4 / 3;
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.35), rgba(2, 6, 23, 0.6));
}

.record-card-media img,
.series-item-media img,
.thumb-card img,
.viewer-main-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.viewer-main-image {
  object-fit: contain;
}

.record-card-body {
  padding: 1rem;
}

.record-card-topline {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.83rem;
}

.record-card h3 {
  margin: 0.7rem 0 0.35rem;
  font-size: 1.08rem;
}

.record-card p {
  margin: 0;
  color: var(--muted);
  min-height: 2.4em;
}

.record-card-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  margin-top: 1rem;
}

.record-card-stats div {
  padding: 0.7rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.record-card-stats strong,
.record-summary-box .meta-value {
  display: block;
  font-size: 1rem;
  font-weight: 800;
  word-break: break-word;
}

.record-card-stats span {
  color: var(--muted);
  font-size: 0.76rem;
}

.record-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.record-detail-head {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.9fr);
  gap: 1rem;
  align-items: start;
}

.record-detail-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.info-pair {
  padding: 0.85rem 0.95rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.info-pair span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.info-pair strong {
  display: block;
  font-size: 0.98rem;
}

.series-list {
  display: grid;
  gap: 0.75rem;
  max-height: calc(100vh - 180px);
  overflow: auto;
  padding-right: 0.2rem;
}

.series-item {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 0.85rem;
  align-items: center;
  width: 100%;
  padding: 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.series-item.active {
  border-color: rgba(126, 200, 255, 0.36);
  box-shadow: inset 0 0 0 1px rgba(126, 200, 255, 0.2);
}

.series-item-media {
  height: 76px;
  overflow: hidden;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.series-item-copy {
  min-width: 0;
}

.series-item-copy strong,
.series-item-copy span,
.series-item-copy small {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.series-item-copy span,
.series-item-copy small {
  color: var(--muted);
}

.viewer-stage-wrap {
  display: grid;
  gap: 1rem;
}

.viewer-stage {
  min-height: 460px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  overflow: hidden;
  background: radial-gradient(circle at top, rgba(64, 161, 255, 0.12), rgba(7, 13, 24, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.viewer-meta-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1rem;
}

.viewer-meta-card {
  padding: 1rem;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.quick-meta-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.9rem;
}

.json-actions {
  margin: 0.75rem 0;
}

.json-preview {
  margin: 0;
  max-height: 420px;
  overflow: auto;
  border-radius: 18px;
  padding: 1rem;
  background: rgba(2, 6, 23, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.78rem;
  line-height: 1.5;
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.8rem;
  max-height: 620px;
  overflow: auto;
}

.thumb-card {
  display: grid;
  gap: 0.4rem;
  padding: 0.45rem;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  cursor: pointer;
}

.thumb-card.active {
  border-color: rgba(126, 200, 255, 0.38);
  box-shadow: inset 0 0 0 1px rgba(126, 200, 255, 0.2);
}

.thumb-card img {
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  object-fit: cover;
}

.thumb-card span {
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
}

.crumb-link {
  display: inline-flex;
  margin-bottom: 1rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.large-empty {
  padding: 2rem;
  border-radius: 22px;
}

:root[data-theme="light"] .glass-panel,
:root[data-theme="light"] .record-card,
:root[data-theme="light"] .series-item,
:root[data-theme="light"] .viewer-meta-card,
:root[data-theme="light"] .thumb-card,
:root[data-theme="light"] .info-pair,
:root[data-theme="light"] .hero-stat,
:root[data-theme="light"] .record-summary-box,
:root[data-theme="light"] .record-card-stats div,
:root[data-theme="light"] .records-helper-block {
  background: rgba(255, 255, 255, 0.84);
  border-color: rgba(15, 23, 42, 0.08);
}

:root[data-theme="light"] .viewer-stage {
  background: radial-gradient(circle at top, rgba(59, 130, 246, 0.14), rgba(226, 232, 240, 0.94));
  border-color: rgba(15, 23, 42, 0.08);
}

:root[data-theme="light"] .json-preview {
  background: rgba(248, 250, 252, 0.96);
  border-color: rgba(15, 23, 42, 0.08);
  color: #0f172a;
}

@media (max-width: 1100px) {
  .records-layout,
  .record-detail-layout,
  .record-detail-head,
  .viewer-meta-grid {
    grid-template-columns: 1fr;
  }

  .records-sidebar,
  .record-series-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .records-hero,
  .records-hero-stats,
  .record-card-stats,
  .record-detail-summary {
    grid-template-columns: 1fr;
  }

  .records-grid {
    grid-template-columns: 1fr;
  }

  .series-item {
    grid-template-columns: 66px minmax(0, 1fr);
  }

  .viewer-stage {
    min-height: 300px;
  }
}


/* ==========================================================================
   MEDICAL RECORDS V2
   ========================================================================== */

.medical-records-page {
  display: grid;
  gap: 1.5rem;
}

.records-hero-v2,
.records-toolbar,
.records-shell-sidebar,
.records-history,
.records-detail-hero,
.records-detail-panel,
.records-viewer-panel,
.raw-json-panel {
  background: linear-gradient(180deg, rgba(7, 18, 32, 0.88) 0%, rgba(7, 14, 25, 0.94) 100%);
}

:root[data-theme="light"] .records-hero-v2,
:root[data-theme="light"] .records-toolbar,
:root[data-theme="light"] .records-shell-sidebar,
:root[data-theme="light"] .records-history,
:root[data-theme="light"] .records-detail-hero,
:root[data-theme="light"] .records-detail-panel,
:root[data-theme="light"] .records-viewer-panel,
:root[data-theme="light"] .raw-json-panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.92) 0%, rgba(246,249,253,0.96) 100%);
}

.records-hero-v2 {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: end;
  padding: 1.6rem;
}

.records-hero-copy .lead {
  margin-bottom: 0;
  max-width: 58ch;
}

.records-hero-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 1rem;
}

.records-total-card,
.records-toolbar-summary,
.records-detail-tile {
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  padding: 1rem 1.05rem;
}

:root[data-theme="light"] .records-total-card,
:root[data-theme="light"] .records-toolbar-summary,
:root[data-theme="light"] .records-detail-tile {
  background: rgba(15,23,42,0.03);
}

.records-total-card span,
.records-toolbar-summary strong {
  display: block;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.records-total-card small,
.records-toolbar-summary small,
.records-detail-tile span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.records-toolbar {
  padding: 1.15rem 1.25rem;
}

.records-toolbar-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 2fr) repeat(2, minmax(180px, 0.8fr)) minmax(150px, 0.65fr);
  align-items: end;
}

.records-field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.records-field span {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 650;
}

.records-shell-grid,
.records-detail-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.88fr) minmax(0, 1.7fr);
  gap: 1.5rem;
  align-items: start;
}

.records-sidebar-body {
  display: grid;
  gap: 1rem;
}

.records-mini-group {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
  padding: 1rem;
}

:root[data-theme="light"] .records-mini-group {
  background: rgba(15,23,42,0.025);
}

.records-mini-title {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
  font-weight: 700;
}

.records-badge-list,
.records-history-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.records-badge,
.record-history-stats span,
.record-type-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 34px;
  padding: 0.42rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-size: 0.82rem;
}

.record-type-pill {
  color: #dbeafe;
  border-color: rgba(56,189,248,0.24);
  background: rgba(14, 165, 233, 0.10);
  font-weight: 700;
}

:root[data-theme="light"] .record-type-pill {
  color: #0f3a75;
  background: rgba(37,99,235,0.08);
  border-color: rgba(37,99,235,0.18);
}

.records-history-list {
  display: grid;
  gap: 1rem;
}

.record-history-card {
  display: grid;
  grid-template-columns: 84px 170px minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: stretch;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,0.025);
}

.record-history-card:hover {
  border-color: rgba(56,189,248,0.24);
  box-shadow: 0 16px 40px rgba(0,0,0,0.14);
}

:root[data-theme="light"] .record-history-card {
  background: rgba(15,23,42,0.02);
}

.record-history-date {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 0.85rem 0.5rem;
  border-radius: 16px;
  background: rgba(59,130,246,0.10);
  border: 1px solid rgba(59,130,246,0.16);
}

.record-history-date strong {
  font-size: 1.65rem;
  line-height: 1;
  letter-spacing: -0.05em;
}

.record-history-date span,
.record-history-date small,
.record-history-time {
  color: var(--muted);
}

.record-history-preview {
  overflow: hidden;
  border-radius: 16px;
  min-height: 145px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.24);
}

.record-history-preview img,
.records-series-item-media img,
.records-thumb img,
.records-main-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.record-history-preview.no-image,
.records-series-item-media.no-image {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.record-history-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.record-history-copy h3 {
  font-size: 1.2rem;
  margin: 0.35rem 0 0.35rem;
}

.record-history-copy p {
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.record-history-topline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.record-history-actions {
  display: flex;
  align-items: center;
}

.records-empty-state {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 2.75rem 1rem;
  gap: 0.4rem;
  color: var(--muted);
}

.records-empty-state.compact {
  min-height: 320px;
}

.records-detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.95fr);
  gap: 1.5rem;
  padding: 1.6rem;
}

.records-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  margin-bottom: 0.85rem;
  font-weight: 650;
}

.records-back-link:hover {
  color: var(--text);
}

.records-detail-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.records-detail-tile strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 1rem;
  line-height: 1.35;
}

.records-detail-sidebar,
.records-detail-main,
.records-meta-panels {
  display: grid;
  gap: 1.5rem;
}

.records-series-list {
  display: grid;
  gap: 0.8rem;
}

.records-series-item {
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 0.8rem;
  padding: 0.8rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  cursor: pointer;
}

.records-series-item.active,
.records-series-item:hover,
.records-thumb.active,
.records-thumb:hover {
  border-color: rgba(56,189,248,0.28);
  box-shadow: 0 0 0 1px rgba(56,189,248,0.16) inset;
}

.records-series-item-media {
  overflow: hidden;
  border-radius: 12px;
  min-height: 78px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.22);
}

.records-series-item-copy {
  min-width: 0;
}

.records-series-item-copy strong,
.records-series-item-copy span,
.records-series-item-copy small {
  display: block;
}

.records-series-item-copy span,
.records-series-item-copy small {
  color: var(--muted);
}

.records-viewer-head {
  align-items: center;
}

.records-viewer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.records-viewer-stage {
  min-height: 560px;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at center, rgba(56,189,248,0.12), transparent 36%),
    rgba(3, 9, 18, 0.9);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.records-main-image {
  max-width: 100%;
  max-height: 540px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 14px;
}

.records-filmstrip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}

.records-thumb {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255,255,255,0.03);
  color: var(--text);
  padding: 0;
  cursor: pointer;
}

.records-thumb img {
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.records-thumb span {
  display: block;
  padding: 0.45rem 0.55rem 0.55rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.records-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
}

.records-meta-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 0.95rem;
  background: rgba(255,255,255,0.03);
}

.records-meta-item span {
  display: block;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.4rem;
  font-weight: 700;
}

.records-meta-item strong {
  display: block;
  line-height: 1.45;
}

.records-json-details {
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255,255,255,0.02);
}

.records-json-details summary {
  cursor: pointer;
  list-style: none;
  padding: 0.95rem 1rem;
  font-weight: 700;
}

.records-json-details summary::-webkit-details-marker {
  display: none;
}

.records-json-preview {
  margin: 0;
  padding: 1rem;
  border-top: 1px solid var(--line);
  overflow: auto;
  max-height: 480px;
  color: #cbd5e1;
  font-size: 0.78rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.records-empty-inline {
  color: var(--muted);
}

@media (max-width: 1100px) {
  .records-toolbar-grid,
  .records-shell-grid,
  .records-detail-grid,
  .records-detail-hero {
    grid-template-columns: 1fr;
  }

  .records-hero-v2 {
    flex-direction: column;
    align-items: stretch;
  }

  .record-history-card {
    grid-template-columns: 84px 140px minmax(0, 1fr);
  }

  .record-history-actions {
    grid-column: 2 / -1;
  }
}

@media (max-width: 760px) {
  .records-hero-totals,
  .records-detail-tiles,
  .records-meta-grid {
    grid-template-columns: 1fr;
  }

  .records-toolbar-grid {
    grid-template-columns: 1fr;
  }

  .record-history-card {
    grid-template-columns: 1fr;
  }

  .record-history-date,
  .record-history-actions {
    justify-self: start;
  }

  .record-history-preview {
    min-height: 220px;
  }

  .records-viewer-stage {
    min-height: 320px;
  }

  .records-main-image {
    max-height: 300px;
  }

  .records-filmstrip {
    grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
  }
}


/* ==========================================================================
   PROFESSIONAL MEDICAL RECORDS UI - PREMIUM CLEAN VERSION
   (Added at the bottom - overrides the old messy styles)
   ========================================================================== */

.medical-records-page {
  background: transparent;
}

/* Clean, flat, clinical panels */
.records-hero-v2,
.records-toolbar,
.records-shell-sidebar,
.records-history,
.records-detail-hero,
.records-detail-panel,
.records-viewer-panel,
.raw-json-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
}

/* Hero & totals */
.records-hero-v2 { padding: 2rem; }
.records-hero-totals { gap: 1rem; }
.records-total-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.25rem;
  text-align: center;
}
.records-total-card span {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

/* History cards - now clean & premium */
.record-history-card {
  grid-template-columns: 78px 168px 1fr auto;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem;
  border-radius: 20px;
  background: rgba(255,255,255,0.025);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.record-history-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(59, 130, 246, 0.22);
  border-color: rgba(59, 130, 246, 0.35);
}
.record-history-date {
  background: rgba(59,130,246,0.1);
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: 16px;
}
.record-history-preview {
  min-height: 168px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.record-history-copy h3 {
  font-size: 1.2rem;
  margin: 0.4rem 0 0.5rem;
}
.record-history-stats {
  gap: 0.75rem;
}

/* Metadata - spacious and readable */
.records-meta-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}
.records-meta-item {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.1rem 1.25rem;
}
.records-meta-item span {
  font-size: 0.73rem;
  letter-spacing: 0.5px;
  opacity: 0.8;
}

/* Image viewer - feels like real medical software */
.records-viewer-stage {
  min-height: 580px;
  background: #0b1725;
  border-radius: 24px;
  padding: 2rem;
  box-shadow: inset 0 0 80px rgba(0,0,0,0.7);
}
.records-main-image {
  max-height: 540px;
  border-radius: 16px;
  box-shadow: 0 15px 35px rgba(0,0,0,0.5);
}
.records-filmstrip {
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 0.85rem;
}
.records-thumb {
  border-radius: 14px;
  padding: 4px;
}
.records-thumb.active,
.records-thumb:hover {
  border-color: #3b82f6;
  box-shadow: 0 0 0 4px rgba(59,130,246,0.3);
}

/* Series list in sidebar */
.records-series-item {
  padding: 1rem;
  border-radius: 18px;
}
.records-series-item.active {
  background: rgba(59,130,246,0.12);
  border-color: #3b82f6;
}

/* Mobile friendly */
@media (max-width: 1100px) {
  .records-toolbar-grid,
  .records-shell-grid,
  .records-detail-grid,
  .records-detail-hero {
    grid-template-columns: 1fr;
  }
  .record-history-card {
    grid-template-columns: 78px 1fr auto;
  }
}
@media (max-width: 760px) {
  .record-history-card {
    grid-template-columns: 1fr;
  }
  .records-viewer-stage {
    min-height: 380px;
    padding: 1rem;
  }
}