:root {
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Sidebar Navy Palette */
  --sidebar-bg: #07152e;
  --sidebar-grad: linear-gradient(180deg, #07152e 0%, #0d2247 60%, #081735 100%);
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-active-pill: #1d68ff;
  --sidebar-active-glow: rgba(29, 104, 255, 0.35);

  /* Body & Surface Colors */
  --bg-app: #f4f7fc;
  --card-bg: #ffffff;
  --card-border: #edf2f7;
  --card-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.06);
  --card-shadow-hover: 0 10px 25px -4px rgba(15, 23, 42, 0.1);

  /* Typography Colors */
  --text-dark: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  /* Pastel Card Colors */
  --card-blue-bg: #ebf3ff;
  --card-blue-border: #d4e4fc;
  --card-blue-icon: #2563eb;

  --card-green-bg: #eafaf1;
  --card-green-border: #d0f4e0;
  --card-green-icon: #10b981;

  --card-purple-bg: #f4edff;
  --card-purple-border: #e6d8fc;
  --card-purple-icon: #8b5cf6;

  --card-orange-bg: #fff2e8;
  --card-orange-border: #fee1cc;
  --card-orange-icon: #f97316;

  /* Action & Buttons */
  --primary: #1d68ff;
  --primary-hover: #0d54eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --warning: #f59e0b;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-family);
}

body {
  background: var(--bg-app);
  color: var(--text-dark);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ========================================================
   LAYOUT GENERAL
   ======================================================== */
.container {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* ========================================================
   SIDEBAR
   ======================================================== */
.sidebar {
  width: 260px;
  background: var(--sidebar-grad);
  color: #ffffff;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 100;
  box-shadow: 4px 0 25px rgba(0, 0, 0, 0.15);
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
  padding: 28px 24px 20px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.sidebar .logo-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.sidebar .logo-img {
  width: 52px;
  height: 52px;
  filter: drop-shadow(0 0 12px rgba(56, 189, 248, 0.6));
  transition: transform 0.3s ease;
}

.sidebar .logo-box:hover .logo-img {
  transform: scale(1.06);
}

.sidebar .logo-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #ffffff;
  line-height: 1.3;
}

/* Navigation Menu */
.sidebar-nav {
  flex: 1;
  padding: 10px 16px;
}

.sidebar ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar li a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-radius: 12px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.25s ease;
}

.sidebar li a i {
  font-size: 17px;
  width: 22px;
  text-align: center;
  transition: transform 0.2s;
}

.sidebar li a:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar li.active a {
  background: var(--sidebar-active-pill);
  color: #ffffff;
  box-shadow: 0 4px 18px var(--sidebar-active-glow);
}

.sidebar li.active a i {
  transform: scale(1.1);
}

/* Sidebar Footer & User Badge */
.sidebar-footer {
  padding: 20px 16px 16px 16px;
  position: relative;
  background: rgba(4, 15, 36, 0.7);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.sidebar-footer::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 260 60' fill='none'%3E%3Cpath d='M0 35 C60 10 140 50 260 25 L260 60 L0 60 Z' fill='%231d68ff' fill-opacity='0.25'/%3E%3Cpath d='M0 45 C80 25 180 55 260 38 L260 60 L0 60 Z' fill='%2338bdf8' fill-opacity='0.18'/%3E%3C/svg%3E") no-repeat bottom center;
  background-size: cover;
  pointer-events: none;
  z-index: 1;
}

.sidebar-footer > * {
  position: relative;
  z-index: 2;
}

.logout-form {
  margin-bottom: 12px;
}

.btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
}

.btn-logout:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #38bdf8 0%, #1d68ff 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-role {
  font-size: 11px;
  color: #94a3b8;
}

/* ========================================================
   MAIN CONTENT & TOPBAR
   ======================================================== */
.main-content {
  margin-left: 260px;
  padding: 24px 32px 40px 32px;
  width: calc(100% - 260px);
  min-height: 100vh;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-toggle-sidebar {
  display: none;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 18px;
  color: var(--text-dark);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.page-title {
  font-size: 24px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.5px;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.notifications-wrapper {
  position: relative;
}

.notification-btn {
  position: relative;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.notification-btn:hover {
  background: #f8fafc;
  color: var(--primary);
  border-color: #cbd5e1;
}

.notification-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #ef4444;
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
}

.notifications-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 330px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.15);
  border: 1px solid #e2e8f0;
  z-index: 1000;
  overflow: hidden;
  animation: modalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.notifications-dropdown.active {
  display: block;
}

.notifications-header {
  padding: 14px 18px;
  background: #f8fafc;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.notifications-header h4 {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
}

.notifications-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: #eff6ff;
  padding: 2px 8px;
  border-radius: 10px;
}

.notifications-body {
  padding: 8px 0;
  max-height: 280px;
  overflow-y: auto;
}

.notification-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 18px;
  transition: background 0.2s;
  cursor: pointer;
}

.notification-item:hover {
  background: #f8fafc;
}

.notification-item.unread {
  background: #fafcff;
}

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

.notification-icon.blue {
  background: #dbeafe;
  color: #2563eb;
}

.notification-icon.green {
  background: #d1fae5;
  color: #10b981;
}

.notification-info {
  flex: 1;
}

.notification-text {
  font-size: 12.5px;
  color: #334155;
  line-height: 1.4;
  margin-bottom: 3px;
}

.notification-time {
  font-size: 11px;
  color: #94a3b8;
}

.top-user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #e0f2fe;
  color: #0284c7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  border: 1px solid #bae6fd;
}

/* ========================================================
   DASHBOARD COMPONENTS
   ======================================================== */

/* Welcome Banner */
.welcome-banner {
  background: linear-gradient(135deg, #d8eaff 0%, #eff6ff 60%, #e0edfe 100%);
  border-radius: 20px;
  padding: 28px 36px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 24px -4px rgba(37, 99, 235, 0.08);
  border: 1px solid #d0e3fc;
}

.welcome-text h2 {
  font-size: 28px;
  font-weight: 800;
  color: #0c2340;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.welcome-text p {
  font-size: 15px;
  color: #2c5282;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.welcome-mascot {
  position: relative;
  z-index: 2;
  max-width: 240px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.welcome-mascot img {
  height: 125px;
  max-height: 125px;
  width: auto;
  filter: drop-shadow(0 10px 15px rgba(2, 132, 199, 0.15));
}

/* Stats Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  border-radius: 18px;
  padding: 20px 22px;
  border: 1px solid transparent;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

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

.stat-card.pacientes {
  background: var(--card-blue-bg);
  border-color: var(--card-blue-border);
}

.stat-card.citas {
  background: var(--card-green-bg);
  border-color: var(--card-green-border);
}

.stat-card.tratamientos {
  background: var(--card-purple-bg);
  border-color: var(--card-purple-border);
}

.stat-card.ingresos {
  background: var(--card-orange-bg);
  border-color: var(--card-orange-border);
}

.stat-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.pacientes .stat-icon {
  background: #dbeafe;
  color: var(--card-blue-icon);
}

.citas .stat-icon {
  background: #d1fae5;
  color: var(--card-green-icon);
}

.tratamientos .stat-icon {
  background: #ede9fe;
  color: var(--card-purple-icon);
}

.ingresos .stat-icon {
  background: #ffedd5;
  color: var(--card-orange-icon);
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.stat-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stat-label {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
}

.stat-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
}

.pacientes .stat-badge {
  background: #dbeafe;
  color: #1d4ed8;
}

.citas .stat-badge {
  background: #d1fae5;
  color: #065f46;
}

.tratamientos .stat-badge {
  background: #ede9fe;
  color: #6d28d9;
}

.ingresos .stat-badge {
  background: #ffedd5;
  color: #c2410c;
}

/* Middle Row: Próximas Citas & Últimos Pacientes */
.dashboard-middle-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.dash-panel {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--card-border);
}

.dash-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.dash-panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

.dash-panel-title i {
  color: var(--primary);
  font-size: 17px;
}

.btn-view-all {
  background: #eff6ff;
  color: var(--primary);
  border: 1px solid #dbeafe;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-view-all:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.dash-panel-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter-pills {
  display: flex;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 20px;
  gap: 2px;
}

.pill-btn {
  border: none;
  background: transparent;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 11.5px;
  font-weight: 700;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
}

.pill-btn:hover {
  color: #0f172a;
}

.pill-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Modern Dashboard Appointments Table */
.dash-table-wrapper {
  overflow-x: auto;
}

.dash-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
}

.dash-table th {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: #94a3b8;
  padding: 8px 14px;
  background: transparent;
  border: none;
  text-align: left;
}

.dash-table tbody tr {
  background: #f8fafc;
  border-radius: 12px;
  transition: all 0.2s;
}

.dash-table tbody tr:hover {
  background: #f1f5f9;
}

.dash-table td {
  padding: 12px 14px;
  border: none;
  font-size: 13px;
  color: #334155;
  vertical-align: middle;
}

.dash-table td:first-child {
  border-radius: 12px 0 0 12px;
}

.dash-table td:last-child {
  border-radius: 0 12px 12px 0;
}

.table-patient-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: #0f172a;
}

.patient-avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #dbeafe;
  color: #1d4ed8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

/* Status Badges */
.status-pill {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  display: inline-block;
  text-transform: capitalize;
}

.status-pill.pendiente {
  background: #fef3c7;
  color: #b45309;
}

.status-pill.confirmada,
.status-pill.atendido {
  background: #d1fae5;
  color: #065f46;
}

.status-pill.cancelada {
  background: #fee2e2;
  color: #b91c1c;
}

/* Patients List */
.patients-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.patient-row-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8fafc;
  transition: all 0.2s;
  text-decoration: none;
  color: inherit;
}

.patient-row-card:hover {
  background: #f1f5f9;
  transform: translateX(3px);
}

.patient-meta-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.patient-name-title {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 2px;
}

.patient-phone-sub {
  font-size: 12px;
  color: #64748b;
}

.patient-chevron {
  color: #94a3b8;
  font-size: 13px;
}

/* Bottom Grid: Quick Actions & Motivational Card */
.dashboard-bottom-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.quick-actions-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
  gap: 14px;
}

.quick-action-card {
  border-radius: 16px;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  cursor: pointer;
}

.quick-action-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--card-shadow-hover);
}

.quick-action-card.cita {
  background: #eef5ff;
  border-color: #dbe8fe;
  color: #1e40af;
}

.quick-action-card.paciente {
  background: #e8f9f0;
  border-color: #cef5df;
  color: #065f46;
}

.quick-action-card.tratamiento {
  background: #f5edff;
  border-color: #e9dbfc;
  color: #6b21a8;
}

.quick-action-card.pago {
  background: #fff4ec;
  border-color: #fedfcb;
  color: #9a3412;
}

.quick-action-card.usuario {
  background: #f3e8ff;
  border-color: #e9d5ff;
  color: #7e22ce;
}

.quick-icon {
  font-size: 24px;
}

.quick-label {
  font-size: 12px;
  font-weight: 700;
}

/* Motivational Card */
.motivational-card {
  background: linear-gradient(135deg, #e0f2fe 0%, #eff6ff 100%);
  border: 1px solid #bae6fd;
  border-radius: 18px;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.motivational-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.motivational-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #0284c7;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.motivational-text {
  font-size: 15px;
  font-weight: 800;
  color: #0369a1;
  line-height: 1.3;
}

.motivational-img {
  width: 50px;
  height: auto;
}

/* ========================================================
   DOCTORS CARDS (CLÍNICA COMPLETA)
   ======================================================== */
.doctors-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.doctor-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
}

.doctor-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--card-shadow-hover);
  border-color: #cbd5e1;
}

.doctor-avatar-circle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #e0f2fe;
  color: #0284c7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

.doctor-details h5 {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 2px;
}

.doctor-details p {
  font-size: 11.5px;
  color: #64748b;
  margin-bottom: 4px;
}

.doctor-fee {
  font-size: 11.5px;
  font-weight: 700;
  color: #10b981;
}

/* ========================================================
   CRUD PAGES: TABLAS, ACCIONES, MODALES
   ======================================================== */
.actions-bar {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  background: #ffffff;
  padding: 16px 20px;
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--card-border);
  margin-bottom: 20px;
  align-items: center;
  justify-content: space-between;
}

.input-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  flex: 1;
  max-width: 400px;
  transition: all 0.2s;
}

.input-box:focus-within {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(29, 104, 255, 0.12);
}

.input-box i {
  color: #94a3b8;
  font-size: 15px;
}

.input-box input {
  border: none;
  outline: none;
  background: transparent;
  width: 100%;
  font-size: 14px;
  font-weight: 500;
}

.table-container {
  background: #ffffff;
  padding: 20px;
  border-radius: 18px;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--card-border);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 14px 16px;
  text-align: left;
}

th {
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #e2e8f0;
}

td {
  border-bottom: 1px solid #f1f5f9;
  font-size: 13.5px;
  color: #334155;
}

tbody tr:hover {
  background: #f8fafc;
}

/* Buttons */
.btn {
  border: none;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn.edit {
  background: var(--primary);
  color: #ffffff;
}

.btn.edit:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(29, 104, 255, 0.25);
}

.btn.delete {
  background: #fee2e2;
  color: #b91c1c;
}

.btn.delete:hover {
  background: #ef4444;
  color: #ffffff;
}

.btn.warning {
  background: #fef3c7;
  color: #b45309;
}

.btn.warning:hover {
  background: #f59e0b;
  color: #ffffff;
}

.btn.secondary {
  background: #eef2ff;
  color: #4338ca;
}

.btn.secondary:hover {
  background: #4338ca;
  color: #ffffff;
}

.btn.sm {
  padding: 6px 10px;
  font-size: 12px;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 999;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.modal-content {
  background: #ffffff;
  padding: 28px;
  border-radius: 20px;
  width: 480px;
  max-width: 92%;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.25);
  animation: modalFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 90vh;
  overflow-y: auto;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
}

.modal-header #cerrarModal {
  cursor: pointer;
  font-size: 24px;
  color: #94a3b8;
  transition: color 0.2s;
}

.modal-header #cerrarModal:hover {
  color: #ef4444;
}

.modal-body label {
  display: block;
  margin-top: 14px;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

.modal-body input,
.modal-body select,
.modal-body textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 14px;
  color: #0f172a;
  outline: none;
  transition: all 0.2s;
  font-family: inherit;
  background: #ffffff;
}

.modal-body textarea {
  resize: vertical;
  min-height: 85px;
}

.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 104, 255, 0.12);
}

.input-error {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.14) !important;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 90;
}

.sidebar-overlay.active {
  display: block;
}

/* ========================================================
   HISTORIAL CLÍNICO Y REPORTES
   ======================================================== */
.clinical-header-card {
  background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
  border: 1px solid #dbeafe;
  border-radius: 18px;
  padding: 20px 24px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  box-shadow: var(--card-shadow);
}

.clinical-patient-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
  font-size: 13px;
  color: #475569;
}

.clinical-tabs {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.clinical-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.clinical-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: var(--card-shadow);
}

.clinical-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f1f5f9;
}

.clinical-card-body p {
  font-size: 13.5px;
  color: #334155;
  line-height: 1.55;
  margin-bottom: 6px;
}

.report-filters-card {
  background: #ffffff;
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--card-shadow);
}

.report-filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  align-items: end;
}

.report-field label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: #475569;
  margin-bottom: 6px;
}

.report-field input,
.report-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 13.5px;
  color: #0f172a;
  background: #f8fafc;
  outline: none;
}

.report-field input:focus,
.report-field select:focus {
  border-color: var(--primary);
  background: #ffffff;
}

.report-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.report-kpi-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 16px 20px;
  box-shadow: var(--card-shadow);
}

.report-kpi-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 6px;
}

.report-kpi-value {
  font-size: 24px;
  font-weight: 800;
  color: #0f172a;
}

.inline-alert {
  display: none;
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
}

.inline-alert.error {
  display: block;
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.inline-alert.success {
  display: block;
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

/* ========================================================
   LOGIN ESTILIZADO
   ======================================================== */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: radial-gradient(circle at top, #0f2952 0%, #07152e 100%);
  padding: 20px;
}

.login-box {
  background: #ffffff;
  padding: 44px 38px;
  border-radius: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  width: 400px;
  max-width: 100%;
  text-align: center;
}

.login-box .logo {
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.login-box .logo img {
  width: 60px;
  height: 60px;
  filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.4));
}

.login-box .logo h1 {
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: 1px;
}

.login-box form {
  text-align: left;
}

.login-box label {
  display: block;
  margin-top: 16px;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

.login-box input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.login-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 104, 255, 0.12);
}

.login-box button {
  width: 100%;
  margin-top: 22px;
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 12px;
  background: var(--primary);
  color: #ffffff;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.login-box button:hover {
  background: var(--primary-hover);
  box-shadow: 0 6px 18px rgba(29, 104, 255, 0.35);
}

.login-box .enlace {
  margin-top: 20px;
  font-size: 13px;
}

.login-box .enlace a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 600;
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 600;
}

/* ========================================================
   RESPONSIVE DESIGN
   ======================================================== */
@media (max-width: 1200px) {
  .doctors-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1100px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-middle-grid {
    grid-template-columns: 1fr;
  }
  .dashboard-bottom-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.active {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
    width: 100%;
    padding: 16px;
  }
  .btn-toggle-sidebar {
    display: inline-flex;
  }
  .quick-actions-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .doctors-grid {
    grid-template-columns: 1fr;
  }
  .actions-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .input-box {
    max-width: 100%;
  }
  .filter-pills {
    flex-wrap: wrap;
    border-radius: 12px;
  }
  .table-container {
    padding: 12px;
    -webkit-overflow-scrolling: touch;
  }
  th, td {
    padding: 10px 10px;
    font-size: 12.5px;
    white-space: nowrap;
  }
}

@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
  .welcome-banner {
    flex-direction: column;
    text-align: center;
    gap: 16px;
    padding: 20px;
  }
  .welcome-text h2 {
    font-size: 22px;
  }
  .welcome-text p {
    justify-content: center;
  }
  .quick-actions-row {
    grid-template-columns: 1fr;
  }
  .notifications-dropdown {
    width: min(330px, calc(100vw - 32px));
  }
  .modal-content {
    padding: 20px;
    border-radius: 16px;
  }
  .page-title {
    font-size: 20px;
  }
}
