:root {
  --bg: #eef2f4;
  --bg-accent: #e3ebe7;
  --surface: #ffffff;
  --ink: #15232b;
  --muted: #5d6f78;
  --line: #d5dde0;
  --primary: #0d5c63;
  --primary-dark: #09464c;
  --primary-soft: #d7ecee;
  --accent: #c45c26;
  --ok: #1f7a4c;
  --ok-soft: #e5f5ec;
  --warn: #9a6b12;
  --warn-soft: #f8efd8;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(21, 35, 43, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
  --font: "Outfit", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #d9ebe8 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #f3e6dc 0%, transparent 45%),
    var(--bg);
  line-height: 1.45;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(960px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1.25rem 0 calc(2rem + var(--safe-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.brand strong {
  font-family: var(--display);
  font-size: clamp(1.45rem, 4vw, 1.9rem);
  font-weight: 650;
  letter-spacing: -0.02em;
}

.brand span {
  color: var(--muted);
  font-size: 0.9rem;
}

.card {
  background: var(--surface);
  border: 1px solid rgba(21, 35, 43, 0.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-pad {
  padding: 1.1rem 1.15rem;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.section-head h1,
.section-head h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 650;
  letter-spacing: -0.02em;
  font-size: clamp(1.35rem, 3.5vw, 1.7rem);
}

.section-head p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.72rem 1.15rem;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  transition: background 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.btn:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid rgba(21, 35, 43, 0.12);
}

.btn-secondary:hover:not(:disabled) {
  background: #f7fafb;
}

.btn-accent {
  background: var(--accent);
}

.btn-accent:hover:not(:disabled) {
  background: #a84c1d;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding-inline: 0.65rem;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 14px;
}

.search-wrap {
  position: relative;
  margin-bottom: 0.9rem;
}

.search-wrap input {
  width: 100%;
  border: 1px solid rgba(21, 35, 43, 0.1);
  background: #f7fafb;
  border-radius: 14px;
  padding: 0.85rem 1rem 0.85rem 2.7rem;
  outline: none;
  min-height: 48px;
}

.search-wrap input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.search-wrap::before {
  content: "";
  position: absolute;
  left: 1rem;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  background: no-repeat center / contain;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%235d6f78'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m21 21-4.3-4.3m1.8-5.2a7 7 0 1 1-14 0 7 7 0 0 1 14 0Z'/%3E%3C/svg%3E");
  opacity: 0.85;
  pointer-events: none;
}

.student-list {
  display: grid;
  gap: 0.65rem;
}

.student-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(21, 35, 43, 0.07);
  background: linear-gradient(180deg, #fff, #fbfcfc);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  text-align: left;
  width: 100%;
}

.student-item:hover,
.student-item:focus-visible {
  border-color: rgba(13, 92, 99, 0.35);
  box-shadow: 0 8px 20px rgba(13, 92, 99, 0.08);
  outline: none;
}

.student-item:active {
  transform: scale(0.995);
}

.student-meta {
  min-width: 0;
}

.student-meta strong {
  display: block;
  font-size: 1.02rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.student-meta span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  margin-top: 0.15rem;
}

.chev {
  color: var(--muted);
  flex-shrink: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.chip-muted {
  background: #eef2f4;
  color: var(--muted);
}

.chip-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.chip-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.date-list {
  display: grid;
  gap: 0.6rem;
}

.date-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(21, 35, 43, 0.07);
  background: #fff;
}

.date-item strong {
  display: block;
}

.date-item span {
  color: var(--muted);
  font-size: 0.85rem;
}

.fab-wrap {
  position: sticky;
  bottom: calc(0.85rem + var(--safe-bottom));
  display: flex;
  justify-content: flex-end;
  margin-top: 1.25rem;
  pointer-events: none;
  z-index: 20;
}

.fab-wrap .btn {
  pointer-events: auto;
  box-shadow: 0 12px 28px rgba(13, 92, 99, 0.28);
}

.work-list {
  display: grid;
  gap: 0.75rem;
}

.work-card {
  border: 1px solid rgba(21, 35, 43, 0.08);
  border-radius: 16px;
  padding: 1rem;
  background: linear-gradient(180deg, #fff, #fafbfc);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.work-card:hover,
.work-card:focus-visible {
  border-color: rgba(13, 92, 99, 0.35);
  box-shadow: 0 2px 10px rgba(15, 28, 34, 0.06);
  outline: none;
}

.work-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.work-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.work-card p {
  margin: 0;
  white-space: pre-wrap;
  color: #31434c;
  font-size: 0.95rem;
}

.empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
}

.empty strong {
  display: block;
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.15rem;
  margin-bottom: 0.35rem;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 28, 34, 0.48);
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(480px, 100%);
  background: #fff;
  border-radius: 22px 22px 18px 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  max-height: min(90vh, 720px);
  overflow: auto;
  animation: slideUp 0.22s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(16px);
    opacity: 0.4;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.1rem 0.4rem;
}

.modal header h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.25rem;
}

.modal .body {
  padding: 0.5rem 1.1rem 1.15rem;
}

.field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.field label {
  font-size: 0.86rem;
  font-weight: 600;
  color: #3d5059;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid rgba(21, 35, 43, 0.12);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  background: #f7fafb;
  outline: none;
  min-height: 46px;
}

.field textarea {
  min-height: 120px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 0.65rem;
  margin-top: 0.35rem;
}

/* Loaders */
.page-loader {
  position: fixed;
  inset: 0;
  background: rgba(238, 242, 244, 0.72);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 80;
}

.page-loader.show {
  display: flex;
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(13, 92, 99, 0.18);
  border-top-color: var(--primary);
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.spinner.sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.btn .spinner {
  display: none;
}

.btn.is-loading .spinner {
  display: inline-block;
}

.btn.is-loading .btn-label {
  opacity: 0.85;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.25rem + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  background: #15232b;
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.92rem;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 90;
  max-width: min(92vw, 420px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: var(--danger);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.login-card {
  width: min(420px, 100%);
  padding: 1.6rem 1.35rem 1.4rem;
}

.login-card .eyebrow {
  color: var(--primary);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.45rem;
}

.login-card h1 {
  margin: 0 0 0.35rem;
  font-family: var(--display);
  font-size: clamp(1.7rem, 5vw, 2.1rem);
}

.login-card .lead {
  margin: 0 0 1.25rem;
  color: var(--muted);
}

.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

@media (min-width: 720px) {
  .modal-backdrop {
    align-items: center;
  }

  .modal {
    border-radius: 20px;
  }

  .student-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
