:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #d9e1ea;
  --primary: #0f766e;
  --primary-strong: #115e59;
  --accent: #2563eb;
  --ok: #15803d;
  --near: #b7791f;
  --over: #b42318;
  --shadow: 0 18px 50px rgba(26, 41, 61, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button,
input,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(18px, 4vw, 48px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

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

.brand-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.brand small,
.muted {
  color: var(--muted);
}

.brand span:last-child {
  display: grid;
  gap: 2px;
}

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

.logout-form {
  margin: 0;
}

.nav a,
.button,
button {
  border-radius: 8px;
}

.nav a {
  padding: 9px 12px;
  color: var(--muted);
}

.nav a.active,
.nav a:hover {
  background: #e7f4f2;
  color: var(--primary-strong);
}

.page {
  width: min(1420px, calc(100% - 32px));
  margin: 28px auto 64px;
}

.alert {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid;
  background: var(--surface);
}

.alert-error {
  border-color: #f2b8b5;
  color: var(--over);
}

.alert-success {
  border-color: #a8d5ba;
  color: var(--ok);
}

.no-cycles-banner {
  display: grid;
  gap: 14px;
  place-items: center;
  margin-bottom: 22px;
  padding: clamp(28px, 6vw, 56px);
  border: 2px solid #f2b8b5;
  border-radius: 8px;
  background: #fff7ed;
  color: var(--over);
  text-align: center;
}

.no-cycles-banner strong {
  font-size: clamp(2rem, 6vw, 4.8rem);
  line-height: 1;
}

.no-cycles-banner span {
  color: #7a271a;
  font-size: 1.05rem;
  font-weight: 700;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.hero h1,
.teacher-card h2,
.panel h2 {
  margin: 0;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary-strong);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

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

.chart-card {
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chart-card h2 {
  margin: 0;
}

.donut-wrap {
  display: grid;
  place-items: center;
}

.donut {
  width: min(280px, 78vw);
  height: auto;
}

.donut-hole {
  fill: transparent;
  stroke: #edf2f7;
  stroke-width: 5;
}

.donut-segment {
  fill: transparent;
  stroke-width: 5;
  transform: rotate(-90deg);
  transform-origin: center;
}

.donut-number {
  fill: var(--text);
  font-size: 0.44rem;
  font-weight: 800;
  text-anchor: middle;
}

.donut-label {
  fill: var(--muted);
  font-size: 0.16rem;
  text-anchor: middle;
}

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

.legend div {
  display: grid;
  grid-template-columns: 14px 42px 1fr;
  align-items: center;
  gap: 10px;
}

.legend span {
  width: 14px;
  height: 14px;
  border-radius: 999px;
}

.legend em {
  color: var(--muted);
  font-style: normal;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.contract-chart {
  display: grid;
  gap: 14px;
}

.contract-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(200px, 2fr) 56px;
  align-items: center;
  gap: 14px;
}

.contract-row div:first-child {
  display: grid;
  gap: 4px;
}

.contract-row span {
  color: var(--muted);
}

.bar-track {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.bar-track span {
  display: block;
  height: 100%;
  background: var(--accent);
}

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

.stat {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.stat span,
.load-row span,
.assignment span {
  color: var(--muted);
  font-size: 0.88rem;
}

.stat strong {
  font-size: 1.8rem;
}

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

.search {
  flex: 1;
}

label {
  display: block;
  margin-bottom: 7px;
  color: #344054;
  font-size: 0.9rem;
  font-weight: 700;
}

.search div,
.cycle-switch {
  display: flex;
  gap: 10px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  padding: 9px 11px;
}

input:focus,
select:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(15, 118, 110, 0.14);
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: white;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
}

.button:hover,
button:hover {
  background: var(--primary-strong);
}

.button.secondary {
  border-color: var(--accent);
  background: var(--accent);
}

.button.ghost,
.icon-button {
  border-color: var(--line);
  background: white;
  color: var(--text);
}

.icon-button.danger {
  color: var(--over);
}

.teacher-list {
  display: grid;
  gap: 14px;
}

.teacher-card {
  padding: 18px;
  border-left-width: 6px;
}

.teacher-card.ok {
  border-left-color: var(--ok);
}

.teacher-card.near {
  border-left-color: var(--near);
}

.teacher-card.over {
  border-left-color: var(--over);
}

.teacher-main,
.load-row,
.assignment {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.teacher-main {
  margin-bottom: 14px;
}

.teacher-card h2 {
  font-size: 1.1rem;
}

.load-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 12px;
}

.load-row > div {
  display: grid;
  gap: 4px;
}

.status-pill,
.mini-pill {
  width: fit-content;
  padding: 7px 10px;
  border-radius: 999px;
  background: #edf2f7;
  font-weight: 800;
  font-size: 0.84rem;
}

.ok .status-pill,
.mini-pill.active {
  background: #dcfce7;
  color: var(--ok);
}

.near .status-pill {
  background: #fef3c7;
  color: var(--near);
}

.over .status-pill {
  background: #fee4e2;
  color: var(--over);
}

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

.progress span {
  display: block;
  height: 100%;
  background: var(--primary);
}

.near .progress span {
  background: var(--near);
}

.over .progress span {
  background: var(--over);
}

.assignment-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.pending-list {
  display: grid;
  gap: 10px;
  max-height: 620px;
  overflow: auto;
}

.pending-list div {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.pending-list span {
  color: var(--muted);
  font-size: 0.9rem;
}

.group-columns {
  align-items: start;
}

.assignment {
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
}

.assignment div {
  display: grid;
  gap: 4px;
}

.compact {
  margin: 0;
}

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

.modal {
  width: min(720px, calc(100% - 28px));
  padding: 0;
  border: 0;
  background: transparent;
}

.subject-picker {
  position: relative;
}

.subject-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.subject-results button,
.subject-empty {
  display: block;
  width: 100%;
  min-height: auto;
  padding: 11px 12px;
  border: 0;
  border-radius: 0;
  background: white;
  color: var(--text);
  text-align: left;
  white-space: normal;
}

.subject-results button:hover {
  background: #e7f4f2;
}

.subject-empty {
  color: var(--muted);
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.modal-panel {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.warning-box {
  padding: 12px 14px;
  border: 1px solid #f2b8b5;
  border-radius: 8px;
  background: #fff1f0;
  color: var(--over);
  font-weight: 700;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-weight: 600;
}

.check-row input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

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

.panel {
  padding: 18px;
}

.stack {
  display: grid;
  gap: 12px;
}

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

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

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

.inline-upload input {
  width: 230px;
}

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

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

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

.error-panel {
  max-width: 720px;
}

.account-panel {
  max-width: 520px;
}

.login-shell {
  display: grid;
  min-height: calc(100vh - 180px);
  place-items: center;
}

.login-panel {
  display: grid;
  width: min(440px, 100%);
  gap: 14px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-logo {
  width: 118px;
  height: 118px;
  object-fit: contain;
  justify-self: center;
  margin-bottom: 2px;
}

.login-panel h1 {
  margin: 0;
  text-align: center;
}

.login-panel .eyebrow,
.login-panel .muted {
  text-align: center;
}

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

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

.user-row,
.catalog-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 170px 100px auto auto;
  gap: 10px;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.small-check {
  margin: 0;
}

.catalog-row {
  grid-template-columns: 130px minmax(260px, 1.5fr) minmax(180px, 1fr) 120px 100px auto;
}

@media (max-width: 900px) {
  .topbar,
  .hero,
  .toolbar,
  .teacher-main {
    align-items: stretch;
    flex-direction: column;
  }

  .stats-grid,
  .chart-grid,
  .load-row,
  .two-column,
  .user-row,
  .catalog-row {
    grid-template-columns: 1fr;
  }

  .contract-row {
    grid-template-columns: 1fr;
  }

  .search div,
  .cycle-switch,
  .modal-actions {
    flex-direction: column;
  }

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