/* Законный родительский контроль — пульт. Apple-style, под iPhone PWA. */
:root {
  --bg: #0b1020;
  --bg2: #121833;
  --card: #171f3d;
  --card2: #1e274b;
  --text: #f2f5ff;
  --muted: #9aa6c7;
  --line: #27315c;
  --accent: #0a84ff;      /* iOS blue */
  --green: #30d158;
  --red: #ff453a;
  --amber: #ff9f0a;
  --radius: 20px;
  --tap: 48px;
  --sat: env(safe-area-inset-top);
  --sab: env(safe-area-inset-bottom);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef1f8; --bg2: #e3e8f4; --card: #ffffff; --card2: #f4f6fc;
    --text: #0b1020; --muted: #5b678a; --line: #e2e7f3;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  padding: calc(var(--sat) + 8px) 16px calc(var(--sab) + 24px);
  max-width: 560px; margin: 0 auto;
  background: radial-gradient(1200px 600px at 50% -200px, var(--bg2), var(--bg));
  min-height: 100vh;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.02em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.spread { justify-content: space-between; }

/* --- Вход --- */
#login { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; }
.brand { text-align: center; margin-bottom: 28px; }
.brand .logo {
  width: 72px; height: 72px; border-radius: 20px; margin: 0 auto 14px;
  background: linear-gradient(145deg, #0a84ff, #30d158);
  display: grid; place-items: center; font-size: 34px;
  box-shadow: 0 10px 30px rgba(10,132,255,.35);
}
.brand h1 { font-size: 24px; }
.brand p { color: var(--muted); margin: 6px 0 0; font-size: 14px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin: 14px 0;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px 2px; }
input, select {
  width: 100%; height: var(--tap); padding: 0 14px; font-size: 17px;
  background: var(--card2); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
.field { margin-bottom: 14px; }

.btn {
  height: var(--tap); border: 0; border-radius: 14px; font-size: 17px; font-weight: 600;
  background: var(--accent); color: #fff; width: 100%; cursor: pointer;
  transition: transform .08s ease, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn.sec { background: var(--card2); color: var(--text); border: 1px solid var(--line); }
.btn.green { background: var(--green); }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.sm { height: 38px; font-size: 14px; width: auto; padding: 0 14px; }
.btn.danger { background: transparent; color: var(--red); border: 1px solid var(--line); }
.err { color: var(--red); font-size: 14px; min-height: 18px; margin: 4px 2px; }

/* --- Шапка устройства --- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 2px; }
.topbar h1 { font-size: 22px; }
.pill { font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px;
  background: var(--card2); color: var(--muted); border: 1px solid var(--line); }
.pill.on { color: var(--green); border-color: rgba(48,209,88,.4); }
.pill.on::before { content: "●"; margin-right: 6px; }
.pill.off::before { content: "○"; margin-right: 6px; }

/* Переключатель контроля */
.switch { position: relative; width: 52px; height: 32px; flex: 0 0 auto; }
.switch input { display: none; }
.switch .track { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .2s; }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; transition: transform .2s; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track + .thumb { transform: translateX(20px); }

/* Переключатель дней */
.days { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 2px; -webkit-overflow-scrolling: touch; }
.days button { flex: 0 0 auto; height: 40px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); font-size: 14px; font-weight: 600; }
.days button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

h2.section { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  margin: 22px 2px 6px; font-weight: 700; }

/* Карточка лимита */
.limit .head { display: flex; justify-content: space-between; align-items: baseline; }
.limit .name { font-size: 18px; font-weight: 700; }
.limit .rem { font-size: 14px; font-weight: 600; }
.limit .rem.ok { color: var(--green); }
.limit .rem.low { color: var(--amber); }
.limit .rem.blocked { color: var(--red); }
.bar { height: 10px; background: var(--card2); border-radius: 999px; overflow: hidden; margin: 10px 0; }
.bar > span { display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #30d158, #0a84ff); transition: width .4s ease; }
.bar.blocked > span { background: linear-gradient(90deg, #ff9f0a, #ff453a); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.subrow { margin-top: 8px; display: flex; gap: 8px; justify-content: flex-end; }

/* Строки списков */
.item { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .ico { width: 38px; height: 38px; border-radius: 10px; background: var(--card2);
  display: grid; place-items: center; font-size: 18px; flex: 0 0 auto; }
.item .main { flex: 1; min-width: 0; }
.item .main .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .main .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .val { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); flex: 0 0 auto; }
.empty { color: var(--muted); font-size: 14px; padding: 14px 2px; }

/* Нижний лист (добавить ограничение / изменить) */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: flex-end;
  z-index: 50; backdrop-filter: blur(4px); }
.sheet { background: var(--card); width: 100%; max-width: 560px; margin: 0 auto;
  border-radius: 22px 22px 0 0; padding: 18px 16px calc(var(--sab) + 20px);
  animation: up .25s ease; }
@keyframes up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet h3 { font-size: 18px; margin-bottom: 14px; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } .bar > span { transition: none; } }
