:root {
  --primary: #315C43;
  --primary-dark: #234334;
  --primary-light: #4A7A5C;
  --primary-soft: #E8EFE9;
  --gold: #C6A15B;
  --gold-light: #E7D6A8;
  --gold-deep: #A88845;
  --gold-soft: #F5EEDC;
  --bg: #F8F6F1;
  --surface: #FFFFFF;
  --surface-2: #FAF8F4;
  --surface-3: #F2EFE6;
  --text: #243126;
  --text-muted: #6E776E;
  --text-dim: #9AA398;
  --border: #E5E1D8;
  --border-strong: #D2CCBC;
  --divider: #EDEAE0;
  --danger: #B85447;
  --warning: #C99441;
  --success: #5F834F;
  --info: #4A7A8C;

  --shadow-xs: 0 1px 2px rgba(36, 49, 38, 0.04);
  --shadow-sm: 0 2px 10px rgba(36, 49, 38, 0.05);
  --shadow-md: 0 8px 28px rgba(36, 49, 38, 0.07);
  --shadow-lg: 0 24px 56px rgba(36, 49, 38, 0.10);
  --shadow-gold: 0 8px 28px rgba(198, 161, 91, 0.28);

  --radius-sm: 14px;
  --radius: 20px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-pill: 999px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --font-display: 'Fraunces', Georgia, serif;
  --font-sans: 'Manrope', 'Inter', -apple-system, sans-serif;
}

[data-theme="dark"] {
  --bg: #1A211B; --surface: #232B25; --surface-2: #2D352E; --surface-3: #383F38;
  --text: #F0EDE0; --text-muted: #B5B0A0; --text-dim: #7A7568;
  --border: #2D352E; --border-strong: #3F4840; --divider: #232B25;
  --primary: #6BA582; --primary-dark: #4A7A5C; --primary-light: #8FBA9F;
  --primary-soft: #2D352E; --gold: #D4B370; --gold-light: #E7D6A8;
  --danger: #D87668; --warning: #D9A85A; --success: #7FB070;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.2); --shadow-sm: 0 2px 8px rgba(0,0,0,0.25);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.35); --shadow-lg: 0 20px 48px rgba(0,0,0,0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { font-family: var(--font-sans); background: var(--bg); color: var(--text); line-height: 1.6; overflow-x: hidden; min-height: 100vh; -webkit-font-smoothing: antialiased; }

body::before { content: ''; position: fixed; inset: 0; z-index: -2; background: radial-gradient(ellipse 70% 50% at 0% 0%, rgba(198,161,91,0.10) 0%, transparent 60%), radial-gradient(ellipse 50% 40% at 100% 100%, rgba(49,92,67,0.06) 0%, transparent 60%); pointer-events: none; }

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.025em; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }
a { color: var(--primary); text-decoration: none; transition: color 0.2s var(--ease); font-weight: 600; }
a:hover { color: var(--primary-dark); }

/* === AUTH === */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 25% 25%, rgba(198,161,91,0.15), transparent 50%), radial-gradient(circle at 75% 75%, rgba(49,92,67,0.08), transparent 50%), var(--bg); }
.auth-card { width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 48px 40px; box-shadow: var(--shadow-lg); position: relative; overflow: hidden; }
.auth-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.auth-brand { text-align: center; margin-bottom: 32px; }
.auth-logo { width: 80px; height: 80px; margin: 0 auto 20px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); display: grid; place-items: center; font-size: 36px; color: var(--gold-light); box-shadow: var(--shadow-md), inset 0 1px 0 rgba(231,214,168,0.2); border: 2px solid var(--gold); transition: transform 0.4s var(--ease-spring); }
.auth-logo:hover { transform: scale(1.05) rotate(-5deg); }
.auth-name { font-family: var(--font-display); font-size: 34px; font-weight: 600; color: var(--primary-dark); letter-spacing: -0.02em; margin-bottom: 6px; }
.auth-tag { font-size: 11px; color: var(--gold-deep); text-transform: uppercase; letter-spacing: 3.5px; font-weight: 700; }
.auth-title { font-family: var(--font-display); font-size: 30px; font-weight: 500; text-align: center; margin-bottom: 8px; }
.auth-sub { text-align: center; color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 11px; font-weight: 700; margin-bottom: 8px; color: var(--text-muted); letter-spacing: 1.5px; text-transform: uppercase; }
.form-input { width: 100%; height: 50px; background: var(--surface-2); border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 0 16px; color: var(--text); font-size: 14px; outline: none; transition: all 0.25s var(--ease); }
.form-input::placeholder { color: var(--text-dim); }
.form-input:focus { border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 4px rgba(49,92,67,0.08); }
.form-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 24px; }
.form-error { background: rgba(184,84,71,0.08); border: 1px solid rgba(184,84,71,0.25); color: var(--danger); padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 18px; display: none; }
.form-error.show { display: block; }
.btn-block { width: 100%; height: 52px; justify-content: center; font-size: 14px; }
.auth-foot { text-align: center; margin-top: 26px; font-size: 13px; color: var(--text-muted); }
.auth-foot a { font-weight: 700; color: var(--primary); }
.divider { display: flex; align-items: center; gap: 14px; margin: 22px 0; color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 2.5px; font-weight: 600; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.btn-google { width: 100%; height: 52px; display: flex; align-items: center; justify-content: center; gap: 12px; background: var(--surface); color: var(--text); border: 1.5px solid var(--border-strong); border-radius: var(--radius-pill); font-size: 14px; font-weight: 600; transition: all 0.3s var(--ease); }
.btn-google:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-google svg { width: 20px; height: 20px; flex-shrink: 0; }

/* === TOP NAV === */
.topnav { position: sticky; top: 16px; z-index: 50; background: rgba(255,255,255,0.78); backdrop-filter: blur(28px) saturate(180%); border: 1px solid var(--border); border-radius: var(--radius-pill); height: 68px; display: flex; align-items: center; padding: 0 14px 0 22px; gap: 18px; margin: 16px 32px 0; box-shadow: var(--shadow-sm); }
.topnav-brand { display: flex; align-items: center; gap: 12px; cursor: pointer; padding-right: 10px; }
.topnav-logo { width: 42px; height: 42px; border-radius: 14px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); display: grid; place-items: center; font-size: 19px; color: var(--gold-light); box-shadow: var(--shadow-xs); border: 1.5px solid var(--gold); }
.brand-name { font-family: var(--font-display); font-size: 22px; font-weight: 600; color: var(--primary-dark); line-height: 1.1; letter-spacing: -0.02em; }
.brand-tag { font-size: 9px; color: var(--gold-deep); text-transform: uppercase; letter-spacing: 2.5px; font-weight: 700; }
.topnav-links { display: flex; align-items: center; gap: 4px; }
.topnav-link { display: flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: var(--radius-pill); color: var(--text-muted); font-size: 13px; font-weight: 600; transition: all 0.25s var(--ease); cursor: pointer; }
.topnav-link:hover { background: var(--primary-soft); color: var(--primary); }
.topnav-link.active { background: var(--primary); color: var(--gold-light); box-shadow: var(--shadow-xs); }
.topnav-link .badge { background: var(--gold); color: var(--primary-dark); font-size: 10px; padding: 1px 7px; border-radius: 10px; font-weight: 700; }
.topnav-link.active .badge { background: rgba(231,214,168,0.3); color: var(--gold-light); }
.topnav-link.admin { background: var(--gold); color: var(--primary-dark); }
.topnav-link.admin .badge { background: var(--primary); color: var(--gold); }
.topnav-spacer { flex: 1; }
.topnav-search { position: relative; width: 240px; }
.topnav-search input { width: 100%; height: 42px; background: var(--surface-2); border: 1.5px solid transparent; border-radius: var(--radius-pill); padding: 0 16px 0 40px; color: var(--text); font-size: 13px; outline: none; transition: all 0.25s var(--ease); }
.topnav-search input:focus { border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 4px rgba(49,92,67,0.08); }
.topnav-search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13px; }
.topnav-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn { width: 42px; height: 42px; border-radius: var(--radius-pill); display: grid; place-items: center; color: var(--text-muted); transition: all 0.25s var(--ease); position: relative; font-size: 15px; }
.icon-btn:hover { background: var(--primary-soft); color: var(--primary); }
.icon-btn .dot { position: absolute; top: 10px; right: 10px; width: 8px; height: 8px; background: var(--danger); border-radius: 50%; border: 2px solid var(--surface); }
.profile { display: flex; align-items: center; gap: 8px; padding: 4px 14px 4px 4px; background: var(--surface-2); border-radius: var(--radius-pill); transition: all 0.25s var(--ease); cursor: pointer; border: 1px solid var(--border); }
.profile:hover { background: var(--primary-soft); border-color: var(--primary); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: var(--primary-dark); font-size: 12px; overflow: hidden; background: linear-gradient(135deg, var(--gold-light), var(--gold)); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { font-size: 13px; font-weight: 600; }
.profile-role { font-size: 10px; color: var(--text-muted); }

.content { padding: 32px 32px 80px; max-width: 1500px; margin: 0 auto; position: relative; }
.page-head { margin-bottom: 32px; display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 24px; }
.page-title { font-family: var(--font-display); font-size: 48px; font-weight: 500; letter-spacing: -0.035em; margin-bottom: 10px; color: var(--primary-dark); line-height: 1; }
.page-title .highlight { font-style: italic; background: linear-gradient(135deg, var(--gold-deep), var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.page-sub { color: var(--text-muted); font-size: 15px; display: flex; align-items: center; gap: 14px; }
.page-sub::before { content: ''; width: 36px; height: 1px; background: linear-gradient(90deg, var(--gold), transparent); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 13px 24px; border-radius: var(--radius-pill); font-size: 14px; font-weight: 600; transition: all 0.3s var(--ease); border: 1.5px solid transparent; letter-spacing: 0.1px; }
.btn-primary { background: var(--primary); color: var(--gold-light); border-color: var(--primary); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-2px); box-shadow: var(--shadow-md), 0 0 0 4px rgba(198,161,91,0.15); }
.btn-secondary { background: var(--gold); color: var(--primary-dark); border-color: var(--gold); box-shadow: var(--shadow-gold); }
.btn-secondary:hover { background: var(--gold-deep); transform: translateY(-2px); box-shadow: 0 12px 36px rgba(198,161,91,0.45); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--primary); color: var(--primary); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(184,84,71,0.3); }
.btn-danger:hover { background: rgba(184,84,71,0.08); }
.btn-block { width: 100%; height: 52px; justify-content: center; }
.btn-sm { padding: 8px 16px; font-size: 13px; }

/* === BENTO === */
.bento { display: grid; grid-template-columns: repeat(6, 1fr); grid-auto-rows: minmax(110px, auto); gap: 20px; margin-bottom: 32px; }
.bento-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 30px; position: relative; overflow: hidden; transition: all 0.3s var(--ease); box-shadow: var(--shadow-xs); display: flex; flex-direction: column; }
.bento-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.col-2 { grid-column: span 2; } .col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; } .col-6 { grid-column: span 6; }
.row-1 { grid-row: span 1; } .row-2 { grid-row: span 2; }
@media (max-width: 1200px) { .bento { grid-template-columns: repeat(4, 1fr); } .col-4 { grid-column: span 2; } .col-3, .col-6 { grid-column: span 4; } }
@media (max-width: 768px) { .bento { grid-template-columns: repeat(2, 1fr); } .col-2, .col-3, .col-4, .col-6 { grid-column: span 2; } }
@media (max-width: 480px) { .bento { grid-template-columns: 1fr; } }

.bento-card.hero { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); color: var(--gold-light); border-color: var(--primary-dark); }
.bento-card.hero .bento-label, .bento-card.hero .bento-subtitle, .bento-card.hero .bento-meta { color: rgba(231,214,168,0.75); }
.bento-card.hero .bento-title { color: var(--gold-light); font-style: italic; }
.bento-card.accent { background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold-soft) 100%); color: var(--primary-dark); border: 1px solid var(--gold); }
.bento-card.accent .bento-label, .bento-card.accent .bento-meta { color: rgba(35,67,52,0.7); }
.bento-card.accent .bento-title { color: var(--primary-dark); }
.bento-card.soft { background: var(--primary-soft); border-color: transparent; }
.bento-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; position: relative; z-index: 1; }
.bento-label { font-size: 11px; text-transform: uppercase; letter-spacing: 2px; font-weight: 700; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.bento-label::before { content: ''; width: 16px; height: 1px; background: var(--gold); }
.bento-icon { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; font-size: 17px; background: var(--primary-soft); color: var(--primary); flex-shrink: 0; }
.bento-card.hero .bento-icon { background: rgba(231,214,168,0.15); color: var(--gold-light); }
.bento-card.accent .bento-icon { background: rgba(49,92,67,0.1); color: var(--primary-dark); }
.bento-title { font-family: var(--font-display); font-size: 42px; font-weight: 500; letter-spacing: -0.03em; line-height: 1; margin-bottom: 8px; color: var(--text); }
.bento-subtitle { font-size: 13px; opacity: 0.85; margin-bottom: 14px; font-style: italic; }
.bento-meta { font-size: 12px; color: var(--text-muted); margin-top: auto; padding-top: 16px; font-weight: 500; }
.bento-spark { display: flex; align-items: flex-end; gap: 4px; height: 48px; margin-top: 20px; }
.bento-spark span { flex: 1; border-radius: 3px; background: var(--gold); opacity: 0.4; animation: sparkRise 1.2s var(--ease-out) backwards; transform-origin: bottom; }
@keyframes sparkRise { from { transform: scaleY(0); opacity: 0; } to { transform: scaleY(1); opacity: 0.7; } }
.bento-card.hero .bento-spark span { background: var(--gold-light); }

.alerts-card { background: var(--surface); border: 1px solid rgba(184,84,71,0.2); border-left: 3px solid var(--danger); border-radius: var(--radius-lg); padding: 24px; margin-bottom: 24px; box-shadow: var(--shadow-xs); }
.alerts-card .card-title { color: var(--danger); font-family: var(--font-display); font-size: 22px; font-weight: 500; margin-bottom: 4px; }
.alerts-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.alert-row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); transition: all 0.25s var(--ease); cursor: pointer; }
.alert-row:hover { border-color: var(--danger); transform: translateX(4px); box-shadow: var(--shadow-sm); }
.alert-icon { color: var(--danger); font-size: 16px; }
.alert-text { flex: 1; font-size: 14px; font-weight: 600; }
.alert-meta { font-size: 12px; color: var(--text-muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow-xs); margin-bottom: 24px; position: relative; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.card-title { font-family: var(--font-display); font-size: 24px; font-weight: 500; color: var(--text); display: flex; align-items: center; gap: 10px; }
.card-title::before { content: '✦'; color: var(--gold); font-size: 14px; }
.card-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon { width: 80px; height: 80px; margin: 0 auto 20px; background: var(--primary-soft); border-radius: 50%; display: grid; place-items: center; font-size: 32px; color: var(--primary); border: 2px dashed var(--gold); }
.empty-title { font-family: var(--font-display); font-size: 22px; font-weight: 500; color: var(--text); margin-bottom: 8px; }
.empty-text { font-size: 14px; margin-bottom: 22px; }

.vitals { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.vital { background: var(--surface-2); border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 16px; transition: all 0.25s var(--ease); }
.vital:focus-within { border-color: var(--primary); background: var(--surface); }
.vital-label { font-size: 11px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 1.5px; margin-bottom: 8px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.vital-label::before { content: ''; width: 8px; height: 8px; background: var(--gold); border-radius: 50%; }
.vital-input { width: 100%; background: transparent; border: none; color: var(--primary-dark); font-size: 28px; font-weight: 500; font-family: var(--font-display); outline: none; padding: 0; }
.vital-input::placeholder { color: var(--text-dim); }
.vital-unit { font-size: 12px; color: var(--text-muted); margin-left: 4px; font-weight: 500; }

.patient-list { display: flex; flex-direction: column; gap: 10px; }
.patient { display: flex; align-items: center; gap: 16px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); transition: all 0.25s var(--ease); cursor: pointer; }
.patient:hover { border-color: var(--primary); transform: translateX(4px); box-shadow: var(--shadow-sm); }
.patient-avatar { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-weight: 600; font-size: 16px; color: white; flex-shrink: 0; font-family: var(--font-display); box-shadow: var(--shadow-xs); border: 1.5px solid var(--gold); }
.patient-info { flex: 1; min-width: 0; }
.patient-name { font-family: var(--font-display); font-size: 18px; font-weight: 500; color: var(--text); margin-bottom: 3px; }
.patient-meta { font-size: 12px; color: var(--text-muted); }
.patient-status { padding: 5px 14px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; }
.status-stable { background: var(--primary-soft); color: var(--primary); }
.status-critical { background: rgba(184,84,71,0.12); color: var(--danger); }
.status-monitor { background: rgba(201,148,65,0.12); color: var(--warning); }

.tasks { display: flex; flex-direction: column; gap: 10px; }
.task { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); transition: all 0.25s var(--ease); }
.task:hover { border-color: var(--primary); }
.task-check { width: 22px; height: 22px; border-radius: 8px; border: 1.5px solid var(--border-strong); display: grid; place-items: center; flex-shrink: 0; cursor: pointer; transition: all 0.25s var(--ease-spring); background: transparent; }
.task.done .task-check { background: var(--primary); border-color: var(--primary); color: var(--gold-light); transform: scale(1.1); }
.task.done .task-text { color: var(--text-dim); text-decoration: line-through; }
.task-text { font-size: 14px; flex: 1; background: transparent; border: none; color: var(--text); outline: none; }
.task-time { font-size: 12px; color: var(--text-muted); background: transparent; border: none; outline: none; width: 70px; text-align: right; font-weight: 600; }
.task-delete { width: 28px; height: 28px; border-radius: 8px; background: transparent; color: var(--text-dim); transition: all 0.25s var(--ease); font-size: 12px; }
.task-delete:hover { background: rgba(184,84,71,0.12); color: var(--danger); }
.task-patient-tag { font-size: 11px; padding: 4px 12px; border-radius: var(--radius-pill); background: var(--gold-soft); color: var(--gold-deep); font-weight: 600; cursor: pointer; border: 1px solid rgba(198,161,91,0.3); }
.task-patient-tag:hover { background: var(--gold); color: var(--primary-dark); }

.med-list { display: flex; flex-direction: column; gap: 10px; }
.med { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); transition: all 0.25s var(--ease); }
.med.overdue { border-color: rgba(184,84,71,0.4); background: rgba(184,84,71,0.04); }
.med.overdue:hover { background: rgba(184,84,71,0.08); }
.med.given { opacity: 0.6; }
.med.given .med-name { text-decoration: line-through; color: var(--text-muted); }
.med-icon { width: 42px; height: 42px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 15px; flex-shrink: 0; border: 1px solid var(--border); }
.med.overdue .med-icon { background: rgba(184,84,71,0.12); color: var(--danger); }
.med.given .med-icon { background: var(--gold-light); color: var(--primary-dark); }
.med-info { flex: 1; min-width: 0; }
.med-name { font-family: var(--font-display); font-size: 17px; font-weight: 500; color: var(--text); margin-bottom: 2px; }
.med-meta { font-size: 12px; color: var(--text-muted); }
.med-due { font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: var(--radius-pill); background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.med.overdue .med-due { color: var(--danger); background: rgba(184,84,71,0.08); }
.med-actions { display: flex; gap: 6px; }
.med-action-btn { width: 32px; height: 32px; border-radius: 8px; background: transparent; color: var(--text-muted); transition: all 0.25s var(--ease); font-size: 13px; }
.med-action-btn:hover { background: var(--primary-soft); color: var(--primary); }
.med-action-btn.given-btn { color: var(--success); }
.med-action-btn.undo-btn { color: var(--warning); }
.med-action-btn.del-btn:hover { background: rgba(184,84,71,0.12); color: var(--danger); }

/* VITALS GLANCE */
.vitals-glance { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.vitals-glance-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 18px; cursor: pointer; transition: all 0.25s var(--ease); }
.vitals-glance-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.vitals-glance-card.no-vitals { border-style: dashed; background: var(--surface-2); }
.vgc-patient { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.vgc-patient-avatar { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; color: white; font-size: 13px; flex-shrink: 0; font-family: var(--font-display); }
.vgc-patient-name { font-family: var(--font-display); font-size: 16px; font-weight: 500; }
.vgc-readings { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.vgc-reading { font-size: 12px; color: var(--text-muted); }
.vgc-reading strong { color: var(--primary-dark); font-size: 14px; margin-left: 2px; font-family: var(--font-display); }
.vgc-time { font-size: 11px; color: var(--text-dim); margin-top: 12px; text-align: right; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(36,49,38,0.45); backdrop-filter: blur(12px); display: none; place-items: center; z-index: 100; padding: 24px; animation: fadeIn 0.25s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-backdrop.show { display: grid; }
.modal { width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 36px; box-shadow: var(--shadow-lg); animation: modalIn 0.4s var(--ease-spring); position: relative; }
.modal::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, transparent, var(--gold), var(--primary), var(--gold), transparent); border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
.modal.modal-lg { max-width: 800px; }
.modal.modal-xl { max-width: 1100px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(30px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 26px; gap: 16px; }
.modal-title { font-family: var(--font-display); font-size: 28px; font-weight: 500; color: var(--primary-dark); line-height: 1.2; }
.modal-close { width: 38px; height: 38px; border-radius: var(--radius-pill); color: var(--text-muted); transition: all 0.25s var(--ease); display: grid; place-items: center; }
.modal-close:hover { background: var(--primary-soft); color: var(--primary); }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--border); }

.toast { position: fixed; bottom: 32px; right: 32px; background: var(--primary); color: var(--gold-light); border-radius: var(--radius); padding: 14px 20px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; z-index: 200; font-size: 14px; font-weight: 600; transform: translateY(140%); transition: transform 0.4s var(--ease-spring); max-width: 380px; border: 1px solid var(--gold); border-left: 3px solid var(--gold); }
.toast.show { transform: translateY(0); }
.toast-icon { font-size: 16px; }
.toast.danger { background: var(--danger); color: white; border-color: var(--danger); }
.toast.success { background: var(--success); color: white; border-color: var(--success); }

.detail-section { margin-bottom: 26px; }
.detail-section-title { font-family: var(--font-display); font-size: 16px; font-weight: 500; color: var(--text); margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.detail-section-title::before { content: '✦'; color: var(--gold); margin-right: 8px; }
.detail-meta { display: flex; gap: 20px; flex-wrap: wrap; font-size: 13px; color: var(--text-muted); align-items: center; padding: 14px 18px; background: var(--surface-2); border-radius: var(--radius-sm); margin-bottom: 14px; }
.detail-meta strong { color: var(--text); font-weight: 600; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; }
.history-item-time { color: var(--text-muted); font-size: 12px; }
.history-item-values { display: flex; gap: 16px; flex-wrap: wrap; }
.history-item-values span { color: var(--primary-dark); font-weight: 700; }
.history-item-values small { color: var(--text-muted); font-weight: 400; margin-left: 3px; }

.spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.syncing-indicator { position: fixed; bottom: 32px; left: 32px; background: var(--primary); color: var(--gold-light); border-radius: var(--radius-pill); padding: 10px 18px; display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; box-shadow: var(--shadow-md); z-index: 150; opacity: 0; transition: opacity 0.3s var(--ease); pointer-events: none; border: 1px solid var(--gold); }
.syncing-indicator.show { opacity: 1; }

/* === ADMIN SPECIFIC === */
.role-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.role-badge.admin { background: var(--gold); color: var(--primary-dark); }
.role-badge.head-doctor { background: var(--primary); color: var(--gold-light); }
.role-badge.nurse { background: var(--primary-soft); color: var(--primary); }
.role-badge.pending { background: rgba(201,148,65,0.15); color: var(--warning); }

table.admin-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.admin-table th { text-align: left; padding: 12px 16px; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
table.admin-table td { padding: 14px 16px; border-bottom: 1px solid var(--divider); }
table.admin-table tr:last-child td { border-bottom: none; }
table.admin-table tr:hover { background: var(--surface-2); }

.stats-mini { display: flex; gap: 24px; padding: 8px 0; }
.stat-mini { text-align: center; }
.stat-mini .num { font-family: var(--font-display); font-size: 32px; font-weight: 500; color: var(--text); line-height: 1; }
.stat-mini .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); margin-top: 4px; }

/* === AI CHAT === */
.ai-fab { position: fixed; bottom: 32px; right: 32px; width: 60px; height: 60px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: var(--gold-light); box-shadow: var(--shadow-lg); display: grid; place-items: center; cursor: pointer; z-index: 90; font-size: 26px; transition: all 0.3s var(--ease-spring); border: 2px solid var(--gold); }
.ai-fab:hover { transform: scale(1.1) rotate(8deg); box-shadow: var(--shadow-gold); }
.ai-fab::after { content: ''; position: absolute; inset: -4px; border: 2px solid var(--gold); border-radius: 50%; opacity: 0.4; animation: aiPulse 2.5s ease-in-out infinite; }
@keyframes aiPulse { 0%, 100% { transform: scale(1); opacity: 0.4; } 50% { transform: scale(1.3); opacity: 0; } }

.ai-window { position: fixed; bottom: 110px; right: 32px; width: 380px; max-width: calc(100vw - 64px); height: 540px; max-height: calc(100vh - 160px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); z-index: 95; display: none; flex-direction: column; overflow: hidden; animation: modalIn 0.3s var(--ease-spring); }
.ai-window.show { display: flex; }
.ai-header { padding: 18px 20px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: var(--gold-light); display: flex; justify-content: space-between; align-items: center; }
.ai-header-title { font-family: var(--font-display); font-size: 16px; font-weight: 500; display: flex; align-items: center; gap: 10px; }
.ai-header-title::before { content: '🌿'; }
.ai-header-close { width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,0.15); color: white; display: grid; place-items: center; font-size: 14px; }
.ai-messages { flex: 1; padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.ai-msg { max-width: 85%; padding: 10px 14px; border-radius: 16px; font-size: 13px; line-height: 1.5; word-wrap: break-word; animation: msgIn 0.3s var(--ease-out); }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.ai-msg.user { background: var(--primary); color: var(--gold-light); align-self: flex-end; border-bottom-right-radius: 4px; }
.ai-msg.bot { background: var(--surface); color: var(--text); align-self: flex-start; border-bottom-left-radius: 4px; box-shadow: var(--shadow-xs); border: 1px solid var(--border); }
.ai-msg.bot strong { color: var(--primary); }
.ai-msg.bot code { background: var(--surface-3); padding: 2px 6px; border-radius: 4px; font-size: 12px; }
.ai-input-area { padding: 12px; background: var(--surface); border-top: 1px solid var(--border); display: flex; gap: 8px; }
.ai-input { flex: 1; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-pill); background: var(--surface-2); font-size: 13px; outline: none; }
.ai-input:focus { border-color: var(--primary); background: var(--surface); }
.ai-send { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: var(--gold-light); display: grid; place-items: center; font-size: 16px; transition: all 0.2s var(--ease); }
.ai-send:hover { background: var(--primary-dark); transform: scale(1.05); }
.ai-send:disabled { opacity: 0.5; cursor: not-allowed; }
.ai-suggestions { padding: 0 12px 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.ai-suggestion { font-size: 11px; padding: 5px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-pill); cursor: pointer; transition: all 0.2s var(--ease); color: var(--text-muted); }
.ai-suggestion:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.ai-typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.ai-typing span { width: 6px; height: 6px; background: var(--text-dim); border-radius: 50%; animation: typingBounce 1.4s infinite; }
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-6px); opacity: 1; } }

/* === AI Streaming + Markdown === */
.ai-msg.bot p { margin: 0 0 6px 0; }
.ai-msg.bot p:last-child { margin-bottom: 0; }
.ai-msg.bot h3, .ai-msg.bot h4 { font-family: var(--font-display); margin: 8px 0 4px 0; color: var(--primary-dark); font-weight: 500; }
.ai-msg.bot h3 { font-size: 16px; } .ai-msg.bot h4 { font-size: 14px; }
.ai-msg.bot ul, .ai-msg.bot ol { margin: 4px 0 6px 0; padding-left: 20px; }
.ai-msg.bot li { margin: 2px 0; }
.ai-msg.bot code { background: var(--surface-3); color: var(--primary-dark); padding: 1px 6px; border-radius: 4px; font-size: 12px; font-family: 'SF Mono', Monaco, monospace; }
.ai-msg.bot pre { background: var(--surface-3); padding: 10px 12px; border-radius: 8px; overflow-x: auto; margin: 6px 0; font-size: 12px; }
.ai-msg.bot pre code { background: transparent; padding: 0; }
.ai-msg.bot a { color: var(--primary); text-decoration: underline; }
.streaming-cursor { display: inline-block; width: 7px; height: 14px; background: var(--primary); margin-left: 2px; vertical-align: middle; animation: blink 0.9s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
#aiStatusDot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); display: inline-block; margin-left: 6px; }
#aiStatusDot.online { background: var(--success); box-shadow: 0 0 8px var(--success); }
#aiStatusDot.error { background: var(--danger); }
#aiStatusDot.loading { background: var(--warning); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

@media (max-width: 768px) {
  .topnav { margin: 12px; padding: 0 12px 0 16px; }
  .topnav-links { display: none; }
  .topnav-search { display: none; }
  .content { padding: 20px 16px 40px; }
  .page-title { font-size: 32px; }
  .vitals { grid-template-columns: 1fr; }
  .ai-window { right: 16px; left: 16px; width: auto; }
}
