:root {
  --bg: #f8f4ef;
  --surface: #fffdf9;
  --surface-strong: #ffffff;
  --ink: #22313a;
  --muted: #68757c;
  --line: #e5ddd4;
  --coral: #c95b4f;
  --coral-dark: #9f3f37;
  --teal: #1f6f70;
  --gold: #c99538;
  --sage: #7f9b7a;
  --shadow: 0 18px 45px rgba(43, 35, 28, 0.11);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

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

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.login-panel {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-brand {
  color: var(--ink);
  margin-bottom: 22px;
  justify-items: center;
  text-align: center;
}

.login-brand span {
  color: var(--muted);
}

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

.form-error {
  background: #ffe6e2;
  color: #9b2f25;
  border-radius: 8px;
  margin: 0;
  padding: 10px 12px;
  font-weight: 700;
}

.form-hint {
  color: var(--muted);
  font-weight: 700;
  margin: 0;
  align-self: end;
}

.user-badge {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-weight: 800;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: #243840;
  color: #fffaf2;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: grid;
  gap: 10px;
}

.brand-mark {
  width: 100%;
  max-width: 210px;
  height: auto;
  object-fit: contain;
}

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

.brand strong {
  font-size: 24px;
}

.brand span {
  color: #dbcfc2;
}

.main-nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  color: #fffaf2;
  background: transparent;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  text-align: left;
}

.nav-item.is-active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
}

.nav-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.13);
}

.sidebar-summary {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  padding-top: 20px;
  display: grid;
  gap: 6px;
  color: #dbcfc2;
}

.sidebar-summary strong {
  color: #fffaf2;
  font-size: 22px;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--coral-dark);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
  margin: 0 0 4px;
}

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

h1 {
  margin-bottom: 0;
  font-size: 34px;
}

h2 {
  font-size: 20px;
  margin-bottom: 0;
}

.topbar-actions,
.toolbar,
.segmented,
footer {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 40px;
}

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

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

.secondary-button {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
  padding: 0 16px;
}

.danger-button {
  background: #fff1ef;
  color: #9b2f25;
  border-color: #f0c9c3;
  padding: 0 16px;
}

.compact-button {
  min-height: 32px;
  padding: 0 10px;
  white-space: nowrap;
}

.icon-button {
  width: 40px;
  display: grid;
  place-items: center;
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.toolbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
  box-shadow: 0 8px 20px rgba(43, 35, 28, 0.05);
}

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

input,
select,
textarea {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

textarea {
  min-height: 110px;
  resize: vertical;
  padding: 10px;
}

.segmented {
  align-self: stretch;
  background: #efe7de;
  padding: 4px;
  border-radius: 8px;
}

.period-nav {
  display: flex;
  align-items: end;
  gap: 8px;
}

.period-nav[hidden] {
  display: none;
}

.day-head span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.segmented button {
  border: 0;
  background: transparent;
  border-radius: 6px;
  min-height: 34px;
  padding: 0 12px;
  color: var(--muted);
}

.segmented button.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 3px 9px rgba(43, 35, 28, 0.08);
}

.planner-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
}

.planner-panel,
.day-detail,
.table-card {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.planner-panel,
.day-detail {
  padding: 16px;
}

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

.panel-heading span {
  color: var(--muted);
  font-weight: 700;
}

.week-grid {
  display: grid;
  grid-template-columns: 74px repeat(6, minmax(122px, 1fr));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.grid-cell,
.time-cell,
.day-head {
  min-height: 72px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 8px;
}

.day-head,
.time-cell {
  background: #fbf7f1;
  font-weight: 800;
}

.time-cell {
  color: var(--muted);
  font-size: 13px;
}

.lesson-chip {
  border: 1px solid var(--course-border, transparent);
  width: 100%;
  text-align: left;
  color: var(--course-fg, #fff);
  background: var(--course-bg, var(--teal));
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 6px;
  display: grid;
  gap: 3px;
}

.lesson-chip strong,
.lesson-chip span {
  overflow-wrap: anywhere;
}

.lesson-chip span {
  font-size: 12px;
  opacity: 0.9;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(90px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.month-day {
  min-height: 128px;
  max-height: 128px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 8px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 6px;
  overflow: hidden;
}

.month-day:hover {
  background: #fbf6ef;
}

.month-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.month-day-head strong {
  display: block;
}

.month-day-head span {
  min-width: 26px;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #efe7de;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.month-lesson-list {
  display: grid;
  gap: 4px;
  overflow: hidden;
}

.month-lesson-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.month-lesson-list span {
  min-height: 20px;
  border-radius: 8px;
  background: #fbf7f1;
  padding: 3px 6px;
}

.month-more-button {
  min-height: 26px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-weight: 800;
  font-size: 12px;
  color: var(--coral-dark);
  text-align: left;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.month-more-button:hover {
  text-decoration: underline;
}

.month-week-button {
  min-height: 30px;
  border: 1px solid #f0c9c3;
  border-radius: 8px;
  background: #fff1ef;
  color: var(--coral-dark);
  font-size: 12px;
  font-weight: 800;
  padding: 0 9px;
  cursor: pointer;
}

.month-week-button:hover {
  background: #ffe3df;
}

.day-dialog-list {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  max-height: min(56vh, 520px);
  overflow: auto;
}

.day-dialog-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
}

.day-dialog-item:hover {
  background: #fbf6ef;
  border-color: #f0c9c3;
}

.day-dialog-item strong,
.day-dialog-item span {
  display: block;
}

.day-dialog-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.detail-item {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 12px 0;
  text-align: left;
}

.detail-item:last-child {
  border-bottom: 0;
}

.detail-item:hover strong {
  color: var(--coral-dark);
}

.detail-item strong {
  display: block;
}

.detail-item span {
  color: var(--muted);
  font-size: 13px;
}

.table-card {
  overflow: auto;
}

.finance-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.finance-summary article {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 10px 26px rgba(43, 35, 28, 0.07);
}

.finance-summary span {
  color: var(--muted);
  display: block;
  font-weight: 800;
  margin-bottom: 8px;
}

.finance-summary strong {
  font-size: 26px;
}

.finance-heading {
  margin-top: 22px;
}

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

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #fbf6ef;
}

td span {
  color: var(--muted);
  font-size: 13px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 8px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.status.ok {
  background: #e6f1ec;
  color: #23614b;
}

.status.warn {
  background: #fff2d8;
  color: #916011;
}

.status.due {
  background: #ffe6e2;
  color: #9b2f25;
}

.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}

.course-card {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 8px solid var(--course-border, var(--line));
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 10px 26px rgba(43, 35, 28, 0.07);
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.course-card:hover {
  border-color: var(--coral);
  transform: translateY(-1px);
}

.course-card h3 {
  margin-bottom: 10px;
}

.course-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.student-dialog {
  width: min(860px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
}

.student-dialog::backdrop {
  background: rgba(20, 28, 32, 0.46);
}

.student-form {
  padding: 22px;
}

.student-form header,
.student-form footer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.student-form footer {
  grid-template-columns: auto 1fr auto auto;
  margin-top: 18px;
}

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

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

.checkbox-grid {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 12px;
}

.transfer-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  align-items: end;
}

.transfer-box[hidden] {
  display: none;
}

.transfer-box legend {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  padding: 0 6px;
}

.transfer-box p {
  grid-column: 1 / -1;
  color: var(--muted);
  margin: 0;
}

.transfer-list {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

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

.checkbox-grid legend {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  padding: 0 6px;
}

.checkbox-grid > div {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
}

.checkbox-option {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  font-weight: 700;
}

.checkbox-option input {
  min-height: auto;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 14px;
  }

  .main-nav {
    grid-template-columns: repeat(4, 1fr);
  }

  .sidebar-summary {
    display: none;
  }

  .planner-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

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

  .primary-button,
  .secondary-button,
  .danger-button {
    width: 100%;
  }
}
