:root {
  --ink: #172238;
  --muted: #67738a;
  --line: #dfe5ef;
  --surface: #ffffff;
  --canvas: #f4f7fb;
  --navy: #10203b;
  --blue: #2d63e2;
  --blue-dark: #1e4fc4;
  --green: #18845e;
  --amber: #b86a08;
  --red: #c43d4b;
  --shadow: 0 12px 32px rgba(29, 48, 83, .08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body {
  min-height: 100vh; margin: 0; color: var(--ink); background:
    radial-gradient(circle at 85% 0%, rgba(45, 99, 226, .08), transparent 28rem),
    var(--canvas);
  font: 15px/1.5 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
code {
  padding: .15rem .35rem; color: #244479; background: #eef3fb; border-radius: 6px;
  font: 500 .9em/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center;
  justify-content: space-between; min-height: 70px; padding: 0 max(24px, calc((100vw - 1180px) / 2));
  color: white; background: rgba(16, 32, 59, .97); box-shadow: 0 6px 24px rgba(8, 20, 42, .18);
}
.brand { display: flex; gap: 11px; align-items: center; color: white; text-decoration: none; letter-spacing: .03em; }
.brand span:last-child { display: flex; flex-direction: column; line-height: 1.05; }
.brand small { margin-top: 5px; color: #aebbd1; font-size: 10px; letter-spacing: .11em; text-transform: uppercase; }
.brand-mark {
  display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid rgba(255,255,255,.24);
  border-radius: 11px; color: white; background: linear-gradient(145deg, #3974ef, #1b4bb8);
  box-shadow: inset 0 1px rgba(255,255,255,.28), 0 7px 16px rgba(20, 64, 163, .3);
  font: 800 20px/1 Georgia, serif;
}
.brand-mark-large { width: 54px; height: 54px; border-radius: 16px; font-size: 30px; }
.topnav { display: flex; gap: 6px; align-items: center; }
.topnav a, .link-button {
  display: inline-flex; padding: 9px 12px; border: 0; border-radius: 8px; color: #dce5f5;
  background: transparent; text-decoration: none; cursor: pointer;
}
.topnav a:hover, .link-button:hover { color: white; background: rgba(255,255,255,.09); }
.topnav form { margin: 0; }

.page { width: min(1180px, calc(100% - 36px)); margin: 42px auto 72px; }
.page-narrow { width: min(760px, calc(100% - 36px)); }
.page-heading { display: flex; gap: 24px; align-items: flex-end; justify-content: space-between; margin: 0 0 24px; }
.page-heading h1, .success-hero h1, .danger-hero h1 { margin: 2px 0 4px; font-size: clamp(27px, 4vw, 38px); line-height: 1.15; letter-spacing: -.035em; }
.eyebrow { margin: 0; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.muted { margin: 5px 0 0; color: var(--muted); }
.back-link { display: inline-flex; margin-bottom: 20px; color: #506079; text-decoration: none; }
.back-link:hover { color: var(--blue); }

.panel {
  overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow);
}
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card {
  display: flex; gap: 15px; align-items: center; min-height: 104px; padding: 22px;
  border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: var(--shadow);
}
.stat-card div { display: flex; flex-direction: column; }
.stat-card strong { font-size: 27px; line-height: 1.1; }
.stat-card div span { margin-top: 3px; color: var(--muted); }
.stat-icon { font-size: 20px; }
.stat-active .stat-icon { color: var(--green); }
.stat-blocked .stat-icon { color: var(--red); }
.stat-expiring .stat-icon { color: var(--amber); }
.panel-toolbar { padding: 18px; border-bottom: 1px solid var(--line); }
.filters { display: flex; gap: 10px; align-items: center; }
.search-field { flex: 1; }
.filters input { width: 100%; min-width: 220px; }

input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #cbd4e2;
  border-radius: 10px; outline: none; color: var(--ink); background: white; transition: .16s ease;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(45,99,226,.12); }
input[type="checkbox"] { width: 18px; min-height: 18px; accent-color: var(--blue); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 13px 16px; color: #718097; background: #f9fbfd; font-size: 11px; font-weight: 800;
  letter-spacing: .06em; text-align: left; text-transform: uppercase; white-space: nowrap;
}
td { padding: 16px; border-top: 1px solid #ebeff5; color: #49566a; vertical-align: middle; }
tbody tr:hover { background: #fbfcfe; }
.student-name { display: block; margin-bottom: 4px; color: var(--ink); font-weight: 750; text-decoration: none; }
.student-name:hover { color: var(--blue); }
.align-right { text-align: right; }
.row-actions { display: flex; gap: 5px; justify-content: flex-end; white-space: nowrap; }
.icon-button {
  padding: 6px 8px; border: 1px solid transparent; border-radius: 7px; color: #53627a;
  background: transparent; text-decoration: none; cursor: pointer;
}
.icon-button:hover { border-color: var(--line); color: var(--blue); background: white; }
.empty-state { padding: 55px 20px; text-align: center; }
.empty-state strong, .empty-state span { display: block; }
.empty-state span { margin-top: 5px; color: var(--muted); }

.badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 750; white-space: nowrap; }
.badge-active { color: #086245; background: #e7f7f0; }
.badge-blocked { color: #9f2637; background: #ffedf0; }
.badge-expired { color: #955605; background: #fff4db; }
.button {
  display: inline-flex; min-height: 42px; align-items: center; justify-content: center; padding: 9px 15px;
  border: 1px solid transparent; border-radius: 10px; font-weight: 700; text-decoration: none; cursor: pointer; transition: .16s ease;
}
.button:disabled { opacity: .48; cursor: not-allowed; }
.button-primary { color: white; background: var(--blue); box-shadow: 0 6px 14px rgba(45,99,226,.2); }
.button-primary:hover:not(:disabled) { background: var(--blue-dark); transform: translateY(-1px); }
.button-secondary { border-color: #cfd7e3; color: #394b66; background: white; }
.button-secondary:hover { border-color: #9eacc0; background: #f9fbfe; }
.button-ghost { color: #516077; background: #f1f4f8; }
.button-danger { color: white; background: var(--red); }
.button-danger:hover { background: #a92c3a; }
.button-wide { width: 100%; }

.form-panel { padding: clamp(20px, 5vw, 34px); }
.stack-form { display: grid; gap: 20px; }
.field { display: grid; gap: 7px; }
.field label { font-weight: 750; }
.field small { color: var(--muted); }
.field .field-error { color: var(--red); font-weight: 650; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.notice { margin: 14px 0; padding: 14px 16px; border: 1px solid; border-radius: 11px; }
.notice-warning { border-color: #f3d495; color: #744406; background: #fff8e8; }
.notice-danger { border-color: #f1b9c0; color: #862433; background: #fff1f3; }
.flash-stack { position: fixed; top: 82px; right: 20px; z-index: 20; width: min(380px, calc(100% - 40px)); }
.flash { margin-bottom: 8px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 11px; background: white; box-shadow: var(--shadow); }
.flash-success { border-color: #a6dbc8; color: #096146; }
.flash-error { border-color: #efb4bd; color: #972a3a; }
.flash-warning { border-color: #f3d28d; color: #82500d; }

.success-hero, .danger-hero { display: flex; gap: 17px; align-items: center; margin-bottom: 22px; }
.success-check, .danger-hero > span {
  display: grid; flex: 0 0 56px; height: 56px; place-items: center; border-radius: 50%;
  color: white; background: var(--green); font-size: 29px; font-weight: 800;
}
.danger-hero > span { background: var(--red); }
.success-hero p { margin: 3px 0 0; color: var(--muted); }
.credential-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 20px 0 14px; }
.credential-card { padding: 20px; }
.credential-wide { grid-column: 1 / -1; }
.credential-label { display: block; margin-bottom: 10px; color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; }
.copy-row, .command-box { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.copy-row code, .command-box code { flex: 1; overflow-wrap: anywhere; padding: 10px 12px; }
.secret { color: #6e3f02; background: #fff4d8; letter-spacing: .035em; }
.firefox-card { display: flex; gap: 30px; justify-content: space-between; padding: 23px; }
.firefox-card h2, .detail-card h2, .actions-panel h2 { margin: 3px 0 0; font-size: 19px; }
.settings-list { display: grid; grid-template-columns: repeat(2, minmax(120px, 1fr)); gap: 12px 24px; margin: 0; }
.settings-list div { display: flex; flex-direction: column; }
.settings-list dt, .detail-list dt { color: var(--muted); font-size: 12px; }
.settings-list dd, .detail-list dd { margin: 2px 0 0; font-weight: 700; }
.acknowledge { display: flex; gap: 16px; align-items: center; justify-content: space-between; margin-top: 20px; }
.check-row { display: flex; gap: 10px; align-items: flex-start; }

.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 20px 0; }
.detail-card { padding: 22px; }
.detail-list { margin: 18px 0 0; }
.detail-list div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid #edf0f4; }
.detail-list dd { text-align: right; }
.notes { color: #4f5c70; white-space: pre-wrap; }
.actions-panel { padding: 22px; }
.action-grid { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 16px; }
.action-grid form { display: contents; }
.pagination { display: flex; gap: 14px; align-items: center; justify-content: center; padding: 18px; border-top: 1px solid var(--line); }

.login-shell { display: grid; min-height: calc(100vh - 52px); padding: 30px 18px; place-items: center; }
.login-card {
  width: min(440px, 100%); padding: clamp(28px, 7vw, 44px); border: 1px solid rgba(214,222,234,.9);
  border-radius: 22px; background: rgba(255,255,255,.96); box-shadow: 0 24px 70px rgba(25,45,78,.14);
}
.login-brand { display: flex; gap: 14px; align-items: center; }
.login-brand h1 { margin: 0; color: var(--navy); font-size: 24px; line-height: 1; letter-spacing: .03em; }
.login-brand p { margin: 5px 0 0; color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.login-copy { margin: 35px 0 25px; }
.login-copy h2 { margin: 0 0 7px; font-size: 28px; letter-spacing: -.025em; }
.login-copy p { margin: 0; color: var(--muted); }
.login-footnote { margin: 22px 0 0; color: #8893a5; font-size: 12px; text-align: center; }
.footer { padding: 18px; color: #8a95a7; font-size: 11px; letter-spacing: .06em; text-align: center; text-transform: uppercase; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.clipboard-fallback { position: fixed; left: -9999px; width: 1px; height: 1px; opacity: 0; }

@media (max-width: 850px) {
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .detail-card:last-child { grid-column: 1 / -1; }
  .firefox-card { flex-direction: column; }
}
@media (max-width: 650px) {
  .topbar { min-height: 62px; padding: 0 14px; }
  .brand small { display: none; }
  .topnav { gap: 0; }
  .topnav a, .link-button { padding: 8px; font-size: 13px; }
  .page { width: min(100% - 24px, 1180px); margin-top: 26px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .stats-grid, .detail-grid, .credential-grid { grid-template-columns: 1fr; }
  .detail-card:last-child, .credential-wide { grid-column: auto; }
  .stat-card { min-height: 82px; padding: 17px; }
  .filters { align-items: stretch; flex-direction: column; }
  .filters input { min-width: 0; }
  th, td { padding: 12px; }
  .row-actions { justify-content: flex-start; }
  .copy-row, .command-box, .acknowledge { align-items: stretch; flex-direction: column; }
  .settings-list { grid-template-columns: 1fr 1fr; }
  .form-actions { align-items: stretch; flex-direction: column-reverse; }
  .button { width: 100%; }
  .action-grid { flex-direction: column; }
  .flash-stack { top: 72px; right: 12px; width: calc(100% - 24px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
