:root {
  --canvas: #f4f7f8;
  --surface: #ffffff;
  --surface-muted: #edf2f3;
  --ink: #15232d;
  --muted: #657580;
  --line: #d7e0e4;
  --teal: #0b746b;
  --teal-dark: #075750;
  --teal-soft: #dff3ef;
  --amber: #ad6811;
  --amber-soft: #fff1d8;
  --red: #b42318;
  --red-soft: #fff0ef;
  --blue: #1d5f96;
  --radius: 6px;
  --shadow: 0 8px 18px rgba(25, 43, 52, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  margin: 0;
  min-width: 320px;
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 50;
  background: var(--ink);
  color: #fff;
  padding: 8px 12px;
}

.skip-link:focus {
  top: 12px;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 440px);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 32px;
}

.error-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(11, 116, 107, 0.12), transparent 34%),
    radial-gradient(circle at right 18%, rgba(29, 95, 150, 0.08), transparent 32%),
    var(--canvas);
}

.error-panel {
  width: min(100%, 520px);
  display: grid;
  gap: 8px;
}

.error-code {
  color: var(--teal);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.24em;
  margin: 10px 0 0;
}

.error-copy {
  max-width: 34ch;
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.error-actions .button {
  width: fit-content;
}

.error-links {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
}

.error-links h2 {
  font-size: 12px;
  letter-spacing: 0.04em;
  margin: 0 0 4px;
  text-transform: uppercase;
}

.error-links a {
  color: var(--blue);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

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

.brand-mark,
.brand {
  align-items: center;
  display: inline-flex;
  font-weight: 750;
  gap: 9px;
  letter-spacing: 0;
  text-decoration: none;
}

.brand-mark {
  color: var(--teal-dark);
  font-size: 20px;
}

.login-panel h1 {
  font-size: 25px;
  letter-spacing: 0;
  line-height: 1.2;
  margin: 30px 0 8px;
}

.login-panel p {
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 24px;
}

.app-shell {
  display: grid;
  grid-template-columns: 246px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--ink);
  color: #edf6f6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 20px 14px;
}

.sidebar .brand {
  color: #ffffff;
  font-size: 19px;
  margin: 0 8px 26px;
}

.nav-list {
  display: grid;
  gap: 3px;
}

.nav-list a {
  align-items: center;
  border-left: 3px solid transparent;
  color: #d5e2e3;
  display: flex;
  font-size: 14px;
  gap: 11px;
  min-height: 42px;
  padding: 8px 10px;
  text-decoration: none;
}

.nav-list a:hover,
.nav-list a[aria-current="page"] {
  background: rgba(255, 255, 255, 0.1);
  border-left-color: #67d4c5;
  color: #ffffff;
}

.nav-list svg {
  height: 17px;
  width: 17px;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  margin-top: auto;
  padding: 16px 8px 0;
}

.user-name {
  color: #fff;
  font-size: 14px;
  font-weight: 650;
  margin: 0;
}

.role-name {
  color: #b9cacc;
  font-size: 12px;
  margin: 3px 0 12px;
  text-transform: capitalize;
}

.main-shell {
  min-width: 0;
}

.topbar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 70px;
  padding: 12px clamp(18px, 4vw, 46px);
}

.topbar h1 {
  font-size: 20px;
  letter-spacing: 0;
  margin: 0;
}

.topbar-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.page-content {
  margin: 0 auto;
  max-width: 1440px;
  padding: 28px clamp(18px, 4vw, 46px) 46px;
}

.page-heading {
  align-items: start;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 22px;
}

.page-heading h2 {
  font-size: 22px;
  line-height: 1.2;
  margin: 0;
}

.page-heading p {
  color: var(--muted);
  margin: 5px 0 0;
}

.metrics {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 24px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  min-height: 120px;
  padding: 18px;
}

.metric-label {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-bottom: 16px;
}

.metric-value {
  color: var(--ink);
  display: block;
  font-size: 30px;
  font-weight: 750;
  line-height: 1;
}

.semester-strip {
  align-items: center;
  background: var(--teal-soft);
  border-left: 4px solid var(--teal);
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  padding: 13px 15px;
}

.semester-strip strong {
  color: var(--teal-dark);
}

.work-grid {
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(290px, 0.72fr) minmax(0, 1.28fr);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  min-width: 0;
}

.panel-heading {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 15px 18px;
}

.panel-heading h3 {
  font-size: 16px;
  margin: 0;
}

.panel-body {
  padding: 18px;
}

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

.field {
  display: grid;
  gap: 6px;
}

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

.field label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

.field input,
.field select,
.field textarea,
.search-input {
  background: #fff;
  border: 1px solid #bfcbd1;
  border-radius: 4px;
  color: var(--ink);
  min-height: 39px;
  outline: none;
  padding: 8px 10px;
  width: 100%;
}

.field textarea {
  min-height: 80px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(11, 116, 107, 0.14);
}

.form-actions,
.toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.form-actions {
  margin-top: 18px;
}

.toolbar {
  justify-content: space-between;
  margin-bottom: 14px;
}

.toolbar .search-input {
  max-width: 360px;
}

.button,
.icon-button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 4px;
  display: inline-flex;
  font-size: 13px;
  font-weight: 650;
  gap: 7px;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  text-decoration: none;
}

.button svg,
.icon-button svg {
  height: 16px;
  width: 16px;
}

.button-primary {
  background: var(--teal);
  color: #fff;
}

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

.button[aria-busy="true"],
.icon-button[aria-busy="true"] {
  cursor: wait;
  opacity: 0.86;
}

.button-spinner {
  animation: button-spin 0.75s linear infinite;
  border: 2px solid currentColor;
  border-radius: 50%;
  border-right-color: transparent;
  flex: 0 0 auto;
  height: 15px;
  width: 15px;
}

.icon-button .button-spinner {
  height: 16px;
  width: 16px;
}

@keyframes button-spin {
  to {
    transform: rotate(360deg);
  }
}


.button-secondary {
  background: var(--surface);
  border-color: #bfcbd1;
  color: var(--ink);
}

.button-danger {
  background: var(--red-soft);
  border-color: #f4b4ae;
  color: var(--red);
}

.icon-button {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  min-width: 38px;
  padding: 8px;
}

.icon-button:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 650px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f7f9fa;
  color: #4e606a;
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

td {
  color: #263944;
  font-size: 13px;
}

.table-subtext {
  color: var(--muted);
  display: block;
  font-size: 11px;
  margin-top: 3px;
}

tbody tr:hover {
  background: #fbfcfc;
}

.table-actions {
  display: flex;
  gap: 4px;
}

.status {
  border-radius: 999px;
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 5px 8px;
  text-transform: capitalize;
}

.status-active,
.status-open {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.status-inactive,
.status-closed,
.status-cancelled {
  background: var(--surface-muted);
  color: var(--muted);
}

.empty-state {
  color: var(--muted);
  padding: 30px 12px;
  text-align: center;
}

.check-list {
  border: 1px solid var(--line);
  display: grid;
  max-height: 200px;
  overflow-y: auto;
}

.check-list label {
  align-items: center;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  display: flex;
  font-size: 13px;
  gap: 9px;
  padding: 10px;
}

.check-list label:last-child {
  border-bottom: 0;
}

.notice {
  background: var(--amber-soft);
  border-left: 4px solid var(--amber);
  color: #654111;
  margin-bottom: 18px;
  padding: 12px 14px;
}

.toast-region {
  bottom: 22px;
  display: grid;
  gap: 8px;
  position: fixed;
  right: 22px;
  width: min(360px, calc(100vw - 44px));
  z-index: 100;
}

.toast {
  background: var(--ink);
  border-left: 4px solid var(--teal);
  box-shadow: var(--shadow);
  color: #fff;
  font-size: 14px;
  padding: 12px 14px;
}

.toast.error {
  border-left-color: var(--red);
}

.mobile-nav-button {
  display: none;
}

@media (max-width: 1050px) {
  .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .work-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    min-height: auto;
    padding: 12px;
  }

  .sidebar .brand {
    margin: 0 4px 10px;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-list a {
    border-bottom: 2px solid transparent;
    border-left: 0;
    font-size: 12px;
    min-height: 38px;
  }

  .nav-list a[aria-current="page"] {
    border-bottom-color: #67d4c5;
  }

  .sidebar-footer {
    display: none;
  }

  .topbar {
    min-height: 58px;
    padding: 10px 18px;
  }

  .page-content {
    padding: 20px 18px 36px;
  }

  .page-heading {
    display: block;
  }

  .page-heading .button {
    margin-top: 12px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric {
    min-height: 102px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .field.full {
    grid-column: auto;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar .search-input {
    max-width: none;
  }
}

@media (max-width: 410px) {
  .nav-list {
    grid-template-columns: 1fr;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .login-panel {
    padding: 24px 20px;
  }

  .error-panel {
    padding: 24px 20px;
  }

  .error-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .error-actions .button {
    width: 100%;
  }
}

.check-list input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}