/* ================================================================
   AMU PhD Research Management System — Design System
   Palette: AMU Institutional Green + Antique Gold
   Type:    Plus Jakarta Sans (UI) + Lora (display headings)
   ================================================================ */

:root {
  /* --- surfaces --- */
  --bg: #f5f5ef;
  --surface: #ffffff;
  --surface-2: #faf9f4;
  --surface-3: #f0efe7;
  --border: #e6e3d8;
  --border-strong: #d2cebc;

  /* --- ink --- */
  --ink-900: #0f1d18;
  --ink-800: #1c2e26;
  --ink-700: #324a3f;
  --ink-500: #5d6f65;
  --ink-400: #8a9890;
  --ink-300: #b3bfb6;

  /* --- AMU green --- */
  --primary-900: #0a3324;
  --primary-800: #0f4a33;
  --primary-700: #156040;
  --primary: #1a7a4f;
  --primary-600: #1e8a5a;
  --primary-100: #d3ebde;
  --primary-50: #ebf6f0;

  /* --- gold accent --- */
  --gold: #b8932a;
  --gold-soft: #d4ae3e;
  --gold-50: #fbf6e6;
  --gold-100: #f4e4b3;

  /* --- functional --- */
  --info: #1d4e89;
  --info-50: #eef3fb;
  --info-100: #d1ddf0;

  --success: #15803d;
  --success-50: #ecfdf3;
  --success-100: #c5e9d3;
  --warning: #b45309;
  --warning-50: #fff7ed;
  --warning-100: #fcd9b1;
  --danger: #b42318;
  --danger-50: #fef3f2;
  --danger-100: #fcd2cc;

  /* --- elevation --- */
  --shadow-xs: 0 1px 2px rgba(15, 29, 24, .04);
  --shadow-sm: 0 1px 2px rgba(15, 29, 24, .04), 0 1px 3px rgba(15, 29, 24, .06);
  --shadow-md: 0 4px 12px rgba(15, 29, 24, .06), 0 2px 4px rgba(15, 29, 24, .04);
  --shadow-lg: 0 10px 28px rgba(15, 29, 24, .10), 0 4px 8px rgba(15, 29, 24, .04);
  --shadow-xl: 0 24px 60px rgba(15, 29, 24, .18);
  --shadow-focus: 0 0 0 3px rgba(26, 122, 79, .18);

  /* --- radii --- */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;

  /* --- motion --- */
  --transition-fast: 120ms cubic-bezier(.4, .0, .2, 1);
  --transition: 180ms cubic-bezier(.4, .0, .2, 1);
  --transition-slow: 320ms cubic-bezier(.4, .0, .2, 1);

  /* --- type --- */
  --font-ui: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Lora", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink-900);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font-family: inherit; }
a { color: var(--primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--primary-700); text-decoration: underline; text-underline-offset: 3px; }
code, pre { font-family: var(--font-mono); font-size: 12.5px; }
h1, h2, h3, h4, h5 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; color: var(--ink-900); }
::selection { background: var(--primary-100); color: var(--primary-900); }

/* =================== Boot loader =================== */
.boot {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg); gap: 18px;
}
.boot-spinner {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  animation: spin 800ms linear infinite;
}
.boot-label { color: var(--ink-500); font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =================== Spinners & skeletons =================== */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  vertical-align: middle;
}
.spinner.lg { width: 28px; height: 28px; border-width: 3px; }

.btn.loading { color: transparent !important; pointer-events: none; position: relative; }
.btn.loading::after {
  content: ''; position: absolute; inset: 0;
  display: grid; place-items: center;
  color: white;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'><circle cx='12' cy='12' r='9' stroke-opacity='.3'/><path d='M21 12a9 9 0 0 1-9 9'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px;
  animation: spin 700ms linear infinite;
}
.btn.loading.btn:not(.btn-primary):not(.btn-success):not(.btn-danger)::after {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23324a3f' stroke-width='3'><circle cx='12' cy='12' r='9' stroke-opacity='.3'/><path d='M21 12a9 9 0 0 1-9 9'/></svg>");
}

.skeleton {
  display: inline-block;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 6px;
  color: transparent !important;
  user-select: none;
}
.skeleton.line { height: 12px; width: 100%; }
.skeleton.line.short { width: 40%; }
.skeleton.line.med { width: 65%; }
.skeleton.title { height: 22px; width: 30%; }
.skeleton.circle { border-radius: 50%; width: 36px; height: 36px; }
.skeleton.box { height: 80px; }
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.loading-overlay {
  position: relative; min-height: 200px;
}
.loading-overlay > .ovl {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(245, 245, 239, .7);
  backdrop-filter: blur(2px);
  z-index: 5;
  border-radius: var(--radius-lg);
}

/* =================== Layout =================== */
.app-shell {
  display: grid;
  grid-template-columns: 270px 1fr;
  min-height: 100vh;
  transition: grid-template-columns 220ms cubic-bezier(.4, 0, .2, 1);
}
.app-shell.collapsed { grid-template-columns: 76px 1fr; }
.drawer-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(7, 22, 16, .55);
  backdrop-filter: blur(2px);
  z-index: 40;
  opacity: 0; pointer-events: none;
  transition: opacity 220ms ease;
}
.sidebar {
  background:
    radial-gradient(at 10% 0%, rgba(184, 147, 42, .08), transparent 40%),
    linear-gradient(180deg, #073022 0%, #0a3a2a 100%);
  color: #c4d3cc;
  padding: 22px 14px 18px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, .04);
  overflow-x: hidden;
  transition: padding 220ms ease;
}
/* Collapsed (icon-only) on desktop */
.app-shell.collapsed .sidebar { padding: 22px 8px 14px; }
.app-shell.collapsed .brand { justify-content: center; padding: 4px 0 18px; gap: 0; }
.app-shell.collapsed .brand-text { display: none; }
.app-shell.collapsed .nav-section { display: none; }
.app-shell.collapsed .nav-link { justify-content: center; padding: 11px 8px; }
.app-shell.collapsed .nav-link span { display: none; }
.app-shell.collapsed .user-card { padding: 6px; justify-content: center; flex-wrap: wrap; gap: 6px; }
.app-shell.collapsed .user-info { display: none; }
.app-shell.collapsed .user-btn { padding: 4px; }
.app-shell.collapsed .version-tag { display: none; }
/* Tooltips on hover when collapsed */
.app-shell.collapsed .nav-link[data-tip],
.app-shell.collapsed .user-card[data-tip] { position: relative; }
.app-shell.collapsed .nav-link[data-tip]:hover::after,
.app-shell.collapsed .user-card[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; left: calc(100% + 14px); top: 50%;
  transform: translateY(-50%);
  background: var(--ink-900); color: white;
  padding: 7px 12px; border-radius: 7px;
  font-size: 12px; font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  z-index: 50;
  pointer-events: none;
}
.app-shell.collapsed .nav-link[data-tip]:hover::before,
.app-shell.collapsed .user-card[data-tip]:hover::before {
  content: '';
  position: absolute; left: calc(100% + 6px); top: 50%;
  transform: translateY(-50%) rotate(45deg);
  width: 8px; height: 8px;
  background: var(--ink-900);
  z-index: 50;
}
.version-tag { text-align: center; opacity: .6; font-size: 11px; margin-top: 6px; }
.user-info { flex: 1; min-width: 0; overflow: hidden; }
.user-info .user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Sidebar toggle in topbar */
.sidebar-toggle { color: var(--ink-700); margin-right: -4px; }
.sidebar-toggle:hover { background: var(--surface-3); color: var(--ink-900); }
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  margin-bottom: 14px;
}
.brand-emblem {
  width: 44px; height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  background: white;
  padding: 3px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .25), inset 0 0 0 1px rgba(212, 174, 62, .35);
  object-fit: contain;
}
.login-side .brand-emblem {
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25), inset 0 0 0 1px rgba(212, 174, 62, .55);
}
.login-hero-emblem {
  width: 110px; height: 110px;
  display: block;
  margin: 0 auto 24px;
  background: rgba(255, 255, 255, .96);
  border-radius: 50%;
  padding: 6px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .35), inset 0 0 0 2px rgba(212, 174, 62, .55);
  object-fit: contain;
}
.brand-title {
  font-family: var(--font-display);
  font-weight: 700; color: white; font-size: 16px;
  line-height: 1.15;
  letter-spacing: -.005em;
}
.brand-sub {
  font-size: 10px; color: #8fa89c; letter-spacing: .14em;
  text-transform: uppercase; margin-top: 4px; font-weight: 600;
}
.nav-section {
  font-size: 10px; letter-spacing: .14em; color: #6f8579;
  text-transform: uppercase;
  margin: 16px 12px 6px; font-weight: 600;
}
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 9px;
  color: #a8bcb1;
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500; font-size: 13.5px;
  user-select: none;
}
.nav-link:hover { background: rgba(255, 255, 255, .05); color: white; }
.nav-link.active {
  background: linear-gradient(90deg, rgba(184, 147, 42, .18), rgba(30, 138, 90, .04));
  color: white;
  box-shadow: inset 2px 0 0 var(--gold);
}
.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .85; }
.nav-link.active svg { opacity: 1; color: var(--gold-soft); }
.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, .06);
  font-size: 11px; color: #8fa89c;
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .04);
  margin-bottom: 10px;
  transition: var(--transition);
}
.user-card:hover { background: rgba(255, 255, 255, .08); }
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-700));
  color: white;
  display: grid; place-items: center;
  font-weight: 600; font-size: 12px;
  flex-shrink: 0;
  font-family: var(--font-display);
  letter-spacing: -.02em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2);
}
.user-name { color: white; font-weight: 600; font-size: 13px; line-height: 1.2; }
.user-role {
  color: var(--gold-soft); font-size: 10px;
  text-transform: uppercase; letter-spacing: .1em;
  margin-top: 2px; font-weight: 600;
}

.main { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.topbar {
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--border);
  padding: 12px 28px;
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 10;
  min-height: 60px;
  backdrop-filter: saturate(180%) blur(12px);
}
.crumb {
  font-size: 13px; color: var(--ink-500);
  display: flex; align-items: center; gap: 8px;
  font-weight: 500;
}
.crumb a { color: var(--ink-500); }
.crumb a:hover { color: var(--ink-900); text-decoration: none; }
.crumb b { color: var(--ink-900); font-weight: 600; }

.search-input-wrap { position: relative; flex: 1; max-width: 480px; }
.search-input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px; color: var(--ink-900);
  transition: var(--transition);
}
.search-input::placeholder { color: var(--ink-400); }
.search-input:hover { border-color: var(--border-strong); }
.search-input:focus {
  outline: none; border-color: var(--primary);
  background: white; box-shadow: var(--shadow-focus);
}
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--ink-400); width: 16px; height: 16px;
  pointer-events: none;
}
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.content { padding: 28px 28px 60px; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-title {
  font-family: var(--font-display);
  font-size: 26px; font-weight: 600; margin: 0;
  letter-spacing: -.015em; color: var(--ink-900);
  line-height: 1.18;
}
.page-sub {
  color: var(--ink-500); font-size: 13.5px; margin-top: 6px;
  max-width: 720px; line-height: 1.55;
}
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* =================== Cards =================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  overflow: hidden;
}
.card-pad { padding: 20px 22px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-weight: 600; font-size: 14px; color: var(--ink-900);
  letter-spacing: -.005em;
}
.card-sub { color: var(--ink-500); font-size: 12px; margin-top: 3px; }

.card[data-id], .card[style*="cursor:pointer"] { cursor: pointer; }
.card[data-id]:hover, .card[style*="cursor:pointer"]:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-100);
  transform: translateY(-1px);
}

.grid { display: grid; gap: 16px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }

.stat {
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.stat::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--primary);
}
.stat::after {
  content: ''; position: absolute; right: -30px; top: -30px;
  width: 100px; height: 100px; border-radius: 50%;
  background: radial-gradient(closest-side, var(--primary-50), transparent);
  opacity: .6;
  pointer-events: none;
}
.stat:hover { box-shadow: var(--shadow-sm); border-color: var(--primary-100); }
.stat.success::before { background: var(--success); }
.stat.success::after  { background: radial-gradient(closest-side, var(--success-50), transparent); }
.stat.warning::before { background: var(--warning); }
.stat.warning::after  { background: radial-gradient(closest-side, var(--warning-50), transparent); }
.stat.accent::before  { background: var(--gold); }
.stat.accent::after   { background: radial-gradient(closest-side, var(--gold-50), transparent); }
.stat.danger::before  { background: var(--danger); }
.stat.danger::after   { background: radial-gradient(closest-side, var(--danger-50), transparent); }
.stat-label {
  color: var(--ink-500); font-size: 11px; text-transform: uppercase;
  letter-spacing: .09em; font-weight: 600;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 30px; font-weight: 600; color: var(--ink-900);
  letter-spacing: -.02em; font-feature-settings: "tnum";
  line-height: 1.1;
}
.stat-hint { color: var(--ink-500); font-size: 12px; }

/* =================== Buttons =================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: white;
  color: var(--ink-900);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  user-select: none;
  position: relative;
  box-shadow: var(--shadow-xs);
  letter-spacing: -.005em;
}
.btn:hover {
  background: var(--surface-2);
  border-color: var(--ink-400);
  box-shadow: var(--shadow-sm);
}
.btn:active { transform: translateY(1px); box-shadow: var(--shadow-xs); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; box-shadow: var(--shadow-xs); }
.btn-primary {
  background: linear-gradient(180deg, var(--primary-600), var(--primary-700));
  border-color: var(--primary-700);
  color: white;
  box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, var(--shadow-sm);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--primary), var(--primary-800)); border-color: var(--primary-800); color: white; }
.btn-success {
  background: linear-gradient(180deg, var(--success), #126d36);
  border-color: #0f5e2e; color: white;
  box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, var(--shadow-sm);
}
.btn-success:hover { background: linear-gradient(180deg, #126d36, #0f5e2e); color: white; }
.btn-danger {
  background: linear-gradient(180deg, var(--danger), #971c14);
  border-color: #871810; color: white;
  box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, var(--shadow-sm);
}
.btn-danger:hover { background: linear-gradient(180deg, #971c14, #871810); color: white; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-500); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink-900); box-shadow: none; transform: none; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 7px; }
.btn-icon { padding: 8px; aspect-ratio: 1; }
.btn-sm.btn-icon { padding: 6px; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* =================== Forms =================== */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label {
  font-size: 12px; color: var(--ink-700); font-weight: 600;
  letter-spacing: .005em;
  display: flex; align-items: center; gap: 4px;
}
.input, select, textarea {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: white;
  font-size: 13.5px;
  color: var(--ink-900);
  transition: var(--transition);
  width: 100%; line-height: 1.45;
}
.input:hover, select:hover, textarea:hover { border-color: var(--ink-400); }
.input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: var(--shadow-focus); background: white;
}
.input::placeholder, textarea::placeholder { color: var(--ink-400); }
.input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--ink-500); cursor: not-allowed; }
.input[readonly] { background: var(--surface-2); color: var(--ink-700); cursor: not-allowed; }
textarea { resize: vertical; min-height: 80px; line-height: 1.55; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235d6f65' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px;
  appearance: none; -webkit-appearance: none; padding-right: 32px;
}
select[multiple] { background-image: none; padding-right: 12px; }
.help { color: var(--ink-500); font-size: 12px; line-height: 1.5; }

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

/* =================== Tables =================== */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  scrollbar-color: var(--border-strong) transparent;
  scrollbar-width: thin;
}
.table-wrap::-webkit-scrollbar { height: 10px; width: 10px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: var(--ink-400); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table thead th {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  font-weight: 600; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-500);
  text-align: left;
  position: sticky; top: 0; white-space: nowrap; z-index: 1;
}
.table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle; white-space: nowrap;
  color: var(--ink-800);
}
.table tbody tr { transition: background-color var(--transition-fast); }
.table tbody tr:hover td { background: var(--primary-50); }
.table tbody tr:last-child td { border-bottom: none; }
.table .clickable { cursor: pointer; }
.table .clickable:hover td { background: var(--primary-50); }
.table .clickable:hover td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.table tbody td b { color: var(--ink-900); font-weight: 600; }

/* =================== Badges =================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: var(--surface-3);
  color: var(--ink-700);
  border: 1px solid var(--border);
  letter-spacing: .005em; line-height: 1.45;
  white-space: nowrap;
}
.badge.success { background: var(--success-50); color: var(--success); border-color: var(--success-100); }
.badge.warning { background: var(--warning-50); color: var(--warning); border-color: var(--warning-100); }
.badge.danger  { background: var(--danger-50);  color: var(--danger); border-color: var(--danger-100); }
.badge.info    { background: var(--info-50);    color: var(--info); border-color: var(--info-100); }
.badge.gold    { background: var(--gold-50);    color: var(--gold); border-color: var(--gold-100); }
.badge.muted   { background: var(--surface-3);  color: var(--ink-500); }
.badge.lg      { padding: 4px 12px; font-size: 12px; }

/* =================== Toast =================== */
.toast-host {
  position: fixed; top: 18px; right: 18px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 200; pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 14px 16px;
  min-width: 280px; max-width: 400px;
  display: flex; align-items: flex-start; gap: 10px;
  animation: slideIn 240ms cubic-bezier(.4, 0, .2, 1);
  border-left: 4px solid var(--primary);
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warn    { border-left-color: var(--warning); }
.toast-title { font-weight: 600; font-size: 13px; color: var(--ink-900); letter-spacing: -.005em; }
.toast-body  { color: var(--ink-500); font-size: 12.5px; margin-top: 2px; line-height: 1.45; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* =================== Modal =================== */
.modal-host {
  position: fixed; inset: 0;
  background: rgba(15, 29, 24, .55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
  backdrop-filter: blur(6px);
  animation: fadeIn 180ms ease-out;
}
.modal-host.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%; max-width: 540px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  animation: fadeUp 240ms cubic-bezier(.16, 1, .3, 1);
  overflow: hidden;
}
.modal.lg { max-width: 760px; }
.modal.xl { max-width: 980px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.modal-title { font-family: var(--font-display); font-weight: 600; font-size: 18px; letter-spacing: -.01em; color: var(--ink-900); }
.modal-body  { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
@keyframes fadeUp {
  from { transform: translateY(12px) scale(.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* =================== Login =================== */
.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--bg); }
.login-side {
  background:
    radial-gradient(at 15% 20%, rgba(184, 147, 42, .25), transparent 50%),
    radial-gradient(at 85% 80%, rgba(30, 138, 90, .35), transparent 50%),
    linear-gradient(135deg, #062919 0%, #0a3a2a 60%, #0e4a36 130%);
  color: white;
  padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-side::before {
  content: ''; position: absolute; right: -120px; top: -120px;
  width: 400px; height: 400px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(212, 174, 62, .15), transparent);
}
.login-brand { display: flex; align-items: center; gap: 14px; position: relative; z-index: 1; }
.login-brand .brand-emblem { width: 56px; height: 56px; }
.login-brand .brand-title { font-size: 18px; }
.login-brand .brand-sub { font-size: 11px; }
.login-side h1 {
  font-family: var(--font-display);
  font-size: 38px; font-weight: 600; line-height: 1.18;
  margin: 0 0 14px; position: relative; z-index: 1;
  letter-spacing: -.02em; color: white;
}
.login-side h1 em { color: var(--gold-soft); font-style: normal; }
.login-side p {
  color: #c9dccf; font-size: 15px;
  max-width: 420px; position: relative; z-index: 1;
  line-height: 1.6;
}
.login-features { display: flex; flex-direction: column; gap: 14px; position: relative; z-index: 1; }
.login-feature { display: flex; gap: 12px; font-size: 13.5px; color: #d6e4dc; align-items: flex-start; }
.login-feature svg { width: 18px; height: 18px; color: var(--gold-soft); flex-shrink: 0; margin-top: 2px; }
.login-form-side { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-card { width: 100%; max-width: 400px; }
.login-card h2 {
  font-family: var(--font-display);
  margin: 0 0 8px; font-size: 26px;
  letter-spacing: -.02em; color: var(--ink-900);
  font-weight: 600;
}
.login-card .help { margin-bottom: 28px; font-size: 13.5px; }
.login-card .btn-primary { padding: 12px 14px; font-size: 14px; font-weight: 600; }

/* =================== Misc =================== */
.empty-state { text-align: center; padding: 64px 24px; color: var(--ink-500); }
.empty-state h3 {
  font-family: var(--font-display);
  color: var(--ink-700); font-size: 17px;
  margin: 8px 0 6px; font-weight: 600;
  letter-spacing: -.01em;
}
.empty-state p { font-size: 13.5px; max-width: 360px; margin: 0 auto; line-height: 1.55; }

.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex-gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.text-muted { color: var(--ink-500); }
.text-sm { font-size: 12px; }
.mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 18px; } .mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 18px; } .mb-4 { margin-bottom: 24px; }
.hidden { display: none !important; }

/* =================== Tabs =================== */
.tab-bar { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.tab {
  padding: 12px 18px; cursor: pointer;
  border-bottom: 2px solid transparent;
  color: var(--ink-500); font-weight: 500; font-size: 13.5px;
  transition: var(--transition); margin-bottom: -1px;
  letter-spacing: -.005em;
}
.tab:hover { color: var(--ink-900); }
.tab.active {
  color: var(--primary-700);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* =================== Step strip (multi-step flows) =================== */
.step-strip {
  display: flex; align-items: center; gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 22px;
  box-shadow: var(--shadow-xs);
}
.step { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-3);
  color: var(--ink-500);
  font-size: 12px; font-weight: 700;
  border: 1px solid var(--border-strong);
  transition: var(--transition);
}
.step-num svg { width: 14px; height: 14px; }
.step.active .step-num {
  background: var(--primary);
  color: white;
  border-color: var(--primary-700);
  box-shadow: 0 0 0 4px var(--primary-50);
}
.step.done .step-num {
  background: var(--success);
  color: white;
  border-color: var(--success);
}
.step-label { font-size: 13px; color: var(--ink-500); font-weight: 500; }
.step.active .step-label { color: var(--ink-900); font-weight: 600; }
.step.done .step-label { color: var(--success); font-weight: 600; }
.step-line {
  flex: 1; height: 2px;
  background: var(--border);
  margin: 0 14px;
  border-radius: 2px;
  transition: background var(--transition);
}
.step-line.done { background: var(--success); }

@media (max-width: 700px) {
  .step-strip { padding: 12px 14px; }
  .step-label { display: none; }
  .step-line { margin: 0 8px; }
}

/* =================== Dropzone =================== */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 56px 30px;
  text-align: center; cursor: pointer;
  transition: var(--transition);
  background: var(--surface-2);
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--primary); background: var(--primary-50);
  transform: translateY(-1px);
}
.dropzone svg { width: 42px; height: 42px; color: var(--primary); }
.dropzone p { color: var(--ink-500); margin: 8px 0 0; font-size: 13.5px; }
.dropzone strong {
  font-family: var(--font-display);
  color: var(--ink-900); display: block; margin-top: 14px;
  font-size: 17px; letter-spacing: -.01em; font-weight: 600;
}

/* =================== Chips & faculty tiles =================== */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary-50);
  color: var(--primary-700);
  font-size: 11.5px; font-weight: 500;
  border: 1px solid var(--primary-100);
  letter-spacing: -.005em;
}
.chip .x { cursor: pointer; opacity: .5; }
.chip .x:hover { opacity: 1; }

.tile-mark {
  width: 44px; height: 44px;
  border-radius: 11px;
  display: grid; place-items: center;
  color: white; font-weight: 700; font-size: 14px;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
  letter-spacing: -.02em;
  font-family: var(--font-display);
  background: linear-gradient(135deg, var(--primary), var(--primary-700));
}
.tile-mark.gold { background: linear-gradient(135deg, var(--gold), #8e6f1c); }
.tile-mark.info { background: linear-gradient(135deg, var(--info), #143869); }
.tile-mark svg { width: 22px; height: 22px; }

.chart-wrap { position: relative; height: 280px; }
.chart-wrap.tall { height: 360px; }

.pagination {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 16px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--ink-500);
  background: var(--surface-2);
}

/* =================== Student profile =================== */
.profile-hero {
  background:
    radial-gradient(at 100% 0%, rgba(184, 147, 42, .12), transparent 50%),
    linear-gradient(135deg, #f7faf6 0%, #ecf3ee 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 30px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 24px;
  align-items: center;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.profile-hero::before {
  content: ''; position: absolute; right: -80px; bottom: -80px;
  width: 240px; height: 240px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(30, 138, 90, .08), transparent);
  pointer-events: none;
}
.profile-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-800));
  color: white;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 600; font-size: 28px;
  letter-spacing: -.02em;
  box-shadow: 0 8px 22px rgba(15, 74, 51, .25), inset 0 1px 0 rgba(255, 255, 255, .25);
  flex-shrink: 0;
  position: relative; z-index: 1;
}
.profile-name {
  font-family: var(--font-display);
  font-size: 28px; font-weight: 600;
  color: var(--ink-900);
  margin: 0; line-height: 1.2;
  letter-spacing: -.015em;
  position: relative; z-index: 1;
}
.profile-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 8px; color: var(--ink-500);
  font-size: 13px;
}
.profile-meta b { color: var(--ink-900); font-weight: 600; font-family: var(--font-mono); font-size: 12.5px; }

.profile-section {
  margin-bottom: 22px;
}
.profile-section-title {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display);
  font-size: 13px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink-500);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.profile-section-title svg {
  width: 16px; height: 16px;
  color: var(--primary);
}

.profile-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 4px 28px;
}
.profile-field {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}
.profile-field:last-child { border-bottom: none; }
.profile-field-label {
  font-size: 11px;
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 600;
}
.profile-field-value {
  font-size: 14px;
  color: var(--ink-900);
  font-weight: 500;
  word-break: break-word; white-space: pre-wrap;
  line-height: 1.5;
  min-height: 22px;
}
.profile-field-value.empty { color: var(--ink-400); font-weight: 400; font-style: italic; }
.profile-field-value.editable {
  padding: 6px 10px;
  margin: -6px -10px;
  border-radius: 7px;
  cursor: text;
  border: 1px dashed transparent;
  transition: var(--transition-fast);
}
.profile-field-value.editable:hover {
  border-color: var(--border-strong);
  background: white;
}
.profile-field-value.editable.editing {
  background: white;
  border-style: solid;
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
  outline: none;
}
.profile-field.full { grid-column: 1 / -1; }
.profile-field.full .profile-field-value { font-size: 14px; line-height: 1.6; }

/* compact KV-grid kept for legacy uses */
.kv-grid { display: grid; grid-template-columns: 220px 1fr; gap: 4px 24px; }
.kv-grid dt { color: var(--ink-500); font-size: 11px; padding: 10px 0; border-bottom: 1px dashed var(--border); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.kv-grid dd { margin: 0; padding: 10px 0; border-bottom: 1px dashed var(--border); color: var(--ink-900); font-size: 13.5px; word-break: break-word; white-space: pre-wrap; line-height: 1.55; }

/* =================== Animations =================== */
.sup-list { animation: slideDown 200ms ease-out; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* =================== Numeric font =================== */
.num { font-feature-settings: "tnum"; }

/* =================== Responsive =================== */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  /* Sidebar becomes a slide-in drawer */
  .app-shell, .app-shell.collapsed { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0;
    width: 280px; height: 100vh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 240ms cubic-bezier(.4, 0, .2, 1);
    box-shadow: var(--shadow-xl);
    padding: 22px 14px 18px !important;
  }
  /* Drawer-open state */
  .app-shell.drawer-open .sidebar { transform: translateX(0); }
  .app-shell.drawer-open .drawer-backdrop { display: block; opacity: 1; pointer-events: auto; }
  /* Reset collapsed-mode visuals on mobile (drawer always shows full) */
  .app-shell.collapsed .brand,
  .app-shell.collapsed .nav-link,
  .app-shell.collapsed .user-card { justify-content: flex-start; padding: 10px 12px; }
  .app-shell.collapsed .brand { padding: 4px 8px 18px; gap: 12px; }
  .app-shell.collapsed .brand-text,
  .app-shell.collapsed .nav-section,
  .app-shell.collapsed .nav-link span,
  .app-shell.collapsed .user-info,
  .app-shell.collapsed .version-tag { display: revert; }
  .app-shell.collapsed .user-card { padding: 10px; }
  .app-shell.collapsed .user-btn { padding: 8px; }

  .login-shell { grid-template-columns: 1fr; }
  .login-side { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .content { padding: 18px 16px 60px; }
  .topbar { padding: 10px 14px; gap: 10px; }
  .profile-hero { grid-template-columns: 1fr; text-align: center; padding: 22px 18px; gap: 16px; }
  .profile-hero > div:last-child { align-items: center !important; }
  .profile-fields { grid-template-columns: 1fr; gap: 0; }
  .profile-name { font-size: 24px; }
  .profile-meta { justify-content: center; }
  .page-title { font-size: 22px; }
  .modal { max-height: calc(100vh - 32px); border-radius: var(--radius-lg); }
  .modal-host { padding: 12px; align-items: flex-end; }
  .stat-value { font-size: 24px; }
  .table thead th, .table tbody td { padding: 10px 12px; }

  /* Search field fades into a smaller form on tight screens */
  .search-input-wrap { max-width: 220px; }
}

@media (max-width: 600px) {
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn { padding: 8px; }
  .search-input-wrap { display: none; }
  .crumb { font-size: 12px; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .page-head { gap: 10px; margin-bottom: 16px; }
  .page-actions { gap: 6px; }
  .login-side { display: none; }
  .login-form-side { padding: 24px 18px; }
}

@media (max-width: 420px) {
  .grid-stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .stat-value { font-size: 22px; }
}
