:root {
  --ink: #18211f;
  --muted: #66726d;
  --line: #dce4e0;
  --surface: #ffffff;
  --canvas: #f4f7f5;
  --green: #116149;
  --green-2: #0c4838;
  --gold: #d99a21;
  --red: #b73535;
  --blue: #246b8f;
  --shadow: 0 18px 45px rgba(21, 35, 30, .12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  color: #fff;
  background: #142620;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px 26px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  color: #142620;
  background: #f5c860;
  font-size: 13px;
  font-weight: 800;
}

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

.brand small {
  margin-top: 3px;
  color: #b6c7c0;
}

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

.nav-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  color: #dce9e4;
  background: transparent;
  text-align: left;
}

.nav-tab svg {
  width: 19px;
  height: 19px;
}

.nav-tab:hover, .nav-tab.active {
  color: #142620;
  background: #f4f0df;
}

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

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

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

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

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
}

h2 {
  font-size: 18px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.icon-button, .primary-button, .text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  min-height: 42px;
  white-space: nowrap;
}

.icon-button {
  width: 42px;
  padding: 0;
  color: #fff;
  background: var(--green);
}

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

.primary-button {
  padding: 0 16px;
  color: #fff;
  background: var(--green);
  font-weight: 700;
}

.text-button {
  min-height: 34px;
  padding: 0 12px;
  color: var(--green);
  background: #edf6f2;
  font-weight: 700;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

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

.metric {
  min-height: 118px;
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 12px;
  font-size: 38px;
  line-height: 1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: 18px;
}

.panel {
  padding: 18px;
}

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

.timeline, .capacity-list {
  display: grid;
  gap: 10px;
}

.timeline-item, .capacity-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.timeline-item strong, .capacity-item strong {
  display: block;
}

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

.bar {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: #e7ece9;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.editor {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  margin-bottom: 16px;
}

.editor.compact {
  grid-template-columns: repeat(3, minmax(180px, 1fr)) auto;
}

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

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

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

input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(17, 97, 73, .14);
}

.wide {
  grid-column: span 2;
}

.search-input {
  max-width: 360px;
}

.table-wrap {
  overflow: auto;
}

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

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

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

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

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.mini-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
}

.mini-button.danger {
  color: var(--red);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--green-2);
  background: #e9f5ef;
  font-size: 13px;
  font-weight: 800;
}

.status.warn {
  color: #7a5208;
  background: #fff3d3;
}

.status.red {
  color: #842626;
  background: #fde5e5;
}

.empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.attendance {
  display: flex;
  align-items: center;
  gap: 8px;
}

.attendance input {
  width: 18px;
  height: 18px;
  min-height: 0;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(340px, calc(100vw - 44px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--green-2);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1050px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
  }
  .nav-tabs {
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    overflow-x: auto;
  }
  .editor, .editor.compact, .dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }
  .wide {
    grid-column: span 2;
  }
  .primary-button {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .main {
    padding: 18px;
  }
  .topbar {
    align-items: flex-start;
  }
  .metric-grid, .editor, .editor.compact, .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .wide {
    grid-column: span 1;
  }
  .nav-tabs {
    grid-template-columns: repeat(5, 150px);
  }
  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .search-input {
    max-width: none;
  }
}
