:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #68726d;
  --line: #d9ded6;
  --paper: #fbfbf8;
  --panel: #ffffff;
  --panel-strong: #f0f3ee;
  --forest: #234b3b;
  --green: #2f7d63;
  --gold: #c8952e;
  --brick: #b5523b;
  --focus: #153f86;
  --shadow: 0 18px 45px rgba(23, 32, 27, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

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

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: #17201b;
  color: #f7faf5;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 52px;
  margin-bottom: 28px;
}

.brand img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: #fff;
}

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

.brand strong {
  font-size: 15px;
  line-height: 1.25;
}

.brand small {
  color: #c9d2c8;
  margin-top: 2px;
}

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

.side-nav a {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 6px;
  color: #dfe8de;
  border: 1px solid transparent;
}

.side-nav a:hover,
.side-nav a.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.workspace {
  min-width: 0;
  padding: 22px 26px 48px;
}

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

.topbar h1,
h2,
h3,
p {
  margin: 0;
}

.topbar h1 {
  font-size: 30px;
  line-height: 1.1;
}

.eyebrow {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-actions,
.section-heading,
.action-cell,
.report-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-heading {
  justify-content: space-between;
  margin-bottom: 14px;
}

.compact-heading {
  margin-bottom: 8px;
}

.page-panel {
  display: grid;
  gap: 16px;
}

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

.metric-card,
.surface {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 96px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

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

.metric-card strong {
  font-size: 34px;
  line-height: 1;
}

.surface {
  padding: 16px;
  margin-bottom: 16px;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(180px, 280px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.search-grid,
.admin-grid {
  display: grid;
  gap: 16px;
}

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

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

.search-filter-bar {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(190px, 1fr) minmax(210px, 1.1fr) auto;
  gap: 12px;
  align-items: end;
}

.tabs {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  min-height: 46px;
  border-bottom: 1px solid var(--line);
}

.tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 45px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  color: var(--muted);
  font-weight: 800;
}

.tabs a.active {
  margin-bottom: -1px;
  background: var(--panel);
  border-color: var(--line);
  border-bottom-color: var(--panel);
  color: var(--ink);
}

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

.form-grid h3,
.wide {
  grid-column: 1 / -1;
}

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

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cbd4ca;
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 11px;
  outline: none;
}

select[multiple] {
  min-height: 150px;
  padding: 8px;
}

input:focus,
select:focus,
summary:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(21, 63, 134, 0.18);
  outline-offset: 2px;
  border-color: var(--focus);
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.primary-button,
.ghost-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.primary-button {
  background: var(--forest);
  color: #ffffff;
}

.primary-button:hover {
  background: #1b3d30;
}

.ghost-button {
  background: var(--panel-strong);
  color: var(--ink);
  border-color: var(--line);
}

.ghost-button:hover {
  background: #e7ece5;
}

.danger-button {
  background: #fff0ec;
  color: #8c2f1f;
  border-color: #f1c5b9;
}

.danger-button:hover {
  background: #ffe2da;
}

.compact {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.icon-button {
  width: 34px;
  min-width: 34px;
  padding: 0;
  font-weight: 800;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: #4d5a54;
  font-size: 12px;
  text-transform: uppercase;
  background: #f3f5f0;
}

tbody tr:hover {
  background: #faf8f1;
}

.empty {
  color: var(--muted);
  padding: 12px 0;
}

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

.result-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.session-result {
  align-items: start;
}

.result-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.result-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.result-item div,
.result-item small,
.result-item span {
  min-width: 0;
}

.result-item span,
.result-item small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.action-cell {
  align-items: flex-start;
  flex-wrap: wrap;
}

.inline-editor {
  position: relative;
}

.inline-editor summary {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  cursor: pointer;
  list-style: none;
}

.inline-editor summary::-webkit-details-marker {
  display: none;
}

.inline-editor[open] form {
  display: grid;
}

.inline-editor form {
  position: absolute;
  z-index: 5;
  right: 0;
  top: 42px;
  width: min(520px, 82vw);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.table-filter {
  max-width: 260px;
}

.toast-stack {
  position: fixed;
  z-index: 10;
  top: 16px;
  right: 18px;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
}

.toast {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.toast.success {
  border-color: #9bc9aa;
  color: #1f5d3a;
}

.toast.error {
  border-color: #e7ad9e;
  color: #842d20;
}

.lesson-dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.lesson-dialog::backdrop {
  background: rgba(15, 25, 20, 0.46);
}

.dialog-card {
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.report-panel {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.report-form {
  align-items: end;
}

.report-form select {
  min-width: 260px;
}

.tracking-table table {
  min-width: 860px;
}

.tracking-table td.done {
  background: #e8f6ec;
}

.tracking-table td.missing {
  background: #fff3ef;
  color: #8b3a2b;
}

.tracking-table td span {
  display: block;
  min-width: 110px;
}

.tracking-table small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

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

  .sidebar {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 14px;
  }

  .brand {
    margin-bottom: 0;
  }

  .side-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-content: center;
  }

  .side-nav a {
    justify-content: center;
    text-align: center;
  }

  .search-grid,
  .split-layout,
  .search-filter-bar {
    grid-template-columns: 1fr;
  }
}

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

  .topbar,
  .section-heading,
  .sidebar {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .metric-grid,
  .admin-grid,
  .form-grid,
  .report-panel {
    grid-template-columns: 1fr;
  }

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

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

  .topbar-actions,
  .report-form {
    width: 100%;
  }

  .topbar-actions > *,
  .report-form > * {
    flex: 1;
  }

  .inline-editor form {
    position: static;
    width: 100%;
    margin-top: 8px;
    grid-template-columns: 1fr;
  }
}
