/* Version: 0.2.0 | Updated: 2026-11-12 */
/* Alumni Database. The look agreed from the mock-ups (2026-11-12): light and
   dark themes chosen per user, big clear targets, everyday words.
   The CSP has no 'unsafe-inline' for styles: no style="" attributes in markup. */

/* ===================== THEMES ===================== */
:root, :root[data-theme="light"] {
  --bg:         #F4F6FA;
  --header:     #FFFFFF;
  --surface:    #FFFFFF;
  --surface2:   #EDF1F7;
  --border:     #D5DCE8;
  --text:       #1A2233;
  --muted:      #56627A;
  --primary:    #1F3864;
  --on-primary: #FFFFFF;
  --link:       #2557A7;
  --good:       #1E7F4F;
  --good-bg:    #E3F3EA;
  --bad:        #B42318;
  --bad-bg:     #FBE7E5;
  --warn:       #8A5A00;
  --warn-bg:    #FCEFD2;
  --chip:       #E6EEF9;
  --chip-text:  #1D4F96;
  --gold-chip:  #FCEFD2;
  --gold-text:  #7A4F00;
  --shadow:     0 12px 32px rgba(20,30,60,0.18);
  --crest-bg:   #0d1320;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg:         #0d1320;
  --header:     #111a2c;
  --surface:    #151e31;
  --surface2:   #1c2740;
  --border:     rgba(123,175,212,0.24);
  --text:       #E9EDF4;
  --muted:      #A7B2C6;
  --primary:    #F0C040;
  --on-primary: #162040;
  --link:       #8EC0E6;
  --good:       #5CC48E;
  --good-bg:    rgba(92,196,142,0.16);
  --bad:        #F08A8A;
  --bad-bg:     rgba(240,138,138,0.14);
  --warn:       #F2C46B;
  --warn-bg:    rgba(240,192,64,0.14);
  --chip:       rgba(123,175,212,0.16);
  --chip-text:  #9CC8EE;
  --gold-chip:  rgba(240,192,64,0.16);
  --gold-text:  #F2C94C;
  --shadow:     0 12px 32px rgba(0,0,0,0.45);
  --crest-bg:   transparent;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  display: flex; flex-direction: column; min-height: 100vh;
}
a { color: var(--link); }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.5; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ===================== HEADER ===================== */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
  padding: 10px 24px; min-height: 64px;
  background: var(--header); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 700; white-space: nowrap; color: var(--text); text-decoration: none; }
.brand .accent { color: var(--primary); }
/* The crest is a JPEG on black: lighten drops the black into a dark header.
   In light mode it sits on a navy tile instead (lighten on white would erase it).
   Don't add a filter too (ARCHITECTURE.md §18, mix-blend-mode + filter). */
.crest-wrap { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; background: var(--crest-bg); flex-shrink: 0; }
.school-crest { width: 30px; height: auto; mix-blend-mode: lighten; }

.nav { display: flex; flex-wrap: wrap; gap: 4px; }
.nav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-weight: 500;
}
.nav a:hover { color: var(--text); background: var(--surface2); }
.nav a.active { color: var(--primary); background: var(--surface2); font-weight: 600; }

.tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.pill-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px;
  border-radius: 22px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.pill-btn:hover { background: var(--surface2); }
.pill-btn[aria-pressed="true"] { border-color: var(--primary); }
.icon-btn { width: 44px; padding: 0; justify-content: center; }
/* Theme button: a sun to go light, a moon to go dark */
:root[data-theme="dark"] #theme-icon-moon, :root[data-theme="light"] #theme-icon-sun, :root:not([data-theme]) #theme-icon-sun { display: none; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

.user { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 14px; }
.user-avatar {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
  display: grid; place-items: center; font-size: 13px; font-weight: 700; overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ===================== LAYOUT ===================== */
.shell { flex: 1; display: flex; flex-wrap: wrap; align-items: flex-start; width: 100%; }
.main { flex: 999 1 640px; min-width: 0; max-width: 1240px; margin: 0 auto; padding: 28px 24px 48px; display: flex; flex-direction: column; gap: 20px; }
.main-view { display: flex; flex-direction: column; gap: 20px; }
.screen { max-width: 560px; margin: 60px auto; text-align: center; }
.screen h1 { font-size: 22px; margin-bottom: 10px; }
.screen .btn { margin-top: 18px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head h1 { font-size: 28px; line-height: 1.2; }
.page-head p { color: var(--muted); margin-top: 4px; }

.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.subtabs a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; color: var(--text); text-decoration: none; border-bottom: 3px solid transparent; }
.subtabs a.active { border-bottom-color: var(--primary); font-weight: 700; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px; }
.card h2 { font-size: 17px; margin-bottom: 8px; }
.card ul { margin: 6px 0 0 20px; }
.card li + li { margin-top: 4px; }

.grid-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.action-tile {
  display: flex; flex-direction: column; gap: 6px; padding: 16px; min-height: 104px;
  border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none;
}
a.action-tile:hover { border-color: var(--primary); }
.action-tile .tile-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); }
.action-tile .tile-title { font-weight: 600; font-size: 16px; }
.action-tile .tile-hint { font-size: 13px; color: var(--muted); }
.action-tile.soon { background: transparent; border-style: dashed; }
.action-tile.soon .tile-icon { background: var(--surface2); color: var(--muted); }

.section-label { font-size: 15px; font-weight: 600; color: var(--muted); }
.footer { text-align: center; font-size: 12px; color: var(--muted); padding: 12px 16px 16px; }

/* ===================== BUTTONS AND FORMS ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 8px;
  font-weight: 500; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface2); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); font-weight: 600; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.danger { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.link-btn { border: 0; background: transparent; color: var(--link); padding: 8px 0; text-decoration: underline; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 600; margin-bottom: 4px; }
.input, .select {
  width: 100%; height: 44px; padding: 0 12px; border-radius: 8px;
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
}
.input:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }

.perm-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 20px; margin: 6px 0 4px; }
.perm-group h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 4px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 36px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); flex-shrink: 0; }

.form-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 18px; }
.form-actions .spacer { flex: 1; }
.form-error { color: var(--bad); margin-top: 10px; }
.note { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* ===================== TABLES ===================== */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: 12px 14px; vertical-align: top; }
table.data th { font-weight: 600; background: var(--surface2); white-space: nowrap; }
table.data tbody tr { border-top: 1px solid var(--border); }
table.data tr.inactive td { color: var(--muted); }
table.data td.nowrap { white-space: nowrap; }
table.data .sub { display: block; font-size: 13px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 13px; padding: 2px 10px; border-radius: 12px; background: var(--chip); color: var(--chip-text); white-space: nowrap; }
.chip.gold { background: var(--gold-chip); color: var(--gold-text); }
.chip.red { background: var(--bad-bg); color: var(--bad); }
.chip.green { background: var(--good-bg); color: var(--good); }

.load-more { text-align: center; }

/* ===================== HELP PANEL ===================== */
.help {
  flex: 1 1 300px; max-width: 380px; margin: 20px 20px 20px 0;
  padding: 20px; border-radius: 12px; background: var(--surface); border: 2px solid var(--primary);
  display: flex; flex-direction: column; gap: 10px;
}
.help-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.help-head h2 { font-size: 18px; }
.help .help-lead { color: var(--muted); font-size: 14px; }
.help h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 6px; }
.help details { border: 1px solid var(--border); border-radius: 10px; background: var(--surface2); }
.help summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 44px; padding: 8px 12px; font-weight: 600; }
.help summary::-webkit-details-marker { display: none; }
.help summary::after { content: 'Show me'; font-size: 13px; font-weight: 400; color: var(--link); white-space: nowrap; }
.help details[open] summary::after { content: 'Hide'; }
.help details > div { padding: 0 12px 12px; font-size: 14px; }
.help details ol { margin: 4px 0 0 18px; }
.help details li + li { margin-top: 4px; }

/* ===================== PANEL (add / edit operator) ===================== */
.panel-backdrop {
  position: fixed; inset: 0; background: rgba(5,8,16,0.6);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 16px 16px; overflow-y: auto; z-index: 20;
}
.panel {
  width: 100%; max-width: 660px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 22px 24px; box-shadow: var(--shadow);
}
.panel h2 { font-size: 20px; margin-bottom: 4px; }
.panel .lead { color: var(--muted); margin-bottom: 16px; }

/* ===================== TOAST ===================== */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  padding: 12px 18px; z-index: 30; max-width: calc(100% - 32px);
}
.toast.error { border-color: var(--bad); color: var(--bad); }

/* ===================== SMALL SCREENS ===================== */
@media (max-width: 760px) {
  .topbar { padding: 8px 16px; }
  .nav { order: 3; width: 100%; }
  .user-name { display: none; }
  .pill-btn .label { display: none; }
  .pill-btn { width: 44px; padding: 0; justify-content: center; }
  .main { padding: 18px 16px 40px; }
  .help { margin: 0 16px 16px; max-width: none; }
  .hide-sm { display: none; }
}
