/* ==========================================================================
   MEDIKAT — Design System & Styles
   ========================================================================== */

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

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --primary-rgb: 79, 70, 229;
  --secondary: #0d9488;
  --secondary-light: #f0fdfa;
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #0f172a;
  --text-soft: #334155;
  --muted: #64748b;
  --muted-light: #94a3b8;
  --border: #e6e9f0;
  --border-soft: #f0f1f6;
  --success: #16a34a;
  --success-light: #ecfdf3;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --info: #2563eb;
  --info-light: #eff6ff;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 16px -4px rgba(15, 23, 42, 0.08), 0 2px 6px -2px rgba(15,23,42,0.04);
  --shadow-lg: 0 20px 40px -12px rgba(15, 23, 42, 0.16);
  --sidebar-w: 264px;
  --sidebar-w-collapsed: 80px;
  --topbar-h: 72px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Plus Jakarta Sans', 'Inter', sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14.5px;
  line-height: 1.5;
}
h1, h2, h3, h4, h5 { font-family: var(--font-display); margin: 0; color: var(--text); font-weight: 700; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
ul { margin: 0; padding: 0; list-style: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d7dbe6; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }
.icon { width: 18px; height: 18px; stroke-width: 2px; flex-shrink: 0; }

/* ============ Entrance motion ============ */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.page-fade-in { animation: fadeInUp .28s ease; }
.kpi-grid .kpi-card, .quick-actions-grid .qa-btn, .doctor-grid .doctor-card {
  animation: fadeInUp .38s ease both;
}
.kpi-grid .kpi-card:nth-child(1) { animation-delay: .02s; }
.kpi-grid .kpi-card:nth-child(2) { animation-delay: .07s; }
.kpi-grid .kpi-card:nth-child(3) { animation-delay: .12s; }
.kpi-grid .kpi-card:nth-child(4) { animation-delay: .17s; }
.quick-actions-grid .qa-btn:nth-child(1) { animation-delay: .02s; }
.quick-actions-grid .qa-btn:nth-child(2) { animation-delay: .06s; }
.quick-actions-grid .qa-btn:nth-child(3) { animation-delay: .1s; }
.quick-actions-grid .qa-btn:nth-child(4) { animation-delay: .14s; }
.quick-actions-grid .qa-btn:nth-child(5) { animation-delay: .18s; }
.doctor-grid .doctor-card:nth-child(1) { animation-delay: .02s; }
.doctor-grid .doctor-card:nth-child(2) { animation-delay: .06s; }
.doctor-grid .doctor-card:nth-child(3) { animation-delay: .1s; }
.doctor-grid .doctor-card:nth-child(4) { animation-delay: .14s; }
.doctor-grid .doctor-card:nth-child(5) { animation-delay: .18s; }
.doctor-grid .doctor-card:nth-child(6) { animation-delay: .22s; }
@media (prefers-reduced-motion: reduce) {
  .page-fade-in, .kpi-grid .kpi-card, .quick-actions-grid .qa-btn, .doctor-grid .doctor-card { animation: none; }
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all .15s ease;
  white-space: nowrap;
}
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(var(--primary-rgb), .25); }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: #0b7a70; }
.btn-outline { background: #fff; color: var(--text-soft); border-color: var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--border-soft); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 13px 24px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-icon { padding: 9px; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ============ Cards ============ */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--border-soft); }
.card-header h3 { font-size: 16px; }
.card-body { padding: 22px; }

/* ============ Badges ============ */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.4;
}
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-muted { background: #f1f3f9; color: var(--muted); }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-secondary { background: var(--secondary-light); color: var(--secondary); }

/* ============ Forms ============ */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 20px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.form-group label .req { color: var(--danger); margin-left: 2px; }
.form-control, select.form-control, textarea.form-control {
  padding: 10px 13px; border: 1.5px solid var(--border); border-radius: 9px; font-size: 14px;
  font-family: inherit; color: var(--text); background: #fff; transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .12); }
.form-control.error { border-color: var(--danger); }
textarea.form-control { resize: vertical; min-height: 80px; }
.field-error { font-size: 12px; color: var(--danger); display: none; }
.field-error.show { display: block; }
.form-hint { font-size: 12px; color: var(--muted); }
.input-icon-wrap { position: relative; }
.input-icon-wrap .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted-light); }
.input-icon-wrap .form-control { padding-left: 38px; }
.input-icon-wrap .toggle-pass { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); cursor: pointer; color: var(--muted); background: none; border: none; padding: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-soft); }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ============ Tables ============ */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }
table.data-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.data-table thead th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 700; padding: 12px 18px; background: #fafbfd; border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
}
.data-table tbody td { padding: 14px 18px; border-bottom: 1px solid var(--border-soft); font-size: 13.8px; color: var(--text-soft); vertical-align: middle; white-space: nowrap; }
.data-table tbody tr { transition: background .12s; cursor: default; }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tbody tr:hover { background: #fafbff; }
.data-table tbody tr:last-child td { border-bottom: none; }
.cell-strong { color: var(--text); font-weight: 600; }
.cell-actions { display: flex; gap: 6px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.avatar-xl { width: 88px; height: 88px; font-size: 30px; }
.row-flex { display: flex; align-items: center; gap: 12px; }

/* ============ Auth Screens ============ */
#auth-screen {
  min-height: 100vh; display: flex; align-items: stretch; background: var(--bg);
}
.auth-visual {
  flex: 1.1; background: linear-gradient(160deg, #4338ca 0%, #4f46e5 45%, #0d9488 130%);
  display: flex; flex-direction: column; justify-content: center; padding: 60px 70px; color: #fff; position: relative; overflow: hidden;
}
.auth-visual::before, .auth-visual::after {
  content: ''; position: absolute; border-radius: 50%; background: rgba(255,255,255,.08);
}
.auth-visual::before { width: 420px; height: 420px; top: -150px; right: -120px; }
.auth-visual::after { width: 280px; height: 280px; bottom: -100px; left: -60px; background: rgba(255,255,255,.06); }
.auth-visual .brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 24px; font-weight: 800; margin-bottom: 46px; position: relative; z-index: 1; }
.auth-visual .brand .logo-mark { width: 40px; height: 40px; background: rgba(255,255,255,.18); border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.auth-visual h1 { font-size: 36px; line-height: 1.25; max-width: 480px; position: relative; z-index: 1; }
.auth-visual p.tagline { margin-top: 16px; font-size: 15.5px; opacity: .88; max-width: 420px; position: relative; z-index: 1; }
.auth-visual .feature-list { margin-top: 40px; display: flex; flex-direction: column; gap: 16px; position: relative; z-index: 1; }
.auth-visual .feature-list li { display: flex; align-items: center; gap: 12px; font-size: 14.5px; opacity: .95; }
.auth-visual .feature-list .icon-wrap { width: 30px; height: 30px; background: rgba(255,255,255,.16); border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.auth-panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px; overflow-y: auto; }
.auth-box { width: 100%; max-width: 420px; }
.auth-box h2 { font-size: 26px; margin-bottom: 6px; }
.auth-box .sub { color: var(--muted); font-size: 14.5px; margin-bottom: 28px; }
.demo-panel {
  margin-top: 22px; background: var(--primary-light); border: 1px dashed var(--primary); border-radius: 12px;
  padding: 14px 16px; font-size: 13px; color: var(--primary-dark);
}
.demo-panel .title { font-weight: 700; display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.demo-panel code { background: #fff; padding: 2px 8px; border-radius: 6px; font-weight: 600; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 22px 0; color: var(--muted-light); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-footer-link { text-align: center; margin-top: 20px; font-size: 14px; color: var(--muted); }
.auth-footer-link a { color: var(--primary); font-weight: 600; }

/* Registration wizard */
.wizard-steps { display: flex; align-items: center; margin-bottom: 34px; }
.wizard-step { display: flex; align-items: center; gap: 10px; flex: 1; }
.wizard-step .dot {
  width: 32px; height: 32px; border-radius: 50%; background: #eef0f6; color: var(--muted); font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center; transition: all .2s; flex-shrink: 0;
}
.wizard-step .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.wizard-step.active .dot, .wizard-step.done .dot { background: var(--primary); color: #fff; }
.wizard-step.active .label, .wizard-step.done .label { color: var(--text); }
.wizard-step .line { flex: 1; height: 2px; background: var(--border); margin: 0 6px; }
.wizard-step.done .line { background: var(--primary); }
.wizard-panel-outer { width: 100%; max-width: 760px; }

.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 6px; }
.plan-card {
  border: 2px solid var(--border); border-radius: var(--radius-lg); padding: 24px 20px; cursor: pointer; position: relative;
  transition: all .15s; background: #fff;
}
.plan-card:hover { border-color: var(--primary-light); transform: translateY(-2px); }
.plan-card.selected { border-color: var(--primary); box-shadow: 0 8px 24px -8px rgba(var(--primary-rgb),.3); }
.plan-card .badge-popular { position: absolute; top: -12px; right: 18px; background: var(--secondary); color: #fff; font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.plan-card .plan-name { font-family: var(--font-display); font-size: 18px; font-weight: 800; }
.plan-card .plan-price { font-size: 30px; font-weight: 800; margin: 10px 0 2px; color: var(--primary); }
.plan-card .plan-price span { font-size: 13px; font-weight: 500; color: var(--muted); }
.plan-card ul { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.plan-card ul li { display: flex; align-items: flex-start; gap: 8px; font-size: 13.2px; color: var(--text-soft); }
.plan-card ul li .icon { color: var(--success); margin-top: 1px; }
.success-screen { text-align: center; padding: 50px 20px; }
.success-screen .check-circle {
  width: 96px; height: 96px; border-radius: 50%; background: var(--success-light); color: var(--success);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 26px; animation: popIn .4s ease;
}
.success-screen .check-circle .icon { width: 48px; height: 48px; }
@keyframes popIn { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.success-screen h2 { font-size: 26px; margin-bottom: 10px; }
.success-screen p { color: var(--muted); font-size: 15px; }

/* ============ App Shell ============ */
#app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: #fff; border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 40; transition: width .2s ease, transform .2s ease;
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 22px 22px; font-family: var(--font-display); font-weight: 800; font-size: 19px; border-bottom: 1px solid var(--border-soft); }
.sidebar .brand .logo-mark { width: 36px; height: 36px; background: var(--primary); border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.sidebar.collapsed .brand span.brand-text { display: none; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 16px 14px; }
.nav-section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-light); padding: 14px 12px 6px; }
.sidebar.collapsed .nav-section-label { display: none; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: var(--muted);
  font-size: 14px; font-weight: 600; cursor: pointer; margin-bottom: 2px; transition: all .12s; position: relative;
}
.nav-item:hover { background: var(--border-soft); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary); }
.nav-item .icon { color: inherit; }
.sidebar.collapsed .nav-item span.nav-text { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; }
.sidebar-footer { border-top: 1px solid var(--border-soft); padding: 16px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; cursor: pointer; }
.sidebar-user:hover { background: var(--border-soft); }
.sidebar-user .info { flex: 1; min-width: 0; }
.sidebar-user .info .name { font-size: 13.5px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .info .role { font-size: 12px; color: var(--muted); }
.sidebar.collapsed .sidebar-user .info { display: none; }
.sidebar-version { text-align: center; font-size: 10.5px; color: var(--muted-light); font-weight: 600; letter-spacing: .02em; padding: 10px 0 2px; }
.sidebar.collapsed .sidebar-version { display: none; }

.shortcut-row { display: flex; align-items: center; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--border-soft); font-size: 13.6px; color: var(--text-soft); }
.shortcut-row:last-child { border-bottom: none; }
.shortcut-row kbd { font-family: var(--font); font-size: 12px; font-weight: 700; color: var(--text); background: var(--border-soft); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; }

.main-wrap { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; transition: margin-left .2s ease; }
.main-wrap.expanded { margin-left: var(--sidebar-w-collapsed); }

.topbar {
  height: var(--topbar-h); background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center;
  justify-content: space-between; padding: 0 28px; position: sticky; top: 0; z-index: 30; gap: 20px;
}
.topbar-left { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 0; }
.hamburger-btn, .mobile-menu-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: 8px; border-radius: 8px; display: flex; }
.hamburger-btn:hover, .mobile-menu-btn:hover { background: var(--border-soft); }
.global-search { position: relative; max-width: 420px; flex: 1; }
.global-search .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted-light); }
.global-search input { width: 100%; padding: 10px 14px 10px 38px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg); font-size: 13.8px; }
.global-search input:focus { outline: none; border-color: var(--primary); background: #fff; }
.global-search input { padding-right: 62px; }
.search-kbd-hint {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  display: flex; gap: 3px; pointer-events: none;
}
.search-kbd-hint kbd {
  font-family: var(--font); font-size: 11px; font-weight: 700; color: var(--muted);
  background: #fff; border: 1px solid var(--border); border-radius: 5px; padding: 2px 6px;
  box-shadow: 0 1px 0 var(--border);
}
.global-search input:focus ~ .search-kbd-hint { display: none; }
.search-results { position: absolute; top: calc(100% + 8px); left: 0; right: 0; min-width: 280px; max-width: calc(100vw - 24px); background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); max-height: 360px; overflow-y: auto; z-index: 50; display: none; padding: 6px 0; }
.search-results.show { display: block; }
.search-results::-webkit-scrollbar { width: 6px; }
.search-results::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.search-results .result-group-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted-light); padding: 10px 16px 6px; }
.search-results .result-group-label:not(:first-child) { margin-top: 4px; border-top: 1px solid var(--border-soft); }
.search-result-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; cursor: pointer; border-radius: 8px; margin: 0 6px; }
.search-result-item:hover { background: var(--border-soft); }
.search-result-item .sr-info { flex: 1; min-width: 0; }
.search-result-item .sr-title { font-size: 13.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-item .meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn { position: relative; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--border-soft); color: var(--text); }
.icon-btn .dot-badge { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid #fff; }
.topbar-user { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; border-radius: 10px; cursor: pointer; border: 1px solid var(--border); }
.topbar-user:hover { background: var(--border-soft); }
.topbar-user .name { font-size: 13.5px; font-weight: 700; }

.dropdown-panel { position: absolute; top: calc(100% + 10px); right: 0; width: 340px; background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); z-index: 60; display: none; overflow: hidden; }
.dropdown-panel.show { display: block; }
.dropdown-panel .dd-header { padding: 14px 18px; border-bottom: 1px solid var(--border-soft); display: flex; justify-content: space-between; align-items: center; }
.dropdown-panel .dd-header h4 { font-size: 14px; }
.dropdown-panel .dd-list { max-height: 360px; overflow-y: auto; }
.notif-item { display: flex; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--border-soft); cursor: pointer; }
.notif-item:hover { background: var(--border-soft); }
.notif-item .n-icon { width: 34px; height: 34px; border-radius: 9px; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-item.unread { background: #fafbff; }
.notif-item .n-text { font-size: 13.2px; color: var(--text-soft); }
.notif-item .n-time { font-size: 11.5px; color: var(--muted-light); margin-top: 3px; }
.user-menu-item { display: flex; align-items: center; gap: 10px; padding: 11px 18px; font-size: 13.6px; font-weight: 600; color: var(--text-soft); cursor: pointer; }
.user-menu-item:hover { background: var(--border-soft); }
.user-menu-item.danger { color: var(--danger); }

.page-content { padding: 28px; flex: 1; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-header h1 { font-size: 24px; }
.page-header .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============ Dashboard ============ */
.greeting-banner { background: linear-gradient(120deg, #4338ca, #4f46e5 60%, #0d9488); border-radius: var(--radius-lg); padding: 30px 34px; color: #fff; margin-bottom: 24px; position: relative; overflow: hidden; }
.greeting-banner::after { content: ''; position: absolute; width: 260px; height: 260px; border-radius: 50%; background: rgba(255,255,255,.08); top: -120px; right: -60px; }
.greeting-banner h2 { font-size: 24px; position: relative; z-index: 1; }
.greeting-banner p { opacity: .9; margin-top: 6px; font-size: 14.5px; position: relative; z-index: 1; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 24px; }
.kpi-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 22px; box-shadow: var(--shadow-sm); }
.kpi-card .kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-card .kpi-icon { width: 42px; height: 42px; border-radius: 11px; display: flex; align-items: center; justify-content: center; }
.kpi-card .kpi-value { font-size: 28px; font-weight: 800; font-family: var(--font-display); margin-top: 14px; }
.kpi-card .kpi-label { color: var(--muted); font-size: 13px; margin-top: 2px; }
.kpi-card .kpi-trend { font-size: 12.5px; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; margin-top: 10px; }
.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--danger); }

.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; margin-bottom: 20px; }
.timeline-item { display: flex; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border-soft); }
.timeline-item:last-child { border-bottom: none; }
.timeline-item .time-col { width: 76px; flex-shrink: 0; font-size: 12.5px; font-weight: 700; color: var(--muted); padding-top: 2px; }
.timeline-item .dot-col { width: 10px; display: flex; flex-direction: column; align-items: center; }
.timeline-item .dot-col .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); margin-top: 4px; }
.timeline-item .dot-col .stem { flex: 1; width: 2px; background: var(--border); margin-top: 4px; }
.timeline-item .content { flex: 1; }
.timeline-item .doc-name { font-weight: 700; font-size: 13.8px; }
.timeline-item .pat-name { color: var(--text-soft); font-size: 13.2px; margin-top: 2px; }
.timeline-item .svc-type { color: var(--muted); font-size: 12.2px; margin-top: 2px; }

.stat-donut-row { display: flex; align-items: center; gap: 24px; }
.legend-list { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.legend-item { display: flex; align-items: center; gap: 10px; font-size: 13.2px; }
.legend-item .sw { width: 10px; height: 10px; border-radius: 3px; }
.legend-item .val { margin-left: auto; font-weight: 700; color: var(--text); }

.quick-actions-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.qa-btn { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 20px 10px; border-radius: 14px; border: 1.5px dashed var(--border); background: #fafbff; cursor: pointer; transition: all .15s; }
.qa-btn:hover { border-color: var(--primary); background: var(--primary-light); transform: translateY(-2px); }
.qa-btn .qa-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; }
.qa-btn span { font-size: 12.8px; font-weight: 700; color: var(--text-soft); text-align: center; }

/* ============ Empty / Loading states ============ */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state .icon-wrap { width: 76px; height: 76px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; margin: 0 auto 18px; }
.empty-state .icon-wrap .icon { width: 34px; height: 34px; }
.empty-state h3 { font-size: 16.5px; margin-bottom: 6px; }
.empty-state p { color: var(--muted); font-size: 13.6px; margin-bottom: 18px; }
.skeleton { background: linear-gradient(90deg, #f0f1f6 25%, #e8eaf1 37%, #f0f1f6 63%); background-size: 400% 100%; animation: skel 1.4s ease infinite; border-radius: 8px; }
@keyframes skel { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner.dark { border-color: rgba(79,70,229,.2); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Tabs ============ */
.tabs-row { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; }
.tab-btn { padding: 12px 18px; font-size: 13.8px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2.5px solid transparent; white-space: nowrap; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ============ Filters bar ============ */
.filters-bar { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.filters-bar .form-control { width: auto; min-width: 150px; }
.filters-bar .search-box { position: relative; flex: 1; min-width: 200px; }
.filters-bar .search-box .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted-light); }
.filters-bar .search-box input { padding-left: 36px; }

/* ============ Pagination ============ */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-top: 1px solid var(--border-soft); }
.pagination .info { font-size: 13px; color: var(--muted); }
.pagination .controls { display: flex; gap: 6px; }
.page-btn { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: #fff; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.page-btn:hover { background: var(--border-soft); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ============ Modals ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 24px; backdrop-filter: blur(2px);
}
.modal-overlay.show { display: flex; animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-box { background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: modalIn .2s cubic-bezier(.2,.9,.3,1.2); }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-box.modal-lg { max-width: 760px; }
.modal-box.modal-xl { max-width: 960px; }
.modal-box.modal-sm { max-width: 420px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border-soft); }
.modal-header h3 { font-size: 17px; }
.modal-close { background: none; border: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; }
.modal-close:hover { background: var(--border-soft); color: var(--text); }
.modal-body { padding: 24px; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border-soft); }
.confirm-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--danger-light); color: var(--danger); display: flex; align-items: center; justify-content: center; margin-bottom: 16px; }

/* ============ Toasts ============ */
#toast-container { position: fixed; top: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { display: flex; align-items: flex-start; gap: 12px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; min-width: 300px; max-width: 380px; box-shadow: var(--shadow-lg); animation: toastIn .25s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
.toast.hide { animation: toastOut .2s ease forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }
.toast .t-icon { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.toast.success .t-icon { background: var(--success-light); color: var(--success); }
.toast.error .t-icon { background: var(--danger-light); color: var(--danger); }
.toast.info .t-icon { background: var(--info-light); color: var(--info); }
.toast.warning .t-icon { background: var(--warning-light); color: var(--warning); }
.toast .t-title { font-weight: 700; font-size: 13.6px; }
.toast .t-msg { font-size: 12.6px; color: var(--muted); margin-top: 2px; }
.toast .t-close { margin-left: auto; background: none; border: none; color: var(--muted-light); cursor: pointer; }

/* ============ Doctor cards ============ */
.doctor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px; }
.doctor-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; text-align: center; position: relative; transition: all .15s; }
.doctor-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.doctor-card .status-pin { position: absolute; top: 16px; right: 16px; }
.doctor-card .avatar { margin: 0 auto 14px; }
.doctor-card .d-name { font-size: 15.5px; font-weight: 700; }
.doctor-card .d-spec { color: var(--secondary); font-size: 13px; font-weight: 600; margin-top: 2px; }
.doctor-card .d-meta { display: flex; justify-content: center; gap: 18px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border-soft); }
.doctor-card .d-meta .m-item { text-align: center; }
.doctor-card .d-meta .m-val { font-weight: 700; font-size: 14px; }
.doctor-card .d-meta .m-lbl { font-size: 11px; color: var(--muted); }
.doctor-card .d-actions { display: flex; gap: 8px; margin-top: 16px; }

/* ============ Schedule builder ============ */
.day-row { display: grid; grid-template-columns: 130px 1fr; gap: 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.day-row:last-child { border-bottom: none; }
.day-row .day-toggle { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 13.6px; }
.switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--border); border-radius: 999px; cursor: pointer; transition: .2s; }
.switch .slider::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.day-times { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.day-times input[type=time] { padding: 7px 10px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 13px; }
.slot-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.slot-chip { padding: 7px 14px; border-radius: 8px; background: var(--primary-light); color: var(--primary); font-size: 12.6px; font-weight: 700; border: 1px solid transparent; cursor: pointer; }
.slot-chip.taken { background: #f1f3f9; color: var(--muted-light); text-decoration: line-through; cursor: not-allowed; }
.slot-chip.selected { background: var(--primary); color: #fff; }

/* ============ Booking wizard ============ */
.booking-progress { display: flex; margin-bottom: 24px; gap: 4px; }
.booking-progress .seg { flex: 1; height: 5px; border-radius: 3px; background: var(--border); }
.booking-progress .seg.active { background: var(--primary); }
.select-tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 12px; max-height: 340px; overflow-y: auto; padding: 2px; }
.select-tile { border: 1.5px solid var(--border); border-radius: 12px; padding: 14px; cursor: pointer; transition: all .12s; }
.select-tile:hover { border-color: var(--primary-light); }
.select-tile.selected { border-color: var(--primary); background: var(--primary-light); }
.select-tile .t-name { font-weight: 700; font-size: 13.8px; }
.select-tile .t-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.date-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.date-chip { min-width: 62px; text-align: center; padding: 12px 8px; border-radius: 12px; border: 1.5px solid var(--border); cursor: pointer; flex-shrink: 0; }
.date-chip:hover { border-color: var(--primary-light); }
.date-chip.selected { background: var(--primary); border-color: var(--primary); color: #fff; }
.date-chip .dow { font-size: 11px; opacity: .8; }
.date-chip .dnum { font-size: 17px; font-weight: 800; margin: 2px 0; }
.date-chip .mon { font-size: 10.5px; opacity: .8; }
.slots-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px,1fr)); gap: 10px; }
.fee-summary { background: var(--primary-light); border-radius: 12px; padding: 18px; }
.fee-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13.6px; }
.fee-row.total { border-top: 1px dashed rgba(var(--primary-rgb),.3); margin-top: 6px; padding-top: 12px; font-weight: 800; font-size: 16px; }
.pay-option-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pay-option { border: 1.5px solid var(--border); border-radius: 12px; padding: 18px; text-align: center; cursor: pointer; }
.pay-option.selected { border-color: var(--primary); background: var(--primary-light); }
.pay-option .icon { width: 28px; height: 28px; margin: 0 auto 8px; color: var(--primary); }

/* ============ Invoice ============ */
.invoice-paper { background: #fff; border-radius: var(--radius-lg); padding: 40px; border: 1px solid var(--border); }
.invoice-top { display: flex; justify-content: space-between; align-items: flex-start; padding-bottom: 24px; border-bottom: 2px solid var(--border); }
.invoice-brand { font-family: var(--font-display); font-weight: 800; font-size: 22px; color: var(--primary); display: flex; align-items: center; gap: 10px; }
.invoice-brand .tag { font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.invoice-meta { text-align: right; font-size: 13px; color: var(--muted); }
.invoice-meta .inv-no { font-size: 16px; font-weight: 800; color: var(--text); }
.invoice-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 24px 0; }
.invoice-parties .label { font-size: 11px; text-transform: uppercase; color: var(--muted-light); font-weight: 700; margin-bottom: 6px; }
.invoice-parties .name { font-weight: 700; font-size: 14.5px; }
table.invoice-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
table.invoice-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; color: var(--muted); padding: 10px 0; border-bottom: 2px solid var(--border); }
table.invoice-table td { padding: 12px 0; border-bottom: 1px solid var(--border-soft); font-size: 13.8px; }
table.invoice-table th:last-child, table.invoice-table td:last-child { text-align: right; }
.invoice-totals { margin-left: auto; width: 260px; margin-top: 16px; }
.invoice-totals .row { display: flex; justify-content: space-between; padding: 7px 0; font-size: 13.6px; color: var(--text-soft); }
.invoice-totals .row.grand { border-top: 2px solid var(--border); margin-top: 6px; padding-top: 14px; font-weight: 800; font-size: 17px; color: var(--text); }
.invoice-footer-note { margin-top: 30px; padding-top: 20px; border-top: 1px dashed var(--border); font-size: 12.5px; color: var(--muted); text-align: center; }

/* ============ Calendar ============ */
.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.view-switch { display: flex; background: var(--border-soft); border-radius: 10px; padding: 3px; }
.view-switch button { padding: 8px 16px; border: none; background: none; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; }
.view-switch button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow-sm); }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.month-grid .dow-label { text-align: center; font-size: 11.5px; font-weight: 700; color: var(--muted); padding-bottom: 6px; }
.month-cell { min-height: 96px; border: 1px solid var(--border); border-radius: 10px; padding: 8px; background: #fff; }
.month-cell.other-month { background: #fafbfd; opacity: .55; }
.month-cell.today { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.month-cell .date-num { font-size: 12.5px; font-weight: 700; }
.month-cell .appt-chip { font-size: 10.6px; background: var(--primary-light); color: var(--primary); border-radius: 5px; padding: 2px 5px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.week-grid, .day-grid { display: flex; flex-direction: column; gap: 8px; }
.hour-row { display: grid; grid-template-columns: 70px 1fr; gap: 10px; min-height: 54px; border-top: 1px solid var(--border-soft); padding-top: 6px; }
.hour-row .hr-label { font-size: 11.5px; color: var(--muted); }
.hour-row .hr-content { display: flex; gap: 8px; flex-wrap: wrap; }
.week-appt-card { background: var(--primary-light); border-left: 3px solid var(--primary); border-radius: 8px; padding: 6px 10px; font-size: 12px; cursor: pointer; }

/* ============ Settings ============ */
.settings-layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; }
.settings-nav .s-item { padding: 11px 14px; border-radius: 9px; font-size: 13.6px; font-weight: 600; color: var(--muted); cursor: pointer; }
.settings-nav .s-item:hover { background: var(--border-soft); }
.settings-nav .s-item.active { background: var(--primary-light); color: var(--primary); }
.logo-upload { width: 88px; height: 88px; border-radius: 16px; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 24px; }

/* ============ Subscription ============ */
.usage-bar-track { height: 8px; background: var(--border-soft); border-radius: 6px; overflow: hidden; margin-top: 8px; }
.usage-bar-fill { height: 100%; background: var(--primary); border-radius: 6px; }
.usage-item { margin-bottom: 18px; }
.usage-item .top-row { display: flex; justify-content: space-between; font-size: 13.4px; font-weight: 600; }
.usage-item .top-row .val { color: var(--muted); font-weight: 500; }

/* ============ Role badge ============ */
.role-chip { display: inline-flex; align-items: center; gap: 6px; }

/* ============ Reports ============ */
.report-summary-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 20px; }

/* ============ Responsive ============ */
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .quick-actions-grid { grid-template-columns: repeat(3,1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .report-summary-grid { grid-template-columns: repeat(2,1fr); }
  .plan-grid { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-wrap, .main-wrap.expanded { margin-left: 0; }
  .hamburger-btn { display: none; }
  .mobile-menu-btn { display: flex !important; }
  .auth-visual { display: none; }
  .global-search { max-width: none; }
}
@media (min-width: 901px) { .mobile-menu-btn { display: none; } }
@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .quick-actions-grid { grid-template-columns: repeat(2,1fr); }
  .doctor-grid { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar-user .name { display: none; }
  .invoice-parties { grid-template-columns: 1fr; }
  .invoice-paper { padding: 20px; }
  .auth-panel { padding: 22px 16px; }
  .auth-box h2 { font-size: 22px; }
  .modal-box { max-height: 92vh; }
  .modal-body, .modal-header, .modal-footer { padding-left: 16px; padding-right: 16px; }
  .wizard-steps .label { display: none; }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .filters-bar .form-control, .filters-bar .search-box { width: 100%; }
  .pay-option-grid { grid-template-columns: 1fr; }
  .report-summary-grid { grid-template-columns: 1fr; }
  .day-row { grid-template-columns: 1fr; gap: 8px; }
  #toast-container { left: 12px; right: 12px; top: 12px; }
  .toast { min-width: 0; max-width: none; }
}
@media (max-width: 400px) {
  .kpi-card .kpi-value { font-size: 24px; }
  .greeting-banner { padding: 22px 20px; }
  .greeting-banner h2 { font-size: 19px; }
}
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 39; display: none; }
.sidebar-backdrop.show { display: block; }

/* Print */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-wrap { margin-left: 0 !important; }
  body { background: #fff; }
}
