:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #687385;
  --line: #e3e7ee;
  --primary: #176b5f;
  --primary-dark: #10554b;
  --accent: #b84a2f;
  --warning-bg: #fff4dc;
  --warning-text: #8b4d00;
  --radius: 8px;
  --shadow: 0 12px 32px rgba(24, 35, 52, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
  overflow-x: hidden;
}

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 252px;
  background: #111827;
  color: #f8fafc;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--primary);
  font-weight: 800;
}

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

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

.nav {
  display: grid;
  gap: 5px;
}

.nav a,
.logout {
  color: #d7dde8;
  padding: 11px 12px;
  border-radius: 8px;
}

.nav a:hover,
.logout:hover {
  background: #1f2937;
  color: #fff;
}

.logout {
  margin-top: auto;
}

.main {
  margin-left: 252px;
  padding: 32px;
  max-width: 1500px;
  min-width: 0;
  overflow-x: hidden;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 22px;
}

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

h1 {
  font-size: 30px;
}

h2 {
  font-size: 18px;
}

p {
  margin: 8px 0 0;
  color: var(--muted);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metrics article,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metrics article {
  padding: 18px;
}

.metrics span {
  color: var(--muted);
  display: block;
}

.metrics strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
}

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

.panel {
  padding: 20px;
  margin-bottom: 18px;
  max-width: 100%;
  overflow-x: auto;
}

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

.panel-head a {
  color: var(--primary);
  font-weight: 700;
}

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

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.list-row:first-child {
  border-top: 0;
}

.list-row span {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #eef2f7;
  color: #334155;
  font-size: 13px;
  white-space: nowrap;
}

.badge.warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

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

.teachers-table {
  table-layout: fixed;
}

.products-table {
  table-layout: fixed;
}

.students-table {
  table-layout: fixed;
}

.assignments-table {
  table-layout: fixed;
}

.lessons-table {
  table-layout: fixed;
}

.teachers-table th:nth-child(1),
.teachers-table td:nth-child(1) {
  width: 24%;
}

.teachers-table th:nth-child(2),
.teachers-table td:nth-child(2) {
  width: 16%;
}

.teachers-table th:nth-child(3),
.teachers-table td:nth-child(3) {
  width: 14%;
}

.teachers-table th:nth-child(4),
.teachers-table td:nth-child(4) {
  width: 11%;
}

.teachers-table th:nth-child(5),
.teachers-table td:nth-child(5) {
  width: 13%;
}

.teachers-table th:nth-child(6),
.teachers-table td:nth-child(6) {
  width: 180px;
}

.products-table th:nth-child(1),
.products-table td:nth-child(1) {
  width: 26%;
}

.products-table th:nth-child(2),
.products-table td:nth-child(2),
.products-table th:nth-child(3),
.products-table td:nth-child(3) {
  width: 10%;
}

.products-table th:nth-child(4),
.products-table td:nth-child(4),
.products-table th:nth-child(5),
.products-table td:nth-child(5) {
  width: 12%;
}

.products-table th:nth-child(6),
.products-table td:nth-child(6) {
  width: 12%;
}

.products-table th:nth-child(7),
.products-table td:nth-child(7) {
  width: 180px;
}

.students-table th:nth-child(1),
.students-table td:nth-child(1) {
  width: 26%;
}

.students-table th:nth-child(2),
.students-table td:nth-child(2) {
  width: 18%;
}

.students-table th:nth-child(3),
.students-table td:nth-child(3) {
  width: 24%;
}

.students-table th:nth-child(4),
.students-table td:nth-child(4) {
  width: 14%;
}

.students-table th:nth-child(5),
.students-table td:nth-child(5) {
  width: 180px;
}

.assignments-table th:nth-child(1),
.assignments-table td:nth-child(1),
.assignments-table th:nth-child(2),
.assignments-table td:nth-child(2) {
  width: 16%;
}

.assignments-table th:nth-child(3),
.assignments-table td:nth-child(3) {
  width: 18%;
}

.assignments-table th:nth-child(4),
.assignments-table td:nth-child(4) {
  width: 10%;
}

.assignments-table th:nth-child(5),
.assignments-table td:nth-child(5) {
  width: 14%;
}

.assignments-table th:nth-child(6),
.assignments-table td:nth-child(6) {
  width: 10%;
}

.assignments-table th:nth-child(7),
.assignments-table td:nth-child(7) {
  width: 180px;
}

.lessons-table th:nth-child(1),
.lessons-table td:nth-child(1) {
  width: 12%;
}

.lessons-table th:nth-child(2),
.lessons-table td:nth-child(2),
.lessons-table th:nth-child(3),
.lessons-table td:nth-child(3) {
  width: 15%;
}

.lessons-table th:nth-child(4),
.lessons-table td:nth-child(4) {
  width: 14%;
}

.lessons-table th:nth-child(5),
.lessons-table td:nth-child(5),
.lessons-table th:nth-child(6),
.lessons-table td:nth-child(6) {
  width: 10%;
}

.lessons-table th:nth-child(7),
.lessons-table td:nth-child(7) {
  width: 16%;
}

.lessons-table th:nth-child(8),
.lessons-table td:nth-child(8) {
  width: 120px;
}

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

.teachers-table td,
.products-table td,
.students-table td,
.assignments-table td,
.lessons-table td {
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.form-panel {
  box-shadow: none;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.assignment-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.form-grid > *,
label {
  min-width: 0;
}

.schedule-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
  grid-column: span 2;
  min-width: 0;
}

.weekday-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(38px, 1fr));
  gap: 6px;
  width: 100%;
  max-width: 100%;
}

.weekday-grid label {
  display: block;
}

.weekday-grid input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.weekday-grid span {
  display: grid;
  place-items: center;
  height: 42px;
  border: 1px solid #cfd6e1;
  border-radius: 8px;
  color: var(--text);
  background: #fff;
  cursor: pointer;
}

.weekday-grid input:checked + span {
  border-color: var(--primary);
  background: #e8f4f1;
  color: var(--primary-dark);
  font-weight: 800;
}

label {
  color: var(--muted);
  font-weight: 700;
}

input,
select,
button {
  font: inherit;
  letter-spacing: 0;
}

input,
select {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 42px;
  margin-top: 6px;
  padding: 9px 11px;
  border: 1px solid #cfd6e1;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #64748b 50%),
    linear-gradient(135deg, #64748b 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 19px,
    calc(100% - 12px) 19px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.native-select-hidden {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}

.select-ui {
  position: relative;
  margin-top: 6px;
  width: 100%;
  min-width: 0;
}

.select-ui-input {
  width: 100%;
  min-height: 42px;
  padding: 9px 46px 9px 13px;
  border: 1px solid #cfd6e1;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  position: relative;
}

.select-ui::after {
  content: "";
  position: absolute;
  right: 18px;
  top: 21px;
  width: 8px;
  height: 8px;
  border-right: 2px solid #64748b;
  border-bottom: 2px solid #64748b;
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}

.select-ui.open .select-ui-input {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 107, 95, 0.14);
}

.select-ui.open::after {
  transform: translateY(-35%) rotate(225deg);
}

.select-ui-list {
  position: absolute;
  z-index: 30;
  left: 0;
  right: auto;
  top: calc(100% + 6px);
  width: min(720px, max(100%, 58vw));
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid #cfd6e1;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(24, 35, 52, 0.18);
  padding: 6px;
}

.select-ui-option {
  width: 100%;
  min-height: 36px;
  justify-content: flex-start;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-weight: 650;
  text-align: left;
  padding: 8px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-ui-option:hover,
.select-ui-option.selected {
  background: #f1f8f6;
  color: var(--primary-dark);
}

.select-ui-option.selected {
  box-shadow: inset 3px 0 0 var(--primary);
}

select:focus,
input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 107, 95, 0.14);
  outline: none;
}

.lessons-table {
  min-width: 1120px;
}

.lessons-table td,
.lessons-table th {
  word-break: normal;
}

.lessons-table th:nth-child(8),
.lessons-table td:nth-child(8) {
  width: 150px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

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

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 15px;
  border: 1px solid #cfd6e1;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.button.primary,
button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

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

.row-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  vertical-align: middle;
  white-space: nowrap;
}

.status-text {
  display: inline-block;
  min-width: 86px;
}

.switch {
  position: relative;
  width: 46px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #cbd5e1;
}

.switch span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.22);
  transition: transform 0.15s ease;
}

.switch.on {
  background: var(--primary);
}

.switch.on span {
  transform: translateX(20px);
}

.icon-danger {
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border: 1px solid #f1c6bd;
  border-radius: 8px;
  color: #a23822;
  background: #fff7f5;
  font-size: 22px;
  line-height: 1;
}

.icon-danger:hover {
  background: #ffe7e1;
}

.icon-edit {
  min-height: 30px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid #cfd6e1;
  border-radius: 8px;
  color: #334155;
  background: #f8fafc;
  font-size: 13px;
}

.icon-edit:hover {
  background: #eef2f7;
}

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

.empty,
.success,
.error {
  margin: 0;
  padding: 12px;
  border-radius: 8px;
}

.empty {
  background: #f8fafc;
}

.success {
  color: #0f5132;
  background: #e7f5ed;
  margin-bottom: 12px;
}

.error {
  color: #842029;
  background: #f8d7da;
}

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

.login-box {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

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

.login-box button {
  width: 100%;
  margin-top: 14px;
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

@media (max-width: 980px) {
  .sidebar {
    position: static;
    width: 100%;
  }

  .main {
    margin-left: 0;
    padding: 20px;
  }

  .metrics,
  .grid.two,
  .form-grid,
  .assignment-form {
    grid-template-columns: 1fr;
  }

  .schedule-field {
    grid-column: span 1;
  }

  .weekday-grid {
    grid-template-columns: repeat(4, minmax(44px, 1fr));
    max-width: none;
  }

  .page-head {
    display: grid;
  }

  table {
    display: block;
    overflow-x: auto;
  }
}
