:root {
  --primary: #0A2A66;
  --secondary: #F5A623;
  --accent: #0D6EFD;
  --sidebar: #081F4D;
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --border: #E5E7EB;
  --text: #2C3E50;
  --success: #28A745;
  --danger: #DC3545;
  --warning: #FFC107;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(8, 31, 77, 0.08);
  --shadow-sm: 0 2px 10px rgba(8, 31, 77, 0.06);
  --sidebar-width: 260px;
  --header-height: 70px;
  --transition: all 0.25s ease;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: 'Poppins', sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--primary); }

/* ========== AUTH ========== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  background:
    linear-gradient(135deg, rgba(8,31,77,.92), rgba(10,42,102,.85)),
    url('../img/login-bg.svg') center/cover no-repeat;
}

.auth-left {
  flex: 1.1;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px;
  position: relative;
  overflow: hidden;
}

.auth-left::after {
  content: '';
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245,166,35,.25), transparent 70%);
  right: -80px;
  bottom: -80px;
}

.auth-brand {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -.5px;
  margin-bottom: .25rem;
}

.auth-tagline {
  color: rgba(255,255,255,.8);
  font-size: 1.05rem;
  margin-bottom: 2rem;
}

.auth-features {
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: 420px;
}

.auth-features li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 1rem;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  padding: 14px 16px;
  backdrop-filter: blur(6px);
}

.auth-features i {
  color: var(--secondary);
  font-size: 1.25rem;
  margin-top: 2px;
}

.auth-right {
  flex: .9;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: rgba(248,250,252,.96);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
  border: 1px solid var(--border);
  animation: fadeUp .45s ease;
}

.auth-card h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: .25rem;
}

.auth-card .subtitle {
  color: #64748b;
  margin-bottom: 1.5rem;
  font-size: .92rem;
}

/* ========== APP SHELL ========== */
.app-shell {
  min-height: 100vh;
  display: flex;
  background: var(--bg);
}

.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #081F4D 0%, #0A2A66 100%);
  color: #fff;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  box-shadow: 8px 0 30px rgba(8,31,77,.18);
}

.sidebar-brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand .logo-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--secondary), #ffc857);
  display: grid;
  place-items: center;
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(245,166,35,.35);
}

.sidebar-brand .brand-text strong {
  display: block;
  font-size: 1.05rem;
  line-height: 1.1;
}

.sidebar-brand .brand-text small {
  color: rgba(255,255,255,.65);
  font-size: .7rem;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px 24px;
}

.nav-section {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.4);
  padding: 12px 12px 8px;
  font-weight: 600;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,.78);
  padding: 11px 14px;
  border-radius: 10px;
  margin-bottom: 4px;
  font-size: .9rem;
  font-weight: 500;
  transition: var(--transition);
}

.sidebar-nav a i {
  font-size: 1.1rem;
  width: 22px;
  text-align: center;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.sidebar-nav a.active {
  background: linear-gradient(90deg, rgba(245,166,35,.95), rgba(245,166,35,.7));
  color: #081F4D;
  box-shadow: 0 8px 18px rgba(245,166,35,.25);
}

.main-wrap {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--header-height);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
}

.page-content {
  padding: 24px;
  animation: fadeUp .35s ease;
}

.page-title {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
}

.page-subtitle {
  color: #64748b;
  font-size: .88rem;
  margin: 2px 0 0;
}

/* ========== CARDS / UI ========== */
.v-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.v-card:hover { box-shadow: var(--shadow); }

.v-card .card-body { padding: 1.25rem 1.35rem; }
.v-card .card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.35rem;
  font-weight: 600;
  color: var(--primary);
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 1.25rem 1.35rem;
  height: 100%;
}

.stat-card::before {
  content: '';
  position: absolute;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  right: -30px;
  top: -30px;
  background: rgba(13,110,253,.08);
}

.stat-card .stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  margin-bottom: .85rem;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  margin-bottom: .35rem;
}

.stat-card .stat-label {
  color: #64748b;
  font-size: .85rem;
  font-weight: 500;
}

.stat-icon.blue { background: rgba(13,110,253,.12); color: var(--accent); }
.stat-icon.orange { background: rgba(245,166,35,.15); color: #d48806; }
.stat-icon.green { background: rgba(40,167,69,.12); color: var(--success); }
.stat-icon.red { background: rgba(220,53,69,.12); color: var(--danger); }
.stat-icon.navy { background: rgba(10,42,102,.12); color: var(--primary); }
.stat-icon.teal { background: rgba(20,184,166,.12); color: #0d9488; }

.stat-card-clickable {
  cursor: pointer;
  user-select: none;
}

.stat-card-clickable:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: #c7d2fe;
}

.stat-card-clickable:active {
  transform: translateY(0);
}

.dashboard-refresh-badge {
  font-weight: 500;
  color: #334155;
  font-size: .78rem;
  vertical-align: middle;
}

.dashboard-refresh-badge strong {
  font-variant-numeric: tabular-nums;
  min-width: 1.2em;
  display: inline-block;
  text-align: center;
}

.btn {
  border-radius: 10px;
  font-weight: 550;
  padding: .55rem 1.1rem;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus {
  background: #081f4d;
  border-color: #081f4d;
}

.btn-secondary {
  background: var(--secondary);
  border-color: var(--secondary);
  color: #081F4D;
}

.btn-secondary:hover {
  background: #e09412;
  border-color: #e09412;
  color: #081F4D;
}

.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline-primary:hover {
  background: var(--primary);
  border-color: var(--primary);
}

  .form-control, .form-select {
  border-radius: 10px;
  border: 1.5px solid #94A3B8;
  padding: .65rem .9rem;
  font-size: .92rem;
  background-color: #fff;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 .2rem rgba(10,42,102,.15);
}

.consultation-form .form-control,
.consultation-form .form-select,
.medicine-table .form-control,
.vital-row .form-control {
  border: 1.5px solid #64748B !important;
  background: #fff;
}

.consultation-form .form-control:focus,
.medicine-table .form-control:focus,
.vital-row .form-control:focus {
  border-color: #0A2A66 !important;
  box-shadow: 0 0 0 .2rem rgba(10,42,102,.18);
}

.consult-header .avatar-lg {
  background: rgba(10, 42, 102, .1);
  color: var(--primary);
}

.consult-actions {
  position: sticky;
  bottom: 12px;
  z-index: 20;
  box-shadow: 0 10px 30px rgba(8, 31, 77, .12);
}

.vital-row .form-control-sm {
  border-radius: 8px;
}

.vital-row .remove-vital-row {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(220,53,69,.1);
  color: #dc3545 !important;
  text-decoration: none;
}

.vital-row .remove-vital-row:hover {
  background: #dc3545;
  color: #fff !important;
}

#clinical-notes-editor {
  min-height: 280px;
  background: #fff;
  border: 1.5px solid #64748B;
  border-radius: 0 0 10px 10px;
}

#clinical-notes-editor .ql-editor {
  min-height: 240px;
  font-family: 'Poppins', sans-serif;
  font-size: .95rem;
}

.ql-toolbar.ql-snow {
  border: 1.5px solid #64748B !important;
  border-bottom: 1px solid #CBD5E1 !important;
  border-radius: 10px 10px 0 0;
  background: #F8FAFC;
}

.form-label {
  font-weight: 550;
  font-size: .86rem;
  color: #334155;
  margin-bottom: .35rem;
}

.table {
  --bs-table-bg: transparent;
  margin-bottom: 0;
}

.table thead th {
  background: #F1F5F9;
  color: #475569;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table tbody td {
  vertical-align: middle;
  border-color: var(--border);
  font-size: .9rem;
  padding: .85rem .75rem;
}

.badge-soft-primary { background: rgba(13,110,253,.12); color: #0d6efd; }
.badge-soft-success { background: rgba(40,167,69,.12); color: #198754; }
.badge-soft-warning { background: rgba(255,193,7,.18); color: #b58100; }
.badge-soft-danger { background: rgba(220,53,69,.12); color: #dc3545; }
.badge-soft-info { background: rgba(13,202,240,.15); color: #0aa2c0; }
.badge-soft-secondary { background: rgba(108,117,125,.12); color: #6c757d; }

.badge {
  font-weight: 550;
  padding: .4em .7em;
  border-radius: 8px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: #e2e8f0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--primary);
}

.avatar-lg { width: 72px; height: 72px; font-size: 1.4rem; }

.search-pill {
  background: #F1F5F9;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: .55rem 1rem;
  min-width: 260px;
}

.search-pill:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 .2rem rgba(13,110,253,.12);
}

.patient-filter-form .patient-filter-control {
  width: 100%;
  min-height: 42px;
}

.patient-filter-form .form-select {
  background-position: right .8rem center;
  padding-right: 2rem;
}

.quick-actions .btn {
  border-radius: 12px;
  padding: .85rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .35rem;
  height: 100%;
  text-align: left;
}

.quick-actions .btn i { font-size: 1.3rem; }

.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 1.25rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -24px;
  top: 18px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--secondary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary);
}

.patient-hero {
  background: linear-gradient(135deg, #0A2A66, #143a82);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: #94a3b8;
}

.empty-state i { font-size: 2.5rem; margin-bottom: .75rem; display: block; }

.notification-item {
  border-left: 3px solid transparent;
  transition: background-color .2s ease, opacity .2s ease;
}

.notification-item.notification-unread {
  background: #f8fafc;
  border-left-color: var(--primary);
}

.notification-item.notification-unread .notification-title {
  color: var(--primary);
}

.notification-item.notification-read {
  background: #fff;
  opacity: 0.72;
}

.notification-item.notification-read .notification-title,
.notification-item.notification-read .notification-message {
  color: #94a3b8 !important;
  font-weight: 400;
}

.js-live-results.is-loading {
  position: relative;
  min-height: 120px;
}

.js-live-results.is-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(248,250,252,.65);
  z-index: 5;
}

.js-live-results.is-loading::before {
  content: '';
  position: absolute;
  top: 40%;
  left: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border: 3px solid #dbe3f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  z-index: 6;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.calendar-day {
  min-height: 110px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
}

.calendar-day .day-num {
  font-weight: 600;
  font-size: .85rem;
  color: var(--primary);
  margin-bottom: 6px;
}

.calendar-day .event {
  font-size: .7rem;
  background: rgba(13,110,253,.1);
  color: var(--primary);
  border-radius: 6px;
  padding: 3px 5px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.medicine-table .form-control,
.medicine-table .form-select {
  padding: .4rem .55rem;
  font-size: .85rem;
}

.medicine-table .form-check-input {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  border: 2px solid #334155;
  background-color: #fff;
  cursor: pointer;
  box-shadow: none;
}

.medicine-table .form-check-input:hover {
  border-color: #0A2A66;
}

.medicine-table .form-check-input:checked {
  background-color: #0A2A66;
  border-color: #0A2A66;
}

.medicine-table .form-check-input:focus {
  border-color: #0A2A66;
  box-shadow: 0 0 0 .2rem rgba(10, 42, 102, .2);
}

.medicine-table td.text-center {
  vertical-align: middle;
}

.sidebar-toggle {
  display: none;
  border: none;
  background: #F1F5F9;
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-105%);
  }
  .sidebar.show { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .sidebar-toggle { display: inline-grid; place-items: center; }
  .auth-left { display: none; }
  .auth-page { background: var(--bg); }
  .search-pill { min-width: 140px; }
}
