:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --text: #18202b;
  --muted: #697386;
  --line: #dfe4ea;
  --panel: #ffffff;
  --accent: #1f7a5a;
  --accent-dark: #155b43;
  --danger: #9d2f2f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Segoe UI, Roboto, Arial, sans-serif;
  font-size: 15px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px clamp(18px, 4vw, 44px);
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 700;
}

h2 {
  margin-bottom: 16px;
  font-size: 18px;
}

.topbar p,
.metric span,
.student-list span {
  color: var(--muted);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 44px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric,
.panel,
.notice,
.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 14px;
}

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

.metric strong {
  margin-top: 8px;
  font-size: 22px;
}

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

.panel {
  padding: 18px;
}

form + form,
.button-link + form,
form + .button-link {
  margin-top: 12px;
}

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

input[type="file"],
input[type="password"],
select {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button-link:hover {
  background: var(--accent-dark);
}

.secondary {
  width: auto;
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.secondary:hover {
  background: #eef2f4;
}

.flash,
.notice {
  margin-bottom: 14px;
  padding: 12px 14px;
}

.flash.ok {
  color: var(--accent-dark);
  background: #e8f4ef;
}

.flash.error {
  color: var(--danger);
  background: #f8eaea;
}

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

.downloads a,
.student-list a {
  color: var(--text);
  text-decoration: none;
}

.downloads a:hover,
.student-list a:hover {
  color: var(--accent-dark);
}

.log,
.summary {
  overflow: auto;
  max-height: 520px;
  margin: 0;
  padding: 14px;
  border-radius: 6px;
  background: #101820;
  color: #f4f7fa;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.summary {
  max-height: none;
  background: #f7f9fb;
  color: var(--text);
  border: 1px solid var(--line);
}

.summary.ai {
  background: #eef8f4;
}

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

.summary-actions form {
  min-width: 220px;
}

.summary-actions p,
.empty-state {
  color: var(--muted);
}

.panel + .panel {
  margin-top: 18px;
}

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

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 320px) auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 16px;
}

.filters label {
  grid-column: 1 / -1;
  margin-bottom: -4px;
}

.filters .secondary {
  width: auto;
}

.student-list a {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

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

.login-panel {
  width: min(420px, calc(100% - 32px));
  padding: 26px;
}

.login-panel h1 {
  margin-bottom: 18px;
}

.login-panel button {
  margin-top: 14px;
}

@media (max-width: 760px) {
  .topbar,
  .workbench {
    display: block;
  }

  .topbar form,
  .topbar .button-link,
  .header-actions {
    margin-top: 14px;
  }

  .header-actions {
    display: grid;
    gap: 10px;
  }

  .workbench .panel + .panel {
    margin-top: 18px;
  }

  .summary-actions {
    display: block;
  }

  .summary-actions form {
    margin-top: 12px;
    min-width: 0;
  }

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

  .filters .secondary {
    width: 100%;
  }
}
