/* ═══════════════════════════════════════════════════════════════════════════
   CloudPrescription — app.css
   One file. Entire site. International medical-grade UI system.
   Place at: /assets/css/app.css
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Google Fonts ─────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── Design Tokens ────────────────────────────────────────────────────────── */
:root {
  /* Brand */
  --primary:        #059669;
  --primary-dark:   #047857;
  --primary-light:  #d1fae5;
  --primary-glow:   rgba(5,150,105,.15);

  /* Neutrals */
  --bg:             #f8fafc;
  --bg-2:           #f1f5f9;
  --surface:        #ffffff;
  --surface-2:      #f8fafc;
  --border:         #e2e8f0;
  --border-2:       #cbd5e1;

  /* Text */
  --text:           #0f172a;
  --text-2:         #334155;
  --text-3:         #64748b;
  --text-4:         #94a3b8;
  --dark:           #0f172a;

  /* Status */
  --success:        #059669;
  --success-light:  #ecfdf5;
  --warning:        #d97706;
  --warning-light:  #fffbeb;
  --error:          #dc2626;
  --error-light:    #fef2f2;
  --info:           #2563eb;
  --info-light:     #eff6ff;

  /* Layout */
  --sidebar-w:      260px;
  --topnav-h:       60px;
  --radius:         12px;
  --radius-lg:      18px;
  --radius-sm:      8px;
  --radius-xs:      5px;

  /* Shadows */
  --shadow-xs:      0 1px 2px rgba(0,0,0,.05);
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow:         0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-md:      0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.05);
  --shadow-lg:      0 20px 25px -5px rgba(0,0,0,.08), 0 8px 10px -6px rgba(0,0,0,.04);
  --shadow-xl:      0 25px 50px -12px rgba(0,0,0,.15);
  --shadow-glow:    0 0 0 3px var(--primary-glow);

  /* Fonts */
  --font:           'Plus Jakarta Sans', sans-serif;
  --font-serif:     'Instrument Serif', serif;
  --font-mono:      'JetBrains Mono', monospace;

  /* Transitions */
  --ease:           cubic-bezier(.4,0,.2,1);
  --ease-spring:    cubic-bezier(.34,1.56,.64,1);
  --t-fast:         150ms;
  --t:              220ms;
  --t-slow:         400ms;
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }
ul, ol { list-style: none; }

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }

/* ═══════════════════════════════════════════════════════════════════════════
   LAYOUT SYSTEM
   ═══════════════════════════════════════════════════════════════════════════ */

/* App shell */
.app-wrapper {
  display: flex;
  min-height: calc(100vh - var(--topnav-h));
  margin-top: var(--topnav-h);
}

/* Main content area */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 32px;
  min-height: calc(100vh - var(--topnav-h));
  transition: margin-left var(--t) var(--ease);
}

/* ═══════════════════════════════════════════════════════════════════════════
   TOP NAV
   ═══════════════════════════════════════════════════════════════════════════ */
.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topnav-h);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
  box-shadow: var(--shadow-xs);
}

/* Logo */
.topnav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 17px;
  color: var(--text);
  letter-spacing: -.3px;
}

.topnav-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: white;
  font-size: 16px;
  font-family: var(--font-serif);
  box-shadow: 0 2px 8px var(--primary-glow);
}

.topnav-logo span {
  color: var(--primary);
}

/* Nav right */
.topnav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Nav icon button */
.nav-icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--text-3);
  transition: all var(--t-fast) var(--ease);
  position: relative;
}
.nav-icon-btn:hover {
  background: var(--bg-2);
  color: var(--text);
  border-color: var(--border-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.nav-icon-btn svg { width: 17px; height: 17px; }

/* Notification badge */
.nav-badge {
  position: absolute;
  top: -3px; right: -3px;
  width: 16px; height: 16px;
  background: var(--error);
  color: white;
  font-size: 9px;
  font-weight: 700;
  border-radius: 99px;
  display: grid;
  place-items: center;
  border: 2px solid white;
}

/* User avatar */
.nav-avatar {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--primary-dark);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  overflow: hidden;
}
.nav-avatar:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.nav-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Breadcrumb */
.topnav-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-3);
}
.topnav-breadcrumb span { color: var(--text-4); }
.topnav-breadcrumb strong { color: var(--text); font-weight: 600; }

/* ═══════════════════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: var(--topnav-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--topnav-h));
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 900;
  transition: width var(--t) var(--ease), transform var(--t) var(--ease);
}

/* Doctor card inside sidebar */
.sidebar-doctor {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-doctor-avatar {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #d1fae5, #059669);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 2px 8px var(--primary-glow);
}
.sidebar-doctor-avatar img { width: 100%; height: 100%; object-fit: cover; }

.sidebar-doctor-info { flex: 1; min-width: 0; }
.sidebar-doctor-name {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-doctor-role {
  font-size: 11px;
  color: var(--primary);
  font-weight: 600;
  margin-top: 1px;
}

/* Sidebar status dot */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 99px;
  background: var(--success);
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--success);
  animation: pulse-dot 2.5s ease infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--success); }
  50% { box-shadow: 0 0 0 2px #fff, 0 0 0 5px rgba(5,150,105,.3); }
}

/* Nav sections */
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-4);
  padding: 12px 8px 6px;
}

/* Nav item */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  position: relative;
  margin-bottom: 2px;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--bg-2);
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 700;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.nav-item-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-xs);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all var(--t-fast) var(--ease);
  font-size: 15px;
}

.nav-item:hover .nav-item-icon { transform: scale(1.1); }
.nav-item.active .nav-item-icon {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.nav-item-label { flex: 1; white-space: nowrap; }

/* Nav item badge */
.nav-item-badge {
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  min-width: 20px;
  text-align: center;
}

.nav-item-badge.warning { background: var(--warning); }
.nav-item-badge.error   { background: var(--error); }

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════════════════════
   PAGE HEADER
   ═══════════════════════════════════════════════════════════════════════════ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.page-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.5px;
  line-height: 1.2;
  font-family: var(--font-serif);
  font-style: italic;
}

.page-sub {
  font-size: 13.5px;
  color: var(--text-3);
  margin-top: 4px;
  font-style: normal;
  font-family: var(--font);
}

/* ═══════════════════════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--t) var(--ease), border-color var(--t) var(--ease);
}

.card:hover { box-shadow: var(--shadow-sm); }

.card-flat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

/* Stat card */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  box-shadow: var(--shadow-xs);
  transition: all var(--t) var(--ease);
  cursor: default;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 60%, rgba(5,150,105,.03));
  pointer-events: none;
}

.stat-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md), 0 0 0 1px var(--primary);
  transform: translateY(-2px);
}

.stat-icon {
  width: 46px; height: 46px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.green  { background: #ecfdf5; color: var(--primary); }
.stat-icon.blue   { background: #eff6ff; color: #2563eb; }
.stat-icon.amber  { background: #fffbeb; color: #d97706; }
.stat-icon.red    { background: #fef2f2; color: #dc2626; }
.stat-icon.purple { background: #f5f3ff; color: #7c3aed; }
.stat-icon.indigo { background: #eef2ff; color: #4f46e5; }

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -1px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
  margin-top: 3px;
}

.stat-change {
  font-size: 11px;
  font-weight: 600;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 3px;
}
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--error); }

/* ═══════════════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--t-fast) var(--ease);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
  position: relative;
  overflow: hidden;
}

/* Ripple effect on click */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.15);
  opacity: 0;
  transition: opacity var(--t-fast);
}
.btn:active::after { opacity: 1; }
.btn:active { transform: scale(.98); }

/* Primary */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 2px 8px var(--primary-glow), 0 1px 2px rgba(0,0,0,.1);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #0a7c5c, var(--primary-dark));
  box-shadow: 0 4px 16px var(--primary-glow), 0 2px 4px rgba(0,0,0,.1);
  transform: translateY(-1px);
}

/* Secondary */
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-2);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--bg-2);
  border-color: var(--border-2);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

/* Outline */
.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--bg-2);
  color: var(--text);
}

/* Danger */
.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  box-shadow: 0 2px 8px rgba(239,68,68,.2);
}
.btn-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(239,68,68,.3);
}

/* Sizes */
.btn-xs  { padding: 5px 10px; font-size: 11.5px; border-radius: 6px; }
.btn-sm  { padding: 7px 13px; font-size: 12.5px; }
.btn-lg  { padding: 12px 24px; font-size: 15px; border-radius: var(--radius); }
.btn-xl  { padding: 15px 32px; font-size: 16px; border-radius: var(--radius); }
.btn-ico { padding: 9px; }

/* Loading state */
.btn.loading { pointer-events: none; opacity: .75; }
.btn.loading::before {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 99px;
  animation: spin .7s linear infinite;
  margin-right: 4px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════════════════════ */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
  letter-spacing: .01em;
}

.form-label-required::after {
  content: ' *';
  color: var(--error);
}

.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  transition: all var(--t-fast) var(--ease);
  outline: none;
  -webkit-appearance: none;
}

.form-control::placeholder { color: var(--text-4); }

.form-control:hover { border-color: var(--border-2); }

.form-control:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
  background: #fff;
}

.form-control:invalid:not(:placeholder-shown) {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(220,38,38,.1);
}

textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control    { cursor: pointer; }

/* Input with icon */
.input-group {
  position: relative;
}
.input-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-4);
  width: 16px; height: 16px;
  pointer-events: none;
}
.input-group .form-control { padding-left: 38px; }
.input-group-right .input-icon { left: auto; right: 12px; }
.input-group-right .form-control { padding-left: 13px; padding-right: 38px; }

/* Input addon */
.input-addon {
  display: flex;
  align-items: stretch;
}
.input-addon-text {
  padding: 9px 13px;
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  font-size: 13px;
  color: var(--text-3);
  font-weight: 500;
}
.input-addon .form-control { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* Form hint */
.form-hint {
  font-size: 11.5px;
  color: var(--text-4);
  margin-top: 5px;
  line-height: 1.5;
}
.form-hint.error { color: var(--error); }
.form-hint.success { color: var(--success); }

/* Form grid */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-2);
}
.form-check input[type=checkbox],
.form-check input[type=radio] {
  width: 17px; height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 42px; height: 24px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border-2);
  border-radius: 99px;
  cursor: pointer;
  transition: background var(--t) var(--ease);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 18px; height: 18px;
  background: white;
  border-radius: 99px;
  transition: transform var(--t) var(--ease-spring);
  box-shadow: var(--shadow-sm);
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ═══════════════════════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════════════════════ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead tr {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
  white-space: nowrap;
}

td {
  padding: 13px 16px;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr {
  transition: background var(--t-fast) var(--ease);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

/* Table actions */
.table-actions { display: flex; align-items: center; gap: 6px; }

/* ═══════════════════════════════════════════════════════════════════════════
   BADGES & PILLS
   ═══════════════════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green   { background: #ecfdf5; color: #059669; }
.badge-red     { background: #fef2f2; color: #dc2626; }
.badge-amber   { background: #fffbeb; color: #d97706; }
.badge-blue    { background: #eff6ff; color: #2563eb; }
.badge-purple  { background: #f5f3ff; color: #7c3aed; }
.badge-gray    { background: var(--bg-2); color: var(--text-3); }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }

/* Dot badge */
.badge-dot::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 99px;
  background: currentColor;
  display: inline-block;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ALERTS
   ═══════════════════════════════════════════════════════════════════════════ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  border: 1px solid transparent;
  margin-bottom: 20px;
  animation: slide-down .3s var(--ease);
}

.alert-success { background: var(--success-light); border-color: #a7f3d0; color: #065f46; }
.alert-error   { background: var(--error-light);   border-color: #fecaca; color: #991b1b; }
.alert-warning { background: var(--warning-light); border-color: #fde68a; color: #92400e; }
.alert-info    { background: var(--info-light);    border-color: #bfdbfe; color: #1e40af; }

/* ═══════════════════════════════════════════════════════════════════════════
   SEARCH BAR
   ═══════════════════════════════════════════════════════════════════════════ */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  transition: all var(--t-fast) var(--ease);
}
.search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}
.search-bar svg { color: var(--text-4); width: 16px; height: 16px; flex-shrink: 0; }
.search-bar input {
  border: none;
  outline: none;
  background: none;
  font-size: 13.5px;
  color: var(--text);
  font-family: var(--font);
  width: 100%;
}
.search-bar input::placeholder { color: var(--text-4); }

/* ═══════════════════════════════════════════════════════════════════════════
   MODALS & OVERLAYS
   ═══════════════════════════════════════════════════════════════════════════ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade-in .2s var(--ease);
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-in .3s var(--ease-spring);
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.modal-body   { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-close {
  width: 30px; height: 30px;
  border-radius: var(--radius-xs);
  background: none;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--text-3);
  transition: all var(--t-fast);
}
.modal-close:hover { background: var(--error-light); color: var(--error); border-color: #fecaca; }

/* ═══════════════════════════════════════════════════════════════════════════
   DROPDOWNS
   ═══════════════════════════════════════════════════════════════════════════ */
.dropdown { position: relative; display: inline-block; }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 190px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 1200;
  overflow: hidden;
  animation: dropdown-in .18s var(--ease);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--t-fast);
  text-decoration: none;
}
.dropdown-item:hover { background: var(--bg-2); color: var(--text); }
.dropdown-item.danger { color: var(--error); }
.dropdown-item.danger:hover { background: var(--error-light); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ═══════════════════════════════════════════════════════════════════════════
   TABS
   ═══════════════════════════════════════════════════════════════════════════ */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--t-fast) var(--ease);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 7px;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 700;
}

/* Pill tabs */
.tabs-pill {
  display: flex;
  gap: 6px;
  background: var(--bg-2);
  padding: 4px;
  border-radius: var(--radius);
  margin-bottom: 24px;
  border: none;
}
.tabs-pill .tab {
  border-radius: var(--radius-sm);
  border-bottom: none;
  margin-bottom: 0;
  padding: 7px 14px;
}
.tabs-pill .tab.active {
  background: white;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  border-bottom: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   AVATAR GROUP & MISC
   ═══════════════════════════════════════════════════════════════════════════ */
.avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--primary-light);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--primary-dark);
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; border-radius: 7px; }
.avatar-lg { width: 48px; height: 48px; font-size: 18px; border-radius: 14px; }
.avatar-xl { width: 64px; height: 64px; font-size: 24px; border-radius: 18px; }

/* Divider */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* Empty state */
.empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-3);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: .4; }
.empty-title { font-size: 16px; font-weight: 700; color: var(--text-2); margin-bottom: 6px; }
.empty-sub { font-size: 13.5px; }

/* Code / mono */
.mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--bg-2);
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--primary-dark);
  border: 1px solid var(--border);
}

/* Tooltip */
.tooltip { position: relative; display: inline-flex; }
.tooltip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast);
  z-index: 9999;
}
.tooltip:hover::after { opacity: 1; }

/* Progress bar */
.progress {
  height: 6px;
  background: var(--bg-2);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: 99px;
  transition: width .6s var(--ease);
}

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, var(--bg-2) 25%, var(--border) 50%, var(--bg-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════════════════ */
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-6px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}

/* Page entrance animation */
.page-animate {
  animation: slide-up .35s var(--ease) both;
}

/* Stagger children */
.page-animate > *:nth-child(1) { animation-delay: 0ms; }
.page-animate > *:nth-child(2) { animation-delay: 60ms; }
.page-animate > *:nth-child(3) { animation-delay: 120ms; }
.page-animate > *:nth-child(4) { animation-delay: 180ms; }
.page-animate > *:nth-child(5) { animation-delay: 240ms; }

/* Hover lift */
.hover-lift { transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease); }
.hover-lift:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

/* ═══════════════════════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════════════════════ */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end  { justify-content: flex-end; }
.gap-4        { gap: 4px; }
.gap-6        { gap: 6px; }
.gap-8        { gap: 8px; }
.gap-10       { gap: 10px; }
.gap-12       { gap: 12px; }
.gap-16       { gap: 16px; }
.gap-20       { gap: 20px; }
.gap-24       { gap: 24px; }
.flex-1       { flex: 1; }
.shrink-0     { flex-shrink: 0; }
.w-full       { width: 100%; }
.grid-2       { display: grid; grid-template-columns: repeat(2,1fr); gap: 16px; }
.grid-3       { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.grid-4       { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.truncate     { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mb-4         { margin-bottom: 4px; }
.mb-8         { margin-bottom: 8px; }
.mb-12        { margin-bottom: 12px; }
.mb-16        { margin-bottom: 16px; }
.mb-20        { margin-bottom: 20px; }
.mb-24        { margin-bottom: 24px; }
.mt-4         { margin-top: 4px; }
.mt-8         { margin-top: 8px; }
.mt-12        { margin-top: 12px; }
.mt-16        { margin-top: 16px; }
.mt-20        { margin-top: 20px; }
.mt-24        { margin-top: 24px; }
.p-0          { padding: 0; }
.hidden       { display: none !important; }
.opacity-0    { opacity: 0; }
.rounded      { border-radius: var(--radius-sm); }
.rounded-lg   { border-radius: var(--radius-lg); }
.rounded-full { border-radius: 99px; }
.font-mono    { font-family: var(--font-mono); }
.font-serif   { font-family: var(--font-serif); }

/* Text sizes */
.text-xs  { font-size: 11px; }
.text-sm  { font-size: 12.5px; }
.text-base { font-size: 14px; }
.text-lg  { font-size: 16px; }
.text-xl  { font-size: 18px; }
.text-2xl { font-size: 22px; }
.text-3xl { font-size: 28px; }

/* Text colors */
.text-primary { color: var(--primary); }
.text-muted   { color: var(--text-3); }
.text-error   { color: var(--error); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }

/* Font weights */
.font-medium  { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold    { font-weight: 700; }
.font-extrabold { font-weight: 800; }

/* ═══════════════════════════════════════════════════════════════════════════
   GSAP ANIMATION HELPERS
   (GSAP loaded via CDN — add to topnav.php or base layout)
   ═══════════════════════════════════════════════════════════════════════════ */

/* Elements that GSAP will animate on page load */
[data-gsap="fade-up"]   { opacity: 0; transform: translateY(20px); }
[data-gsap="fade-in"]   { opacity: 0; }
[data-gsap="fade-left"] { opacity: 0; transform: translateX(-20px); }
[data-gsap="scale-in"]  { opacity: 0; transform: scale(.95); }

/* GSAP stagger children marker */
[data-gsap-stagger]     { opacity: 0; transform: translateY(16px); }

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .grid-4 { grid-template-columns: repeat(2,1fr); }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .main-content { padding: 20px 16px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4  { grid-template-columns: 1fr; }
  .page-title { font-size: 20px; }
  .tabs { overflow-x: auto; }
}

@media (max-width: 480px) {
  .main-content { padding: 16px 12px; }
  .card { padding: 16px; }
  .btn-lg { padding: 10px 18px; font-size: 14px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   PRINT — hide UI chrome
   ═══════════════════════════════════════════════════════════════════════════ */
@media print {
  .topnav, .sidebar, .no-print { display: none !important; }
  .main-content { margin: 0 !important; padding: 0 !important; }
  .app-wrapper { display: block; margin: 0; }
  body { background: white !important; }
}