:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #eef6f3;
  --ink: #172126;
  --muted: #627179;
  --line: #d9e2e5;
  --nav: #102932;
  --nav-soft: #173843;
  --teal: #0f766e;
  --teal-dark: #0b5f59;
  --amber: #d97706;
  --blue: #2563eb;
  --red: #dc2626;
  --green: #15803d;
  --shadow: 0 16px 42px rgba(16, 41, 50, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(380px, 0.95fr);
  background: var(--surface);
}

.login-visual {
  position: relative;
  overflow: hidden;
  background: #dcebe6;
}

.login-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.login-brand {
  position: absolute;
  left: 32px;
  top: 32px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-brand span,
.sidebar-brand span {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid !important;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  color: #fff !important;
  background: linear-gradient(135deg, var(--teal), #1e3a8a);
  font-weight: 800;
  letter-spacing: 0;
}

.login-panel {
  width: min(100%, 560px);
  align-self: center;
  justify-self: center;
  padding: 48px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.02;
}

h2 {
  font-size: 1.28rem;
}

h3 {
  font-size: 1rem;
}

.muted {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
  margin: 28px 0;
}

label {
  display: grid;
  gap: 7px;
  color: #314047;
  font-size: 0.88rem;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.primary-button,
.ghost-button,
.subtle-button,
.danger-button,
.icon-button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 750;
  white-space: nowrap;
}

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

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

.ghost-button,
.subtle-button {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  padding: 0 14px;
}

.subtle-button {
  background: var(--surface-2);
}

.subtle-button.is-active {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}

.danger-button {
  color: #fff;
  background: var(--red);
  padding: 0 14px;
}

.icon-button {
  width: 40px;
  padding: 0;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  position: relative;
}

button svg {
  width: 18px;
  height: 18px;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-weight: 700;
}

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

.demo-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  text-align: left;
}

.demo-card strong,
.demo-card span {
  display: block;
}

.demo-card span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.83rem;
}

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

.sidebar {
  min-height: 100vh;
  background: var(--nav);
  color: #fff;
  padding: 18px;
  position: sticky;
  top: 0;
}

.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 6px 18px;
}

.side-nav {
  display: grid;
  gap: 6px;
}

.nav-link {
  border: 0;
  width: 100%;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 8px;
  text-align: left;
}

.nav-link:hover,
.nav-link.active {
  color: #fff;
  background: var(--nav-soft);
}

.nav-link svg {
  width: 18px;
  height: 18px;
}

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

.topbar {
  height: 76px;
  padding: 0 28px;
  background: rgba(245, 247, 248, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.notif-count {
  position: absolute;
  min-width: 18px;
  height: 18px;
  right: -6px;
  top: -7px;
  display: grid;
  place-items: center;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--amber);
  color: #fff;
  font-size: 0.72rem;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #1d4ed8;
  font-size: 0.75rem;
  font-weight: 800;
}

.content {
  padding: 28px;
  display: grid;
  gap: 20px;
}

.notification-tray {
  position: fixed;
  right: 24px;
  top: 86px;
  width: min(420px, calc(100vw - 32px));
  max-height: 72vh;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  z-index: 20;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr);
  gap: 20px;
  align-items: stretch;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.hero-copy {
  padding: 24px;
  display: grid;
  align-content: center;
  gap: 14px;
}

.hero-copy h2 {
  font-size: clamp(1.5rem, 2.6vw, 2.25rem);
}

.hero-image {
  min-height: 220px;
  background: #dcebe6;
}

.hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.metric-grid,
.card-grid,
.module-grid,
.form-grid {
  display: grid;
  gap: 14px;
}

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

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

.module-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  align-items: start;
}

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

.metric-card,
.panel,
.item-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-card {
  padding: 16px;
  display: grid;
  gap: 8px;
}

.metric-card span {
  color: var(--muted);
  font-size: 0.85rem;
}

.metric-card strong {
  font-size: 1.75rem;
}

.panel {
  padding: 18px;
}

.panel-stack {
  display: grid;
  gap: 14px;
}

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

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-header p {
  margin: 4px 0 0;
}

.item-list {
  display: grid;
  gap: 10px;
}

.item-card {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.item-row,
.split-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.83rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #edf2f7;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 750;
}

.tag.green {
  color: #14532d;
  background: #dcfce7;
}

.tag.amber {
  color: #78350f;
  background: #fef3c7;
}

.tag.red {
  color: #7f1d1d;
  background: #fee2e2;
}

.tag.blue {
  color: #1e3a8a;
  background: #dbeafe;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar .filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.field-group {
  display: grid;
  gap: 8px;
  color: #314047;
  font-size: 0.88rem;
}

.checkbox-list {
  max-height: 240px;
  overflow: auto;
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.check-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  font-weight: 500;
}

.check-row input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
}

.data-table th,
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: #4b5b63;
  background: #f0f5f6;
  font-size: 0.82rem;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table .group-row td {
  padding: 10px 12px;
  background: #e8f3f4;
  color: var(--teal-dark);
  font-weight: 800;
}

.course-details {
  min-width: 160px;
}

.course-details summary {
  cursor: pointer;
  color: var(--teal-dark);
  font-weight: 750;
}

.course-details-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  color: var(--muted);
}

.khs-panel {
  background: #fff;
  border: 1px solid #e5f2f2;
  border-radius: 8px;
  box-shadow: 0 18px 36px rgba(15, 118, 110, 0.08);
  padding: 20px;
  display: grid;
  gap: 16px;
}

.print-only {
  display: none;
}

.khs-letterhead,
.letterhead-preview {
  width: 100%;
  max-height: 140px;
  object-fit: contain;
  object-position: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.letterhead-file {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 92px;
  color: var(--ink);
}

.letterhead-file svg {
  width: 24px;
  height: 24px;
  color: var(--teal);
}

.khs-print-identity {
  gap: 6px;
  color: var(--ink);
}

.khs-print-identity span,
.khs-print-identity strong {
  display: block;
}

.khs-notes {
  display: grid;
  gap: 4px;
  padding: 14px 18px;
  border-radius: 4px;
  color: #fff;
  background: #7c91bb;
  font-size: 0.9rem;
}

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

  .sidebar,
  .topbar,
  .notification-tray,
  .print-khs-button,
  #menuToggle,
  #notifButton,
  #logoutButton {
    display: none !important;
  }

  .app-shell,
  .app-main,
  .content {
    display: block;
    min-height: auto;
    padding: 0;
  }

  .content > *:not(.khs-panel) {
    display: none !important;
  }

  .khs-panel {
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  .print-only {
    display: grid !important;
  }

  .khs-meta-row {
    min-height: 0;
  }

  .khs-table,
  .khs-summary-table {
    min-width: 0;
    font-size: 11px;
  }

  .khs-table th,
  .khs-table td {
    padding: 7px 6px;
  }
}

.khs-meta-row {
  min-height: 78px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.khs-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.khs-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 4px;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
}

.khs-badge.green {
  background: #31c7aa;
}

.khs-badge.amber {
  background: #ffc65a;
}

.khs-badge.blue {
  background: #3797f5;
}

.print-khs-button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  color: #fff;
  background: #ff4f73;
  box-shadow: 0 8px 18px rgba(255, 79, 115, 0.28);
  font-weight: 750;
}

.print-khs-button:hover {
  background: #ef3d62;
}

.khs-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.staff-khs-summary {
  margin-top: 14px;
}

.khs-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  color: #60758a;
  font-size: 0.84rem;
}

.khs-table th,
.khs-table td {
  border: 1px solid #e5eef8;
  padding: 13px 10px;
  text-align: center;
}

.khs-table th {
  color: #fff;
  background: #3697e8;
  font-weight: 800;
}

.khs-table tbody tr {
  background: #fbfbfc;
}

.khs-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.khs-table .subject-cell {
  text-align: left;
  color: #617990;
  letter-spacing: 0;
}

.khs-total-row td {
  background: #fbfbfc;
  font-weight: 500;
}

.khs-summary-table {
  min-width: 640px;
}

.khs-summary-table th:first-child,
.khs-summary-table td:first-child {
  text-align: left;
}

.progress {
  height: 9px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.progress span {
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue));
}

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

.calendar-day {
  min-height: 92px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.calendar-day strong {
  display: block;
  margin-bottom: 7px;
}

.mini-event {
  display: block;
  margin-top: 5px;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 700;
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.mobile-only {
  display: none;
}

@media (max-width: 1100px) {
  .metric-grid,
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .module-grid,
  .dashboard-hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .login-screen {
    grid-template-columns: 1fr;
  }

  .login-visual {
    min-height: 260px;
  }

  .login-panel {
    padding: 28px 20px 36px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 86vw);
    z-index: 30;
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  .mobile-only {
    display: inline-flex;
  }

  .topbar {
    height: auto;
    min-height: 72px;
    padding: 12px 16px;
  }

  .topbar-actions {
    gap: 7px;
  }

  .user-chip {
    display: none;
  }

  .content {
    padding: 18px;
  }

  .metric-grid,
  .card-grid,
  .form-grid,
  .demo-grid,
  .calendar-grid {
    grid-template-columns: 1fr;
  }

  .hero-image {
    min-height: 170px;
  }

  .item-row,
  .split-row,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .khs-panel {
    padding: 14px;
  }

  .khs-meta-row {
    min-height: 0;
    flex-direction: column;
  }

  .print-khs-button {
    width: 100%;
  }
}
