:root {
  --bg: #F3F4EF;
  --card: #FFFFFF;
  --ink: #15171A;
  --ink-2: #3F444B;
  --muted: #5A5F66;
  --line: #ECEDE8;
  --border: #D5D8D0;
  --blue: #0B5CAD;
  --blue-soft: #E8F0FB;
  --green: #146C43;
  --green-soft: #DDF0E4;
  --green-ink: #0F4D2C;
  --amber-soft: #FDF0D5;
  --amber-ink: #7A4A00;
  --red-soft: #FCEDE4;
  --red-ink: #8A3410;
  --dark: #15171A;
  --dark-2: #24272B;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-tap-highlight-color: transparent; }
body { min-height: 100vh; }
button, input, select, textarea { font-family: inherit; font-size: 16px; color: var(--ink); }
a { color: var(--blue); }

#app { max-width: 560px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.page { flex: 1; padding: 18px 16px 110px; display: flex; flex-direction: column; gap: 16px; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.top h1 { margin: 0; font-size: 24px; font-weight: 700; }
.sub { font-size: 13px; color: var(--muted); }
.hello { font-size: 22px; font-weight: 700; }

.chip { height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--border); background: var(--card); font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
select.chip { appearance: none; -webkit-appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2315171A' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip.on { background: var(--dark); color: #fff; border-color: var(--dark); }
.chip.warn { background: var(--red-soft); color: var(--red-ink); border-color: #F0C3A8; }

.hero { background: var(--dark); color: #F3F4EF; border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.hero .lbl { font-size: 13px; color: #A9AEB5; }
.hero .big { font-size: 30px; font-weight: 700; }
.hero .grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.hero .cell { background: var(--dark-2); border-radius: 12px; padding: 10px 12px; }
.hero .cell .v { font-size: 16px; font-weight: 600; }
.hero .cell.debt .lbl { color: #F3A57A; }
.hero .cell.debt .v { color: #F7B48E; }

.section { display: flex; flex-direction: column; gap: 10px; }
.section-h { display: flex; justify-content: space-between; align-items: baseline; }
.section-h h2 { margin: 0; font-size: 16px; font-weight: 700; }

.card { background: var(--card); border-radius: 14px; }
.card.pad { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.list { background: var(--card); border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row .main { flex: 1; min-width: 0; }
.row .t { font-size: 15px; font-weight: 600; }
.row .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .amt { font-size: 15px; font-weight: 700; }
.row .amt.plus { color: var(--green); }
.empty { padding: 18px 14px; color: var(--muted); font-size: 14px; }

.ava { width: 40px; height: 40px; border-radius: 20px; background: #E3E6DD; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; flex-shrink: 0; }
.ava.lg { width: 60px; height: 60px; border-radius: 30px; font-size: 20px; font-weight: 700; }

.badge { font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.b-ok { color: var(--green-ink); background: var(--green-soft); }
.b-today, .b-soon { color: var(--amber-ink); background: var(--amber-soft); }
.b-overdue { color: var(--red-ink); background: var(--red-soft); }
.b-none, .b-muted { color: var(--muted); background: #F0F1EC; }

.btn { height: 50px; border-radius: 12px; border: none; background: var(--blue); color: #fff; font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; cursor: pointer; text-decoration: none; }
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid #C9CDC3; }
.btn.danger { background: var(--card); color: var(--red-ink); border: 1px solid #F0C3A8; }
.btn.sm { height: 36px; width: auto; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .55; }
.hint { font-size: 12px; color: var(--muted); text-align: center; }

.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: none; background: var(--card); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; text-decoration: none; }
.icon-btn.plain { background: transparent; }
.icon-btn.wa { background: var(--green-soft); }

.fab { position: fixed; right: max(16px, calc(50% - 264px)); bottom: 92px; height: 52px; padding: 0 20px; border-radius: 26px; border: none; background: var(--blue); color: #fff; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; box-shadow: 0 6px 18px rgba(11, 92, 173, .28); cursor: pointer; z-index: 5; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: 76px; background: var(--card); border-top: 1px solid #E3E5DE; display: flex; justify-content: center; z-index: 10; padding-bottom: env(safe-area-inset-bottom); }
.tabbar .in { width: 100%; max-width: 560px; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; color: #6B7078; text-decoration: none; padding-bottom: 8px; }
.tabbar a.on { color: var(--ink); font-weight: 600; }
.tabbar a svg { stroke: currentColor; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .lbl { font-size: 13px; color: var(--muted); }
.input, select.input, textarea.input { height: 48px; border-radius: 12px; border: 1px solid var(--border); padding: 0 14px; background: var(--card); width: 100%; }
textarea.input { height: 110px; padding: 12px 14px; resize: vertical; line-height: 1.45; }
.input.big { height: 54px; font-size: 22px; font-weight: 700; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.search { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px; background: var(--card); border-radius: 12px; border: 1px solid #E0E2DA; }
.search input { flex: 1; border: none; outline: none; background: transparent; font-size: 15px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; background: #F0F1EC; padding: 4px; border-radius: 12px; }
.seg button { height: 42px; border-radius: 9px; border: none; background: transparent; font-size: 14px; cursor: pointer; }
.seg button.on { background: var(--dark); color: #fff; font-weight: 600; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--bg); border-radius: 12px; font-size: 14px; font-weight: 600; cursor: pointer; }
.switch { width: 48px; height: 28px; border-radius: 14px; background: #C9CDC3; position: relative; flex-shrink: 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 11px; background: #fff; transition: left .15s; }
.switch.on { background: var(--green); }
.switch.on::after { left: 23px; }

.bubble { background: #DCF5D3; border-radius: 12px 12px 4px 12px; padding: 12px 14px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; }

.sheet-bg { position: fixed; inset: 0; background: rgba(21, 23, 26, .55); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 560px; border-radius: 22px 22px 0 0; padding: 10px 18px 24px; display: flex; flex-direction: column; gap: 16px; max-height: 92vh; overflow-y: auto; }
.sheet .grab { align-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--border); }
.sheet h3 { margin: 0; font-size: 20px; }

.sub-card { border: 2px solid #E9B44C; }
.kv { display: flex; justify-content: space-between; font-size: 14px; color: var(--ink-2); gap: 10px; }
.kv b { color: var(--ink); }
.bar { height: 8px; border-radius: 4px; background: #EEF0EA; }
.bar > div { height: 8px; border-radius: 4px; background: var(--dark); }
.money-plus { color: var(--green); }
.money-minus { color: #A3400F; }

.banner { background: var(--amber-soft); color: var(--amber-ink); border-radius: 12px; padding: 10px 14px; font-size: 13px; line-height: 1.4; }

.login { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px; gap: 16px; }
.login h1 { margin: 0 0 4px; font-size: 28px; }
.err { color: var(--red-ink); font-size: 14px; }

.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: var(--dark); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 30; max-width: 90vw; text-align: center; }
.cancelled { text-decoration: line-through; opacity: .55; }

.btn.wa { background: #1F8A4C; color: #fff; border: none; }
.btn.wa-done { background: var(--green-soft); color: var(--green-ink); border: none; }
.btn.sm.wa, .btn.sm.wa-done { flex-shrink: 0; gap: 6px; }

/* Ученики: плитки-счётчики, метка филиала, сумма и статус справа */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { background: var(--card); border: 2px solid transparent; border-radius: 12px; padding: 10px 12px; text-align: left; cursor: pointer; font-family: inherit; color: var(--ink); }
.tile .tl { font-size: 12px; color: var(--muted); }
.tile .tv { font-size: 22px; font-weight: 700; line-height: 1.2; }
.tile .ts { font-size: 11px; }
.tile.t-debt { background: var(--red-soft); }
.tile.t-debt .tl, .tile.t-debt .tv, .tile.t-debt .ts { color: var(--red-ink); }
.tile.t-soon { background: var(--amber-soft); }
.tile.t-soon .tl, .tile.t-soon .tv, .tile.t-soon .ts { color: var(--amber-ink); }
.tile.sel { border-color: var(--ink); }
.s-tags { display: flex; gap: 6px; align-items: center; }
.s-tags span:last-child { overflow: hidden; text-overflow: ellipsis; }
.btag { padding: 1px 6px; border-radius: 5px; font-weight: 600; font-size: 12px; flex-shrink: 0; }
.amt-col { text-align: right; flex-shrink: 0; }
.amt-col .a1 { font-size: 14px; font-weight: 700; }
.amt-col .a2 { font-size: 11px; }
.amt-col.c-debt { color: var(--red-ink); }
.amt-col.c-soon { color: var(--amber-ink); }
.amt-col.c-ok { color: var(--green); }
.amt-col.c-ok .a1 { font-weight: 600; }
.amt-col.c-none { color: var(--muted); }
.top select.chip { flex-shrink: 0; }

/* Доступ секции: плашки срока и экран «Доступ приостановлен» */
.access-bar { margin: 12px 16px 0; padding: 10px 14px; border-radius: 12px; background: var(--blue-soft); color: var(--blue); font-size: 14px; line-height: 1.4; }
.access-bar a { font-weight: 600; white-space: nowrap; margin-left: 4px; }
.access-bar.red { background: #FCE4E1; color: #A3231B; font-weight: 600; }
.access-bar.red a { color: #A3231B; }
.closed-screen { justify-content: center; padding-bottom: 32px; }
.closed-screen h1 { margin: 0 0 4px; font-size: 26px; }
.cancelled .badge { display: inline-block; }
