:root {
  color-scheme: light;
  --bg: #f5f2ec;
  --panel: #fffdfa;
  --ink: #202124;
  --muted: #6b6862;
  --line: #ded8cc;
  --accent: #0e766e;
  --accent-dark: #075d57;
  --accent-soft: #d9efeb;
  --rose: #b13f5a;
  --amber: #b7791f;
  --shadow: 0 18px 42px rgba(37, 32, 24, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(14, 118, 110, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(177, 63, 90, 0.1), transparent 30%),
    var(--bg);
  color: var(--ink);
  font-size: 14px;
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto;
  align-items: end;
  gap: 18px;
  padding: 16px 0 14px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 720px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.summary-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(116px, 1fr));
  gap: 10px;
}

.teacher-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.metric {
  min-height: 70px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.78);
}

.metric strong {
  display: block;
  margin-bottom: 5px;
  font-size: 22px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.92);
  box-shadow: var(--shadow);
}

.sidebar {
  align-self: start;
  padding: 16px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  min-height: 38px;
  border-radius: 8px;
  background: #ede7dc;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.tab.is-active {
  background: var(--accent);
  color: #fff;
}

.stacked-form,
.operation-form {
  display: grid;
  gap: 12px;
}

.operation-form {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.stacked-form {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.hidden {
  display: none;
}

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

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 400;
  padding: 0 12px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft);
}

.form-grid,
.operation-grid {
  display: grid;
  gap: 10px;
}

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

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

.primary,
.secondary,
.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 700;
}

.operation-form .primary,
.operation-form .secondary {
  height: 40px;
  margin-top: auto;
}

.link-button {
  min-width: 74px;
}

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

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

.secondary {
  background: var(--ink);
  color: #fff;
}

.secondary:hover {
  background: #000;
}

.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.list-block {
  padding-top: 18px;
}

.directory-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.directory-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.directory-item strong,
.directory-item span {
  overflow-wrap: anywhere;
}

.directory-item strong {
  font-size: 14px;
}

.directory-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.item-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.delete-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid #efd0d7;
  border-radius: 8px;
  background: #fff;
  color: var(--rose);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.delete-button:hover {
  background: #f7d7df;
}

.main-column {
  display: grid;
  gap: 18px;
}

.action-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
  gap: 18px;
  padding: 16px;
}

.table-panel {
  padding: 16px;
}

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

.search {
  max-width: 260px;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

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

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.warn {
  background: #f8e8c8;
  color: var(--amber);
}

.pill.bad {
  background: #f7d7df;
  color: var(--rose);
}

.ledger {
  display: grid;
  gap: 8px;
}

.ledger-row {
  display: grid;
  grid-template-columns: 108px 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 50px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.ledger-row time {
  color: var(--muted);
  font-size: 12px;
}

.ledger-row strong {
  display: block;
  margin-bottom: 3px;
  font-size: 14px;
}

td strong {
  font-size: 14px;
}

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

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

.auth-shell {
  width: min(460px, 100%);
  padding: 18px;
}

.auth-panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 250, 0.94);
  box-shadow: var(--shadow);
}

.auth-panel h1 {
  margin-bottom: 20px;
  font-size: 42px;
}

.auth-form {
  border-bottom: 0;
  padding-bottom: 0;
}

.form-error {
  padding: 12px;
  border-radius: 8px;
  background: #f7d7df;
  color: var(--rose);
  font-weight: 700;
}

.auth-hint {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1080px) {
  .action-panel {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

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

  .summary-grid,
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
  }

  h1 {
    font-size: 30px;
    line-height: 1;
  }

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

  .section-header,
  .ledger-row {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .search {
    max-width: none;
  }

  .teacher-box {
    justify-content: flex-start;
  }

  .panel,
  .auth-panel {
    box-shadow: none;
  }

  .metric {
    min-height: 72px;
  }

  .tabs {
    position: sticky;
    top: 0;
    z-index: 2;
    padding-top: 2px;
    background: rgba(255, 253, 250, 0.92);
  }

  .primary,
  .secondary,
  .ghost {
    width: 100%;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  tr {
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  td {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 10px;
    border-bottom: 1px solid var(--line);
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .auth-panel h1 {
    font-size: 30px;
  }
}

@media (max-width: 420px) {
  .app-shell {
    padding: 8px;
  }

  .topbar {
    gap: 16px;
    padding-top: 14px;
  }

  .sidebar,
  .action-panel,
  .table-panel,
  .auth-panel {
    padding: 12px;
  }

  .directory-item {
    display: grid;
  }

  td {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}
