:root {
  --bg: #0b1020;
  --bg2: #10172b;
  --card: rgba(255, 255, 255, .045);
  --card-b: rgba(255, 255, 255, .07);
  --txt: #e8ecf6;
  --mut: #8b94ab;
  --dim: #5d6680;
  --amber: #fbbf24;
  --amber2: #f59e0b;
  --green: #34d399;
  --green2: #10b981;
  --red: #f87171;
  --blue: #60a5fa;
  --r: 22px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #1b2550 0%, transparent 60%),
              radial-gradient(900px 500px at -10% 10%, #1a1f3a 0%, transparent 55%), var(--bg);
  background-attachment: fixed;
  color: var(--txt);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.boot { display: grid; place-items: center; height: 100vh; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.12);
  border-top-color: var(--amber); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- вход ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 32px 22px calc(32px + var(--safe-b)); max-width: 420px; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: 14px; margin-bottom: 30px; }
.logo .mark { width: 54px; height: 54px; border-radius: 16px; background: linear-gradient(160deg, #1e2a4a, #0f1528);
  display: grid; place-items: center; box-shadow: 0 10px 30px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.06); }
.logo .mark svg { width: 30px; height: 30px; color: var(--amber); }
.logo h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.logo p { margin: 2px 0 0; color: var(--mut); font-size: 14px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--mut); margin: 0 0 6px 4px; }
.field input, .field select { width: 100%; height: 52px; border-radius: 16px; padding: 0 16px; background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08); outline: none; transition: border-color .15s, background .15s; font-size: 16px; }
.field input:focus { border-color: rgba(251,191,36,.6); background: rgba(255,255,255,.08); }
.btn { height: 52px; border-radius: 16px; padding: 0 20px; font-weight: 600; font-size: 16px; width: 100%;
  background: linear-gradient(180deg, var(--amber), var(--amber2)); color: #1a1205; box-shadow: 0 8px 24px rgba(245,158,11,.25);
  transition: transform .08s, opacity .15s; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .5; }
.btn.ghost { background: rgba(255,255,255,.06); color: var(--txt); box-shadow: none; border: 1px solid rgba(255,255,255,.08); }
.btn.danger { background: rgba(248,113,113,.12); color: var(--red); box-shadow: none; border: 1px solid rgba(248,113,113,.25); }
.btn.sm { height: 40px; font-size: 14px; border-radius: 12px; width: auto; }
.err { color: var(--red); font-size: 14px; min-height: 20px; margin: 4px 4px 12px; }
.hint { color: var(--mut); font-size: 13px; margin: 14px 4px 0; }

/* ---------- каркас ---------- */
.top { position: sticky; top: 0; z-index: 5; padding: calc(12px + var(--safe-t)) 18px 10px;
  background: linear-gradient(180deg, rgba(11,16,32,.96) 60%, rgba(11,16,32,0)); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.top-row { display: flex; align-items: center; justify-content: space-between; max-width: 760px; margin: 0 auto; }
.top h2 { margin: 0; font-size: 28px; letter-spacing: -.02em; }
.top .who { color: var(--mut); font-size: 13px; margin-top: 2px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; font-size: 12px; color: var(--mut); background: rgba(255,255,255,.05); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.pill.off .dot { background: var(--red); box-shadow: 0 0 8px var(--red); }
main { padding: 4px 16px calc(100px + var(--safe-b)); max-width: 760px; margin: 0 auto; }

.seg { display: flex; gap: 6px; padding: 4px; border-radius: 16px; background: rgba(255,255,255,.05); margin: 6px 0 14px; }
.seg button { flex: 1; height: 38px; border-radius: 12px; font-weight: 600; font-size: 14px; color: var(--mut); transition: background .15s, color .15s; }
.seg button.on { background: rgba(255,255,255,.10); color: var(--txt); }

/* ---------- группы и плитки ---------- */
.group { margin: 0 0 18px; padding: 14px; border-radius: var(--r); background: var(--card); border: 1px solid var(--card-b); }
.g-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 2px 12px; }
.g-title { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.g-sub { color: var(--mut); font-size: 12.5px; margin-top: 1px; }
.g-acts { display: flex; gap: 6px; flex-shrink: 0; }
.g-acts button { height: 32px; padding: 0 12px; border-radius: 10px; font-size: 13px; font-weight: 600; background: rgba(255,255,255,.06); color: var(--txt); transition: background .15s; }
.g-acts button.arm { background: rgba(251,191,36,.18); color: var(--amber); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tile { position: relative; text-align: left; min-height: 104px; padding: 14px; border-radius: 18px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06); display: flex; flex-direction: column; justify-content: space-between;
  transition: background .2s, border-color .2s, transform .08s, box-shadow .2s; overflow: hidden; }
.tile:active { transform: scale(.97); }
.tile .ic { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; background: rgba(255,255,255,.06); color: var(--mut); transition: all .2s; }
.tile .ic svg { width: 22px; height: 22px; }
.tile .nm { font-weight: 600; font-size: 15px; margin-top: 12px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile .st { font-size: 12.5px; color: var(--dim); margin-top: 3px; }
.tile.on.light { background: linear-gradient(155deg, rgba(251,191,36,.22), rgba(245,158,11,.07)); border-color: rgba(251,191,36,.35); box-shadow: 0 10px 30px rgba(245,158,11,.12); }
.tile.on.light .ic { background: var(--amber); color: #2a1c03; box-shadow: 0 0 22px rgba(251,191,36,.55); }
.tile.on.light .st { color: var(--amber); }
.tile.on.power { background: linear-gradient(155deg, rgba(52,211,153,.20), rgba(16,185,129,.06)); border-color: rgba(52,211,153,.35); box-shadow: 0 10px 30px rgba(16,185,129,.12); }
.tile.on.power .ic { background: var(--green); color: #032116; box-shadow: 0 0 22px rgba(52,211,153,.5); }
.tile.on.power .st { color: var(--green); }
.tile.na { opacity: .45; }
.tile.busy::after { content: ""; position: absolute; top: 14px; right: 14px; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.2); border-top-color: var(--txt); animation: spin .7s linear infinite; }
.tile.big { min-height: 128px; }
.tile.big .nm { font-size: 16px; }

/* ---------- нижняя навигация ---------- */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 8px 12px calc(8px + var(--safe-b));
  background: rgba(13,18,36,.88); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid rgba(255,255,255,.06); }
.nav-in { display: flex; max-width: 520px; margin: 0 auto; }
.nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; font-size: 11px; color: var(--dim); }
.nav button svg { width: 24px; height: 24px; }
.nav button.on { color: var(--amber); }

/* ---------- списки ---------- */
.list { border-radius: var(--r); background: var(--card); border: 1px solid var(--card-b); overflow: hidden; margin-bottom: 16px; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-bottom: 1px solid rgba(255,255,255,.05); width: 100%; text-align: left; }
.row:last-child { border-bottom: 0; }
.row .av { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; font-weight: 700; background: rgba(96,165,250,.14); color: var(--blue); }
.row .av svg { width: 20px; height: 20px; }
.row .av.ok { background: rgba(52,211,153,.13); color: var(--green); }
.row .av.bad { background: rgba(248,113,113,.13); color: var(--red); }
.row .av.act { background: rgba(251,191,36,.14); color: var(--amber); }
.row .mid { flex: 1; min-width: 0; }
.row .t1 { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t2 { color: var(--mut); font-size: 12.5px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; }
.row .rt { color: var(--dim); font-size: 12.5px; flex-shrink: 0; text-align: right; }
.day { color: var(--mut); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin: 18px 6px 8px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; height: 34px; padding: 0 14px; border-radius: 999px; background: rgba(255,255,255,.06); color: var(--mut); font-size: 13.5px; font-weight: 600; }
.chip.on { background: var(--txt); color: var(--bg); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 6px; background: rgba(255,255,255,.07); color: var(--mut); margin-left: 6px; vertical-align: 1px; }
.tag.admin { background: rgba(251,191,36,.15); color: var(--amber); }
.tag.off { background: rgba(248,113,113,.14); color: var(--red); }
.empty { text-align: center; color: var(--mut); padding: 40px 10px; }
.sec-t { font-size: 13px; color: var(--mut); margin: 6px 6px 8px; }

/* ---------- лист снизу ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.5); opacity: 0; transition: opacity .2s; }
.sheet-bg.show { opacity: 1; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 92vh; overflow-y: auto; background: #121a31;
  border-radius: 26px 26px 0 0; padding: 10px 18px calc(22px + var(--safe-b)); transform: translateY(100%); transition: transform .25s cubic-bezier(.2,.8,.2,1);
  max-width: 620px; margin: 0 auto; border: 1px solid rgba(255,255,255,.06); }
.sheet.show { transform: none; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.18); margin: 0 auto 14px; }
.sheet h3 { margin: 0 0 16px; font-size: 20px; }
.checks { display: grid; gap: 8px; margin-bottom: 14px; }
.check { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,.05); }
.check input { width: 22px; height: 22px; accent-color: var(--amber); }
.btns { display: grid; gap: 10px; margin-top: 8px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.toast { position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translateX(-50%) translateY(20px); z-index: 30;
  background: #1f2a47; color: var(--txt); padding: 11px 18px; border-radius: 14px; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4);
  opacity: 0; pointer-events: none; transition: all .2s; max-width: calc(100% - 40px); }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.bad { background: #4a1f28; }
