/* ============================================================
   ClinicaOS — Design System
   Fonts: Outfit (display) + DM Sans (UI)
   Theme: Clinical Precision — deep teal + warm navy
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

/* ── Tokens ──────────────────────────────────────────────── */
:root {
  /* Brand */
  --primary:        #0891b2;
  --primary-dark:   #0e7490;
  --primary-darker: #155e75;
  --primary-light:  #ecfeff;
  --primary-mid:    #a5f3fc;
  --primary-glow:   rgba(8, 145, 178, 0.18);

  /* Semantic */
  --success:        #059669;
  --success-light:  #d1fae5;
  --warning:        #d97706;
  --warning-light:  #fef3c7;
  --danger:         #e11d48;
  --danger-dark:    #be123c;
  --danger-light:   #ffe4e6;

  /* Neutral */
  --bg:          #f0f4f8;
  --surface:     #ffffff;
  --surface2:    #f8fafc;
  --surface3:    #f1f5f9;
  --border:      #e2e8f0;
  --border-soft: rgba(0, 0, 0, 0.06);
  --text:        #0f172a;
  --text-2:      #334155;
  --text-muted:  #64748b;
  --text-faint:  #94a3b8;

  /* Sidebar (dark always) */
  --sb-bg:          #08111f;
  --sb-surface:     #0e1a2d;
  --sb-border:      rgba(255, 255, 255, 0.07);
  --sb-text:        #94a3b8;
  --sb-text-hover:  #e2e8f0;
  --sb-active:      #22d3ee;
  --sb-active-bg:   rgba(34, 211, 238, 0.09);
  --sb-hover:       rgba(255, 255, 255, 0.04);
  --sb-icon:        #64748b;
  --sb-icon-active: #22d3ee;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-md: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.05);
  --shadow-lg: 0 20px 40px rgba(0,0,0,0.12), 0 8px 16px rgba(0,0,0,0.06);
  --shadow-primary: 0 4px 14px rgba(8, 145, 178, 0.28);

  /* Shape */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  /* Motion */
  --ease:     cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --fast:     0.15s;
  --normal:   0.25s;
}

[data-theme="dark"] {
  --bg:          #070d1a;
  --surface:     #0e1929;
  --surface2:    #112038;
  --surface3:    #162540;
  --border:      #1e3048;
  --border-soft: rgba(255, 255, 255, 0.06);
  --text:        #e2e8f0;
  --text-2:      #cbd5e1;
  --text-muted:  #64748b;
  --text-faint:  #475569;
  --primary-light: rgba(8, 145, 178, 0.12);
  --primary-mid:   rgba(8, 145, 178, 0.25);
  --success-light:  rgba(5, 150, 105, 0.15);
  --warning-light:  rgba(217, 119, 6, 0.15);
  --danger-light:   rgba(225, 29, 72, 0.15);
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow:    0 4px 6px rgba(0,0,0,0.25);
  --shadow-md: 0 10px 25px rgba(0,0,0,0.4);
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--normal) var(--ease-out),
              color var(--normal) var(--ease-out);
}

a { text-decoration: none; color: inherit; }

/* ── Layout ──────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  border-right: 1px solid var(--sb-border);
  /* Subtle texture */
  background-image:
    radial-gradient(ellipse at 0% 0%, rgba(8,145,178,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 100% 100%, rgba(34,211,238,0.04) 0%, transparent 50%);
}

/* Logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 22px 20px 20px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--primary), #22d3ee);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(8,145,178,0.4);
}

.sidebar-logo-icon i {
  color: #fff;
  font-size: 16px;
}

.sidebar-logo-text {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 17px;
  color: #fff;
  letter-spacing: -0.3px;
}

/* User section */
.sidebar-user {
  padding: 14px 18px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
  position: relative;
}

.sidebar-user::before {
  content: '';
  display: block;
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary-dark), #22d3ee);
  border-radius: 50%;
  margin-bottom: 10px;
  opacity: 0.85;
}

.sidebar-user-name {
  color: #f1f5f9;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.sidebar-user-role {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  display: inline-block;
}

.sidebar-user-unit {
  font-size: 11px;
  color: var(--sb-text);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-user-unit::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  background: var(--sb-active);
  border-radius: 50%;
  flex-shrink: 0;
}

/* Role badges */
.role-admin     { background: rgba(225,29,72,0.18);  color: #fb7185; }
.role-unit-admin { background: rgba(245,158,11,0.18); color: #fbbf24; }
.role-recepcao  { background: rgba(8,145,178,0.18);  color: #67e8f9; }
.role-medico    { background: rgba(5,150,105,0.18);  color: #6ee7b7; }

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 10px 10px;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--sb-border); border-radius: 99px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: var(--sb-text);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: background var(--fast) var(--ease-out),
              color var(--fast) var(--ease-out);
  cursor: pointer;
  margin-bottom: 2px;
  position: relative;
}

.nav-item i {
  width: 18px;
  text-align: center;
  font-size: 14px;
  color: var(--sb-icon);
  flex-shrink: 0;
  transition: color var(--fast) var(--ease-out);
}

.nav-item span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item:hover {
  background: var(--sb-hover);
  color: var(--sb-text-hover);
}

.nav-item:hover i { color: var(--sb-text-hover); }

.nav-item.active {
  background: var(--sb-active-bg);
  color: var(--sb-active);
}

.nav-item.active i { color: var(--sb-active); }

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--sb-active);
  border-radius: 0 3px 3px 0;
}

/* Footer */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--sb-border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.theme-toggle,
.btn-logout {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--sb-text);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--fast), color var(--fast), border-color var(--fast);
}

.theme-toggle:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-color: rgba(255,255,255,0.15);
}

.btn-logout:hover {
  background: rgba(225,29,72,0.15);
  color: #fb7185;
  border-color: rgba(225,29,72,0.2);
}

/* ── Main content ────────────────────────────────────────── */
.main-content {
  margin-left: 240px;
  flex: 1;
  min-width: 0;
  padding: 0 32px 40px;
}

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 26px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
  gap: 16px;
}

.page-title {
  font-family: 'Outfit', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.3px;
}

.page-title i {
  color: var(--primary);
  font-size: 20px;
}

.topbar-date {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

.topbar-greeting {
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 2px;
  font-weight: 500;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Stats Grid ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--normal) var(--ease), transform var(--normal) var(--ease);
}

.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #22d3ee);
  opacity: 0.6;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}

.bg-blue   { background: linear-gradient(135deg, #0891b2, #22d3ee); box-shadow: 0 4px 12px rgba(8,145,178,0.3); }
.bg-green  { background: linear-gradient(135deg, #059669, #34d399); box-shadow: 0 4px 12px rgba(5,150,105,0.3); }
.bg-orange { background: linear-gradient(135deg, #d97706, #fbbf24); box-shadow: 0 4px 12px rgba(217,119,6,0.3); }
.bg-red    { background: linear-gradient(135deg, #e11d48, #fb7185); box-shadow: 0 4px 12px rgba(225,29,72,0.3); }

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  font-weight: 600;
  white-space: nowrap;
}

.stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  margin-top: 6px;
  letter-spacing: -1px;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 24px;
  transition: box-shadow var(--normal) var(--ease);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  gap: 12px;
}

.card-header h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  letter-spacing: 0;
}

.card-header h2 i { color: var(--primary); }

.card-body-padded { padding: 18px 22px; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 11px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr:nth-child(even) td {
  background: rgba(0,0,0,0.012);
}

[data-theme="dark"] .data-table tbody tr:nth-child(even) td {
  background: rgba(255,255,255,0.02);
}

.data-table tbody tr:hover td {
  background: var(--primary-light);
  transition: background var(--fast) var(--ease-out);
}

[data-theme="dark"] .data-table tbody tr:hover td {
  background: rgba(8,145,178,0.08);
}

.empty-msg {
  text-align: center;
  color: var(--text-muted);
  padding: 56px 16px !important;
  font-size: 13px;
}

.empty-msg::before {
  content: '\f119';
  font-family: 'Font Awesome 6 Free';
  font-weight: 400;
  display: block;
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.3;
  color: var(--text-muted);
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.badge::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-success {
  background: var(--success-light);
  color: #065f46;
}
.badge-success::before { background: #059669; }

.badge-danger {
  background: var(--danger-light);
  color: #9f1239;
}
.badge-danger::before { background: #e11d48; }

.badge-warning {
  background: var(--warning-light);
  color: #92400e;
}
.badge-warning::before { background: #d97706; }

.badge-info {
  background: var(--primary-light);
  color: #0e7490;
}
.badge-info::before { background: var(--primary); }

.badge-gray {
  background: var(--surface3);
  color: var(--text-muted);
}
.badge-gray::before { background: var(--text-faint); }

/* Dark overrides */
[data-theme="dark"] .badge-success { background: rgba(5,150,105,0.15); color: #6ee7b7; }
[data-theme="dark"] .badge-success::before { background: #34d399; }
[data-theme="dark"] .badge-danger  { background: rgba(225,29,72,0.15);  color: #fb7185; }
[data-theme="dark"] .badge-danger::before  { background: #f43f5e; }
[data-theme="dark"] .badge-warning { background: rgba(217,119,6,0.15);  color: #fbbf24; }
[data-theme="dark"] .badge-warning::before { background: #fbbf24; }
[data-theme="dark"] .badge-info    { background: rgba(8,145,178,0.15);  color: #67e8f9; }
[data-theme="dark"] .badge-info::before    { background: #22d3ee; }
[data-theme="dark"] .badge-gray    { background: var(--surface2); color: #64748b; }
[data-theme="dark"] .badge-gray::before    { background: #475569; }

/* Status select inline */
.status-select {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: border-color var(--fast);
}

.status-select:focus { border-color: var(--primary); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--fast), box-shadow var(--fast), transform 0.1s, opacity var(--fast);
  white-space: nowrap;
  position: relative;
  text-decoration: none;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 2px 6px rgba(8,145,178,0.2);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary-darker));
  box-shadow: var(--shadow-primary);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text-2);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
  border-color: var(--text-faint);
}

.btn-danger {
  background: linear-gradient(135deg, #e11d48, #be123c);
  color: #fff;
  box-shadow: 0 2px 6px rgba(225,29,72,0.15);
}

.btn-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, #be123c, #9f1239);
  box-shadow: 0 4px 12px rgba(225,29,72,0.25);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface2);
  color: var(--text);
}

.btn-sm  { padding: 6px 12px; font-size: 12px; border-radius: 5px; }
.btn-icon { padding: 7px 9px; }

.view-toggle { display: flex; gap: 4px; }

.view-toggle .btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(8,145,178,0.2);
}

.action-btns { display: flex; gap: 5px; }

/* ── Search ──────────────────────────────────────────────── */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  transition: border-color var(--fast), box-shadow var(--fast);
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--surface);
}

.search-box i {
  color: var(--text-muted);
  font-size: 13px;
  flex-shrink: 0;
}

.search-box input {
  border: none;
  background: transparent;
  outline: none;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  width: 210px;
}

.search-box input::placeholder { color: var(--text-faint); }

/* ── Forms ───────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.required { color: var(--danger); }

input[type="text"],
input[type="email"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="password"],
input[type="number"],
select,
textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  width: 100%;
  transition: border-color var(--fast), box-shadow var(--fast), background var(--fast);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--surface);
}

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

.readonly-input {
  background: var(--surface3) !important;
  cursor: not-allowed;
  color: var(--text-muted) !important;
  border-color: var(--border) !important;
  box-shadow: none !important;
}

.input-action {
  display: flex;
  gap: 8px;
}

.input-action input { flex: 1; }

.input-with-icon {
  position: relative;
}

.input-with-icon i {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

.input-with-icon input {
  padding-left: 40px;
}

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.field-hint.success { color: var(--success); }
.field-hint.error   { color: var(--danger); }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

.form-group-btn { justify-content: flex-end; }

.availability-form {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.availability-form .form-row {
  grid-template-columns: 1fr 1fr 1fr auto;
  align-items: end;
}

/* ── Modals ──────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(7, 13, 26, 0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn var(--normal) var(--ease) both;
}

.modal-lg { max-width: 740px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  position: relative;
}

.modal-header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #22d3ee);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.modal-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

.modal-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--fast), color var(--fast), border-color var(--fast);
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger-light);
}

.modal-body { padding: 22px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.modal-actions .btn-danger { margin-right: auto; }

/* ── Modal Tabs ──────────────────────────────────────────── */
.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  padding: 0 22px;
  gap: 0;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 11px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color var(--fast), border-color var(--fast);
  margin-bottom: -1px;
}

.tab-btn:hover { color: var(--text); }

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ── Patient badge ───────────────────────────────────────── */
.patient-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--primary-light), rgba(8,145,178,0.06));
  border: 1px solid rgba(8,145,178,0.2);
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  margin-bottom: 16px;
  color: var(--primary-dark);
  font-weight: 600;
  font-size: 14px;
}

.patient-badge i { color: var(--primary); }

[data-theme="dark"] .patient-badge {
  background: rgba(8,145,178,0.1);
  border-color: rgba(8,145,178,0.2);
  color: #67e8f9;
}

/* ── Audit ───────────────────────────────────────────────── */
.audit-info {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 4px 0;
}

.audit-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 2px;
}

.audit-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.audit-created { background: rgba(8,145,178,0.12); color: var(--primary); }
.audit-updated { background: rgba(217,119,6,0.12);  color: var(--warning); }

.audit-detail {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.audit-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.audit-user {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.audit-date {
  font-size: 12px;
  color: var(--text-muted);
}

.audit-divider {
  height: 1px;
  background: var(--border);
}

/* ── Toast ───────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  font-size: 13.5px;
  font-weight: 500;
  animation: toastIn 0.3s var(--ease) both;
  min-width: 280px;
  max-width: 380px;
  pointer-events: all;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0)    scale(1); }
}

.toast.toast-success { border-left: 4px solid var(--success); }
.toast.toast-error   { border-left: 4px solid var(--danger); }
.toast.toast-info    { border-left: 4px solid var(--primary); }

.toast i { font-size: 16px; flex-shrink: 0; }
.toast.toast-success i { color: var(--success); }
.toast.toast-error   i { color: var(--danger); }
.toast.toast-info    i { color: var(--primary); }

/* ── FullCalendar overrides ──────────────────────────────── */
#fullCalendar { padding: 20px; }

.fc {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
}

.fc .fc-toolbar { flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

.fc .fc-toolbar-title {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 700;
}

.fc .fc-button {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark)) !important;
  border-color: transparent !important;
  border-radius: var(--radius-sm) !important;
  font-family: 'DM Sans', sans-serif !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  padding: 5px 12px !important;
  box-shadow: none !important;
  transition: opacity var(--fast) !important;
}

.fc .fc-button:hover { opacity: 0.88 !important; }

.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary-darker)) !important;
  border-color: transparent !important;
}

.fc-event {
  border-radius: 6px !important;
  cursor: pointer;
  border: none !important;
  overflow: hidden;
}

.fc-event-inner {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 3px 7px;
}

.fc-event-name {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.fc-event-meta {
  font-size: 10px;
  color: rgba(255,255,255,0.8);
  line-height: 1.2;
}

.fc-event-doctor {
  font-size: 10px;
  color: rgba(255,255,255,0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fc-event .fc-event-title-container { display: none; }
.fc-event .fc-event-time { display: none; }

.fc .fc-timegrid-now-indicator-line {
  border-color: var(--danger);
  border-width: 2px;
}

.fc .fc-timegrid-slot-label {
  font-size: 11px;
  color: var(--text-muted);
}

.fc .fc-timegrid-slot-minor {
  border-top-style: dashed;
  opacity: 0.4;
}

[data-theme="dark"] .fc { color: var(--text); }
[data-theme="dark"] .fc .fc-scrollgrid { border-color: var(--border); }
[data-theme="dark"] .fc-theme-standard td,
[data-theme="dark"] .fc-theme-standard th { border-color: var(--border); }
[data-theme="dark"] .fc .fc-daygrid-day-number,
[data-theme="dark"] .fc .fc-col-header-cell-cushion { color: var(--text); }
[data-theme="dark"] .fc .fc-toolbar-title { color: var(--text); }
[data-theme="dark"] .fc .fc-daygrid-day.fc-day-today,
[data-theme="dark"] .fc .fc-timegrid-col.fc-day-today { background: var(--primary-light); }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ── Reports extras ──────────────────────────────────────── */
.report-filters {
  grid-template-columns: 2fr 1fr 1fr 1fr;
  align-items: end;
}

.report-count {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--surface3);
  padding: 3px 10px;
  border-radius: 99px;
}

/* ── Login ───────────────────────────────────────────────── */
.login-page {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
}

.login-wrapper {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* Brand side */
.login-brand {
  flex: 0 0 45%;
  background: linear-gradient(145deg, #060e1f 0%, #0a1628 30%, #0c2340 65%, #0f3461 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 48px;
  position: relative;
  overflow: hidden;
}

/* Decorative circles */
.login-brand::before {
  content: '';
  position: absolute;
  top: -80px; left: -80px;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(8,145,178,0.15) 0%, transparent 70%);
  border-radius: 50%;
}

.login-brand::after {
  content: '';
  position: absolute;
  bottom: -60px; right: -60px;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(34,211,238,0.08) 0%, transparent 70%);
  border-radius: 50%;
}

.login-brand-content {
  position: relative;
  z-index: 1;
  text-align: center;
}

.login-brand-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--primary), #22d3ee);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  box-shadow: 0 8px 32px rgba(8,145,178,0.4);
}

.login-brand-icon i {
  font-size: 32px;
  color: #fff;
}

.login-brand-name {
  font-family: 'Outfit', sans-serif;
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}

.login-brand-tagline {
  font-size: 15px;
  color: rgba(148,163,184,0.9);
  line-height: 1.6;
  max-width: 300px;
  margin: 0 auto 48px;
}

.login-brand-features {
  list-style: none;
  text-align: left;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-brand-features li {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(148,163,184,0.85);
  font-size: 13.5px;
}

.login-brand-features li i {
  width: 28px;
  height: 28px;
  background: rgba(8,145,178,0.15);
  border: 1px solid rgba(8,145,178,0.3);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #67e8f9;
  font-size: 12px;
  flex-shrink: 0;
}

/* Form side */
.login-form-side {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  background: var(--surface);
}

/* Keep the original classes working */
.login-container {
  width: 100%;
  max-width: 400px;
}

.login-card {
  background: transparent;
  padding: 0;
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}

.login-logo i {
  color: var(--primary);
  font-size: 26px;
}

.login-title {
  font-family: 'Outfit', sans-serif;
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  text-align: center;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 32px;
}

.login-form-group {
  margin-bottom: 18px;
}

.login-form-group label {
  display: block;
  margin-bottom: 6px;
}

.btn-login {
  width: 100%;
  justify-content: center;
  padding: 12px;
  font-size: 14px;
  margin-top: 8px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  letter-spacing: 0.2px;
}

.login-error {
  background: var(--danger-light);
  color: #9f1239;
  border: 1px solid rgba(225,29,72,0.2);
  border-left: 4px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 11px 15px;
  font-size: 13px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

[data-theme="dark"] .login-error {
  background: rgba(225,29,72,0.12);
  color: #fb7185;
  border-color: rgba(225,29,72,0.2);
}

[data-theme="dark"] .login-form-side {
  background: var(--surface);
}

/* Responsive login */
@media (max-width: 768px) {
  .login-brand { display: none; }
  .login-form-side { padding: 32px 20px; }
}

/* ── Page load animation ─────────────────────────────────── */
.main-content {
  animation: fadeInUp 0.4s var(--ease) both;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card {
  animation: fadeInUp 0.4s var(--ease) both;
}

.card:nth-child(2) { animation-delay: 0.06s; }
.card:nth-child(3) { animation-delay: 0.12s; }

.stat-card {
  animation: fadeInUp 0.4s var(--ease) both;
}
.stat-card:nth-child(2) { animation-delay: 0.07s; }
.stat-card:nth-child(3) { animation-delay: 0.14s; }
.stat-card:nth-child(4) { animation-delay: 0.21s; }

/* ── FullCalendar — botões prev/next customizados ────────── */
.fc .fc-customPrev-button::before {
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  content: '\f053';
}
.fc .fc-customNext-button::before {
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  content: '\f054';
}

/* ── Misc utilities ──────────────────────────────────────── */
.text-muted { color: var(--text-muted); }

.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ── Date Picker ─────────────────────────────────────────── */
.date-picker-wrap {
  position: relative;
}

.date-picker-calendar {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 12px;
  width: 256px;
  display: none;
}

.date-picker-calendar.open {
  display: block;
}

.dp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.dp-month-year {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
  text-transform: capitalize;
  flex: 1;
  text-align: center;
}

.dp-nav {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--fast), color var(--fast);
  font-size: 0.75rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}

.dp-nav:hover {
  background: var(--surface3);
  color: var(--text);
}

.dp-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  padding: 0 2px;
}

.dp-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.dp-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text);
  transition: background var(--fast), color var(--fast);
  font-family: inherit;
  font-weight: 500;
  width: 100%;
}

.dp-day.dp-other {
  color: var(--text-faint);
  pointer-events: none;
}

.dp-day.dp-available {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

.dp-day.dp-available:hover {
  background: var(--primary);
  color: white;
}

.dp-day.dp-selected {
  background: var(--primary) !important;
  color: white !important;
  font-weight: 700;
}

.dp-day.dp-today:not(.dp-selected) {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.dp-day.dp-disabled {
  color: var(--text-faint);
  cursor: not-allowed;
  opacity: 0.4;
  pointer-events: none;
}

/* ── Time Slot Grid ──────────────────────────────────────── */
.time-slot-group {
  margin-top: 4px;
}

.time-slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.time-slot-btn {
  padding: 7px 4px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--fast), background var(--fast), color var(--fast);
  font-family: inherit;
  text-align: center;
}

.time-slot-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.time-slot-btn.slot-selected {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  font-weight: 600;
}

.time-slot-btn.slot-occupied {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--text-faint);
  cursor: not-allowed;
  text-decoration: line-through;
  opacity: 0.55;
}

.time-slots-msg {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 10px;
  font-style: italic;
}

/* ── Interval bar (schedule modal) ──────────────────────── */
.interval-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.interval-bar i { color: var(--primary); font-size: 0.95rem; }
.interval-bar label { font-size: 0.875rem; font-weight: 500; color: var(--text-muted); white-space: nowrap; }
.interval-bar select {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
}

/* ── Calendar toolbar ────────────────────────────────────── */
.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 4px;
  flex-wrap: wrap;
}

.calendar-filter {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calendar-filter i { color: var(--primary); }

.calendar-filter select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  min-width: 200px;
  cursor: pointer;
}

.calendar-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

/* ── Availability background events ─────────────────────── */
.fc .availability-bg-event { opacity: 0.35; }
