:root {
  --paper: #f7f5ef;
  --panel: #ffffff;
  --ink: #18231f;
  --muted: #64716b;
  --line: #dfe5df;
  --accent: #b7192b;
  --accent-dark: #831625;
  --gold: #b28735;
  --green: #166f57;
  --blue: #2d5f91;
  --warn: #9b5a14;
  --shadow: 0 18px 42px rgba(24, 35, 31, 0.09);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans SC", "PingFang SC", Arial, sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: 76px;
  padding: 14px 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  align-items: center;
  display: flex;
  gap: 14px;
  min-width: 0;
}

.brand img {
  border-radius: 4px;
  height: 48px;
  object-fit: cover;
  width: 48px;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 17px;
  line-height: 1.25;
}

.brand span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  margin-top: 4px;
}

.main-tabs {
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 28px 0;
}

.tab {
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  min-height: 46px;
  min-width: max-content;
  padding: 0 18px;
}

.tab.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 800;
}

main {
  padding: 28px;
}

.site-footer {
  align-items: center;
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  font-size: 13px;
  gap: 14px;
  justify-content: space-between;
  line-height: 1.6;
  padding: 18px 28px 28px;
}

.site-footer strong,
.site-footer span {
  display: block;
}

.site-footer strong {
  color: var(--ink);
}

.footer-links {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  justify-content: flex-end;
}

.footer-links a {
  color: var(--blue);
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.page-head {
  align-items: flex-end;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin: 0 0 22px;
}

.eyebrow {
  color: var(--gold);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.15;
  margin-bottom: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
  margin-bottom: 0;
}

p {
  line-height: 1.7;
}

.layout {
  display: grid;
  gap: 18px;
}

.two-col {
  grid-template-columns: minmax(0, 1.25fr) minmax(330px, 0.75fr);
}

.side-stack {
  display: grid;
  gap: 18px;
  height: fit-content;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
  padding: 18px;
}

.accent-panel {
  border-color: #e7d3a9;
  background: #fffaf0;
}

.status-pill {
  align-items: center;
  background: #f0f5f2;
  border: 1px solid #d3e3dc;
  border-radius: 999px;
  color: var(--green);
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  min-height: 32px;
  padding: 0 12px;
  white-space: nowrap;
}

.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.full {
  grid-column: 1 / -1;
}

.section-title {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.section-title.compact {
  margin-bottom: 10px;
  padding-bottom: 10px;
}

.section-title p {
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 0;
}

label {
  color: var(--muted);
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid #ccd7d0;
  border-radius: 6px;
  color: var(--ink);
  min-height: 42px;
  outline: none;
  padding: 10px 11px;
  width: 100%;
}

textarea {
  line-height: 1.55;
  min-height: 96px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(183, 25, 43, 0.12);
}

.file-drop {
  background: #fbfcfb;
  border: 1px dashed #b8c7bf;
  border-radius: 8px;
  padding: 14px;
}

.file-drop input {
  border: 0;
  min-height: 0;
  padding: 4px 0 0;
}

.declarations {
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.declarations h2 {
  margin-bottom: 12px;
}

.checkbox-line {
  align-items: flex-start;
  color: var(--ink);
  display: flex;
  font-size: 14px;
  font-weight: 650;
  gap: 10px;
  line-height: 1.55;
  margin: 10px 0;
}

.checkbox-line input {
  flex: 0 0 auto;
  height: 18px;
  margin-top: 2px;
  min-height: 18px;
  width: 18px;
}

.form-actions,
.top-actions,
.admin-toolbar,
.lookup-form {
  align-items: center;
  display: flex;
  gap: 10px;
}

button,
.link-button {
  align-items: center;
  border-radius: 6px;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-height: 42px;
  padding: 0 15px;
  text-decoration: none;
}

.primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-dark);
}

.secondary,
.ghost {
  background: #fff;
  border: 1px solid #cbd6d0;
  color: var(--ink);
}

.secondary:hover,
.ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.rule-list {
  color: var(--ink);
  display: grid;
  gap: 10px;
  line-height: 1.65;
  margin: 0;
  padding-left: 20px;
}

.hidden {
  display: none !important;
}

.result-card {
  background: #f7faf8;
  border: 1px solid #d8e6de;
  border-radius: 8px;
  color: var(--ink);
  line-height: 1.65;
  padding: 16px;
}

.result-card:empty {
  display: none;
}

.result-card strong {
  color: var(--accent);
}

.lookup-panel {
  max-width: 980px;
}

.auth-panel {
  max-width: 980px;
}

.lookup-form {
  align-items: flex-end;
  margin-bottom: 16px;
}

.lookup-form label {
  flex: 1 1 220px;
}

.admin-login {
  align-items: flex-end;
  display: flex;
  gap: 12px;
  max-width: 720px;
}

.admin-login label {
  flex: 1 1 auto;
}

.admin-console {
  display: grid;
  gap: 18px;
}

.student-console,
.student-records {
  display: grid;
  gap: 18px;
}

.student-toolbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.student-toolbar h2 {
  margin: 0;
}

.student-record {
  display: grid;
  gap: 14px;
}

.student-file-groups {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.student-file-groups h3,
.supplement-area h3 {
  margin: 0 0 8px;
}

.supplement-area {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.supplement-form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.metric-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.metric strong {
  display: block;
  font-size: 28px;
  line-height: 1;
  margin-bottom: 8px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.admin-toolbar {
  margin-bottom: 16px;
}

.admin-toolbar input {
  flex: 1 1 auto;
}

.admin-toolbar select {
  max-width: 190px;
}

.record-list {
  display: grid;
  gap: 12px;
}

.record {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 14px;
}

.record-head {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.record-title {
  min-width: 0;
}

.record-title h3 {
  margin: 0 0 4px;
}

.record-title p,
.meta-line {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
}

.record-actions {
  align-items: flex-end;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(150px, 0.35fr) minmax(220px, 1fr) auto;
}

.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.file-list a {
  background: #f3f5f4;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 750;
  max-width: 100%;
  overflow: hidden;
  padding: 6px 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge {
  border-radius: 999px;
  color: #fff;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 850;
  min-width: max-content;
  padding: 6px 10px;
}

.status-submitted,
.status-format_check {
  background: var(--warn);
}

.status-needs_revision,
.status-not_selected {
  background: var(--accent);
}

.status-eligible,
.status-shortlisted {
  background: var(--green);
}

.status-adopted {
  background: var(--blue);
}

@media (max-width: 980px) {
  main {
    padding: 20px;
  }

  .two-col,
  .metric-grid,
  .student-file-groups {
    grid-template-columns: 1fr;
  }

  .page-head,
  .record-head,
  .student-toolbar,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .footer-links {
    justify-content: flex-start;
  }

  .status-pill {
    white-space: normal;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 18px;
  }

  .main-tabs {
    padding-left: 18px;
    padding-right: 18px;
  }

  main {
    padding: 18px;
  }

  h1 {
    font-size: 26px;
  }

  .form-grid,
  .lookup-form,
  .admin-login,
  .admin-toolbar,
  .record-actions {
    grid-template-columns: 1fr;
  }

  .form-grid {
    display: grid;
  }

  .lookup-form,
  .admin-login,
  .admin-toolbar {
    align-items: stretch;
    display: grid;
  }

  .form-actions {
    align-items: stretch;
    display: grid;
  }
}
