:root {
  --primary: #4F46E5;
  --primary-dark: #4338CA;
  --green: #15803D; --green-bg: #DCFCE7;
  --amber: #B45309; --amber-bg: #FEF3C7;
  --red: #B91C1C;   --red-bg: #FEE2E2;
  --teal: #155E75;  --teal-bg: #CFFAFE;
  --indigo-bg: #E0E7FF; --indigo: #4338CA;
  --ink: #0F172A; --muted: #64748B; --line: #E2E8F0; --bg: #F1F5F9;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, 'Segoe UI', Inter, Roboto, sans-serif;
}
.screen {
  max-width: 430px; min-height: 100vh; margin: 0 auto; background: #fff;
  border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  padding-bottom: 150px; position: relative;
}
@media (max-width: 430px) { .screen { border: none; } }

/* Шапка и контент */
.top { padding: 20px 16px 12px; }
.top h1 { font-size: 20px; margin: 0 0 2px; }
.top .sub { color: var(--muted); font-size: 14px; }
.top .more { position: absolute; top: 20px; right: 16px; }
.content { padding: 0 16px; display: flex; flex-direction: column; gap: 12px; }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px;
}
.card.flat { border: none; background: #F8FAFC; }
.card h2 { font-size: 15px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.hint { color: var(--muted); font-size: 13px; }

/* Уроки */
.lesson {
  display: flex; gap: 12px; align-items: center; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 14px; text-decoration: none; color: inherit;
}
.lesson + .lesson { margin-top: 8px; }
.lesson-time { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 64px; }
.lesson-time small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.lesson-main { flex: 1; }
.lesson-name { font-weight: 600; }
.lesson-subj { color: var(--muted); font-size: 13px; }
.lesson-actions { display: flex; gap: 8px; padding: 8px 2px 2px; }
.lesson-actions .btn { flex: 1; }

/* Чипы статусов: цвет + текст + иконка, не только цвет */
.chip {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 999px;
  padding: 3px 10px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.chip.planned { background: #F1F5F9; color: #475569; }
.chip.done    { background: var(--green-bg); color: var(--green); }
.chip.debt    { background: var(--amber-bg); color: var(--amber); }
.chip.bad     { background: var(--red-bg); color: var(--red); }
.chip.advance { background: var(--teal-bg); color: var(--teal); }
.chip.moved   { background: var(--indigo-bg); color: var(--indigo); }

/* Кнопки, 44px цели */
.btn {
  min-height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600;
  padding: 8px 14px; cursor: pointer;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:active { background: var(--primary-dark); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--primary); }
.btn.danger { color: var(--red); }
.btn.small { min-height: 36px; padding: 4px 10px; font-size: 14px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}

/* Должники */
.debtor { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.debtor:first-of-type { border-top: none; }
.debtor .who { flex: 1; }
.debtor .who small { display: block; font-size: 13px; font-weight: 600; color: var(--amber); }

/* Нижняя навигация + FAB */
.nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: min(430px, 100%); display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 40;
}
.nav a, .nav button {
  min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11.5px; color: var(--muted); text-decoration: none; background: none; border: none; font-family: inherit;
}
.nav .active { color: var(--primary); font-weight: 600; }
.nav svg { width: 22px; height: 22px; }
.fab {
  position: fixed; bottom: 72px; right: calc(50% - 215px + 16px); width: 56px; height: 56px;
  border-radius: 50%; border: none; background: var(--primary); color: #fff; font-size: 28px;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .35); cursor: pointer; z-index: 40;
}
@media (max-width: 430px) { .fab { right: 16px; } }

/* Bottom sheet */
.backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); opacity: 0;
  pointer-events: none; transition: opacity .18s; z-index: 50;
}
.backdrop.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; bottom: 0; left: 50%; transform: translate(-50%, 105%);
  width: min(430px, 100%); background: #fff; border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); z-index: 51;
  transition: transform .22s; max-height: 86vh; overflow: auto;
}
.sheet.open { transform: translate(-50%, 0); }
.sheet h3 { margin: 0 0 4px; font-size: 17px; }
.sheet .sub { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet-actions .btn { flex: 1; }

/* Формы */
label.field { display: block; font-size: 13.5px; color: var(--muted); margin: 12px 0 4px; }
input[type=text], input[type=number], select {
  width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; font: inherit; background: #fff;
}
.radio-row { display: flex; gap: 10px; margin-top: 8px; }
.radio-row label {
  flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 10px;
  display: flex; gap: 8px; align-items: center; cursor: pointer; font-size: 14.5px;
}
.radio-row label:has(input:checked) { border-color: var(--primary); background: #EEF2FF; }
.radio-row input { accent-color: var(--primary); }
.preview {
  margin-top: 12px; border-radius: 10px; background: var(--amber-bg); color: var(--amber);
  padding: 10px 12px; font-size: 14px; display: none;
}
.preview.show { display: block; }
.preview.neutral { background: #F1F5F9; color: #475569; }

/* Журнал и балансы */
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tabs button {
  flex: 1; min-height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tabs button.active { background: #EEF2FF; border-color: var(--primary); color: var(--primary); }
.entry { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); align-items: center; }
.entry:first-of-type { border-top: none; }
.entry .e-main { flex: 1; }
.entry .e-label { font-weight: 600; font-size: 14.5px; }
.entry .e-note { color: var(--muted); font-size: 12.5px; }
.entry .e-amount { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }
.entry .plus { color: var(--amber); }
.entry .minus { color: var(--green); }
.entry .e-actions { margin-left: 6px; }

/* Кабинет семьи */
.kv { display: flex; justify-content:space-between; gap: 10px; padding: 6px 0; font-size: 15px; }
.kv b { font-variant-numeric: tabular-nums; }
.balance-hero { text-align: center; padding: 18px 0 6px; }
.balance-hero .sum { font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums; }
.balance-hero .cap { color: var(--muted); }

/* Тост */
.toast {
  position: fixed; top: 14px; left: 50%; transform: translate(-50%, -20px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60;
  max-width: min(430px, 92vw); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Главная прототипа */
.index-list a {
  display: block; padding: 14px; border: 1px solid var(--line); border-radius: 14px;
  text-decoration: none; color: inherit; margin-bottom: 10px;
}
.index-list a b { color: var(--primary); }
footer.proto { text-align: center; padding: 20px 16px; color: var(--muted); font-size: 12.5px; }
