:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-muted: #eef3ef;
  --line: #d8dfd9;
  --ink: #17211b;
  --muted: #657268;
  --green: #23704a;
  --green-dark: #174d35;
  --yellow: #c47b16;
  --red: #b54848;
  --blue: #2b5d8a;
  --shadow: 0 18px 50px rgba(23, 33, 27, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(35, 112, 74, 0.08), transparent 34%),
    var(--bg);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "YuGothic",
    "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

button:hover {
  border-color: #aeb9b1;
  transform: translateY(-1px);
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(43, 93, 138, 0.22);
  outline-offset: 2px;
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

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

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
  padding: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-size: 25px;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.brand h1,
.brand p,
.toolbar h2,
.toolbar p,
.panel h2,
.section-heading h2 {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
  letter-spacing: 0;
}

.brand p,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  box-shadow: 0 10px 28px rgba(23, 33, 27, 0.04);
}

.panel.subtle {
  background: var(--surface-muted);
}

.panel h2 {
  margin-bottom: 14px;
  font-size: 15px;
}

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

.summary-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafcfb;
  padding: 12px;
}

.summary-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.summary-grid dd {
  margin: 4px 0 0;
  font-size: 26px;
  font-weight: 800;
}

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

.primary-button {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
  font-weight: 800;
}

.primary-button:hover {
  border-color: var(--green-dark);
  background: var(--green-dark);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.panel-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  color: var(--green-dark);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.panel-link:focus-visible {
  outline: 3px solid rgba(43, 93, 138, 0.22);
  outline-offset: 2px;
}

.main-content {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 28px;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.toolbar h2 {
  margin-top: 4px;
  font-size: clamp(25px, 3vw, 38px);
  letter-spacing: 0;
}

.toolbar-controls {
  display: grid;
  grid-template-columns: 170px 170px;
  gap: 12px;
}

.action-strip {
  display: flex;
  align-items: end;
  gap: 10px;
  min-height: 56px;
}

.search-box {
  margin-left: auto;
  width: min(280px, 100%);
}

.table-wrap {
  position: relative;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8faf8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.number-col {
  width: 76px;
}

.action-col {
  width: 86px;
}

.student-number {
  color: var(--muted);
  font-weight: 800;
}

.student-name {
  min-width: 150px;
  font-weight: 800;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 74px);
  gap: 6px;
}

.segmented button {
  min-height: 36px;
  padding: 0 8px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.segmented button.is-active[data-status="present"] {
  border-color: rgba(35, 112, 74, 0.35);
  background: rgba(35, 112, 74, 0.12);
  color: var(--green-dark);
}

.segmented button.is-active[data-status="late"] {
  border-color: rgba(196, 123, 22, 0.38);
  background: rgba(196, 123, 22, 0.14);
  color: #8a5510;
}

.segmented button.is-active[data-status="absent"] {
  border-color: rgba(181, 72, 72, 0.38);
  background: rgba(181, 72, 72, 0.13);
  color: #8c3434;
}

.note-input {
  min-width: 220px;
}

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

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

.history-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
}

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

.section-heading h2 {
  font-size: 17px;
}

.section-heading span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

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

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

.status-pill {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
}

.status-present {
  background: rgba(35, 112, 74, 0.12);
  color: var(--green-dark);
}

.status-late {
  background: rgba(196, 123, 22, 0.14);
  color: #8a5510;
}

.status-absent {
  background: rgba(181, 72, 72, 0.13);
  color: #8c3434;
}

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .action-strip {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .search-box {
    margin-left: 0;
    width: 100%;
  }
}

@media (max-width: 560px) {
  .sidebar,
  .main-content {
    padding: 18px;
  }

  .toolbar-controls,
  .button-row {
    grid-template-columns: 1fr;
  }

  .action-strip > button {
    flex: 1 1 150px;
  }

  .history-item {
    grid-template-columns: 1fr;
  }
}
