:root {
  --navy: #4E77AD;
  --navy-dark: #3D6089;
  --focus-blue: #4e77ad;
  --green: #2E8B47;
  --green-dark: #1a6027;
  --red: #A32828;
  --red-dark: #7c1414;
  --orange: #F0701A;
  --orange-dark: #E8590C;
  --page-bg: #f2f4f8;
  --border: #E1E4EA;
  --border-input: #D0D5DD;
  --text-main: #222222;
  --text-sub: #6B7280;
  --text-placeholder: #9CA3AF;
  --shadow-card: 0 2px 10px rgba(17, 24, 39, 0.06);
  --shadow-modal: 0 24px 48px rgba(17, 24, 39, 0.18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page-bg);
  font-family: 'Inter', -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text-main);
}

.material-symbols-outlined {
  font-size: 20px;
  line-height: 1;
  vertical-align: middle;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}

/* ===================== Layout ===================== */

.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 32px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.app-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 auto;
}

.page-wrap {
  max-width: 1170px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

/* ===================== Buttons ===================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn .material-symbols-outlined { font-size: 18px; }

.btn-back {
  background: #fff;
  border-color: var(--border);
  color: var(--navy);
  box-shadow: 0 1px 2px rgba(17,24,39,0.04);
}
.btn-back:hover { background: #F7F8FA; }

.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); }

.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: var(--green-dark); }

.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: var(--red-dark); border-color: var(--red-dark); }

.btn-outline { background: #fff; border-color: var(--navy); color: var(--navy); }
.btn-outline:hover { background: #EEF1F6; }

.btn-warning { background: var(--orange); border: none; color: #fff; }
.btn-warning:hover { background: var(--orange-dark); }

.hidden { display: none !important; }

.required-mark { color: var(--red); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ===================== Cards ===================== */

.card-block {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  padding: 28px 32px;
  margin-bottom: 24px;
}

.card-section + .card-section {
  margin-top: 28px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 16px;
}

/* ===================== Forms ===================== */

.form-group { margin-bottom: 16px; }
.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.form-row > .form-group { flex: 1 1 200px; margin-bottom: 0; }

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-control, .form-select {
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-main);
  background: #fff;
  border: 1px solid var(--border-input);
  border-radius: 8px;
  appearance: none;
}
.form-control::placeholder { color: var(--text-placeholder); }
.form-control:disabled, .form-control[readonly] {
  background: #F3F4F6;
  color: var(--text-sub);
  cursor: not-allowed;
}
.form-select.is-placeholder { color: var(--text-placeholder); }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--red); }
.field-error { color: var(--red); font-size: 12px; margin-top: 4px; display: none; }
.field-error.show { display: block; }
.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--focus-blue);
  box-shadow: 0 0 0 3px rgba(78, 119, 173, 0.18);
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
  transition: border-color .15s ease;
}
.form-select:hover { border-color: var(--navy); }

button.form-select {
  text-align: left;
  cursor: pointer;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-check input[type="checkbox"], .form-check input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--navy);
  cursor: pointer;
  flex: none;
}
.form-check label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
}

/* ===================== Subjects ===================== */

.subject-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 18px 4px;
  margin-bottom: 14px;
  position: relative;
  background: #FAFBFC;
  box-shadow: var(--shadow-card);
}
.subject-row .remove-row {
  position: absolute;
  top: -12px;
  left: -12px;
  width: 28px;
  height: 28px;
  padding: 0;
  justify-content: center;
}
.subject-row .remove-row .material-symbols-outlined { font-size: 16px; }

.subject-row .form-row { align-items: center; }
.subject-row .col-predmet { flex: 2 1 260px; }
.subject-row .col-chasov  { flex: 1 1 200px; }
.subject-row .col-check   { flex: 0 1 240px; }
.subject-row .col-uch     { flex: 2 1 240px; }
.invisible { visibility: hidden; }

/* ===================== Table ===================== */

.table-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}
.table-wrap {
  overflow: auto;
  max-height: 75vh;
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  background: #fff;
}
.table-wrap:fullscreen {
  max-height: 100vh;
  padding: 16px;
  border-radius: 0;
}
.tarif-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tarif-table th, .tarif-table td {
  border: 1px solid #C7CDD6;
  padding: 6px 8px;
  text-align: center;
  white-space: nowrap;
}
.tarif-table thead th {
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  font-size: 12px;
  position: sticky;
  z-index: 3;
}
/* Закреплённая шапка при прокрутке таблицы вниз — только заголовки колонок,
   без закрепления боковых колонок (упрощает раскладку, не ломает границы). */
.tarif-table-rotated thead tr:first-child { height: 44px; }
.tarif-table-rotated thead tr:first-child th { top: 0; }
.tarif-table-rotated thead tr:nth-child(2) th {
  top: 44px;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  height: 220px;
  width: 34px;
  padding: 8px 4px;
  vertical-align: bottom;
  white-space: normal;
}
.tarif-table tbody tr.row-total td {
  font-weight: 600;
  background: #F5F6F8;
}
.tarif-table tbody tr.row-grand-total td {
  font-weight: 700;
  background: #E9ECF2;
}
.tarif-table td.text-start {
  white-space: normal;
  min-width: 140px;
}
.text-start { text-align: left !important; }
.text-muted { color: var(--text-placeholder); }

/* ===================== Modals ===================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
}
.modal-box.modal-lg { max-width: 760px; }

.modal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  margin: 0;
}
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--navy);
  padding: 4px;
  display: flex;
}
.modal-close .material-symbols-outlined { font-size: 24px; }

/* ===================== Tabs ===================== */

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.tab-btn {
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--navy);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.tab-btn.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ===================== Employee list (select modal) ===================== */

.employee-list { max-height: 340px; overflow-y: auto; margin-bottom: 20px; }
.employee-list-item {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  border-radius: 6px;
}
.employee-list-item:hover { background: #F2F4F8; }
.employee-list-item.selected { background: var(--navy); color: #fff; }

.search-row { display: flex; gap: 10px; margin-bottom: 16px; }
.search-row .form-control { flex: 1; }
.search-row .btn { padding: 10px 14px; }

.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.modal-actions .btn-outline { margin-left: auto; }

/* ===================== Achievements ===================== */

.achievement-item {
  display: flex;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.achievement-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--navy);
  margin-top: 2px;
  flex: none;
  cursor: pointer;
}
.achievement-item label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
}
.achievement-item input[type="checkbox"]:disabled {
  cursor: not-allowed;
  opacity: .4;
}
.achievement-item input[type="checkbox"]:disabled + label {
  cursor: not-allowed;
  color: var(--text-placeholder);
}

/* ===================== Constants row ===================== */

.konst-row {
  display: flex;
  align-items: end;
  gap: 16px;
  margin-bottom: 24px;
}
.konst-row .form-group { margin-bottom: 0; flex: 1 1 auto; min-width: 0; }
.konst-row button { flex: 0 0 auto; }

.export-row { margin-top: 20px; }

/* ===================== Searchable combobox (Предмет) ===================== */

.combo {
  position: relative;
}
.combo-input {
  cursor: pointer;
}
.combo-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border-input);
  border-radius: 8px;
  box-shadow: var(--shadow-modal);
  max-height: 240px;
  overflow-y: auto;
  z-index: 50;
}
.combo-panel.hidden { display: none; }
.combo-option {
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-main);
  cursor: pointer;
}
.combo-option:hover, .combo-option.active {
  background: #F2F4F8;
}
.combo-option.disabled {
  color: var(--text-placeholder);
  cursor: not-allowed;
  background: #F7F8FA;
}
.combo-empty {
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-placeholder);
}

/* ===================== Кастомный select (единый стиль выпадающих списков) ===================== */

.custom-select {
  position: relative;
}
.custom-select select {
  display: none;
}
.custom-select-trigger {
  width: 100%;
  text-align: left;
}
.custom-select-trigger:disabled {
  opacity: .6;
  cursor: not-allowed;
  background: #F3F4F6;
}

/* ===================== Блокировка секций до выбора учителя ===================== */

.js-requires-employee.section-locked {
  opacity: .55;
}
.js-requires-employee.section-locked .btn,
.js-requires-employee.section-locked .form-control,
.js-requires-employee.section-locked .custom-select-trigger {
  pointer-events: none;
}

/* ===================== Страница входа ===================== */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page-bg);
  padding: 24px;
}
.auth-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
}
.auth-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--navy);
  text-align: center;
  margin-bottom: 6px;
}
.auth-subtitle {
  font-size: 14px;
  color: var(--text-sub);
  text-align: center;
  margin-bottom: 24px;
}
.auth-error {
  background: #FCEAEA;
  color: var(--red-dark);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 16px;
}
.auth-form .form-group { margin-bottom: 16px; }
.auth-submit { width: 100%; justify-content: center; margin-top: 8px; }

/* ===================== Страница сервисов ===================== */

.services-org {
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
}
.services-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  padding: 40px 32px;
}
.service-tile {
  width: 220px;
  height: 220px;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-decoration: none;
  color: var(--text-main);
  text-align: center;
  padding: 20px;
  transition: box-shadow .15s ease, transform .15s ease;
  position: relative;
}
.service-tile:hover {
  box-shadow: 0 8px 24px rgba(17,24,39,0.12);
  transform: translateY(-2px);
}
.service-tile-icon {
  font-size: 48px;
  color: var(--navy);
}
.service-tile-title {
  font-size: 16px;
  font-weight: 600;
}
.service-tile-disabled {
  cursor: not-allowed;
  color: var(--text-placeholder);
}
.service-tile-disabled:hover {
  box-shadow: var(--shadow-card);
  transform: none;
}
.service-tile-disabled .service-tile-icon { color: var(--text-placeholder); }
.service-tile-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  background: #F3F4F6;
  color: var(--text-sub);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
}
