/* Учись Играй — приложение родителя. Цвета бренда: синий «Учись», зелёный «Играй». */
:root {
  color-scheme: dark;
  --bg: #0a1120;
  --bg-grad: radial-gradient(1200px 600px at 10% -10%, rgba(31,95,214,.18), transparent 60%),
             radial-gradient(900px 500px at 110% 10%, rgba(42,168,74,.12), transparent 60%);
  --surface: #111a2c;
  --surface-2: #18233a;
  --surface-3: #202d48;
  --border: #25324d;
  --text: #e9eef8;
  --muted: #95a2bb;
  --primary: #4d8dff;
  --primary-strong: #2f6fe6;
  --on-primary: #ffffff;
  --success: #3fd06e;
  --on-success: #062712;
  --warn: #ffb534;
  --danger: #ff6b70;
  --blue-grad: linear-gradient(135deg, #2f6fe6 0%, #1f4fbf 100%);
  --brand-grad: linear-gradient(120deg, #2f6fe6 0%, #2aa84a 100%);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --shadow-sm: 0 2px 10px rgba(0,0,0,.25);
  --tabbar-h: 68px;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f5fb;
  --bg-grad: radial-gradient(1200px 600px at 10% -10%, rgba(31,95,214,.10), transparent 60%),
             radial-gradient(900px 500px at 110% 10%, rgba(42,168,74,.08), transparent 60%);
  --surface: #ffffff;
  --surface-2: #eef2f9;
  --surface-3: #e3e9f4;
  --border: #dbe2ee;
  --text: #0f1b33;
  --muted: #56627a;
  --primary: #1f5fd6;
  --primary-strong: #1747a8;
  --success: #1c8a3a;
  --on-success: #ffffff;
  --warn: #a86400;
  --danger: #cc2f36;
  --shadow: 0 10px 30px rgba(20,40,90,.10);
  --shadow-sm: 0 2px 10px rgba(20,40,90,.08);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f2f5fb;
    --bg-grad: radial-gradient(1200px 600px at 10% -10%, rgba(31,95,214,.10), transparent 60%),
               radial-gradient(900px 500px at 110% 10%, rgba(42,168,74,.08), transparent 60%);
    --surface: #ffffff; --surface-2: #eef2f9; --surface-3: #e3e9f4; --border: #dbe2ee;
    --text: #0f1b33; --muted: #56627a; --primary: #1f5fd6; --primary-strong: #1747a8;
    --success: #1c8a3a; --on-success: #ffffff; --warn: #a86400; --danger: #cc2f36;
    --shadow: 0 10px 30px rgba(20,40,90,.10); --shadow-sm: 0 2px 10px rgba(20,40,90,.08);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); background-image: var(--bg-grad); background-attachment: fixed;
  color: var(--text); line-height: 1.45; overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
.app { max-width: 560px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); }
.app.no-tabs { padding-bottom: 32px; }
h1, h2, h3 { margin: 0 0 10px; font-weight: 750; letter-spacing: -.015em; line-height: 1.2; }
h1 { font-size: 1.55rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.tiny { font-size: .76rem; }
.hidden { display: none !important; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
a { color: var(--primary); text-decoration: none; font-weight: 600; }
svg.i { width: 22px; height: 22px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 18px; height: 18px; }
svg.i.lg { width: 28px; height: 28px; }

/* ── Верхняя панель ── */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 16px; min-height: 48px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.12rem; letter-spacing: -.02em; }
.brand img { width: 36px; height: 36px; border-radius: 10px; background: #fff; padding: 2px; box-shadow: var(--shadow-sm); }
.brand .b1 { color: var(--primary); } .brand .b2 { color: var(--success); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; cursor: pointer; padding: 0; min-height: 0;
}
.icon-btn:active { transform: scale(.96); }
.child-pill {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 12px 6px 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; color: var(--text); font-weight: 700; cursor: pointer;
}
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: .95rem; background: var(--brand-grad); flex: none; }
.avatar.lg { width: 44px; height: 44px; font-size: 1.15rem; }

/* ── Карточки и раскладка ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow-sm); }
.card.flat { box-shadow: none; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title h2, .card-title h3 { margin: 0; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stack > * + * { margin-top: 10px; }
.section-label { font-size: .78rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 22px 4px 10px; }

/* ── Главная: карточка баланса ── */
.hero-card { position: relative; overflow: hidden; border: none; color: #fff; background: var(--brand-grad); box-shadow: var(--shadow); }
.hero-card::after { content: ""; position: absolute; inset: auto -40px -60px auto; width: 220px; height: 220px; border-radius: 50%; background: rgba(255,255,255,.08); }
.hero-card .muted, .hero-card .small { color: rgba(255,255,255,.85); }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; position: relative; z-index: 1; }
.dev-status { display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,.16); padding: 6px 12px; border-radius: 999px; font-size: .84rem; font-weight: 650; max-width: 70%; }
.dev-status span.txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #c9d3e6; flex: none; }
.dot.on { background: #6bff9a; box-shadow: 0 0 0 4px rgba(107,255,154,.25); }
.ring-wrap { display: grid; place-items: center; margin: 14px 0 8px; position: relative; z-index: 1; }
.ring { width: 210px; height: 210px; }
.ring .track { stroke: rgba(255,255,255,.22); }
.ring .val { stroke: #fff; transition: stroke-dashoffset .6s ease; }
.ring-center { position: absolute; text-align: center; max-width: 150px; }
.ring-center .big { font-size: 2.1rem; font-weight: 850; letter-spacing: -.03em; line-height: 1.05; }
.ring-center .big .u { font-size: 1rem; font-weight: 750; opacity: .9; margin-left: 2px; letter-spacing: 0; }
.ring-center .big small { display: block; font-size: 1.05rem; font-weight: 750; opacity: .92; letter-spacing: 0; margin-top: 2px; }
.ring-center .cap { font-size: .8rem; opacity: .9; margin-top: 6px; }
.hero-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; position: relative; z-index: 1; }
.hero-metrics .m { background: rgba(255,255,255,.14); border-radius: 14px; padding: 10px 6px; text-align: center; }
.hero-metrics .v { font-weight: 800; font-size: clamp(.92rem, 4vw, 1.12rem); white-space: nowrap; }
.hero-metrics .l { font-size: .72rem; opacity: .9; }

.metric { text-align: center; padding: 12px 6px; background: var(--surface-2); border-radius: 14px; }
.metric .v { font-size: clamp(.95rem, 4.2vw, 1.3rem); font-weight: 800; white-space: nowrap; }
.metric .l { font-size: .75rem; color: var(--muted); }
.metric.earn .v { color: var(--success); }
.metric.spent .v { color: var(--warn); }

/* ── Кнопки ── */
button, .btn {
  font: inherit; font-weight: 700; cursor: pointer; border: none; border-radius: 14px;
  padding: 12px 16px; background: var(--primary-strong); color: var(--on-primary);
  transition: transform .06s ease, background .15s, opacity .15s; min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
}
button:active, .btn:active { transform: scale(.98); }
button:disabled { opacity: .55; cursor: default; transform: none; }
.btn-lg { width: 100%; font-size: 1.08rem; min-height: 56px; }
.btn-primary { background: var(--blue-grad); color: #fff; box-shadow: 0 6px 18px rgba(31,95,214,.30); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-success { background: var(--success); color: var(--on-success); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-link { background: none; color: var(--primary); min-height: 44px; padding: 8px; }
.chip { min-height: 48px; padding: 8px; font-size: 1rem; border-radius: 13px; }
.btn-spin { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.35); border-top-color: currentColor; border-radius: 50%; animation: spin .8s linear infinite; }

/* Плитки управления ПК */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { flex-direction: column; align-items: flex-start; justify-content: space-between; min-height: 84px; padding: 14px; text-align: left;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 16px; font-weight: 700; }
.tile svg.i { width: 26px; height: 26px; }
.tile.primary svg { color: var(--primary); } .tile.green svg { color: var(--success); }
.tile.warn svg { color: var(--warn); } .tile.red svg { color: var(--danger); }
.tile .t-sub { font-size: .74rem; color: var(--muted); font-weight: 600; }

/* ── Поля ввода ── */
input, select, textarea {
  font: inherit; width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1.5px solid var(--border); color: var(--text); min-height: 50px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); }
label { display: block; font-size: .86rem; color: var(--muted); margin: 12px 0 6px; font-weight: 600; }
textarea { min-height: 80px; resize: vertical; }
.hint { font-size: .78rem; color: var(--muted); margin-top: 6px; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.field-row:last-child { border-bottom: none; }
.field-row .fr-label { flex: 1; min-width: 0; }
.field-row .fr-label b { display: block; font-weight: 650; }
.field-row input[type=number], .field-row input.num { width: 110px; text-align: center; font-weight: 700; }

/* Переключатель */
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .sl { position: absolute; inset: 0; background: var(--surface-3); border-radius: 999px; transition: .2s; border: 1px solid var(--border); cursor: pointer; }
.switch .sl::before { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.switch input:checked + .sl { background: var(--success); border-color: var(--success); }
.switch input:checked + .sl::before { transform: translateX(20px); }

/* Сегменты */
.segmented { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 4px; gap: 4px; }
.segmented button { flex: 1; min-height: 42px; background: none; color: var(--muted); border-radius: 10px; font-weight: 700; padding: 6px 8px; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ── Нижняя панель вкладок ── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border); display: flex; justify-content: center;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.tabbar .tb-inner { display: flex; width: 100%; max-width: 560px; }
.tabbar button {
  background: none; color: var(--muted); flex: 1; flex-direction: column; gap: 3px; font-size: .7rem; font-weight: 700;
  padding: 6px 2px; min-height: 56px; border-radius: 14px; position: relative;
}
.tabbar button.active { color: var(--primary); }
.tabbar button.active svg { stroke-width: 2.4; }
.tab-badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: .68rem; font-weight: 800; display: grid; place-items: center; }

/* ── Списки ── */
.list-item { display: flex; align-items: center; justify-content: space-between; padding: 13px 0; border-bottom: 1px solid var(--border); gap: 12px; }
.list-item:last-child { border-bottom: none; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-main b { display: block; overflow-wrap: anywhere; }
.list-item .li-sub { font-size: .82rem; color: var(--muted); overflow-wrap: anywhere; }
.li-actions { display: flex; gap: 8px; flex: none; }
.li-actions button { min-height: 44px; min-width: 44px; padding: 8px 12px; }
.nav-item { display: flex; align-items: center; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--border); cursor: pointer; background: none; width: 100%; color: var(--text); border-radius: 0; min-height: 60px; justify-content: flex-start; font-weight: 650; }
.nav-item:last-child { border-bottom: none; }
.nav-item .ni-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--primary); flex: none; }
.nav-item .ni-txt { flex: 1; text-align: left; min-width: 0; }
.nav-item .ni-txt small { display: block; color: var(--muted); font-weight: 500; font-size: .8rem; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .74rem; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.badge.green { background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success); border-color: transparent; }
.badge.blue { background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--primary); border-color: transparent; }
.badge.red { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); border-color: transparent; }
.delta-pos { color: var(--success); font-weight: 800; white-space: nowrap; }
.delta-neg { color: var(--danger); font-weight: 800; white-space: nowrap; }

/* Оценки */
.grade-btns { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.grade-btns button { min-height: 58px; font-size: 1.35rem; font-weight: 850; border-radius: 16px; border: 3px solid transparent; }
.grade-btns button.sel { border-color: var(--text); transform: translateY(-2px); box-shadow: var(--shadow); }
.g5 { background: #1f9d49; color: #fff; } .g4 { background: #5aa532; color: #fff; } .g3 { background: #d89a12; color: #fff; }
.g2 { background: #d9434a; color: #fff; } .g1 { background: #9b1c24; color: #fff; }
.gbadge { width: 34px; height: 34px; border-radius: 10px; display: inline-grid; place-items: center; font-weight: 850; color: #fff; flex: none; }

/* Запросы/ожидание */
.pending-card { border: 1.5px solid color-mix(in srgb, var(--primary) 55%, transparent); }
.pending-card.tasks { border-color: color-mix(in srgb, var(--success) 55%, transparent); }
.pending-card.alert-card { border-color: color-mix(in srgb, var(--warn, #ffb534) 60%, transparent); }
.pending-card.alert-card h3 { color: var(--warn, #ffb534); }
.req-reason { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; margin-top: 6px; font-size: .88rem; overflow-wrap: anywhere; }
.banner { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; margin-bottom: 14px; font-weight: 600; font-size: .9rem; }
.banner.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--text); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); }
.banner.info { background: color-mix(in srgb, var(--primary) 14%, transparent); border: 1px solid color-mix(in srgb, var(--primary) 40%, transparent); }

/* Авторизация */
.auth-hero { text-align: center; margin: 18px 0 8px; }
.auth-hero img { width: min(220px, 60%); height: auto; border-radius: 32px; background: #fff; box-shadow: 0 16px 40px rgba(31,95,214,.22); }
.auth-tag { text-align: center; color: var(--muted); margin: 0 12px 18px; }
.connect-card { background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 14%, var(--surface)), color-mix(in srgb, var(--success) 12%, var(--surface))); border: 1.5px dashed color-mix(in srgb, var(--primary) 55%, transparent); }
.connect-card .ic { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 10px; display: grid; place-items: center; background: var(--surface); box-shadow: var(--shadow-sm); }
.connect-card .ic img { width: 48px; height: 48px; }
.empty { text-align: center; padding: 18px 8px; color: var(--muted); }
.empty svg { width: 40px; height: 40px; opacity: .6; margin-bottom: 6px; }

/* Графики */
.chart { width: 100%; height: 160px; display: block; }
.chart.sm { height: 130px; }

/* Уведомление */
#toast { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom)); z-index: 300; display: flex; justify-content: center; pointer-events: none; padding: 0 16px; }
.toast { background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px; box-shadow: var(--shadow); max-width: 520px; text-align: center; font-weight: 650; animation: pop .2s ease; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Модальные окна (снизу, как в мобильных приложениях) */
.modal { position: fixed; inset: 0; background: rgba(5,10,20,.62); backdrop-filter: blur(4px); display: flex; align-items: flex-end; justify-content: center; z-index: 200; overflow-y: auto; }
.modal-card { background: var(--surface); border: 1px solid var(--border); border-radius: 24px 24px 0 0; padding: 20px 18px calc(22px + env(safe-area-inset-bottom)); width: 100%; max-width: 520px; box-shadow: var(--shadow); animation: up .22s ease; max-height: 92vh; overflow-y: auto; }
@media (min-width: 600px) { .modal { align-items: center; padding: 16px; } .modal-card { border-radius: 24px; } }
@keyframes up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal-grip { width: 42px; height: 5px; border-radius: 99px; background: var(--border); margin: -6px auto 12px; }
.steps { margin: 4px 0; padding-left: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; display: flex; gap: 12px; align-items: flex-start; margin: 10px 0; color: var(--text); font-size: .93rem; }
.steps li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; font-weight: 800; font-size: .82rem; flex: none; color: var(--primary); }
.code-input { text-align: center; font-size: 1.7rem; font-weight: 800; letter-spacing: .12em; font-variant-numeric: tabular-nums; }

.spinner { width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.err { color: var(--danger); font-size: .9rem; font-weight: 600; min-height: 1em; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 12px; }
@keyframes sk { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
