/* ============ ระบบทะเบียนนักศึกษา — Glassmorphism ============ */

:root {
  --indigo-900: #1e1b4b;
  --indigo-800: #1e3a8a;
  --indigo-700: #3730a3;
  --indigo-600: #4f46e5;
  --indigo-500: #6366f1;
  --indigo-400: #818cf8;
  --blue-500: #3b82f6;
  --violet-500: #8b5cf6;
  --violet-300: #c4b5fd;
  --rose-500: #f43f5e;
  --rose-100: #ffe4e6;
  --amber-500: #f59e0b;
  --amber-100: #fef3c7;
  --emerald-500: #10b981;
  --emerald-100: #d1fae5;
  --sky-500: #0ea5e9;
  --sky-100: #e0f2fe;

  --ink-900: #0f172a;
  --ink-700: #334155;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --ink-300: #cbd5e1;
  --ink-200: #e2e8f0;
  --ink-100: #f1f5f9;

  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-bg-strong: rgba(255, 255, 255, 0.78);
  --glass-bg-soft: rgba(255, 255, 255, 0.32);
  --glass-border: rgba(255, 255, 255, 0.6);
  --glass-border-soft: rgba(255, 255, 255, 0.35);
  --glass-shadow: 0 10px 40px -10px rgba(30, 27, 75, 0.18), 0 2px 8px -2px rgba(30, 27, 75, 0.08);
  --glass-shadow-lg: 0 30px 80px -20px rgba(30, 27, 75, 0.28), 0 10px 24px -8px rgba(30, 27, 75, 0.12);

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Prompt', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  color: var(--ink-900);
  min-height: 100vh;
  background: #eef2ff;
  position: relative;
  overflow-x: hidden;
  letter-spacing: 0.01em;
}

/* ---------- Animated gradient backdrop ---------- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 800px 600px at 12% 8%, #c7d2fe 0%, transparent 55%),
    radial-gradient(ellipse 900px 700px at 92% 18%, #ddd6fe 0%, transparent 55%),
    radial-gradient(ellipse 700px 600px at 50% 95%, #bfdbfe 0%, transparent 50%),
    radial-gradient(ellipse 600px 500px at 88% 88%, #fbcfe8 0%, transparent 55%),
    linear-gradient(135deg, #eef2ff 0%, #f5f3ff 50%, #eff6ff 100%);
  z-index: -2;
  animation: drift 30s ease-in-out infinite alternate;
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 40%, rgba(99, 102, 241, 0.04) 0%, transparent 1px),
    radial-gradient(circle at 80% 60%, rgba(139, 92, 246, 0.04) 0%, transparent 1px);
  background-size: 24px 24px, 32px 32px;
  z-index: -1;
  pointer-events: none;
}
@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-20px, 10px) scale(1.05); }
  100% { transform: translate(15px, -10px) scale(1.02); }
}

/* ---------- Glass primitives ---------- */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
}
.glass-strong {
  background: var(--glass-bg-strong);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
}
.glass-soft {
  background: var(--glass-bg-soft);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--radius-md);
}

/* ---------- Layout shell ---------- */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  gap: 0;
}

.sidebar {
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-inner {
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  padding: 22px 16px;
  height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 18px;
  border-bottom: 1px solid rgba(99, 102, 241, 0.12);
  margin-bottom: 12px;
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--indigo-700) 0%, var(--violet-500) 100%);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 600;
  font-size: 18px;
  box-shadow: 0 6px 18px -4px rgba(67, 56, 202, 0.5);
}
.brand-name {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
  color: var(--indigo-900);
}
.brand-sub {
  font-size: 11px;
  color: var(--ink-500);
  font-weight: 400;
}

.nav-section {
  font-size: 11px;
  color: var(--ink-500);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 14px 10px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  color: var(--ink-700);
  font-size: 14px;
  font-weight: 400;
  transition: all 0.18s ease;
  border: 1px solid transparent;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.5);
  color: var(--indigo-900);
}
.nav-item.active {
  background: linear-gradient(135deg, rgba(67, 56, 202, 0.12), rgba(139, 92, 246, 0.10));
  color: var(--indigo-900);
  font-weight: 500;
  border-color: rgba(99, 102, 241, 0.25);
  box-shadow: 0 4px 12px -4px rgba(79, 70, 229, 0.18);
}
.nav-item .ic {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: var(--indigo-600);
  opacity: 0.85;
}
.nav-item.active .ic { opacity: 1; }
.nav-badge {
  margin-left: auto;
  font-size: 11px;
  background: var(--indigo-600);
  color: white;
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 500;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(99, 102, 241, 0.12);
}
.profile-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.5);
}
.avatar-sm {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo-500), var(--violet-500));
  color: white;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 500;
  flex: 0 0 32px;
}

/* ---------- Main ---------- */
.main {
  padding: 20px 24px 40px;
  min-width: 0;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}
.topbar h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--indigo-900);
  letter-spacing: -0.01em;
}
.topbar .sub {
  font-size: 13px;
  color: var(--ink-500);
  margin-top: 2px;
}
.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--indigo-700), var(--indigo-600));
  color: white;
  box-shadow: 0 6px 16px -4px rgba(67, 56, 202, 0.45);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -4px rgba(67, 56, 202, 0.55);
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(12px);
  color: var(--ink-700);
  border-color: var(--glass-border-soft);
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.85);
  color: var(--indigo-900);
}
.btn-danger {
  background: rgba(244, 63, 94, 0.1);
  color: var(--rose-500);
  border-color: rgba(244, 63, 94, 0.25);
}
.btn-danger:hover { background: rgba(244, 63, 94, 0.18); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
}
.btn .ic { width: 16px; height: 16px; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-700);
}
.field-label .req { color: var(--rose-500); margin-left: 2px; }
.field-hint { font-size: 11.5px; color: var(--ink-500); }
.field-error { font-size: 11.5px; color: var(--rose-500); margin-top: 2px; }

.input, .select, .textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 13.5px;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(99, 102, 241, 0.18);
  border-radius: var(--radius-md);
  color: var(--ink-900);
  transition: all 0.18s;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  background: rgba(255, 255, 255, 0.95);
  border-color: var(--indigo-500);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}
.input::placeholder { color: var(--ink-400); }
.textarea { resize: vertical; min-height: 80px; font-family: inherit; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-wrap .ic {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--ink-400);
  pointer-events: none;
}
.search-wrap .input {
  padding-left: 40px;
  background: rgba(255, 255, 255, 0.7);
}

/* ---------- Chips & badges ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(99, 102, 241, 0.18);
  color: var(--ink-700);
  white-space: nowrap;
}
.chip-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.chip-active {
  background: var(--emerald-100); color: #047857; border-color: rgba(16, 185, 129, 0.3);
}
.chip-grad {
  background: var(--sky-100); color: #0369a1; border-color: rgba(14, 165, 233, 0.3);
}
.chip-leave {
  background: var(--amber-100); color: #b45309; border-color: rgba(245, 158, 11, 0.3);
}
.chip-out {
  background: var(--rose-100); color: #be123c; border-color: rgba(244, 63, 94, 0.3);
}
.chip-pend {
  background: #f3e8ff; color: #6b21a8; border-color: rgba(168, 85, 247, 0.3);
}

/* ---------- Cards / panels ---------- */
.panel {
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  padding: 22px;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.panel-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--indigo-900);
}
.panel-head .sub {
  font-size: 12px;
  color: var(--ink-500);
  margin-top: 2px;
}
.panel-head-actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------- Stat cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}
.stat {
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--glass-shadow);
}
.stat-label {
  font-size: 12.5px;
  color: var(--ink-500);
  font-weight: 400;
  margin-bottom: 8px;
}
.stat-value {
  font-size: 30px;
  font-weight: 600;
  color: var(--indigo-900);
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 10px;
}
.stat-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ink-500);
}
.stat-trend-up { color: var(--emerald-500); font-weight: 500; }
.stat-trend-down { color: var(--rose-500); font-weight: 500; }
.stat-glyph {
  position: absolute;
  top: 16px; right: 16px;
  width: 38px; height: 38px;
  border-radius: 12px;
  display: grid; place-items: center;
  color: white;
}
.stat-glyph svg { width: 18px; height: 18px; }
.g-indigo { background: linear-gradient(135deg, #4f46e5, #6366f1); }
.g-violet { background: linear-gradient(135deg, #7c3aed, #a78bfa); }
.g-emerald { background: linear-gradient(135deg, #059669, #34d399); }
.g-rose { background: linear-gradient(135deg, #e11d48, #fb7185); }
.g-amber { background: linear-gradient(135deg, #d97706, #fbbf24); }
.g-sky { background: linear-gradient(135deg, #0284c7, #38bdf8); }

/* ---------- Dashboard grid ---------- */
.dash-row {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
}
.dash-row.r2 { grid-template-columns: 2fr 1fr; }
.dash-row.r3 { grid-template-columns: 1fr 1fr 1fr; }
.dash-row.r2b { grid-template-columns: 1fr 2fr; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: -6px; padding: 6px; }
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.table thead th {
  text-align: left;
  font-weight: 500;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-500);
  padding: 10px 14px;
  border-bottom: 1px solid rgba(99, 102, 241, 0.15);
  background: rgba(255, 255, 255, 0.3);
  position: sticky; top: 0;
}
.table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(99, 102, 241, 0.08);
  color: var(--ink-700);
}
.table tbody tr {
  transition: background 0.15s;
  cursor: pointer;
}
.table tbody tr:hover {
  background: rgba(99, 102, 241, 0.06);
}
.table tbody tr.selected {
  background: rgba(99, 102, 241, 0.10);
}
.table thead th:first-child, .table tbody td:first-child { padding-left: 18px; }
.table thead th:last-child, .table tbody td:last-child { padding-right: 18px; }
.table .name-cell { display: flex; align-items: center; gap: 12px; }
.table .name-main { font-weight: 500; color: var(--ink-900); }
.table .name-sub { font-size: 11.5px; color: var(--ink-500); }
.table .row-actions {
  display: flex; gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.table tbody tr:hover .row-actions { opacity: 1; }
.icon-btn {
  background: transparent;
  border: none;
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-500);
  display: grid; place-items: center;
  transition: all 0.15s;
}
.icon-btn:hover { background: rgba(99, 102, 241, 0.12); color: var(--indigo-700); }
.icon-btn.danger:hover { background: rgba(244, 63, 94, 0.12); color: var(--rose-500); }
.icon-btn svg { width: 15px; height: 15px; }

/* ---------- Avatar ---------- */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: white;
  font-weight: 500;
  font-size: 13px;
  flex: 0 0 36px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.avatar-lg { width: 96px; height: 96px; font-size: 32px; flex: 0 0 96px; border-radius: 28px; }
.avatar-md { width: 44px; height: 44px; font-size: 15px; flex: 0 0 44px; }

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--glass-border-soft);
  font-size: 12.5px;
  color: var(--ink-700);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.filter-pill:hover { background: rgba(255, 255, 255, 0.85); }
.filter-pill.has-value {
  background: rgba(99, 102, 241, 0.12);
  color: var(--indigo-700);
  border-color: rgba(99, 102, 241, 0.3);
  font-weight: 500;
}
.filter-pill .x { color: currentColor; opacity: 0.7; cursor: pointer; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 27, 75, 0.35);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.18s ease;
  overflow-y: auto;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: var(--glass-shadow-lg);
  max-width: 100%;
  width: 560px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pop {
  from { transform: scale(0.94) translateY(8px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}
.modal.modal-wide { width: 820px; }
.modal.modal-xl { width: 1080px; }
.modal-head {
  padding: 20px 24px 16px;
  border-bottom: 1px solid rgba(99, 102, 241, 0.12);
  display: flex; align-items: center; gap: 12px;
}
.modal-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--indigo-900);
}
.modal-head .sub { font-size: 12.5px; color: var(--ink-500); margin-top: 2px; }
.modal-close { margin-left: auto; }
.modal-body { padding: 22px 24px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 14px 24px;
  border-top: 1px solid rgba(99, 102, 241, 0.12);
  display: flex; gap: 10px; justify-content: flex-end;
  background: rgba(255, 255, 255, 0.5);
}

/* ---------- Grid for form ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.form-grid .span-2 { grid-column: span 2; }
.form-section {
  margin-bottom: 22px;
}
.form-section-title {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--indigo-700);
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.form-section-title::before {
  content: '';
  width: 3px; height: 14px;
  background: linear-gradient(135deg, var(--indigo-600), var(--violet-500));
  border-radius: 2px;
}

/* ---------- Pagination ---------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px 4px;
  font-size: 12.5px;
  color: var(--ink-500);
}
.pager-btns { display: flex; gap: 4px; }
.pager-btn {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--ink-700);
  cursor: pointer;
  transition: all 0.15s;
}
.pager-btn:hover { background: rgba(99, 102, 241, 0.10); }
.pager-btn.active {
  background: var(--indigo-700);
  color: white;
}
.pager-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 200;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  box-shadow: var(--glass-shadow-lg);
  padding: 12px 16px 12px 14px;
  display: flex; align-items: center; gap: 10px;
  min-width: 260px;
  max-width: 380px;
  font-size: 13px;
  color: var(--ink-900);
  animation: slideInR 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes slideInR {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.toast .ic-wrap {
  width: 26px; height: 26px;
  border-radius: 8px;
  display: grid; place-items: center;
  color: white;
  flex: 0 0 26px;
}
.toast.success .ic-wrap { background: var(--emerald-500); }
.toast.info .ic-wrap { background: var(--indigo-600); }
.toast.warn .ic-wrap { background: var(--amber-500); }
.toast.error .ic-wrap { background: var(--rose-500); }
.toast .ic-wrap svg { width: 14px; height: 14px; }

/* ---------- Profile screen ---------- */
.profile-head {
  display: flex;
  gap: 22px;
  align-items: center;
  margin-bottom: 18px;
}
.profile-meta { flex: 1; }
.profile-meta h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: var(--indigo-900);
}
.profile-meta .sub { font-size: 13px; color: var(--ink-500); margin-top: 4px; }
.profile-meta .chip-row { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 24px;
}
.kv { font-size: 13.5px; }
.kv-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-500);
  font-weight: 500;
  margin-bottom: 4px;
}
.kv-value { color: var(--ink-900); font-weight: 400; }
.kv-value.muted { color: var(--ink-400); font-style: italic; font-weight: 300; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  border: 1px solid var(--glass-border-soft);
  width: fit-content;
  margin-bottom: 16px;
}
.tab {
  padding: 7px 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-500);
  cursor: pointer;
  background: transparent;
  border: none;
  font-family: inherit;
  transition: all 0.18s;
}
.tab:hover { color: var(--ink-900); }
.tab.active {
  background: white;
  color: var(--indigo-900);
  box-shadow: 0 2px 6px rgba(30, 27, 75, 0.08);
}

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 32px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 13px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: linear-gradient(to bottom, var(--indigo-300, #c7d2fe), rgba(199, 210, 254, 0.2));
}
.tl-item {
  position: relative;
  padding-bottom: 22px;
}
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute;
  left: -25px;
  top: 4px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--indigo-500);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.tl-dot.dot-call { border-color: var(--sky-500); }
.tl-dot.dot-line { border-color: var(--emerald-500); }
.tl-dot.dot-note { border-color: var(--amber-500); }
.tl-dot.dot-issue { border-color: var(--rose-500); }
.tl-dot.dot-appt { border-color: var(--violet-500); }
.tl-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.tl-title { font-size: 13.5px; font-weight: 500; color: var(--ink-900); }
.tl-meta { font-size: 11.5px; color: var(--ink-500); }
.tl-body { font-size: 13px; color: var(--ink-700); line-height: 1.55; }

/* ---------- Doc list ---------- */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.doc-card {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--glass-border-soft);
  border-radius: 14px;
  padding: 14px;
  transition: all 0.18s;
}
.doc-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--glass-shadow);
  background: rgba(255, 255, 255, 0.8);
}
.doc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.doc-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--indigo-100, #e0e7ff), var(--violet-300));
  display: grid; place-items: center;
  color: var(--indigo-700);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.doc-title { font-size: 13px; font-weight: 500; color: var(--ink-900); }
.doc-sub { font-size: 11.5px; color: var(--ink-500); }
.doc-foot { display: flex; align-items: center; justify-content: space-between; }

/* ---------- Empty state ---------- */
.empty {
  padding: 50px 20px;
  text-align: center;
  color: var(--ink-500);
}
.empty-icon {
  width: 56px; height: 56px;
  border-radius: 18px;
  background: rgba(99, 102, 241, 0.08);
  color: var(--indigo-500);
  display: grid; place-items: center;
  margin: 0 auto 14px;
}
.empty-title { font-size: 14px; color: var(--ink-700); font-weight: 500; margin-bottom: 4px; }
.empty-sub { font-size: 12.5px; }

/* ---------- Misc ---------- */
.divider {
  height: 1px;
  background: rgba(99, 102, 241, 0.12);
  margin: 18px 0;
}
.spacer-12 { height: 12px; }
.spacer-20 { height: 20px; }
.muted { color: var(--ink-500); }
.bold500 { font-weight: 500; }
.row { display: flex; gap: 10px; align-items: center; }
.row-between { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; }

.scroll-y { overflow-y: auto; }

/* small scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.25);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(99, 102, 241, 0.45); background-clip: padding-box; border: 2px solid transparent; }

/* ---------- Charts ---------- */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-700);
}
.chart-legend .swatch {
  width: 10px; height: 10px;
  border-radius: 3px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}
.donut-center {
  font-size: 24px;
  font-weight: 600;
  fill: var(--indigo-900);
}
.donut-center-sub {
  font-size: 11px;
  fill: var(--ink-500);
  font-weight: 400;
}

/* ---------- Responsive (basic) ---------- */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-row.r2, .dash-row.r2b, .dash-row.r3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* ================================================================
   ADDITIONS FOR VANILLA JS VERSION
   ================================================================ */

/* Modal box (replaces .modal in plain-JS version) */
.modal-box {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: var(--glass-shadow-lg);
  max-width: calc(100vw - 48px);
  width: 560px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-box.modal-wide { width: 820px; }
.modal-box.modal-xl   { width: 1080px; }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid rgba(99, 102, 241, 0.12);
  display: flex; align-items: flex-start; gap: 12px;
}
.modal-title {
  font-size: 17px; font-weight: 600; color: var(--indigo-900);
}
.modal-sub { font-size: 12.5px; color: var(--ink-500); margin-top: 2px; }
.modal-header > div:first-child { flex: 1; }
.modal-header .icon-btn { margin-left: auto; flex-shrink: 0; }

.modal-body { padding: 22px 24px; overflow-y: auto; flex: 1; }

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid rgba(99, 102, 241, 0.12);
  display: flex; gap: 10px; justify-content: flex-end;
  background: rgba(255, 255, 255, 0.5);
}

/* Status chip */
.status-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid;
  white-space: nowrap;
}

/* Avatar sizes */
.avatar-lg {
  width: 64px; height: 64px;
  border-radius: 18px;
  font-size: 22px; font-weight: 600; color: white;
  display: grid; place-items: center;
  margin: 0 auto;
}

/* Quick action button */
.quick-action {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 14px;
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(255,255,255,0.4);
  text-align: left; cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  width: 100%;
  color: inherit;
}
.quick-action:hover {
  background: rgba(255,255,255,0.85);
  transform: translateY(-1px);
}

/* Report sidebar button */
.report-btn {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px; border-radius: 12px;
  background: transparent;
  border: 1px solid transparent;
  text-align: left; cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  width: 100%;
  color: inherit;
}
.report-btn.active {
  background: linear-gradient(135deg, rgba(67,56,202,0.12), rgba(139,92,246,0.08));
  border-color: rgba(99,102,241,0.25);
}
.report-btn-icon {
  width: 32px; height: 32px; border-radius: 9px;
  background: rgba(99,102,241,0.12); color: #4f46e5;
  display: grid; place-items: center; flex: 0 0 32px;
}
.report-btn-icon.active {
  background: linear-gradient(135deg,#4f46e5,#818cf8);
  color: white;
}

/* Search input with icon */
.search-wrap { position: relative; }
.search-icon {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--ink-400); pointer-events: none;
  display: flex; align-items: center;
}
.search-input {
  width: 100%; padding: 9px 14px 9px 40px;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  font-family: inherit; font-size: 13.5px; color: var(--ink-900);
  outline: none; transition: all 0.2s;
  box-sizing: border-box;
}
.search-input:focus {
  background: rgba(255,255,255,0.95);
  border-color: rgba(99,102,241,0.4);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.search-input::placeholder { color: var(--ink-400); }

/* Filter select */
.filter-select {
  padding: 8px 12px;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  font-family: inherit; font-size: 12.5px; color: var(--ink-700);
  outline: none; cursor: pointer;
  transition: all 0.15s;
}
.filter-select:focus {
  border-color: rgba(99,102,241,0.4);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

/* Hover row */
.hover-row:hover { background: rgba(99,102,241,0.06); }

/* Form row */
.form-row {
  display: flex; gap: 14px; margin-bottom: 14px;
  flex-wrap: wrap;
}
.form-row .field { flex: 1; min-width: 160px; }

/* Required asterisk */
.req { color: var(--rose-500); margin-left: 2px; }

/* Additional gradient colors for avatars */
.g-teal    { background: linear-gradient(135deg, #0d9488, #2dd4bf); }
.g-fuchsia { background: linear-gradient(135deg, #a21caf, #e879f9); }

/* Timeline dot colors for new dot-* classes */
.tl-dot.dot-blue    { border-color: #0ea5e9; }
.tl-dot.dot-green   { border-color: #10b981; }
.tl-dot.dot-purple  { border-color: #8b5cf6; }
.tl-dot.dot-emerald { border-color: #059669; }
.tl-dot.dot-amber   { border-color: #f59e0b; }

/* Toast dismiss animation */
@keyframes slideOutR {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(30px); opacity: 0; }
}

/* Pager info */
.pager-info { font-size: 12.5px; color: var(--ink-500); }

/* Form - ensure textarea and select inherit .input styles */
textarea.input { resize: vertical; min-height: 80px; }
select.input { cursor: pointer; }

