/* ==========================================================
   Library Science Admissions — UI stylesheet (no build step)
   ========================================================== */
:root {
  --ink: #16323d;
  --primary: #1f5566;
  --primary-600: #194656;
  --primary-50: #e9f1f3;
  --accent: #c9822b;
  --accent-50: #fbf2e6;
  --bg: #f4f3ef;
  --surface: #ffffff;
  --line: #e2e0d9;
  --line-strong: #cfccc3;
  --muted: #6b7378;
  --text: #1c2529;
  --green: #2f7d4f; --green-50: #e7f3ec;
  --amber: #a86a00; --amber-50: #fcf1dc;
  --red: #b23a35;   --red-50: #fbe9e8;
  --blue: #2c5f9e;  --blue-50: #e8eff8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(22, 50, 61, .06), 0 2px 8px rgba(22, 50, 61, .05);
  --sidebar: 240px;
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; color: var(--ink); letter-spacing: -.01em; }
h1 { font-size: 1.45rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
small, .muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .92em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); background: var(--ink); color: #cfdde1; position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column; z-index: 40; transition: transform .2s ease;
}
.brand { padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand b { display: block; color: #fff; font-size: 1.02rem; }
.brand span { font-size: .75rem; color: #9fb6bd; }
.brand .mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 800; margin-bottom: 10px; }
.nav { padding: 12px 10px; display: grid; gap: 2px; flex: 1; overflow-y: auto; align-content: start; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #cfdde1; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(255,255,255,.12); color: #fff; }
.nav .count { margin-left: auto; background: var(--accent); color: #fff; font-size: .72rem; padding: 1px 7px; border-radius: 10px; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav .sep { height: 1px; background: rgba(255,255,255,.08); margin: 8px 4px; }
.me { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: .85rem; }
.me b { color: #fff; display: block; }
.me button { background: none; border: 0; color: #9fb6bd; padding: 0; cursor: pointer; font: inherit; margin-top: 4px; }
.me button:hover { color: #fff; }

.main { flex: 1; margin-left: var(--sidebar); min-width: 0; }
.topbar { display: none; }
.content { padding: 26px 30px 60px; max-width: 1280px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.stack { display: grid; gap: 18px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

/* ---------- Metrics ---------- */
.section-label { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; }
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.metric { display: block; padding: 14px 16px; border-left: 3px solid var(--line-strong); color: inherit; }
.metric:hover { text-decoration: none; border-color: var(--primary); }
.metric .v { font-size: 1.65rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.metric .l { font-size: .82rem; color: var(--muted); }
.metric.green { border-left-color: var(--green); }
.metric.red { border-left-color: var(--red); }
.metric.amber { border-left-color: var(--accent); }
.metric.teal { border-left-color: var(--primary); }
.metric.ink { border-left-color: var(--ink); }
.money { font-variant-numeric: tabular-nums; }
.fin { padding: 16px 18px; }
.fin .v { font-size: 1.45rem; font-weight: 700; color: var(--ink); }
.bar { height: 8px; background: var(--primary-50); border-radius: 6px; overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; background: var(--primary); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600;
  cursor: pointer; line-height: 1.2; white-space: nowrap; min-height: 40px;
}
.btn:hover { text-decoration: none; background: #faf9f6; border-color: var(--muted); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: #b37222; border-color: #b37222; }
.btn-danger { color: var(--red); border-color: #e6c3c1; }
.btn-danger:hover { background: var(--red-50); border-color: var(--red); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 16px; }
.f { grid-column: span 4; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.f.s3 { grid-column: span 3; } .f.s6 { grid-column: span 6; } .f.s8 { grid-column: span 8; } .f.s12 { grid-column: span 12; } .f.s2 { grid-column: span 2; }
.f label, .label { font-size: .8rem; font-weight: 600; color: #3b464b; }
.f label .req { color: var(--red); }
.input, .f input:not([type=checkbox]):not([type=radio]), .f select, .f textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff;
  font: inherit; color: var(--text); min-height: 42px;
}
.f textarea { min-height: 76px; resize: vertical; }
.f input:focus, .f select:focus, .f textarea:focus, .input:focus { outline: 2px solid rgba(31, 85, 102, .25); border-color: var(--primary); }
.f input[disabled], .f select[disabled], .f textarea[disabled] { background: #f3f2ee; color: #4b555a; }
.f .hint { font-size: .76rem; color: var(--muted); }
.f .err { font-size: .78rem; color: var(--red); }
.f.has-err input, .f.has-err select, .f.has-err textarea { border-color: var(--red); }
.suffix { position: relative; }
.suffix input { padding-right: 34px !important; }
.suffix span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .9rem; pointer-events: none; }
.check { display: flex; gap: 8px; align-items: center; font-size: .9rem; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.form-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: #fbfaf7; border-radius: 0 0 var(--radius) var(--radius); flex-wrap: wrap; }
.form-foot .grow { flex: 1; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

/* Course picker */
.choice { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choice label { border: 1.5px solid var(--line-strong); border-radius: 10px; padding: 12px 14px; cursor: pointer; display: flex; gap: 10px; align-items: center; background: #fff; }
.choice label b { display: block; color: var(--ink); }
.choice label small { font-size: .78rem; }
.choice input { accent-color: var(--primary); width: 18px; height: 18px; }
.choice label:has(input:checked) { border-color: var(--primary); background: var(--primary-50); }

/* Stepper (create) */
.steps { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.steps::-webkit-scrollbar { display: none; }
.steps button { flex: 1; min-width: 110px; border: 0; background: transparent; border-bottom: 3px solid var(--line); padding: 8px 4px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; text-align: left; }
.steps button span { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--line); color: var(--ink); font-size: .75rem; margin-right: 6px; }
.steps button.active { color: var(--ink); border-color: var(--primary); }
.steps button.active span { background: var(--primary); color: #fff; }
.steps button.done span { background: var(--green); color: #fff; }
.step { display: none; } .step.active { display: block; }
.js-off .step { display: block; }

/* ---------- Tabs (application) ---------- */
.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 18px; scrollbar-width: thin; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom: 2.5px solid transparent; margin-bottom: -1px; display: flex; align-items: center; gap: 6px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--ink); border-color: var(--primary); }
.tabs a .n { font-size: .72rem; color: var(--muted); font-weight: 500; }
.tabs a .lock { width: 12px; height: 12px; opacity: .55; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: var(--line-strong); }
.dot.ok { background: var(--green); } .dot.warn { background: var(--accent); } .dot.bad { background: var(--red); }

/* Profile header */
.profile { display: grid; grid-template-columns: 1fr auto; gap: 16px; padding: 18px 20px; align-items: center; }
.profile .id { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; color: var(--primary); font-size: .9rem; }
.profile h1 { margin: 2px 0 6px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.summary { display: grid; grid-template-columns: repeat(3, auto); gap: 4px 22px; text-align: right; }
.summary .k { font-size: .74rem; color: var(--muted); }
.summary .v { font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.summary .v.due { color: var(--red); } .summary .v.ok { color: var(--green); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 600; background: #eeede8; color: #4b555a; white-space: nowrap; line-height: 1.6; }
.b-green { background: var(--green-50); color: var(--green); }
.b-amber { background: var(--amber-50); color: var(--amber); }
.b-red { background: var(--red-50); color: var(--red); }
.b-blue { background: var(--blue-50); color: var(--blue); }
.b-teal { background: var(--primary-50); color: var(--primary); }
.b-ink { background: var(--ink); color: #fff; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
.t th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fbfaf7; white-space: nowrap; }
.t td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr:hover { background: #fbfaf7; }
.t .who b { display: block; color: var(--ink); }
.t .who small { font-size: .78rem; }

/* ---------- Filters ---------- */
.filters { display: grid; grid-template-columns: 2fr repeat(5, minmax(0, 1fr)) auto; gap: 10px; padding: 14px; align-items: end; }
.filters .f { grid-column: auto; }
.more-filters { display: none; grid-column: 1 / -1; }
.filters.open .more-filters { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 9px; border: 1px solid; margin-bottom: 16px; font-size: .92rem; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.alert-ok { background: var(--green-50); border-color: #bfdcc9; color: #1f5c39; }
.alert-err { background: var(--red-50); border-color: #ecc3c0; color: #85211d; }
.alert-warn { background: var(--amber-50); border-color: #ecd3a3; color: #7a4d00; }
.alert-info { background: var(--blue-50); border-color: #c5d6ec; color: #1f467a; }

/* ---------- Payments list (cards) ---------- */
.pay { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); align-items: center; }
.pay:last-child { border-bottom: 0; }
.pay .amt { font-weight: 700; font-size: 1.08rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.pay .meta { font-size: .82rem; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.pay .thumb { width: 46px; height: 46px; border-radius: 8px; border: 1px solid var(--line); object-fit: cover; background: #f3f2ee; display: grid; place-items: center; font-size: .7rem; color: var(--muted); overflow: hidden; }
.pay .thumb img { width: 100%; height: 100%; object-fit: cover; }
details.inline > summary { list-style: none; cursor: pointer; }
details.inline > summary::-webkit-details-marker { display: none; }
.pay-edit { grid-column: 1 / -1; background: #fbfaf7; border: 1px solid var(--line); border-radius: 9px; padding: 14px; }

/* Timeline (history) */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 130px 1fr; gap: 14px; padding: 10px 20px; border-bottom: 1px solid var(--line); font-size: .88rem; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted); font-size: .8rem; }
.timeline del { color: var(--red); text-decoration-color: rgba(178,58,53,.4); }
.timeline ins { color: var(--green); text-decoration: none; font-weight: 600; }

/* Pagination */
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; gap: 10px; flex-wrap: wrap; font-size: .88rem; }
.pager .pages { display: flex; gap: 4px; flex-wrap: wrap; }
.pager a, .pager span.cur, .pager span.gap { min-width: 34px; height: 34px; display: grid; place-items: center; border-radius: 7px; border: 1px solid var(--line); padding: 0 8px; color: var(--ink); }
.pager span.cur { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager span.gap { border: 0; }

/* Login */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { background: var(--ink); color: #dbe7ea; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art h1 { color: #fff; font-size: 2rem; line-height: 1.15; max-width: 420px; }
.auth-art .shelf { position: absolute; right: -40px; bottom: 60px; display: flex; gap: 6px; align-items: flex-end; opacity: .18; }
.auth-art .shelf i { display: block; width: 26px; background: #fff; border-radius: 3px 3px 0 0; }
.auth-form { display: grid; place-items: center; padding: 32px 20px; }
.auth-form .card { width: 100%; max-width: 400px; padding: 28px; }

/* Empty state */
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* Duplicate warning */
.dupe { display: none; }
.dupe.show { display: block; }

/* Overlay for mobile nav */
.scrim { display: none; }

/* ==========================================================
   Responsive
   ========================================================== */
@media (max-width: 1180px) {
  .g5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1fr 1fr 1fr auto; }
  .filters:not(.open) .hide-md { display: none; }
  .filters.open .more-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1023px) {
  .sidebar { transform: translateX(-100%); }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10,25,30,.4); z-index: 30; }
  .main { margin-left: 0; }
  .topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 20; }
  .topbar b { font-size: .95rem; }
  .topbar button { background: none; border: 0; color: #fff; padding: 6px; cursor: pointer; display: grid; }
  .topbar svg { width: 22px; height: 22px; }
  .topbar .plus { margin-left: auto; }
  .content { padding: 18px 16px 90px; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile { grid-template-columns: 1fr; }
  .summary { text-align: left; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  :root { font-size: 15px; }
  h1 { font-size: 1.25rem; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .g4, .g5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .f, .f.s3, .f.s6, .f.s8, .f.s2 { grid-column: span 12; }
  .f.half { grid-column: span 6; }
  .card-pad { padding: 16px; }
  .form-foot { padding: 12px 16px; position: sticky; bottom: 0; z-index: 5; box-shadow: 0 -4px 12px rgba(0,0,0,.05); }
  .form-foot .btn { flex: 1; }
  .form-foot .grow { display: none; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .f.keep, .filters > .actions { grid-column: 1 / -1; }
  .filters:not(.open) .f:not(.keep) { display: none; }
  .filters.open .more-filters { grid-template-columns: 1fr 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
  .pay { grid-template-columns: auto 1fr; }
  .pay .pay-actions { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
  .metric .v { font-size: 1.4rem; }

  /* Tables become cards */
  table.t.cards thead { display: none; }
  table.t.cards, table.t.cards tbody, table.t.cards tr, table.t.cards td { display: block; width: 100%; }
  table.t.cards tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  table.t.cards td { padding: 3px 0; border: 0; display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 4px 6px; text-align: right; }
  table.t.cards td br { display: none; }
  table.t.cards td::before { content: attr(data-l); font-size: .76rem; color: var(--muted); font-weight: 600; flex: none; margin-right: auto; }
  table.t.cards td[data-l=""]::before { content: none; }
  table.t.cards td.primary { display: block; margin-bottom: 4px; }
  table.t.cards td.primary::before { content: none; }
  table.t.cards td.hide-sm { display: none; }
  .actions .btn { flex: 1; }
  .page-head { align-items: stretch; }
}
@media print {
  .sidebar, .topbar, .form-foot, .tabs, .actions, .btn { display: none !important; }
  .main { margin: 0; }
  .card { box-shadow: none; }
}
.split { grid-template-columns: 2fr 1fr; }
@media (max-width: 1023px) { .split { grid-template-columns: 1fr; } }

/* Password show / hide */
.pw-wrap { position: relative; width: 100%; }
.pw-wrap input { padding-right: 44px !important; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; border-radius: 6px; padding: 0; }
.pw-toggle:hover { color: var(--ink); background: #f3f2ee; }
.pw-toggle svg { width: 20px; height: 20px; }
