:root {
  color-scheme: dark;
  --bg: #08090c;
  --panel: #11141b;
  --panel-2: #171b24;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f6fb;
  --muted: #8d94a6;
  --accent: #8be0c7;
  --accent-2: #d8b36a;
  --bad: #ff7b7b;
  --warn: #f0bd62;
  --ok: #71d991;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  width: 100%;
  height: 100%;
  min-height: var(--tg-viewport-stable-height, var(--tg-viewport-height, 100vh));
  margin: 0;
  padding: 0;
}

body {
  min-height: var(--tg-viewport-stable-height, var(--tg-viewport-height, 100vh));
  background:
    radial-gradient(circle at 20% -10%, rgba(139, 224, 199, 0.18), transparent 34%),
    radial-gradient(circle at 110% 12%, rgba(216, 179, 106, 0.16), transparent 30%),
    var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(980px, 100%);
  min-height: var(--tg-viewport-stable-height, var(--tg-viewport-height, 100vh));
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 12px calc(108px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  z-index: 5;
  top: max(8px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid rgba(139, 224, 199, 0.12);
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(139, 224, 199, 0.1), rgba(216, 179, 106, 0.045)),
    #0b0d12;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045), 0 16px 44px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(18px);
}

body.tg-fullscreen .app-shell {
  padding-top: calc(max(64px, env(safe-area-inset-top)) + 8px);
}

body.tg-fullscreen .topbar {
  top: calc(max(54px, env(safe-area-inset-top)) + 6px);
  width: min(560px, calc(100% - 108px));
  min-height: 46px;
  margin-right: auto;
  margin-left: auto;
  padding: 8px 9px;
  border-radius: 16px;
}

body.tg-fullscreen .brand-lockup {
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 0 8px;
}

body.tg-fullscreen .brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  font-size: 14px;
}

body.tg-fullscreen .brand-lockup p {
  display: none;
}

body.tg-fullscreen .brand-lockup h1 {
  align-self: center;
  font-size: 16px;
}

body.tg-fullscreen .icon-button {
  width: 32px;
  height: 32px;
}

.topbar h1,
h2,
h3,
p {
  margin: 0;
}

.topbar h1 {
  font-size: 22px;
  letter-spacing: 0;
  line-height: 1.12;
}

.brand-lockup {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 2px 9px;
  align-items: center;
  min-width: 0;
}

.brand-mark {
  display: grid;
  grid-row: 1 / span 2;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(139, 224, 199, 0.3);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(139, 224, 199, 0.24), rgba(216, 179, 106, 0.12));
  color: var(--accent);
  cursor: pointer;
  font-size: 16px;
  font-weight: 950;
}

.brand-mark.active {
  border-color: rgba(139, 224, 199, 0.65);
  background: rgba(139, 224, 199, 0.18);
  box-shadow: 0 0 0 2px rgba(139, 224, 199, 0.08);
}

.brand-mark:disabled {
  cursor: default;
}

.brand-lockup p {
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.05em;
  line-height: 1.12;
  text-transform: uppercase;
}

.brand-lockup h1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.icon-button,
.mini-button,
.primary-button,
.fab,
.fab-menu button,
.tabbar button,
.student-card,
.metric-button {
  border: 0;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.icon-button:active,
.mini-button:active,
.primary-button:active,
.fab:active,
.tabbar button:active,
.student-card:active {
  transform: scale(0.98);
}

.icon-button {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.hero-crm {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: end;
  padding: 18px;
  border: 1px solid rgba(139, 224, 199, 0.14);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(139, 224, 199, 0.14), rgba(216, 179, 106, 0.08)),
    rgba(17, 20, 27, 0.86);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.24);
}

.hero-crm h2 {
  max-width: 620px;
  font-size: clamp(30px, 8vw, 52px);
  line-height: 0.96;
  letter-spacing: 0;
}

.hero-crm p {
  margin-top: 12px;
  color: var(--muted);
}

.hero-income {
  display: grid;
  gap: 6px;
  min-width: 124px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.22);
}

.hero-income span,
.metric span,
.section-head span,
.item-subtitle,
.calendar-day h3,
label span {
  color: var(--muted);
  font-size: 12px;
}

.hero-income strong {
  font-size: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.metric {
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 20, 27, 0.92);
  color: var(--text);
  text-align: left;
}

.metric-button {
  width: 100%;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
  line-height: 1.1;
}

.panel,
.drawer-panel {
  margin: 10px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 20, 27, 0.92);
}

.drawer-panel {
  scroll-margin-top: 86px;
}

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

.section-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.section-head h2,
.detail-head h2 {
  font-size: 20px;
}

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

.student-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.student-card,
.problem-card,
.lesson-row,
.homework-row,
.finance-row {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--text);
  text-align: left;
}

.student-card.selected {
  border-color: rgba(139, 224, 199, 0.55);
  background: rgba(139, 224, 199, 0.08);
}

.student-card strong,
.problem-card strong,
.lesson-row strong,
.homework-row strong,
.finance-row strong {
  font-size: 16px;
}

.student-card span,
.student-card em,
.problem-card p,
.lesson-row p,
.homework-row p,
.homework-row span,
.finance-row p {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.student-card em {
  color: var(--accent-2);
  font-weight: 800;
}

.problem-card,
.finance-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.lesson-row {
  grid-template-columns: 58px 1fr;
  align-items: start;
}

.lesson-row time {
  color: var(--accent);
  font-weight: 900;
}

.lesson-statuses,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  grid-column: 2;
}

.detail-head .row-actions,
.section-head .section-actions {
  grid-column: auto;
}

.detail-head .row-actions {
  flex-wrap: nowrap;
}

.status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
  color: var(--muted);
  font-size: 11px;
}

.status.ok {
  color: var(--ok);
}

.status.warn {
  color: var(--warn);
}

.status.bad {
  color: var(--bad);
}

.calendar-day {
  display: grid;
  gap: 8px;
  padding: 4px 0 10px;
}

.calendar-day h3 {
  letter-spacing: 0.08em;
}

.calendar-panel {
  overflow: hidden;
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  margin-bottom: 9px;
}

.calendar-title-block {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.calendar-title-block h2 {
  font-size: 22px;
  line-height: 1;
}

.calendar-title-block span {
  width: fit-content;
  padding: 4px 8px;
  border: 1px solid rgba(139, 224, 199, 0.16);
  border-radius: 999px;
  background: rgba(139, 224, 199, 0.07);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.calendar-ghost-action,
.calendar-action {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  font-weight: 850;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.calendar-ghost-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
  font-size: 12px;
}

.calendar-ghost-action span,
.calendar-action span {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.calendar-ghost-action span {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--accent);
  font-size: 13px;
}

.calendar-action-rail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 14px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.065);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.18);
}

.calendar-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  min-height: 36px;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.045);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.calendar-action span {
  width: 20px;
  height: 20px;
  border-radius: 8px;
  background: rgba(139, 224, 199, 0.1);
  color: var(--accent);
  font-size: 13px;
  font-weight: 950;
}

.calendar-action.primary {
  border-color: rgba(139, 224, 199, 0.38);
  background: linear-gradient(135deg, rgba(139, 224, 199, 0.22), rgba(139, 224, 199, 0.1));
  color: var(--accent);
}

.calendar-action.primary span {
  background: var(--accent);
  color: #07100d;
}

.calendar-ghost-action:active,
.calendar-action:active {
  transform: scale(0.98);
}

.calendar-ghost-action:hover,
.calendar-action:hover {
  border-color: rgba(139, 224, 199, 0.34);
}

.filters {
  display: grid;
  grid-template-columns: 1fr 0.8fr 0.6fr;
  gap: 8px;
  margin: 0 0 10px;
}

input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  outline: none;
  padding: 11px;
}

input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="number"] {
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
}

input::-webkit-date-and-time-value {
  min-width: 0;
  text-align: left;
}

select option {
  background: #11141b;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(139, 224, 199, 0.68);
  box-shadow: 0 0 0 3px rgba(139, 224, 199, 0.12);
}

.edit-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.edit-form label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.weekday-field {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.weekday-field legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.weekday-field label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.weekday-field input {
  width: auto;
}

.button-field {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.button-field legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.button-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.button-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.button-options label {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
}

.button-options input:checked + label {
  border-color: rgba(139, 224, 199, 0.48);
  background: rgba(139, 224, 199, 0.16);
  color: var(--accent);
}

.schedule-slots {
  display: grid;
  gap: 8px;
}

.schedule-slot-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 120px) 42px;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.045);
  overflow: hidden;
}

.schedule-slot-row label,
.schedule-slot-row input,
.schedule-slot-row select {
  min-width: 0;
}

.edit-form .full,
.primary-button {
  grid-column: 1 / -1;
}

.primary-button,
.danger-button,
.mini-button {
  min-height: 38px;
  border-radius: var(--radius);
  font-weight: 850;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), #5abda5);
  color: #07100d;
}

.mini-button {
  align-self: center;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.075);
  color: var(--text);
}

.danger-button {
  grid-column: 1 / -1;
  border: 1px solid rgba(255, 123, 123, 0.38);
  background: rgba(255, 123, 123, 0.1);
  color: var(--bad);
}

.mini-button:hover,
.student-card:hover {
  border-color: rgba(139, 224, 199, 0.28);
}

.detail-section {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.info-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.045);
}

.info-item span {
  color: var(--muted);
  font-size: 12px;
}

.info-item strong {
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.25;
}

.subsection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.subsection-head h3 {
  font-size: 15px;
}

.plan-list {
  display: grid;
  gap: 6px;
}

.plan-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 9px;
  align-items: start;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.045);
}

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

.plan-row span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.plan-row small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

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

.homework-row a {
  color: var(--accent);
  font-size: 13px;
}

.homework-detail {
  display: grid;
  gap: 12px;
}

.homework-detail p,
.homework-text {
  color: var(--muted);
  line-height: 1.45;
}

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 8px;
}

.attachment-link {
  display: grid;
  place-items: center;
  min-height: 76px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--accent);
  font-size: 13px;
  overflow: hidden;
}

.attachment-preview {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 8px;
}

.empty-state,
.error-state,
.auth-panel {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 180px;
  text-align: center;
}

.empty-state h3,
.error-state h2,
.auth-panel h2 {
  font-size: 18px;
}

.empty-state p,
.error-state p,
.auth-panel p {
  max-width: 360px;
  color: var(--muted);
  font-size: 14px;
}

.empty-mark {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(139, 224, 199, 0.18), rgba(216, 179, 106, 0.12));
}

.progress-chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 28px;
  align-items: end;
  gap: 7px;
  height: 170px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.18);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(139, 224, 199, 0.42) transparent;
}

.bar-wrap {
  display: grid;
  grid-template-rows: 1fr 20px;
  align-items: end;
  gap: 6px;
  height: 100%;
  min-width: 0;
}

.bar {
  justify-self: stretch;
  min-height: 4px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--accent), rgba(139, 224, 199, 0.36));
}

.bar-wrap span {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-chart.custom-progress {
  grid-auto-columns: minmax(78px, 1fr);
  gap: 10px;
}

.custom-progress .bar-wrap {
  grid-template-rows: 1fr 26px;
}

.custom-progress .bar {
  justify-self: center;
  width: min(54px, 72%);
  border-radius: 9px 9px 3px 3px;
}

.custom-progress .bar-wrap span {
  align-self: start;
  font-size: 11px;
  line-height: 1.12;
}

.progress-task-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.progress-task-row {
  display: grid;
  grid-template-columns: minmax(56px, 0.38fr) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
}

.progress-task-row strong {
  color: var(--accent);
  font-size: 13px;
}

.progress-task-row span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  text-align: right;
}

.form-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.free-slots-view {
  display: grid;
  gap: 10px;
}

.slot-warning {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 123, 123, 0.34);
  border-radius: 14px;
  background: rgba(255, 123, 123, 0.08);
  color: var(--bad);
  font-size: 13px;
  font-weight: 800;
}

.slot-day {
  display: grid;
  gap: 7px;
}

.slot-day h3 {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.slot-chip {
  display: grid;
  gap: 2px;
  min-height: 48px;
  padding: 8px;
  border: 1px solid rgba(139, 224, 199, 0.22);
  border-radius: 14px;
  background: rgba(139, 224, 199, 0.08);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.slot-chip strong {
  color: var(--accent);
  font-size: 15px;
}

.slot-chip span {
  color: var(--muted);
  font-size: 11px;
}

.fab-wrap {
  position: fixed;
  z-index: 16;
  right: 16px;
  bottom: calc(88px + env(safe-area-inset-bottom));
  display: grid;
  justify-items: end;
  gap: 8px;
}

.fab {
  width: 54px;
  height: 54px;
  border-radius: 999px;
  background: var(--accent);
  color: #07100d;
  font-size: 28px;
  font-weight: 700;
  box-shadow: 0 16px 42px rgba(139, 224, 199, 0.22);
}

.fab-menu {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 20, 27, 0.96);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.38);
}

.fab-menu button {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  text-align: left;
}

.tabbar {
  position: fixed;
  z-index: 14;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 4px;
  width: min(680px, calc(100% - 24px));
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(17, 20, 27, 0.92);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
  transform: translateX(-50%);
  backdrop-filter: blur(18px);
}

.tabbar button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 42px;
  border-radius: 18px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.05;
  overflow: hidden;
  text-align: center;
  white-space: nowrap;
}

.tabbar button.active {
  background: rgba(139, 224, 199, 0.14);
  color: var(--accent);
}

.modal-backdrop {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  align-items: end;
  background: rgba(0, 0, 0, 0.58);
}

.modal {
  width: min(760px, 100%);
  max-height: 88vh;
  margin: 0 auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  background: #10131a;
  overflow-y: auto;
}

.modal .detail-head {
  position: sticky;
  z-index: 2;
  top: -16px;
  min-height: 48px;
  margin: -16px -16px 12px;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 19, 26, 0.96);
  backdrop-filter: blur(18px);
}

.modal-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.modal-submit-button {
  min-width: 72px;
  min-height: 34px;
  border: 1px solid rgba(139, 224, 199, 0.36);
  background: rgba(139, 224, 199, 0.14);
  color: var(--accent);
}

.modal-submit-source {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

body.tg-fullscreen .modal {
  max-height: calc(var(--tg-viewport-stable-height, var(--tg-viewport-height, 100vh)) - 28px);
}

.skeleton-stack {
  display: grid;
  gap: 10px;
}

.skeleton-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.skeleton {
  min-height: 94px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.06));
  background-size: 240% 100%;
  animation: shimmer 1.2s infinite;
}

.hero-skeleton {
  min-height: 180px;
}

.register-hero {
  display: grid;
  gap: 8px;
  margin: 8px 0;
  padding: 16px;
  border: 1px solid rgba(139, 224, 199, 0.18);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(139, 224, 199, 0.14), rgba(216, 179, 106, 0.06)),
    rgba(17, 20, 27, 0.82);
}

.register-hero h2 {
  font-size: 30px;
  line-height: 1;
}

.register-hero p:not(.eyebrow) {
  max-width: 520px;
  color: var(--muted);
  font-size: 14px;
}

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

.register-card {
  align-content: start;
}

.register-card h2 {
  font-size: 18px;
}

[hidden] {
  display: none !important;
}

@keyframes shimmer {
  to {
    background-position: -240% 0;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding-inline: 10px;
  }

  .hero-crm,
  .metric-grid,
  .filters,
  .edit-form,
  .info-grid,
  .student-grid,
  .register-grid {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: flex-start;
  }

  .section-actions {
    justify-content: flex-end;
  }

  .hero-crm h2 {
    font-size: 34px;
  }

  .metric-grid.compact {
    grid-template-columns: repeat(2, 1fr);
  }

  .lesson-row,
  .homework-row,
  .finance-row,
  .schedule-slot-row,
  .problem-card {
    grid-template-columns: 1fr;
  }

  .lesson-statuses,
  .row-actions {
    grid-column: 1;
  }

  .tabbar {
    width: calc(100% - 24px);
    border-radius: 24px;
  }

  .tabbar button {
    min-height: 40px;
    padding: 0 2px;
    font-size: 10px;
    border-radius: 17px;
  }
}

@media (max-width: 360px) {
  .tabbar {
    gap: 3px;
    width: calc(100% - 18px);
    padding: 5px;
  }

  .tabbar button {
    border-radius: 16px;
    font-size: 9px;
  }
}

/* Dense CRM redesign */
.app-shell {
  padding: max(8px, env(safe-area-inset-top)) 10px calc(82px + env(safe-area-inset-bottom));
}

.topbar {
  padding: 10px;
  border-radius: 18px;
}

.topbar h1 {
  font-size: 18px;
}

.brand-lockup p {
  font-size: 10px;
}

.icon-button {
  width: 36px;
  height: 36px;
}

.dashboard-top {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
  margin-bottom: 8px;
}

.hello-block,
.top-stat,
.metric,
.panel,
.drawer-panel {
  border: 1px solid rgba(255, 255, 255, 0.075);
  background: rgba(17, 20, 27, 0.78);
  backdrop-filter: blur(16px);
}

.hello-block,
.top-stat {
  min-height: 56px;
  padding: 10px;
  border-radius: 12px;
  color: var(--text);
  text-align: left;
}

.hello-block h2 {
  font-size: 25px;
  line-height: 1;
}

.top-stat {
  display: grid;
  align-content: space-between;
  min-width: 0;
}

.top-stat.wide {
  grid-column: span 1;
}

.top-stat span {
  color: var(--muted);
  font-size: 11px;
}

.top-stat strong {
  overflow: hidden;
  font-size: 15px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-crm {
  padding: 12px;
  min-height: 92px;
}

.hero-crm h2 {
  font-size: 26px;
}

.hero-crm p {
  margin-top: 6px;
  font-size: 13px;
}

.hero-income {
  min-width: 104px;
  padding: 10px;
}

.metric-grid {
  gap: 7px;
  margin: 8px 0;
}

.metric-grid.compact,
.kpi-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric {
  min-height: 58px;
  padding: 9px 10px;
  border-radius: 12px;
}

.metric strong {
  margin-top: 4px;
  font-size: 18px;
}

.metric span {
  font-size: 11px;
}

.panel,
.drawer-panel {
  margin: 8px 0;
  padding: 10px;
  border-radius: 14px;
}

.dense-panel {
  padding: 10px;
}

.section-head,
.detail-head,
.student-profile-head {
  margin-bottom: 8px;
}

.compact-head h2,
.section-head h2,
.detail-head h2 {
  font-size: 17px;
}

.section-actions {
  gap: 5px;
}

.stack,
.student-grid {
  gap: 6px;
}

.crm-toolbar {
  display: grid;
  grid-template-columns: 1.2fr 0.85fr 0.8fr;
  gap: 7px;
  margin-bottom: 8px;
}

.crm-toolbar input,
.crm-toolbar select,
.filters select {
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 13px;
}

.crm-list {
  grid-template-columns: 1fr;
}

.student-card.compact-student {
  position: relative;
  grid-template-columns: 1fr auto;
  gap: 3px 8px;
  min-height: 74px;
  padding: 9px 10px;
  border-radius: 12px;
}

.compact-student strong {
  font-size: 15px;
}

.compact-student span,
.compact-student small {
  grid-column: 1;
  color: var(--muted);
  font-size: 12px;
}

.compact-student em {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: start;
  color: var(--accent-2);
  font-size: 12px;
}

.payment-dot {
  grid-column: 2;
  align-self: end;
  justify-self: end;
  min-width: 50px;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-style: normal;
  text-align: center;
}

.payment-dot.ok {
  background: rgba(113, 217, 145, 0.14);
  color: var(--ok);
}

.payment-dot.warn {
  background: rgba(240, 189, 98, 0.14);
  color: var(--warn);
}

.payment-dot.bad {
  background: rgba(255, 123, 123, 0.14);
  color: var(--bad);
}

.attention-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.compact-lessons {
  display: grid;
  gap: 6px;
}

.compact-lesson {
  display: grid;
  grid-template-columns: 42px 1fr auto auto;
  gap: 7px;
  align-items: center;
  min-height: 42px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  text-align: left;
}

.compact-lesson.ok {
  border-left-color: var(--ok);
}

.compact-lesson.warn {
  border-left-color: var(--warn);
}

.compact-lesson.bad {
  border-left-color: var(--bad);
}

.compact-lesson time {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.compact-lesson strong {
  font-size: 13px;
}

.compact-lesson span {
  color: var(--muted);
  font-size: 11px;
}

.attention-item {
  display: grid;
  gap: 4px;
  min-height: 58px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  text-align: left;
}

.attention-item span {
  color: var(--muted);
  font-size: 11px;
}

.attention-item strong {
  font-size: 19px;
}

.attention-item.bad strong {
  color: var(--bad);
}

.attention-item.warn strong {
  color: var(--warn);
}

.student-profile-head {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: center;
}

.student-profile-head h2 {
  font-size: 22px;
}

.student-profile-head p:not(.eyebrow) {
  color: var(--muted);
  font-size: 12px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(139, 224, 199, 0.35);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(139, 224, 199, 0.28), rgba(216, 179, 106, 0.12));
  color: var(--accent);
  font-size: 22px;
  font-weight: 900;
}

.profile-sections {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.profile-block {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
}

.profile-block h3 {
  font-size: 14px;
}

.compact-info {
  grid-template-columns: 1fr;
}

.compact-info .info-item {
  padding: 8px;
}

.mini-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.mini-metric {
  display: grid;
  gap: 3px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
}

.mini-metric span {
  color: var(--muted);
  font-size: 10px;
}

.mini-metric strong {
  font-size: 16px;
}

.link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.link-list a,
.muted-link {
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(139, 224, 199, 0.1);
  color: var(--accent);
  font-size: 12px;
  text-decoration: none;
}

.muted-link {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.timeline-list {
  position: relative;
  display: grid;
  gap: 6px;
  padding-left: 10px;
}

.timeline-list::before {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  width: 1px;
  content: "";
  background: rgba(139, 224, 199, 0.2);
}

.lesson-row {
  grid-template-columns: 48px 1fr auto;
  gap: 6px 9px;
  padding: 9px;
  border-radius: 12px;
  cursor: pointer;
}

.lesson-row:hover {
  border-color: rgba(139, 224, 199, 0.28);
  background: rgba(255, 255, 255, 0.06);
}

.timeline-event {
  position: relative;
}

.timeline-event::before {
  position: absolute;
  left: -14px;
  top: 17px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  content: "";
  background: var(--muted);
}

.timeline-event.ok::before {
  background: var(--ok);
}

.timeline-event.warn::before {
  background: var(--warn);
}

.timeline-event.bad::before {
  background: var(--bad);
}

.lesson-row time {
  font-size: 13px;
}

.lesson-row p {
  font-size: 12px;
}

.lesson-statuses {
  grid-column: 2;
  gap: 4px;
}

.lesson-menu {
  grid-column: 3;
  grid-row: 1 / span 2;
  align-self: center;
}

.closed-slots-panel {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.closed-slot-list {
  display: grid;
  gap: 6px;
}

.closed-slot-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 8px 9px;
  border: 1px solid rgba(255, 123, 123, 0.22);
  border-left: 3px solid var(--bad);
  border-radius: 12px;
  background: rgba(255, 123, 123, 0.06);
}

.closed-slot-row time {
  color: var(--bad);
  font-size: 12px;
  font-weight: 900;
}

.closed-slot-row strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.closed-slot-row p {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-button.micro {
  min-width: 32px;
  min-height: 30px;
  padding: 0 8px;
  border-radius: 10px;
  font-size: 12px;
}

.status {
  min-height: 20px;
  padding: 2px 7px;
  font-size: 10px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
}

.segmented button {
  min-height: 32px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.segmented button.active {
  background: rgba(139, 224, 199, 0.15);
  color: var(--accent);
}

.homework-row {
  grid-template-columns: 1fr auto;
  min-height: 72px;
  padding: 9px;
  border-radius: 12px;
}

.homework-row strong {
  font-size: 14px;
}

.homework-row p,
.homework-row span,
.homework-row small {
  font-size: 12px;
}

.finance-screen {
  background:
    linear-gradient(180deg, rgba(139, 224, 199, 0.08), transparent 180px),
    rgba(17, 20, 27, 0.9);
}

.finance-kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  margin-bottom: 9px;
}

.finance-kpis article {
  display: grid;
  gap: 4px;
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
}

.finance-kpis span {
  color: var(--muted);
  font-size: 11px;
}

.finance-kpis strong {
  font-size: 18px;
}

.income-chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 6px;
  height: 118px;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.2);
}

.income-chart div {
  display: grid;
  grid-template-rows: 1fr 18px;
  gap: 5px;
  height: 100%;
  align-items: end;
}

.income-chart span {
  display: block;
  width: 100%;
  min-height: 6px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, var(--accent), rgba(139, 224, 199, 0.28));
}

.income-chart small {
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.fab-wrap {
  right: 14px;
  bottom: calc(74px + env(safe-area-inset-bottom));
}

.fab {
  width: 44px;
  height: 44px;
  font-size: 24px;
}

.fab-menu button {
  padding: 9px 11px;
  font-size: 13px;
}

.tabbar {
  bottom: calc(8px + env(safe-area-inset-bottom));
  width: min(640px, calc(100% - 22px));
  padding: 5px;
  border-radius: 22px;
}

.tabbar button {
  min-height: 36px;
  border-radius: 16px;
  font-size: 10px;
  transition: color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.tabbar button.active {
  position: relative;
  background: rgba(139, 224, 199, 0.18);
  color: var(--accent);
  transform: translateY(-1px);
}

.tabbar button.active::before {
  position: absolute;
  top: 5px;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  content: "";
  background: var(--accent);
}

@media (max-width: 760px) {
  .topbar {
    gap: 8px;
    padding: 9px;
  }

  .topbar h1 {
    font-size: 17px;
  }

  .brand-lockup {
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 2px 8px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 11px;
  }

  .dashboard-top {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .top-stat.wide {
    grid-column: 1 / -1;
  }

  .crm-toolbar {
    grid-template-columns: 1fr;
  }

  .profile-sections,
  .attention-grid {
    grid-template-columns: 1fr;
  }

  .lesson-row {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .lesson-menu {
    grid-column: 2;
    grid-row: auto;
    justify-content: flex-start;
  }

  .lesson-statuses {
    grid-column: 2;
  }

  .schedule-slot-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .calendar-toolbar {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .calendar-title-block h2 {
    font-size: 19px;
  }

  .calendar-title-block span {
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .calendar-action-rail {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    border-radius: 16px;
  }

  .calendar-action {
    gap: 4px;
    min-height: 34px;
    padding: 0 5px;
    font-size: 11px;
  }

  .calendar-action span {
    width: 18px;
    height: 18px;
    border-radius: 7px;
    font-size: 12px;
  }

  .lesson-statuses {
    grid-column: 2 / -1;
  }

  .lesson-menu {
    grid-column: 3;
  }

  .homework-row,
  .finance-row {
    grid-template-columns: 1fr auto;
  }

  .closed-slot-row {
    grid-template-columns: 78px minmax(0, 1fr) auto;
  }

  .tabbar {
    width: calc(100% - 18px);
  }
}

@media (max-width: 380px) {
  .calendar-action {
    font-size: 10px;
  }

  .calendar-action span {
    display: none;
  }
}
