/* ==========================================================================
   Kingsfield University Portal - design system
   Palette: deep navy + warm brass/gold, cool light neutrals (no cream)
   Type: Cormorant Garamond (display) + Archivo (UI)
   ========================================================================== */

:root {
  /* Navy scale */
  --navy-900: #081524;
  --navy-800: #0c2138;
  --navy-700: #113054;
  --navy-600: #17406e;
  --navy-500: #1f527f;
  --navy-tint: #eef3f9;

  /* Brass / gold accent */
  --gold-600: #a67c2e;
  --gold-500: #c39a4d;
  --gold-400: #d7b877;
  --gold-300: #e7d3a3;
  --gold-glow: rgba(199, 154, 77, 0.22);

  /* Neutrals (cool, never cream) */
  --ink: #121a26;
  --slate-700: #33404f;
  --slate-500: #5c6a7a;
  --slate-400: #8593a3;
  --line: #dde4ec;
  --line-soft: #eaeff5;
  --paper: #f4f7fb;
  --white: #ffffff;

  /* Semantic */
  --success: #1c7a57;
  --success-bg: #e4f3ec;
  --warning: #a97514;
  --warning-bg: #fbf1dd;
  --danger: #b23a3a;
  --danger-bg: #f8e6e6;
  --info: #1f527f;
  --info-bg: #e7eef6;

  --font-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-ui: "Archivo", "Segoe UI", Helvetica, Arial, sans-serif;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(12, 33, 56, 0.06), 0 1px 3px rgba(12, 33, 56, 0.08);
  --shadow: 0 6px 18px rgba(12, 33, 56, 0.08), 0 2px 6px rgba(12, 33, 56, 0.06);
  --shadow-lg: 0 24px 60px rgba(8, 21, 36, 0.22);

  --sidebar-w: 264px;
  --topbar-h: 68px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 0.4em; font-weight: 600; line-height: 1.15; }
p { margin: 0 0 1em; }
a { color: var(--navy-600); text-decoration: none; }
a:hover { color: var(--navy-500); }

.display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.2px;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-600);
  font-weight: 600;
}

.muted { color: var(--slate-500); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- crest ---------- */
.crest { display: inline-flex; align-items: center; gap: 12px; }
.crest-mark { width: 40px; height: 40px; flex: none; }
.crest-name { font-family: var(--font-display); font-weight: 700; line-height: 1; }
.crest-name b { display: block; font-size: 20px; letter-spacing: 0.3px; }
.crest-name span { font-family: var(--font-ui); font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold-600); font-weight: 600; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-ui); font-size: 14px; font-weight: 600;
  padding: 11px 20px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer; transition: all 0.16s ease;
  text-decoration: none; white-space: nowrap; line-height: 1;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--navy-700); color: #fff; }
.btn-primary:hover { background: var(--navy-600); color: #fff; }
.btn-gold { background: linear-gradient(180deg, var(--gold-400), var(--gold-500)); color: var(--navy-900); }
.btn-gold:hover { filter: brightness(1.04); color: var(--navy-900); }
.btn-ghost { background: transparent; color: var(--navy-700); border-color: var(--line); }
.btn-ghost:hover { background: var(--navy-tint); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.05); color: #fff; }
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--slate-700); margin-bottom: 6px; }
.input, .select, textarea.input {
  width: 100%; font-family: var(--font-ui); font-size: 15px; color: var(--ink);
  padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none; border-color: var(--gold-500); box-shadow: 0 0 0 3px var(--gold-glow);
}
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235c6a7a' d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px; }

/* ---------- cards ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 22px 24px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 24px; border-bottom: 1px solid var(--line-soft); }
.card-head h3 { margin: 0; font-size: 16px; }
.card-title-serif { font-family: var(--font-display); font-size: 22px; font-weight: 600; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 100px; line-height: 1.3; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--line-soft); color: var(--slate-500); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--slate-400); font-weight: 700; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data tbody tr:hover { background: var(--navy-tint); }
table.data tbody tr:last-child td { border-bottom: none; }

/* ---------- stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--gold-500); }
.stat .stat-label { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--slate-400); font-weight: 700; }
.stat .stat-value { font-family: var(--font-display); font-size: 34px; font-weight: 600; color: var(--navy-700); line-height: 1.1; margin-top: 4px; }
.stat .stat-sub { font-size: 12.5px; color: var(--slate-500); margin-top: 2px; }

/* ---------- app shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--navy-800); color: #cdd8e6;
  display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 40;
}
.sidebar-brand { padding: 20px 22px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-brand .crest-name b { color: #fff; font-size: 19px; }
.sidebar-nav { padding: 14px 12px; overflow-y: auto; flex: 1; }
.nav-group-label { font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: #6f8299; padding: 14px 12px 6px; font-weight: 700; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: #b9c6d6; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.14s; margin-bottom: 2px; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--navy-600); color: #fff; }
.nav-item.active .nav-ico { color: var(--gold-400); }
.nav-ico { width: 19px; height: 19px; flex: none; color: #8ea1b7; }
.nav-item.active .nav-ico, .nav-item:hover .nav-ico { color: var(--gold-400); }
.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,0.08); }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h); background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 28px; position: sticky; top: 0; z-index: 30;
}
.topbar .page-title { font-family: var(--font-display); font-size: 24px; font-weight: 600; color: var(--navy-800); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.icon-btn { width: 40px; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--slate-500); position: relative; }
.icon-btn:hover { background: var(--navy-tint); color: var(--navy-700); }
.icon-btn .pip { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); border: 1.5px solid #fff; }

.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--navy-700); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex: none; overflow: hidden; }
.avatar.gold { background: linear-gradient(180deg, var(--gold-400), var(--gold-600)); color: var(--navy-900); }

.usermenu { display: flex; align-items: center; gap: 11px; cursor: pointer; padding: 5px 8px 5px 5px; border-radius: 100px; border: 1px solid var(--line); }
.usermenu:hover { background: var(--navy-tint); }
.usermenu .um-name { font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.usermenu .um-role { font-size: 11.5px; color: var(--slate-400); line-height: 1.2; }

.content { padding: 28px; flex: 1; }
.page-lead { color: var(--slate-500); margin: -4px 0 22px; max-width: 70ch; }

/* ---------- layout helpers ---------- */
.row { display: flex; gap: 20px; }
.col { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.gap-16 { gap: 16px; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 14px; }

/* ---------- progress / meter ---------- */
.meter { height: 8px; border-radius: 100px; background: var(--line-soft); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 100px; background: linear-gradient(90deg, var(--gold-500), var(--gold-400)); }

/* ---------- toast ---------- */
.toast-wrap { position: fixed; right: 24px; bottom: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--navy-800); color: #fff; padding: 13px 18px; border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: 14px; display: flex; align-items: center; gap: 10px; min-width: 260px; animation: toastin 0.25s ease; border-left: 3px solid var(--gold-500); }
.toast.success { border-left-color: var(--success); }
.toast.danger { border-left-color: var(--danger); }
@keyframes toastin { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(8, 21, 36, 0.55); backdrop-filter: blur(3px); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; animation: fadein 0.18s ease; }
.modal { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; animation: modalin 0.22s ease; }
.modal-head { padding: 20px 26px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-family: var(--font-display); font-size: 24px; margin: 0; }
.modal-body { padding: 24px 26px; }
.modal-foot { padding: 18px 26px; border-top: 1px solid var(--line-soft); display: flex; justify-content: flex-end; gap: 12px; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalin { from { transform: translateY(12px) scale(0.99); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }

/* ---------- misc ---------- */
.divider { height: 1px; background: var(--line-soft); margin: 20px 0; }
.pill-tabs { display: inline-flex; gap: 4px; background: var(--navy-tint); padding: 4px; border-radius: 100px; }
.pill-tab { padding: 7px 16px; border-radius: 100px; font-size: 13px; font-weight: 600; color: var(--slate-500); cursor: pointer; border: none; background: transparent; }
.pill-tab.active { background: #fff; color: var(--navy-700); box-shadow: var(--shadow-sm); }
.empty { text-align: center; padding: 48px 24px; color: var(--slate-400); }
.empty svg { opacity: 0.5; margin-bottom: 12px; }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; font-size: 14px; }
.kv dt { color: var(--slate-500); }
.kv dd { margin: 0; font-weight: 500; }

.hide { display: none !important; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); transition: transform 0.25s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex !important; }
}
.menu-toggle { display: none; }
