:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --ink: #16202b;
  --ink-2: #5b6b7c;
  --ink-3: #8b98a6;
  --line: #e2e8ef;
  --brand: #16324f;
  --brand-2: #24507a;
  --accent: #b8862b;
  --ok: #1f7a4d;
  --ok-bg: #e6f4ec;
  --warn: #a8401c;
  --warn-bg: #fdeee7;
  --shadow: 0 1px 2px rgba(16, 32, 48, .06), 0 8px 24px rgba(16, 32, 48, .06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #e9edf3;
  color: var(--ink);
  display: flex;
  justify-content: center;
}
.hidden { display: none !important; }

#app {
  width: 100%;
  max-width: 460px;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(16, 32, 48, .18);
}

/* ---------- шапка ---------- */
.app-header {
  flex: 0 0 auto;
  padding: calc(13px + env(safe-area-inset-top)) 18px 13px;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  color: #fff;
}
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.logo {
  width: 30px; height: 30px; border-radius: 9px; flex: 0 0 auto;
  background: linear-gradient(145deg, #f3e2b6, #c9a24a);
  color: #3a2c0c; font-weight: 800; font-size: 13px;
  display: grid; place-items: center;
}
.brand-name { font-weight: 650; font-size: 15px; }
.brand-sub { font-size: 11px; opacity: .66; margin-top: 1px; }
.role-badge {
  font-size: 10px; letter-spacing: .5px; text-transform: uppercase; font-weight: 700;
  border: 1px solid rgba(255, 255, 255, .35); border-radius: 999px;
  padding: 5px 10px; background: rgba(255, 255, 255, .08); color: #fff;
  font-family: inherit; cursor: pointer; white-space: nowrap;
}
.greet { margin-top: 14px; font-size: 21px; font-weight: 700; letter-spacing: -.2px; }
.greet-sub { font-size: 12px; opacity: .72; margin-top: 3px; }
.clubbar { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.club-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .25);
  color: #fff; border-radius: 999px; padding: 6px 11px;
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
}
.club-chip svg { width: 11px; height: 11px; opacity: .75; }
.dotl { width: 6px; height: 6px; border-radius: 50%; background: #c9a24a; }

/* ---------- контент ---------- */
.app-body { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 14px 22px; scrollbar-width: none; }
.app-body::-webkit-scrollbar { display: none; }
.view { animation: fade .2s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card); border-radius: 18px; padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow); border: 1px solid rgba(22, 32, 48, .04);
}
.card.flush { padding: 0; overflow: hidden; }
.card.empty { text-align: center; color: var(--ink-3); font-size: 12.5px; padding: 22px 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.head-card { padding: 15px 16px 13px; }
.eyebrow { font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--ink-3); font-weight: 700; }
h1 { font-size: 26px; margin: 6px 0 4px; letter-spacing: -.6px; }
h2.title { font-size: 16px; margin: 0; }
.strong { font-weight: 700; font-size: 14px; }
.muted { color: var(--ink-2); font-size: 12.5px; }
.tiny { font-size: 11.5px; color: var(--ink-3); }
.money { font-size: 24px; font-weight: 750; letter-spacing: -.5px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.status { display: inline-flex; align-items: center; font-size: 11px; font-weight: 650; border-radius: 999px; padding: 5px 10px; white-space: nowrap; }
.status.ok { background: var(--ok-bg); color: var(--ok); }
.status.warn { background: var(--warn-bg); color: var(--warn); }
.status.neutral { background: #eef2f7; color: var(--ink-2); }

.hero { background: linear-gradient(150deg, #1c3d5f, #16324f 60%, #122a42); color: #fff; border: 0; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; border: 1px solid rgba(201, 162, 74, .35); }
.hero .eyebrow { color: rgba(255, 255, 255, .62); }
.hero-time { font-size: 26px; font-weight: 750; letter-spacing: -.6px; margin: 2px 0; }
.hero-date { font-size: 12.5px; opacity: .75; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: 12.5px; opacity: .9; }
.hero-meta span { display: inline-flex; gap: 6px; align-items: center; }
.dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.tile {
  background: #fff; border-radius: 14px; padding: 11px 6px 9px; text-align: center;
  box-shadow: var(--shadow); border: 1px solid rgba(22, 32, 48, .04);
  font: inherit; color: var(--ink); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.tile:active { transform: scale(.96); }
.tile svg { width: 20px; height: 20px; color: var(--brand-2); }
.tile span { font-size: 10.5px; font-weight: 600; color: var(--ink-2); }

.sub-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.bar { height: 6px; border-radius: 99px; background: #e9eef4; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #2b7a50, #1f7a4d); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.li-icon { width: 34px; height: 34px; border-radius: 11px; flex: 0 0 auto; display: grid; place-items: center; background: #eef2f7; color: var(--brand-2); font-size: 12px; font-weight: 700; }
.li-icon.ok { background: var(--ok-bg); color: var(--ok); }
.li-icon.warn { background: var(--warn-bg); color: var(--warn); }
.li-main { flex: 1 1 auto; min-width: 0; }
.li-title { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-right { text-align: right; font-size: 12.5px; font-weight: 650; white-space: nowrap; }
li.tap { cursor: pointer; }
li.tap:active { background: #f7fafc; }

.lesson { cursor: default; }
.lesson-time { font-size: 15px; font-weight: 700; }
.lesson-row { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.lesson-row:first-of-type { border-top: 0; }
.lesson-row-time { min-width: 84px; font-weight: 700; font-size: 13px; }
.lesson-row-main { flex: 1; }
.lesson-row.canceled { opacity: .55; }

.section-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--ink-3); font-weight: 700; margin: 16px 4px 8px; }

.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi { background: #f4f7fa; border-radius: 14px; padding: 12px; }
.kpi .money { font-size: 19px; }
.delta { font-size: 11px; color: var(--ink-3); margin-top: 3px; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--warn); }

.bars { display: flex; align-items: flex-end; gap: 9px; height: 108px; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
.bar-col i { display: block; width: 100%; border-radius: 8px 8px 4px 4px; background: linear-gradient(180deg, #2f5b86, #16324f); }
.bar-col.cur i { background: linear-gradient(180deg, #d7b25f, #b8862b); }
.bar-col span { font-size: 10px; color: var(--ink-3); }
.bar-val { font-size: 9.5px; font-weight: 700; color: var(--ink-2); }

.att-sum { display: flex; gap: 10px; margin-top: 12px; }
.att-sum > div { flex: 1; background: #f4f7fa; border-radius: 14px; padding: 11px; }
.att-sum .money { font-size: 20px; }
.att-row { cursor: pointer; }
.att-row[aria-pressed="true"] { background: #fbfdfc; }
.att-chip { font-size: 10.5px; font-weight: 700; border-radius: 999px; padding: 5px 10px; background: #eef2f7; color: var(--ink-3); }
.att-row[aria-pressed="true"] .att-chip { background: var(--ok-bg); color: var(--ok); }

.search { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 11px 13px; font: inherit; font-size: 13.5px; margin-bottom: 10px; outline: none; }
.search:focus { border-color: #c3d3e3; }

.notice { display: flex; gap: 10px; background: #fff7ef; border: 1px solid #f5dfc9; border-radius: 14px; padding: 12px; font-size: 12.5px; color: #8a5a2b; margin-bottom: 12px; line-height: 1.45; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 13px; border-radius: 14px; border: 0; cursor: pointer; font: inherit; font-size: 14px; font-weight: 650; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:active { background: #10273d; }
.btn-ghost { background: #eef2f7; color: var(--brand); }
.btn svg { width: 16px; height: 16px; }

.chip { border: 1px solid var(--line); background: #fff; color: var(--brand); border-radius: 999px; padding: 7px 12px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.chip-brand { background: var(--brand); color: #fff; border-color: var(--brand); }

.nav { flex: 0 0 auto; display: grid; background: rgba(255, 255, 255, .96); border-top: 1px solid var(--line); padding: 7px 4px calc(7px + env(safe-area-inset-bottom)); }
.nav button { background: none; border: 0; font: inherit; color: var(--ink-3); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 9.5px; font-weight: 600; padding: 5px 0; border-radius: 12px; }
.nav button svg { width: 22px; height: 22px; }
.nav button[aria-current="page"] { color: var(--brand); }

.backdrop { position: fixed; inset: 0; background: rgba(12, 22, 34, .45); opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 20; }
.backdrop.on { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 50%; transform: translate(-50%, 105%); bottom: 0; width: 100%; max-width: 460px; z-index: 21; background: #fff; border-radius: 24px 24px 0 0; padding: 16px 16px calc(18px + env(safe-area-inset-bottom)); transition: transform .26s cubic-bezier(.2, .8, .2, 1); box-shadow: 0 -20px 40px -20px rgba(12, 22, 34, .5); max-height: 86vh; overflow-y: auto; }
.sheet.on { transform: translate(-50%, 0); }
.sheet-grab { width: 38px; height: 4px; border-radius: 99px; background: #dbe3ec; margin: 0 auto 14px; }
.sheet h3 { margin: 0 0 4px; font-size: 16px; }
.sheet .subtitle { font-size: 12px; color: var(--ink-3); margin-bottom: 12px; }
.opt { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; margin-top: 9px; cursor: pointer; font: inherit; color: inherit; background: #fff; width: 100%; text-align: left; }
.opt.sel { border-color: var(--brand); background: #f2f7fb; }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 12px); background: #122a42; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 12.5px; opacity: 0; pointer-events: none; transition: all .22s ease; z-index: 30; white-space: nowrap; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

.login { max-width: 340px; margin: 0 auto; padding: 48px 8px 24px; text-align: center; }
.login-logo { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 14px; background: linear-gradient(145deg, #f3e2b6, #c9a24a); color: #3a2c0c; font-weight: 800; font-size: 24px; display: grid; place-items: center; }
.login h1 { margin: 0 0 4px; }
.login .search { text-align: center; margin-top: 18px; }
.demo-code { background: #eef7f1; border: 1px solid #cfe8da; color: #1f7a4d; border-radius: 12px; padding: 9px 12px; font-size: 13px; margin: 12px 0 6px; }
.error { color: var(--warn); font-size: 12.5px; margin: 8px 0; }
.link { background: none; border: 0; color: var(--ink-3); font: inherit; font-size: 12px; margin-top: 18px; text-decoration: underline; cursor: pointer; }
.demo { margin-top: 22px; }
.demo-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.boot-error { position: fixed; inset: 0; background: #fff; padding: 32px 24px; font-size: 14px; line-height: 1.6; color: #16202b; z-index: 100; overflow: auto; }
code { background: #eef2f7; padding: 1px 5px; border-radius: 5px; font-size: .92em; }

/* навигация по датам на экране занятий */
.date-nav { display: flex; align-items: center; gap: 10px; padding: 4px 2px 12px; }
.date-nav-main { flex: 1; min-width: 0; }
.date-nav .chip { min-width: 42px; text-align: center; }
.date-nav .chip[disabled] { opacity: .35; cursor: default; }

/* календарь даты занятия */
.date-input { flex: 1; min-width: 0; font: inherit; font-size: 14px; font-weight: 600; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.date-input::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .7; }
.date-hint { display: flex; align-items: baseline; gap: 8px; padding: 0 4px 10px; flex-wrap: wrap; }
.date-hint .link { margin-left: auto; }
/* площадки преподавателя */
.venue-bar { display: flex; gap: 8px; overflow-x: auto; padding: 0 2px 10px; -webkit-overflow-scrolling: touch; }
.venue-bar .chip { white-space: nowrap; }
/* панель установки PWA */
.install-bar { position: fixed; left: 12px; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 60;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px;
  box-shadow: 0 12px 30px rgba(16, 32, 48, .18); }
.install-bar.hidden { display: none; }
.install-bar .install-text { flex: 1; min-width: 140px; font-size: 13px; font-weight: 600; color: var(--ink); }
.install-bar .btn { width: auto; padding: 9px 16px; font-size: 13px; }
.install-bar .link { font-size: 12px; }
/* метка режима: демо или рабочая база */
.env { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 10px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; white-space: nowrap; }
.env::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.env-demo { background: #fff2d8; color: #8a5a10; border: 1px solid #f0d9a8; }
.env-real { background: #e4f3ea; color: #1b6c46; border: 1px solid #bfe3d0; }
.env-test { background: #e7eefb; color: #27528c; border: 1px solid #c3d4f2; }
.clubbar .env { margin-left: auto; }
/* индикатор отметки в карточке занятия */
.marks { font-size: 12px; font-weight: 800; color: var(--brand); white-space: nowrap; }
.marks b { font-size: 14px; }
.marks.muted { color: var(--ink-3); font-weight: 650; }

@keyframes barsIn {
  from { opacity: .35; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.bars.bars-in {
  animation: barsIn .18s ease-out;
}

/* плашка «вышло обновление» */
.update-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  width: min(520px, calc(100% - 24px));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  background: #16324f;
  color: #eaf3fb;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(8, 20, 34, .35);
  z-index: 60;
  font-size: 14px;
}
.update-bar .update-text { flex: 1; }
.update-bar .btn { padding: 8px 14px; font-size: 14px; }
