:root {
  color-scheme: light;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background: #f6f7f9;
  color: #1c1f2a;
}

html,
body {
  height: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #eef2ff 0%, #f6f7f9 28%);
  overflow: hidden;
}

.admin-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  transition: grid-template-columns 0.22s ease;
}

body.sidebar-collapsed .admin-shell {
  grid-template-columns: 0 minmax(0, 1fr);
}

.sidebar {
  position: relative;
  height: 100vh;
  padding: 28px 18px 24px;
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.22), transparent 34%),
    linear-gradient(180deg, #111827 0%, #172033 100%);
  color: #fff;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform 0.22s ease, opacity 0.22s ease;
  z-index: 20;
  overflow-y: auto;
  overscroll-behavior: contain;
}

body.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}

.sidebar-brand {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 24px;
  padding-left: 62px;
  min-height: 44px;
}

.brand-logo {
  display: block;
  height: 38px;
  width: auto;
  max-width: 170px;
  object-fit: contain;
}

.sidebar-nav {
  display: grid;
  gap: 12px;
}

.nav-group {
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 16px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(6px);
}

.nav-group-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border: none;
  background: transparent;
  color: #f8fafc;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}

.nav-group-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.nav-group-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: rgba(248, 250, 252, 0.94);
}

.nav-group-icon svg {
  display: block;
  width: 100%;
  height: 100%;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-group-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
}

.nav-group-toggle.is-open .nav-group-caret {
  transform: rotate(0deg);
}

.nav-group-caret {
  color: rgba(226, 232, 240, 0.8);
  transition: transform 0.18s ease;
}

.nav-group-items {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}

.nav-group.is-collapsed .nav-group-items {
  display: none;
}

.nav-group.is-collapsed .nav-group-caret {
  transform: rotate(-90deg);
}

.nav-group-items.is-static {
  margin-top: 0;
}

.nav-btn {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: #dbe4f0;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(148, 163, 184, 0.18);
  color: #fff;
}

.nav-btn.is-active {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border-color: rgba(147, 197, 253, 0.42);
  color: #fff;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.28);
}

.content {
  height: 100vh;
  padding: 72px 28px 48px;
  display: grid;
  gap: 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar-toggle {
  display: inline-grid;
  gap: 5px;
  width: 46px;
  padding: 10px;
  border: none;
  border-radius: 14px;
  background: #111827;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.12);
  cursor: pointer;
  flex: 0 0 auto;
}

.sidebar-toggle.is-floating {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 40;
}

.sidebar-toggle span {
  display: block;
  height: 2px;
  border-radius: 999px;
  background: #fff;
}

.panel {
  background: #fff;
  border-radius: 12px;
  padding: 16px 16px 24px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
}

h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

h3 {
  margin: 24px 0 12px;
  font-size: 16px;
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #374151;
  user-select: none;
}

.toolbar-check input[type="checkbox"] {
  accent-color: #2563eb;
}

.toolbar-link {
  color: #2563eb;
  text-decoration: none;
  font-size: 13px;
  border-bottom: 1px dashed #93c5fd;
}

.toolbar-link:hover {
  color: #1d4ed8;
  border-bottom-color: #1d4ed8;
}

.toolbar input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #d6dae3;
}

.toolbar button {
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: #111827;
  color: #fff;
  cursor: pointer;
}

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

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(320px, calc(100vw - 32px));
    height: 100vh;
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
    box-shadow: 24px 0 48px rgba(15, 23, 42, 0.26);
  }

  .content {
    padding: 72px 20px 36px;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  body.sidebar-open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.36);
    backdrop-filter: blur(2px);
    z-index: 10;
  }
}

@media (min-width: 1101px) {
  body.sidebar-open::before {
    display: none;
  }
}

.clients-toolbar {
  justify-content: flex-start;
  margin-bottom: 14px;
}

.group-block {
  border: 1px solid #eef1f6;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.group-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.group-title {
  font-weight: 600;
}

.group-place,
.clients-group-place {
  color: #6b7280;
  font-size: 12px;
  font-weight: 500;
}

.group-meta {
  color: #6b7280;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.status {
  font-weight: 600;
}

.status.paid {
  color: #16a34a;
}

.status.partial {
  color: #d97706;
}

.status.unpaid {
  color: #dc2626;
}

.status.not_attended {
  color: #2563eb;
}

[data-view].is-hidden {
  display: none;
}

.is-hidden {
  display: none !important;
}

.form {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-bottom: 16px;
}

.form input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #d6dae3;
  font-size: 14px;
}

.form input[type="checkbox"] {
  width: auto;
  padding: 0;
  border: none;
  border-radius: 0;
  accent-color: #2563eb;
}

.form select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #d6dae3;
  font-size: 14px;
  background: #fff;
}

.form button {
  grid-column: span 2;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.form .checkbox-inline {
  align-self: center;
  margin: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #eef1f6;
}

th {
  color: #6b7280;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

button.action {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #fff;
  cursor: pointer;
}

button.copy-link,
button.action.copy-link {
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}

button.copy-link.is-copied,
button.action.copy-link.is-copied {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}

button.copy-link:active,
button.action.copy-link:active {
  transform: translateY(1px);
}

button.action.danger {
  border-color: #fecaca;
  color: #b91c1c;
}

.row-actions {
  display: inline-flex;
  gap: 6px;
}

.teacher-groups-cell {
  white-space: normal;
  line-height: 1.35;
}

.teacher-group-item + .teacher-group-item {
  margin-top: 4px;
}

.teacher-active {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid #93c5fd;
  border-radius: 4px;
  background: #fff;
  position: relative;
  margin: 0;
  vertical-align: middle;
}

.teacher-active:checked {
  background: #2563eb;
  border-color: #2563eb;
}

.teacher-active:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.teacher-active[disabled] {
  opacity: 1;
  cursor: not-allowed;
}

.inline-input {
  width: 100%;
  min-width: 120px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #d6dae3;
  font-size: 13px;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #4b5563;
  margin-right: 8px;
}

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

.subgroup-item {
  display: grid;
  grid-template-columns: 48px 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.subgroup-id {
  color: #6b7280;
  font-size: 12px;
}

.muted {
  color: #6b7280;
  font-size: 12px;
}

#all-payments-table .inline-input {
  min-width: 90px;
}

#all-payments-table .inline-input[disabled] {
  background: #f3f4f6;
  color: #6b7280;
}

#all-payments-table .tx-view {
  display: block;
  min-height: 18px;
}

#all-payments-table .tx-sub {
  color: #6b7280;
  font-size: 12px;
}

#all-payments-table .tx-edit {
  display: none;
}

#all-payments-table tr[data-editing="1"] .tx-view {
  display: none;
}

#all-payments-table tr[data-editing="1"] .tx-edit {
  display: block;
}

#all-payments-table .tx-readonly {
  display: inline-block;
  min-width: 80px;
}

#all-payments-table td:last-child {
  display: grid;
  gap: 6px;
  justify-items: start;
}

#all-payments-table .icon-edit {
  min-width: 36px;
  font-size: 16px;
  line-height: 1;
  padding: 6px 8px;
}

#all-payments-table tr.tx-alert-row td {
  background: #fff7ed;
}

#all-payments-table .tx-flag {
  color: #c2410c;
  font-weight: 700;
}

#all-payments-table .tx-warning {
  margin-top: 4px;
  color: #9a3412;
  font-size: 11px;
}

#all-payments-table tr[data-editing="0"] .save-regular-payment,
#all-payments-table tr[data-editing="0"] .save-once-payment,
#all-payments-table tr[data-editing="0"] .save-exam-payment {
  display: none;
}

.clients-group {
  border: 1px solid #eef1f6;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.clients-group-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.clients-group-title {
  font-weight: 600;
}

.clients-group-meta {
  color: #6b7280;
  font-size: 12px;
}

.group-collapse-toggle {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-align: left;
}

.group-collapse-caret {
  width: 12px;
  color: #6b7280;
  font-size: 12px;
}

.group-block.is-collapsed .group-body,
.clients-group.is-collapsed .clients-group-body {
  display: none;
}

#clients-by-group table {
  width: 100%;
  table-layout: fixed;
}

#clients-by-group .client-edit-cell {
  display: grid;
  gap: 6px;
}

#clients-by-group .client-payments-toggle {
  min-width: 34px;
  padding: 6px 8px;
  font-weight: 700;
}

#clients-by-group .client-payments-row td {
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
}

#clients-by-group .client-payments-table {
  width: 100%;
  table-layout: auto;
  font-size: 12px;
}

#clients-by-group .client-payments-table th,
#clients-by-group .client-payments-table td {
  white-space: nowrap;
  padding: 6px 8px;
  border-bottom: 1px solid #e5e7eb;
}

#clients-by-group .inline-input[disabled],
#clients-by-group .inline-select[disabled] {
  background: #f3f4f6;
  color: #6b7280;
}

#exam-overview-container .exam-overview-table {
  width: 100%;
  table-layout: fixed;
}

#exam-overview-container .exam-overview-table .exam-col-index {
  width: 6%;
}

#exam-overview-container .exam-overview-table .exam-col-child {
  width: 29%;
}

#exam-overview-container .exam-overview-table .exam-col-phone {
  width: 20%;
}

#exam-overview-container .exam-overview-table .exam-col-amount {
  width: 14%;
}

#exam-overview-container .exam-overview-table .exam-col-date {
  width: 31%;
}

#exam-overview-container .exam-overview-table th,
#exam-overview-container .exam-overview-table td {
  vertical-align: top;
}

#exam-overview-container .exam-overview-table th:first-child,
#exam-overview-container .exam-overview-table td:first-child {
  text-align: center;
  white-space: nowrap;
}

#exam-overview-container .exam-overview-table th:nth-child(3),
#exam-overview-container .exam-overview-table th:nth-child(4),
#exam-overview-container .exam-overview-table th:nth-child(5),
#exam-overview-container .exam-overview-table td:nth-child(3),
#exam-overview-container .exam-overview-table td:nth-child(4),
#exam-overview-container .exam-overview-table td:nth-child(5) {
  white-space: nowrap;
}

.exam-payment-comment {
  margin-top: 4px;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
}

.attendance-meta {
  margin-bottom: 10px;
  color: #4b5563;
  font-size: 13px;
}

.attendance-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.attendance-admin-table {
  min-width: 740px;
}

.attendance-admin-table .col-index {
  width: 52px;
  text-align: center;
}

.attendance-admin-table th,
.attendance-admin-table td {
  text-align: center;
  white-space: nowrap;
}

.attendance-admin-table th:nth-child(2),
.attendance-admin-table td:nth-child(2) {
  text-align: left;
  white-space: normal;
}

.attendance-mark.yes {
  color: #15803d;
  font-weight: 700;
}

.attendance-mark.no {
  color: #b91c1c;
  font-weight: 700;
}

.attendance-mark.empty {
  color: #9ca3af;
}

.inline-select {
  width: 100%;
  min-width: 70px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #d6dae3;
  font-size: 13px;
  background: #fff;
}

.exam-status-note {
  margin: 0 0 14px;
  font-size: 13px;
}

.exam-status-summary {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #d6dae3;
  border-radius: 12px;
  background: #f8fafc;
}

.exam-status-summary-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}

.exam-status-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.exam-status-summary-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.exam-status-summary-total,
.exam-status-summary-award {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #e5e7eb;
  font-size: 13px;
  color: #374151;
}

.exam-status-summary-card {
  padding: 12px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e5e7eb;
}

.exam-status-summary-count {
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 8px;
}

.exam-status-summary-label {
  font-size: 13px;
  color: #374151;
  line-height: 1.35;
}

.exam-status-summary-awards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.exam-status-summary-icon {
  font-size: 14px;
  line-height: 1;
}

#exam-statuses-container .exam-status-table th:first-child,
#exam-statuses-container .exam-status-table td:first-child {
  text-align: center;
  white-space: nowrap;
}

#exam-statuses-container .exam-status-table td:nth-child(4),
#exam-statuses-container .exam-status-table td:nth-child(5) {
  min-width: 280px;
}

.exam-attendance-journal-table {
  min-width: 1180px;
}

.exam-attendance-journal-table th:nth-child(2),
.exam-attendance-journal-table td:nth-child(2),
.exam-attendance-journal-table th:nth-child(4),
.exam-attendance-journal-table td:nth-child(4),
.exam-attendance-journal-table th:nth-child(5),
.exam-attendance-journal-table td:nth-child(5),
.exam-attendance-journal-table th:nth-child(8),
.exam-attendance-journal-table td:nth-child(8),
.exam-attendance-journal-table th:nth-child(9),
.exam-attendance-journal-table td:nth-child(9) {
  text-align: left;
  white-space: normal;
}

#clients-by-group th,
#clients-by-group td {
  white-space: normal;
  word-break: break-word;
  vertical-align: top;
}

#clients-by-group .inline-input {
  min-width: 70px;
}

#clients-by-group .clients-table-wrap {
  width: 100%;
  overflow-x: hidden;
}

#clients-by-group table.is-resizing {
  user-select: none;
}

#clients-by-group th {
  position: relative;
}

#clients-by-group .col-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
}

.modal.is-hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
}

.modal-card {
  position: relative;
  width: min(860px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.confirm-modal-card {
  width: min(520px, calc(100vw - 24px));
}

.confirm-modal-text {
  margin: 0 0 14px;
  color: #374151;
}

.confirm-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

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

.modal-header h3 {
  margin: 0;
}

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

.client-create-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: #4b5563;
}

.client-create-form input,
.client-create-form select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #d6dae3;
  font-size: 14px;
}

.client-create-form button {
  grid-column: 1 / -1;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

@media (max-width: 960px) {
  .form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  header,
  main {
    padding: 16px;
  }

  .client-create-form {
    grid-template-columns: 1fr;
  }
}
