:root {
  --ink: #17231f;
  --muted: #65736e;
  --paper: #ffffff;
  --canvas: #f3f6f3;
  --green-950: #0c2e27;
  --green-900: #123b32;
  --green-800: #1b5649;
  --green-700: #27705f;
  --green-100: #dcebe5;
  --green-50: #edf5f1;
  --gold: #d8a940;
  --red: #a43e3e;
  --red-soft: #f8e8e6;
  --blue: #2e618d;
  --blue-soft: #e8f1f7;
  --line: #dce3df;
  --shadow: 0 18px 55px rgba(18, 59, 50, 0.09);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--canvas); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 1%, rgba(216, 169, 64, 0.15), transparent 28rem),
    radial-gradient(circle at 94% 15%, rgba(39, 112, 95, 0.12), transparent 34rem),
    var(--canvas);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
a { color: inherit; }

.page-shell { width: min(1480px, calc(100% - 40px)); margin: 0 auto; }

.site-header {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark {
  width: 46px; height: 46px; display: grid; place-items: center;
  color: white; background: var(--green-900); border-radius: 14px;
  font: 700 22px/1 Georgia, serif; box-shadow: 0 9px 22px rgba(18,59,50,.22);
}
.brand strong { display: block; font: 700 17px/1.2 Georgia, serif; }
.brand small { display: block; margin-top: 4px; color: var(--muted); }
.user-menu { display: flex; align-items: center; gap: 14px; color: var(--muted); }

main { min-height: calc(100vh - 166px); }
.hidden { display: none !important; }

.login-layout {
  min-height: calc(100vh - 190px);
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, .75fr);
  align-items: center;
  gap: clamp(40px, 8vw, 130px);
  padding: 35px clamp(0px, 4vw, 65px) 75px;
}

.welcome-copy { max-width: 750px; }
.welcome-copy h1 {
  max-width: 720px; margin: 10px 0 22px;
  font: 700 clamp(40px, 5.5vw, 76px)/1.03 Georgia, "Times New Roman", serif;
  letter-spacing: -.035em; color: var(--green-950);
}
.welcome-copy > p:not(.eyebrow) { max-width: 620px; color: var(--muted); font-size: 18px; }
.eyebrow {
  margin: 0 0 6px; color: var(--green-700); font-size: 12px;
  font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
}
.feature-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
.feature-list span {
  padding: 9px 13px; border: 1px solid rgba(39,112,95,.18);
  border-radius: 999px; background: rgba(255,255,255,.58); color: var(--green-800); font-size: 13px;
}

.card {
  background: rgba(255,255,255,.92); border: 1px solid rgba(18,59,50,.08);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.login-card { width: 100%; max-width: 440px; justify-self: end; padding: 34px; }
.login-card h2, .section-heading h2, .edit-card h2, .template-card h2 {
  margin: 0; font: 700 27px/1.2 Georgia, serif; color: var(--green-950);
}

label > span:not(.sr-only) { display: block; margin-bottom: 6px; color: #40504a; font-size: 13px; font-weight: 700; }
.login-card label { display: block; margin-top: 20px; }
input, select, textarea {
  width: 100%; border: 1px solid #cfd9d4; border-radius: 10px; outline: none;
  color: var(--ink); background: #fff; transition: border-color .15s, box-shadow .15s;
}
input, select { min-height: 44px; padding: 9px 11px; }
textarea { padding: 13px; }
input:focus, select:focus, textarea:focus { border-color: var(--green-700); box-shadow: 0 0 0 3px rgba(39,112,95,.12); }

.button {
  min-height: 42px; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px;
  text-decoration: none; font-weight: 750; transition: transform .15s, background .15s, border-color .15s;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.button-primary { color: white; background: var(--green-800); border-color: var(--green-800); }
.button-primary:hover { background: var(--green-900); }
.button-ghost { color: var(--green-800); background: white; border-color: #cbd8d2; }
.button-ghost:hover { border-color: var(--green-700); background: var(--green-50); }
.button-danger { color: var(--red); background: var(--red-soft); border-color: #edc9c6; }
.button-wide { width: 100%; margin-top: 24px; }
.button-small { min-height: 34px; padding: 6px 11px; font-size: 13px; }
.form-note { margin: 17px 0 0; color: var(--muted); font-size: 13px; }

.hero-card {
  min-height: 210px; display: flex; align-items: center; justify-content: space-between;
  gap: 30px; margin: 24px 0; padding: clamp(28px, 5vw, 58px);
  color: white; overflow: hidden; position: relative; border-radius: 26px;
  background: linear-gradient(125deg, var(--green-950), var(--green-800)); box-shadow: 0 22px 60px rgba(18,59,50,.22);
}
.hero-card::after {
  content: ""; position: absolute; width: 360px; height: 360px; right: -120px; top: -185px;
  border: 70px solid rgba(255,255,255,.045); border-radius: 50%;
}
.hero-card .eyebrow { color: #add5c8; }
.hero-card h1 { position: relative; z-index: 1; margin: 3px 0 7px; font: 700 clamp(32px, 4vw, 52px)/1.08 Georgia, serif; }
.hero-meta { position: relative; z-index: 1; margin: 0; color: #c9ddd6; font-size: 17px; }
.hero-badge {
  width: 108px; height: 108px; flex: 0 0 auto; display: grid; place-items: center;
  position: relative; z-index: 1; border: 1px solid rgba(255,255,255,.25); border-radius: 50%;
  background: rgba(255,255,255,.08); color: #f1d48f; font: 700 35px/1 Georgia, serif;
}

.student-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, .8fr); gap: 22px; margin-bottom: 22px; }
.selection-card, .info-card, .table-card, .toolbar-card, .edit-card, .template-card { padding: 26px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.selection-card form label { max-width: 780px; }
.selection-card select { font-weight: 650; }
.selection-card .button { margin-top: 18px; }
.course-preview { margin-top: 14px; padding: 14px 16px; border-left: 3px solid var(--gold); border-radius: 7px; background: #fbf7eb; }
.course-preview strong { display: block; }
.course-preview span { display: inline-block; margin: 5px 14px 0 0; color: #655d45; font-size: 13px; }
.info-card { background: linear-gradient(145deg, #fff, var(--green-50)); }
.info-card ol { margin: 19px 0 0; padding-left: 22px; }
.info-card li { padding: 5px 0 12px 6px; color: #45564f; }

.table-card { margin-bottom: 30px; }
.table-wrap { width: 100%; overflow-x: auto; }
.table-wide { margin-bottom: 2px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
td { font-size: 14px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(237,245,241,.42); }
.cell-title { display: block; font-weight: 750; color: var(--green-950); }
.cell-subtitle { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.row-actions { text-align: right; white-space: nowrap; }

.status-pill { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.status-pending { color: #77580d; background: #f9edc6; }
.status-confirmed { color: var(--green-800); background: var(--green-100); }
.status-rejected { color: var(--red); background: var(--red-soft); }
.status-withdrawn { color: var(--muted); background: #ebefed; }
.empty-state { padding: 32px 12px 18px; color: var(--muted); text-align: center; }
.empty-state strong, .empty-state span { display: block; }
.empty-state strong { margin-bottom: 5px; color: var(--green-950); }

.admin-hero { min-height: 190px; }
.registration-control {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  margin: -6px 0 18px; padding: 18px 22px; border-left: 4px solid var(--green-700);
}
.registration-control > div > * { display: block; }
.registration-control .eyebrow { margin-bottom: 4px; }
.registration-control strong { color: var(--green-950); font-size: 18px; }
.registration-control span { margin-top: 3px; color: var(--muted); font-size: 13px; }
.registration-control.registration-closed { border-left-color: var(--red); background: #fffafa; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(100px, 1fr)); gap: 10px; position: relative; z-index: 1; }
.stat { min-width: 110px; padding: 15px; border: 1px solid rgba(255,255,255,.15); border-radius: 14px; background: rgba(255,255,255,.07); }
.stat strong, .stat span { display: block; }
.stat strong { color: #f2d898; font: 700 27px/1 Georgia, serif; }
.stat span { margin-top: 5px; color: #c9ddd6; font-size: 11px; }

.tabs { display: flex; gap: 7px; margin: 18px 0; padding: 5px; border-radius: 13px; background: #e5ebe8; width: fit-content; }
.tab { min-height: 39px; padding: 7px 16px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font-weight: 750; }
.tab.active { color: var(--green-900); background: white; box-shadow: 0 4px 15px rgba(18,59,50,.08); }
.toolbar-card { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 18px; padding-block: 18px; box-shadow: 0 10px 35px rgba(18,59,50,.06); }
.toolbar-group { display: flex; flex-wrap: wrap; gap: 9px; }
.file-button input { display: none; }
.compact-field { min-width: 190px; }
.compact-field > span { margin-bottom: 4px !important; }
.compact-field input, .compact-field select { min-height: 39px; padding-block: 6px; }
.edit-card { margin-bottom: 18px; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--green-50); color: var(--green-900); font-size: 25px; }
.course-form-grid { display: grid; grid-template-columns: repeat(6, minmax(100px, 1fr)); gap: 13px; margin-bottom: 18px; }
.course-form-grid .wide-field { grid-column: span 2; }
.check-field { display: flex; align-items: center; gap: 8px; padding-top: 24px; }
.check-field input { width: 18px; min-height: 18px; }
.check-field span { margin: 0 !important; }
.admin-table-card { padding: 23px; }
.count-badge { padding: 5px 10px; border-radius: 999px; background: var(--green-50); color: var(--green-800); font-size: 12px; font-weight: 800; }

.editable-table { min-width: 1040px; }
.editable-table input { min-width: 76px; min-height: 36px; padding: 6px 8px; font-size: 13px; }
.editable-table .edit-code { width: 100px; }
.editable-table .edit-name { min-width: 190px; }
.editable-table .edit-grades { width: 85px; }
.editable-table .edit-teacher { min-width: 180px; }
.editable-table .edit-room { width: 75px; }
.editable-table .edit-capacity { width: 73px; }
.editable-table input[type="checkbox"] { width: 18px; min-width: 18px; min-height: 18px; }
.occupied-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }
.full-text { color: var(--red); font-weight: 750; }

.applications-toolbar { align-items: center; flex-direction: column; }
.filters { width: 100%; display: grid; grid-template-columns: 1fr .8fr .9fr minmax(240px, 1.3fr); gap: 12px; }
.search-field { min-width: 230px; }
.export-actions { width: 100%; justify-content: flex-end; }
#applicationsTable { min-width: 1000px; }
#applicationsTable select { min-width: 160px; min-height: 36px; padding: 6px 8px; font-size: 13px; }
.template-card { margin-bottom: 30px; }
.template-help { color: var(--muted); }
code { padding: 2px 5px; border-radius: 5px; color: var(--green-800); background: var(--green-50); font-size: 12px; }
#statementTemplate { min-height: 440px; resize: vertical; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

footer { min-height: 75px; display: flex; justify-content: space-between; align-items: center; gap: 20px; color: var(--muted); font-size: 12px; }
.loading {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; gap: 12px;
  color: white; background: rgba(12,46,39,.64); backdrop-filter: blur(3px); font-weight: 750;
}
.spinner { width: 24px; height: 24px; border: 3px solid rgba(255,255,255,.3); border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; z-index: 110; right: 22px; bottom: 22px; max-width: min(440px, calc(100% - 44px));
  padding: 13px 17px; border-radius: 12px; color: white; background: var(--green-900);
  box-shadow: 0 15px 45px rgba(0,0,0,.22); font-weight: 650;
}
.toast.error { background: #822f2f; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

@media (max-width: 1000px) {
  .login-layout { grid-template-columns: 1fr; gap: 30px; padding-top: 50px; }
  .login-card { justify-self: start; }
  .welcome-copy h1 { font-size: clamp(40px, 8vw, 66px); }
  .student-grid { grid-template-columns: 1fr; }
  .course-form-grid { grid-template-columns: repeat(3, 1fr); }
  .filters { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 740px) {
  .page-shell { width: min(100% - 22px, 1480px); }
  .site-header { min-height: 74px; }
  .brand strong { max-width: 205px; font-size: 14px; }
  .brand small, #headerUserName { display: none; }
  .login-layout { min-height: auto; padding: 45px 0 55px; }
  .welcome-copy h1 { font-size: 41px; }
  .welcome-copy > p:not(.eyebrow) { font-size: 16px; }
  .feature-list { display: none; }
  .login-card { padding: 25px; }
  .hero-card { min-height: 175px; padding: 27px 24px; border-radius: 19px; }
  .hero-card h1 { font-size: 31px; }
  .hero-badge { display: none; }
  .admin-hero { display: block; }
  .registration-control { align-items: stretch; flex-direction: column; }
  .registration-control .button { width: 100%; }
  .stats { margin-top: 24px; grid-template-columns: repeat(3, 1fr); }
  .stat { min-width: 0; padding: 11px; }
  .stat span { font-size: 9px; }
  .selection-card, .info-card, .table-card, .toolbar-card, .edit-card, .template-card { padding: 19px; }
  .tabs { width: 100%; overflow-x: auto; }
  .tab { flex: 1 0 auto; }
  .toolbar-card { align-items: stretch; flex-direction: column; }
  .toolbar-group .button { flex: 1 1 100%; }
  .course-form-grid, .filters { grid-template-columns: 1fr; }
  .course-form-grid .wide-field { grid-column: auto; }
  .check-field { padding-top: 3px; }
  .export-actions { flex-direction: column; }
  .export-actions .button { width: 100%; }
  footer { flex-direction: column; align-items: flex-start; justify-content: center; }
}
