/* Campus Link — Staff portal design system */
:root {
  --bg: #f5f6fa; --panel: #ffffff; --panel-2: #f9fafc; --ink: #0f172a; --ink-2: #334155; --muted: #64748b;
  --line: #e5e7ef; --line-2: #eef0f5;
  --brand: #e8385a; --brand-600: #d42c4d; --brand-50: #fdeef1; --brand-ink: #ffffff;
  --ok: #12a150; --ok-50: #e7f7ee; --warn: #c27c0e; --warn-50: #fdf4e3; --bad: #d92d3a; --bad-50: #fdecee;
  --info: #2563eb; --info-50: #eaf1ff; --violet: #7c3aed; --violet-50: #f2ecfe;
  --side: #111827; --side-ink: #cbd5e1; --side-muted: #64748b; --side-hover: #1f2937; --side-active: #ffffff;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .05);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f17; --panel: #121826; --panel-2: #0f1522; --ink: #e8ecf3; --ink-2: #c3cad6; --muted: #8a94a7;
    --line: #232b3b; --line-2: #1a2130;
    --brand-50: #3a1520; --ok-50: #0f2a1c; --warn-50: #2e2410; --bad-50: #33131a; --info-50: #13213d; --violet-50: #231a3a;
    --side: #080b12; --side-hover: #141a26;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--font); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; }
p { margin: 0 0 8px; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 700; font-size: 15px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #ff5f7e, var(--brand)); display: grid; place-items: center; }
.brand-mark .icon { stroke: #fff; width: 17px; height: 17px; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--side-muted); letter-spacing: .02em; }
.nav { padding: 6px 10px 16px; flex: 1; }
.nav-group { margin-top: 14px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--side-muted); padding: 0 10px 6px; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--side-ink); font-weight: 500; }
.nav a:hover { background: var(--side-hover); text-decoration: none; color: #fff; }
.nav a.on { background: rgba(232, 56, 90, .16); color: var(--side-active); box-shadow: inset 2px 0 0 var(--brand); }
.nav a.on .icon { stroke: #ff7a93; }
.nav .count { margin-left: auto; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.side-foot { border-top: 1px solid rgba(255, 255, 255, .06); padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #6366f1, #ec4899); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.side-foot .who { flex: 1; min-width: 0; }
.side-foot .who b { display: block; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot .who a { color: var(--side-muted); font-size: 12px; }
.side-foot button { background: none; border: 0; color: var(--side-muted); cursor: pointer; padding: 6px; border-radius: 8px; }
.side-foot button:hover { color: #fff; background: var(--side-hover); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); padding: 12px 28px; display: flex; align-items: center; gap: 14px; }
.topbar .menu-btn { display: none; }
.search { flex: 1; max-width: 460px; position: relative; }
.topbar .search input { width: 100%; padding: 9px 12px 9px 36px; background: var(--panel); }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topbar .env { margin-left: auto; }
.content { padding: 24px 28px 48px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin: 4px 0 0; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.crumbs a { color: var(--muted); }

/* ---------- Surfaces ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }
.card + .card, .stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.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)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-side { grid-template-columns: 340px minmax(0, 1fr); }

/* ---------- KPI tiles ---------- */
.kpi { padding: 16px 18px; display: flex; gap: 14px; align-items: flex-start; color: var(--ink); }
a.kpi:hover { text-decoration: none; border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.kpi-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.kpi-icon.rose { background: var(--brand-50); color: var(--brand); }
.kpi-icon.green { background: var(--ok-50); color: var(--ok); }
.kpi-icon.amber { background: var(--warn-50); color: var(--warn); }
.kpi-icon.blue { background: var(--info-50); color: var(--info); }
.kpi-icon.violet { background: var(--violet-50); color: var(--violet); }
.kpi-icon.red { background: var(--bad-50); color: var(--bad); }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 750; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: 12px; color: var(--muted); }

/* ---------- Queue list ---------- */
.queue { display: flex; flex-direction: column; }
.queue a { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-top: 1px solid var(--line-2); color: var(--ink); }
.queue a:first-child { border-top: 0; }
.queue a:hover { background: var(--panel-2); text-decoration: none; }
.queue .q-count { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.queue .q-count.zero { color: var(--muted); font-weight: 500; }

/* ---------- Charts (server-rendered SVG) ---------- */
.chart { width: 100%; height: 170px; display: block; }
.chart .bar { fill: var(--brand); opacity: .85; }
.chart .bar.alt { fill: var(--info); }
.chart .bar.alt2 { fill: var(--violet); }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .grid-line { stroke: var(--line-2); stroke-width: 1; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--brand); }
.legend i.alt { background: var(--info); }
.meter { height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.split-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; padding: 8px 0; }
.split-row .meter { grid-column: 1 / -1; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--panel-2); position: sticky; top: 0; }
tbody tr:hover td { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: 0; }
td .person { display: flex; align-items: center; gap: 10px; }
td .person .avatar { width: 30px; height: 30px; font-size: 12px; }
td .person b { font-weight: 600; color: var(--ink); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 0; }
.kv > div { padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.kv > div:nth-last-child(-n+2) { border-bottom: 0; }
.kv dt, .kv .k { color: var(--muted); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge.plain::before { display: none; }
.badge.ok, .badge.active, .badge.approved, .badge.verified, .badge.actioned, .badge.resolved, .badge.safe { background: var(--ok-50); color: var(--ok); }
.badge.warn, .badge.onboarding, .badge.pending, .badge.manual_review, .badge.in_review, .badge.grace, .badge.high, .badge.scheduled, .badge.resubmission { background: var(--warn-50); color: var(--warn); }
.badge.bad, .badge.banned, .badge.declined, .badge.rejected, .badge.urgent, .badge.refunded, .badge.revoked, .badge.sos, .badge.alerted { background: var(--bad-50); color: var(--bad); }
.badge.info, .badge.open, .badge.suspended, .badge.normal { background: var(--info-50); color: var(--info); }
.badge.violet { background: var(--violet-50); color: var(--violet); }
.badge.brand { background: var(--brand-50); color: var(--brand); }

/* ---------- Forms & buttons ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input:not([type]), select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 12px; width: 100%; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
textarea { resize: vertical; min-height: 90px; }
label { display: block; font-weight: 550; font-size: 13px; }
label > input, label > select, label > textarea { margin-top: 6px; }
.field + .field { margin-top: 12px; }
.field .help { color: var(--muted); font-size: 12px; margin-top: 4px; font-weight: 400; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; text-decoration: none !important; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-600); }
.btn-secondary { background: var(--panel); border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { border-color: var(--muted); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-2); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.toolbar .grow { flex: 1; min-width: 220px; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--line-2); border-radius: 11px; width: fit-content; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 550; font-size: 13px; }
.tabs a:hover { text-decoration: none; background: var(--panel); }
.tabs a.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.tabs a .badge { margin-left: 4px; }
.inline { display: inline; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Alerts / empty ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-weight: 500; }
.alert.error { background: var(--bad-50); color: var(--bad); }
.alert.ok { background: var(--ok-50); color: var(--ok); }
.alert.warn { background: var(--warn-50); color: var(--warn); }
.alert.info { background: var(--info-50); color: var(--info); }
.empty { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty .icon { width: 34px; height: 34px; margin-bottom: 8px; stroke: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 2px; }

/* ---------- Media ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.gallery figure { margin: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--panel-2); }
.gallery img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; }
.gallery figcaption { padding: 8px; display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.gallery.docs { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.gallery.docs img { aspect-ratio: auto; max-height: 340px; object-fit: contain; background: #000; }
.profile-head { display: flex; gap: 16px; align-items: center; }
.profile-head .avatar { width: 72px; height: 72px; font-size: 26px; }

/* ---------- Chat transcript ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; padding: 18px; background: var(--panel-2); max-height: 640px; overflow-y: auto; }
.msg { max-width: 72%; padding: 9px 13px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); }
.msg.right { align-self: flex-end; background: color-mix(in srgb, var(--info) 9%, var(--panel)); }
.msg.flagged { border-color: var(--warn); box-shadow: 0 0 0 2px var(--warn-50); }
.msg.target { border-color: var(--bad); box-shadow: 0 0 0 2px var(--bad-50); }
.msg.note { background: var(--warn-50); }
.msg small { display: block; color: var(--muted); font-size: 11.5px; margin-bottom: 3px; }
.msg p { margin: 0; white-space: pre-wrap; }
.msg img { max-width: 240px; border-radius: 10px; margin-top: 4px; }

/* ---------- Danger zone / perms ---------- */
.danger-zone { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.danger-zone .card-head h2 { color: var(--bad); }
.perms { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 6px 18px; }
.perms label { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; padding: 6px 0; }
.perms label input { margin-top: 3px; accent-color: var(--brand); width: 15px; height: 15px; }
.perms b { font-family: var(--mono); font-size: 12px; font-weight: 600; display: block; }
.perms span { color: var(--muted); font-size: 12.5px; }
.pager { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line-2); }
.secret { font-family: var(--mono); font-size: 15px; letter-spacing: .08em; background: var(--panel-2); border: 1px dashed var(--line); padding: 10px 14px; border-radius: 10px; display: inline-block; }
.qr { width: 190px; height: 190px; image-rendering: pixelated; border-radius: 12px; background: #fff; padding: 8px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 10px 18px; border-top: 1px solid var(--line-2); }
.timeline li:first-child { border-top: 0; }
.timeline .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-top: 7px; flex: none; }
.timeline .t { color: var(--muted); font-size: 12px; }

/* ---------- Auth screens ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { background: radial-gradient(1200px 600px at -10% 120%, #7c3aed 0%, transparent 60%), radial-gradient(900px 500px at 120% -10%, #ff7a93 0%, transparent 55%), #111827;
  color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-art h2 { font-size: 34px; line-height: 1.15; max-width: 440px; letter-spacing: -.02em; }
.auth-art p { color: #cbd5e1; max-width: 420px; font-size: 15px; }
.auth-art .points { display: grid; gap: 12px; margin-top: 24px; }
.auth-art .points div { display: flex; gap: 10px; align-items: center; color: #e2e8f0; }
.auth-art .points .icon { stroke: #ff9db0; }
.auth-panel { display: grid; place-items: center; padding: 32px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 24px; margin-bottom: 6px; }
.auth-card .lead { color: var(--muted); margin-bottom: 22px; }
.auth-card .btn { width: 100%; padding: 11px; margin-top: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main, .g-side { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
  .topbar .menu-btn { display: inline-flex; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .kv { grid-template-columns: 1fr; }
}

/* ---------- Settings: setup guide ---------- */
.steps { margin: 0; padding-left: 0; list-style: none; counter-reset: step; display: grid; gap: 14px; }
.steps li { position: relative; padding-left: 38px; font-size: 13.5px; line-height: 1.55; }
.steps li::before { counter-increment: step; content: counter(step); position: absolute; left: 0; top: 0; width: 26px; height: 26px;
  border-radius: 50%; background: var(--brand-50); color: var(--brand); font-weight: 700; font-size: 12.5px; display: grid; place-items: center; }
.copy { cursor: copy; padding: 1px 6px; border-radius: 6px; background: var(--panel-2, var(--brand-50)); border: 1px dashed var(--line); }
.copy.copied { border-color: var(--ok); color: var(--ok); }
