:root {
  --ks-navy: #214e63;
  --ks-primary: #2f7d8c;
  --ks-primary-hover: #256878;
  --ks-primary-light: #e7f6f7;
  --ks-sun: #f7c948;
  --ks-coral: #f26d5b;
  --ks-grass: #5aa469;
  --ks-lavender: #8d7cc3;
  --ks-surface: #ffffff;
  --ks-bg: #fbf7ef;
  --ks-text: #243642;
  --ks-text-secondary: #51606a;
  --ks-text-muted: #7d8a92;
  --ks-border: #ded6c8;
  --ks-border-light: #eee7da;
  --ks-radius: 0.5rem;
  --ks-radius-sm: 0.375rem;
  --ks-transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(47, 125, 140, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(47, 125, 140, 0.035) 1px, transparent 1px),
    var(--ks-bg);
  background-size: 28px 28px;
  color: var(--ks-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

::selection {
  background: var(--ks-primary);
  color: #fff;
}

/* Navbar */
.navbar {
  background: #214e63;
  color: #fff;
  border-bottom: 4px solid var(--ks-sun);
  box-shadow: 0 3px 0 rgba(33, 78, 99, 0.18);
  padding: 0.7rem 0;
}

.nav-shell,
.nav-main,
.navbar-nav,
.nav-account {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-main {
  flex: 1;
}

.navbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 800;
  font-size: 1.18rem;
  letter-spacing: 0;
  color: #fff !important;
  text-decoration: none;
  padding: 0.2rem 0.65rem 0.25rem;
  margin-right: 1.5rem;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 0.5rem;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12);
}

.brand-mark {
  display: inline-flex;
  width: 1.7rem;
  height: 1.7rem;
  align-items: center;
  justify-content: center;
  color: #214e63;
  background: #ffe08a;
  border-radius: 0.45rem;
  font-size: 0.72rem;
  font-weight: 800;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.08);
}

.nav-link {
  color: rgba(255, 255, 255, 0.86) !important;
  text-decoration: none;
  padding: 0.35rem 0.6rem !important;
  border-radius: 999px;
  transition: color var(--ks-transition), background var(--ks-transition);
  font-size: 0.9rem;
}

.nav-link:hover,
.nav-link:focus-visible {
  color: #214e63 !important;
  background: #ffe08a;
}

.navbar-nav {
  list-style: none;
  margin: 0;
  padding: 0;
}

.navbar-text {
  color: rgba(255, 255, 255, 0.9) !important;
  font-size: 0.875rem;
}

.nav-account .nav-dropdown > .navbar-text {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
}

.nav-account .nav-dropdown:hover > .navbar-text,
.nav-account .nav-dropdown:focus-within > .navbar-text {
  color: #214e63 !important;
  background: #ffe08a;
}

.nav-dropdown {
  position: relative;
  display: flex;
  align-items: center;
}

.nav-dropdown::after {
  content: "";
  position: absolute;
  top: 100%;
  left: -0.75rem;
  right: -0.75rem;
  height: 1rem;
}

.nav-dropdown-menu {
  display: block;
  position: absolute;
  z-index: 1060;
  min-width: 14rem;
  list-style: none;
  margin: 0;
  padding: 0.375rem 0;
  background: #fff;
  border: 1px solid #d6c8b0;
  border-radius: var(--ks-radius);
  box-shadow: 0 12px 24px rgba(61, 74, 82, 0.14);
  top: calc(100% + 0.15rem);
  left: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(0.35rem);
  transition:
    opacity var(--ks-transition),
    transform var(--ks-transition),
    visibility 0s linear 150ms;
}

.nav-account .nav-dropdown-menu,
.nav-dropdown-menu-end {
  left: auto;
  right: 0;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition-delay: 0s;
}

.nav-dropdown-menu a,
.nav-dropdown-menu button {
  display: block;
  width: 100%;
  padding: 0.45rem 1rem;
  color: var(--ks-text);
  text-decoration: none;
  background: transparent;
  border: 0;
  text-align: left;
  font-size: 0.9rem;
  transition: background var(--ks-transition);
}

.nav-dropdown-menu a:hover,
.nav-dropdown-menu a:focus-visible,
.nav-dropdown-menu button:hover,
.nav-dropdown-menu button:focus-visible {
  background: #fff4cf;
  color: var(--ks-primary);
}

/* Typography */
h1, h2, h3, h4, .h1, .h2, .h3, .h4 {
  color: var(--ks-text);
  letter-spacing: 0;
  font-weight: 700;
}

h1, .h1 { font-size: 1.75rem; }
h2, .h2 { font-size: 1.375rem; }
h3, .h3 { font-size: 1.125rem; }
h4, .h4 { font-size: 1rem; }

a {
  color: var(--ks-primary);
  transition: color var(--ks-transition);
}

a:hover {
  color: var(--ks-primary-hover);
}

/* Cards */
.card {
  border-color: var(--ks-border);
  border-radius: var(--ks-radius);
  box-shadow: 0 2px 0 rgba(126, 105, 75, 0.08);
  transition: box-shadow var(--ks-transition);
  overflow: hidden;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(126, 105, 75, 0.12);
}

.card-header {
  background: #fffaf0;
  border-bottom-color: var(--ks-border-light);
  padding: 1rem 1.25rem;
  font-weight: 600;
}

.card-body {
  padding: 1.25rem;
}

.card-footer {
  background: transparent;
  border-top-color: var(--ks-border-light);
  padding: 0.875rem 1.25rem;
}

.shadow-sm {
  box-shadow: 0 2px 0 rgba(126, 105, 75, 0.08) !important;
}

.rounded {
  border-radius: var(--ks-radius) !important;
}

/* Tables */
.table {
  margin-bottom: 0;
}

.table thead th {
  border-bottom-width: 1px;
  border-bottom-color: var(--ks-border);
  color: var(--ks-text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.75rem 0.75rem;
  background: #fff4cf;
}

.table td {
  padding: 0.7rem 0.75rem;
  vertical-align: middle;
  border-bottom-color: var(--ks-border-light);
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
  background: rgba(47, 125, 140, 0.035);
}

.table-hover > tbody > tr:hover > * {
  background: #e7f6f7;
}

.table-sm td,
.table-sm th {
  padding: 0.45rem 0.6rem;
}

/* Forms */
.form-control,
.form-select {
  border-color: var(--ks-border);
  border-radius: var(--ks-radius-sm);
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  transition: border-color var(--ks-transition), box-shadow var(--ks-transition);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--ks-primary);
  box-shadow: 0 0 0 3px rgba(47, 125, 140, 0.16);
}

.form-control::placeholder {
  color: var(--ks-text-muted);
}

.form-label {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--ks-text-secondary);
  margin-bottom: 0.375rem;
}

.form-text {
  font-size: 0.8rem;
  color: var(--ks-text-muted);
}

.report-response-lines {
  white-space: normal;
}

.report-response-lines > div + div {
  margin-top: 0.2rem;
}

.form-check-input:checked {
  background-color: var(--ks-primary);
  border-color: var(--ks-primary);
}

.form-check-input:focus {
  border-color: var(--ks-primary);
  box-shadow: 0 0 0 3px rgba(47, 125, 140, 0.16);
}

.input-group-text {
  background: #fff8e6;
  border-color: var(--ks-border);
  font-size: 0.875rem;
}

/* Buttons */
.btn {
  font-weight: 700;
  border-radius: var(--ks-radius-sm);
  font-size: 0.875rem;
  padding: 0.45rem 1rem;
  transition: all var(--ks-transition);
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.3rem 0.75rem;
}

.btn-lg {
  font-size: 1rem;
  padding: 0.6rem 1.5rem;
}

.btn-primary {
  background: var(--ks-primary);
  border-color: var(--ks-primary);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--ks-primary-hover);
  border-color: var(--ks-primary-hover);
}

.btn-outline-primary {
  color: var(--ks-primary);
  border-color: var(--ks-primary);
}

.btn-outline-primary:hover {
  background: var(--ks-primary);
  border-color: var(--ks-primary);
}

.btn-light {
  color: #214e63;
  background: #fff4cf;
  border-color: #ffe08a;
}

.btn-outline-secondary {
  color: #51606a;
  border-color: #cfc3b1;
}

.btn-outline-secondary:hover {
  color: #243642;
  background: #fff4cf;
  border-color: #d8bd72;
}

.btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ks-text-secondary);
}

.btn-ghost:hover {
  background: var(--ks-bg);
  color: var(--ks-text);
}

/* Badges */
.badge {
  font-weight: 500;
  font-size: 0.75rem;
  padding: 0.25em 0.65em;
  border-radius: 999px;
}

.text-bg-success {
  background-color: var(--ks-grass) !important;
}

.text-bg-light {
  color: #214e63 !important;
  background-color: #fff4cf !important;
}

/* Alerts */
.alert {
  border: none;
  border-radius: var(--ks-radius);
  padding: 0.875rem 1.125rem;
  font-size: 0.9rem;
}

.alert-info {
  background: #e7f6f7;
  color: #214e63;
  border-left: 4px solid var(--ks-primary);
}

.alert-dismissible .btn-close {
  padding: 1rem;
  font-size: 0.75rem;
}

/* List group */
.list-group {
  border-radius: var(--ks-radius);
  border-color: var(--ks-border);
}

.list-group-item {
  border-color: var(--ks-border-light);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
}

.list-group-item:hover {
  background: #fffaf0;
}

.list-group-item:first-child {
  border-top-left-radius: var(--ks-radius);
  border-top-right-radius: var(--ks-radius);
}

.list-group-item:last-child {
  border-bottom-left-radius: var(--ks-radius);
  border-bottom-right-radius: var(--ks-radius);
}

/* Modal / dropdown */
.dropdown-menu {
  border-color: var(--ks-border);
  border-radius: var(--ks-radius);
  box-shadow: 0 12px 24px rgba(61, 74, 82, 0.14);
}

.dropdown-item {
  font-size: 0.875rem;
  padding: 0.45rem 1rem;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: #fff4cf;
  color: var(--ks-primary);
}

/* Footer */
.footer {
  background: #fffaf0;
  font-size: 0.825rem;
  border-top-color: #e1d4bf !important;
}

.footer-links a:hover {
  color: var(--ks-primary) !important;
}

/* HR */
hr {
  border-color: var(--ks-border);
  opacity: 0.6;
}

/* Code */
code {
  color: #7c3f8c;
  font-size: 0.85em;
  background: #f5effc;
  padding: 0.1em 0.35em;
  border-radius: 0.25rem;
}

/* PDF embed */
.pdf-frame {
  width: 100%;
  min-height: 720px;
  border: 1px solid var(--ks-border);
  border-radius: var(--ks-radius);
}

.pdf-frame-sm {
  min-height: 420px;
}

/* Responsive tables */
@media (max-width: 767.98px) {
  .table-responsive-cards thead {
    display: none;
  }

  .table-responsive-cards tbody tr {
    display: block;
    margin-bottom: 0.75rem;
    border: 1px solid var(--ks-border);
    border-radius: var(--ks-radius);
    padding: 0.75rem;
    background: #fff;
  }

  .table-responsive-cards td {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0;
    border: none;
    font-size: 0.875rem;
  }

  .table-responsive-cards td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--ks-text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }
}

/* Utility */
.text-muted {
  color: var(--ks-text-muted) !important;
}

.text-secondary {
  color: var(--ks-text-secondary) !important;
}

.bg-soft-primary {
  background: var(--ks-primary-light);
}

main.container {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(222, 214, 200, 0.7);
  border-radius: 0.75rem;
  margin-top: 1.25rem;
  padding: 1.5rem !important;
  box-shadow: 0 4px 0 rgba(126, 105, 75, 0.06);
}

main h1:first-child,
main .h4:first-child {
  position: relative;
}

main h1:first-child::after,
main .h4:first-child::after {
  content: "";
  display: block;
  width: 3.5rem;
  height: 0.25rem;
  margin-top: 0.45rem;
  background: linear-gradient(90deg, var(--ks-sun), var(--ks-coral), var(--ks-primary));
  border-radius: 999px;
}

/* Transitions for interactive elements */
.btn, .nav-link, .dropdown-item, .list-group-item, .card {
  will-change: auto;
}

.daily-sheet {
  background: #fff;
  color: #111827;
}

.sheet-header,
.sheet-student-header,
.sheet-signature {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.sheet-header {
  border-bottom: 2px solid #111827;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
}

.sheet-header h1,
.sheet-student-header h2 {
  margin: 0;
}

.sheet-student {
  border: 1px solid #111827;
  margin-bottom: 1rem;
  padding: 0.75rem;
  page-break-inside: avoid;
}

.sheet-student-header {
  border-bottom: 1px solid #111827;
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
}

.sheet-area-summary {
  border: 1px solid #111827;
  font-size: 0.82rem;
  margin-bottom: 0.5rem;
  padding: 0.25rem 0.4rem;
}

.sheet-table {
  border-collapse: collapse;
  width: 100%;
}

.sheet-table th,
.sheet-table td {
  border: 1px solid #111827;
  padding: 0.35rem;
  vertical-align: top;
}

.sheet-table th {
  background: #f3f4f6;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.sheet-subject td {
  background: #e5e7eb;
  font-weight: 700;
  text-transform: uppercase;
}

.sheet-table span {
  color: #4b5563;
  font-size: 0.8rem;
}

.sheet-text-responses {
  display: grid;
  gap: 0.25rem;
}

.sheet-response-label {
  color: #111827 !important;
  font-weight: 700;
}

.sheet-required {
  border: 1px solid #111827;
  color: #111827 !important;
  display: inline-block;
  font-size: 0.65rem !important;
  font-weight: 700;
  margin-left: 0.4rem;
  padding: 0.05rem 0.25rem;
  text-transform: uppercase;
}

.sheet-line {
  border-bottom: 1px solid #111827;
  height: 1.6rem;
}

.sheet-line.tall {
  height: 4.8rem;
}

.sheet-grid {
  border-collapse: collapse;
  width: 100%;
}

.sheet-grid th,
.sheet-grid td {
  border: 1px solid #111827;
  font-size: 0.72rem;
  padding: 0.25rem;
  text-align: center;
}

.sheet-grid td:first-child,
.sheet-grid th:first-child {
  text-align: left;
}

.sheet-check-cell {
  height: 1.35rem;
  min-width: 2rem;
}

.sheet-check-cell-filled {
  background: #e0f2fe;
  color: #0f172a;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1;
}

.sheet-checkboxes {
  display: grid;
  gap: 0.25rem 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
}

.sheet-checkboxes span {
  align-items: center;
  display: inline-flex;
  gap: 0.35rem;
}

.sheet-choice-box {
  align-items: center;
  border: 1px solid #111827;
  display: inline-flex;
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 800;
  height: 0.85rem;
  justify-content: center;
  line-height: 1;
  width: 0.85rem;
}

.sheet-choice-box-filled {
  background: #e0f2fe;
}

.trial-boxes {
  display: grid;
  grid-template-columns: repeat(5, minmax(2rem, 1fr));
  gap: 0.25rem;
}

.trial-boxes span {
  border: 1px solid #111827;
  color: #111827;
  display: inline-flex;
  min-height: 1.8rem;
  align-items: center;
  justify-content: center;
}

.sheet-notes {
  min-width: 10rem;
}

.sheet-signature {
  margin-top: 0.75rem;
}

.sheet-signature span {
  border-bottom: 1px solid #111827;
  min-height: 1.6rem;
  flex: 1;
  padding-right: 0.5rem;
}

.dashboard-calendar {
  background: #fff;
  border: 1px solid #d6dde7;
  border-radius: 0.5rem;
  padding: 1rem;
}

.dashboard-calendar-weekdays,
.dashboard-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.dashboard-calendar-weekdays {
  color: #5b6675;
  font-size: 0.78rem;
  font-weight: 700;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
  text-align: center;
  text-transform: uppercase;
}

.dashboard-calendar-grid {
  border: 1px solid #e3e8ef;
  border-bottom: 0;
  border-right: 0;
}

.dashboard-calendar-day {
  border-bottom: 1px solid #e3e8ef;
  border-right: 1px solid #e3e8ef;
  min-height: 6.25rem;
  padding: 0.45rem;
}

.dashboard-calendar-day.is-muted {
  background: #f7f9fc;
  color: #778293;
}

.dashboard-calendar-day.is-today {
  box-shadow: inset 0 0 0 2px #2563eb;
}

.dashboard-calendar-date {
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.dashboard-calendar-pill,
.dashboard-calendar-empty {
  display: block;
  font-size: 0.78rem;
  line-height: 1.2;
  margin-top: 0.25rem;
}

.dashboard-calendar-pill {
  border-radius: 0.25rem;
  padding: 0.2rem 0.35rem;
  text-decoration: none;
}

.dashboard-calendar-pill.submitted {
  background: #dcfce7;
  color: #166534;
}

.dashboard-calendar-pill.draft {
  background: #fef3c7;
  color: #92400e;
}

.dashboard-calendar-pill.missing {
  background: #fee2e2;
  color: #991b1b;
}

.dashboard-calendar-pill.expiring {
  background: #e0f2fe;
  color: #075985;
}

.dashboard-calendar-empty {
  color: #8a95a5;
}

.admin-ops-metric {
  background: #fff;
  border: 1px solid var(--ks-border);
  border-radius: 0.5rem;
  color: var(--ks-text);
  display: block;
  min-height: 100%;
  padding: 0.85rem;
  text-decoration: none;
}

.admin-ops-metric:hover,
.admin-ops-metric:focus-visible {
  border-color: var(--ks-primary);
  color: var(--ks-text);
  box-shadow: 0 4px 12px rgba(47, 125, 140, 0.12);
}

.admin-ops-metric-value,
.admin-ops-metric-title,
.admin-ops-metric-help {
  display: block;
}

.admin-ops-metric-value {
  color: var(--ks-primary);
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1;
}

.admin-ops-metric-title {
  font-weight: 700;
  margin-top: 0.45rem;
}

.admin-ops-metric-help {
  color: var(--ks-text-muted);
  font-size: 0.78rem;
  margin-top: 0.2rem;
}

@media (max-width: 767.98px) {
  .dashboard-calendar-day {
    min-height: 5rem;
    padding: 0.35rem;
  }

  .dashboard-calendar-pill,
  .dashboard-calendar-empty {
    font-size: 0.7rem;
  }
}

@media print {
  body {
    background: #fff;
    display: block;
  }

  .navbar,
  .footer,
  .print-hide {
    display: none !important;
  }

  main.container {
    max-width: none;
    width: 100%;
    padding: 0 !important;
    margin: 0 !important;
  }

  .daily-sheet {
    font-size: 10pt;
  }

  .sheet-student {
    page-break-inside: avoid;
  }
}
