:root {
  color-scheme: dark;
  --bg: #0b0f2a; --line: #ffffff1c; --text: #eef1ff; --mute: #9aa3cf;
  --accent: #6f8cff; --accent2: #38e1c6; --bad: #ff5c6c; --good: #3fdc8a; --warn: #ffc53d;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0; min-height: 100dvh; color: var(--text);
  background:
    radial-gradient(900px 500px at 85% -10%, #3a46b555, transparent 70%),
    radial-gradient(800px 500px at -10% 110%, #0f8d8233, transparent 70%), var(--bg);
  background-attachment: fixed;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1, h2, p { margin: 0; }
svg { display: block; width: 100%; height: 100%; }
small { color: var(--mute); font-weight: 400; }

.primary { padding: 9px 16px; border-radius: 12px; font-weight: 600; color: #071033; background: linear-gradient(135deg, #8ea6ff, var(--accent2)); box-shadow: 0 6px 18px #5f7fff44; }
.ghost { padding: 9px 14px; border-radius: 12px; border: 1px solid var(--line); background: #ffffff0c; }
.ghost:hover { background: #ffffff18; }
.danger { padding: 9px 14px; border-radius: 12px; color: var(--bad); border: 1px solid #ff5c6c66; }
:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
.err { min-height: 1.2em; color: var(--bad); font-size: 14px; }
.note { font-size: 13px; color: var(--mute); }

/* Giris */
#auth { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.auth-box { width: min(100%, 420px); display: grid; gap: 14px; padding: 24px; border-radius: 22px; border: 1px solid var(--line); background: #151b45cc; backdrop-filter: blur(14px); box-shadow: 0 30px 60px #0007; }
.auth-art { width: 84px; height: 84px; margin: auto; }
.auth-box h1 { text-align: center; font-size: 26px; }
.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #ffffff0d; padding: 4px; border-radius: 12px; }
.tabs button { padding: 7px 4px; border-radius: 9px; font-size: 14px; color: var(--mute); }
.tabs .on { background: #ffffff1f; color: var(--text); }
form { display: grid; gap: 11px; }
label { display: grid; gap: 4px; font-size: 14px; font-weight: 500; }
input { padding: 10px 12px; border-radius: 11px; border: 1px solid var(--line); background: #0a0e2bb0; width: 100%; min-width: 0; }
input:focus { border-color: var(--accent); outline: none; }

/* Ust cubuk */
.top { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 10px clamp(12px, 3vw, 32px); background: #0b0f2ad9; backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.brand div { display: grid; min-width: 0; }
.brand strong { font-size: 18px; }
.brand small { font-size: 12px; }
.logo { width: 38px; height: 38px; flex: none; }
.conn { font-size: 12px; color: var(--mute); }
.conn.off { color: var(--bad); font-weight: 600; }

/* Izin istekleri */
#requests { display: grid; gap: 8px; padding: 0 clamp(12px, 3vw, 32px); }
#requests:not(:empty) { padding-top: 14px; }
.req { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 12px 16px; border-radius: 16px; background: linear-gradient(120deg, #4b3a0d, #2b2a54); border: 1px solid #ffc53d88; animation: glow 1.6s ease-in-out infinite; }
.req .pic { width: 44px; height: 44px; flex: none; }
.req strong { flex: 1 1 180px; }
.req .yes { padding: 9px 24px; border-radius: 12px; font-weight: 700; color: #04210f; background: var(--good); }
.req .no { padding: 9px 24px; border-radius: 12px; font-weight: 700; color: #2c0309; background: var(--bad); }
@keyframes glow { 50% { box-shadow: 0 0 22px #ffc53d66; } }

/* Cocuk listesi: genis monitorde cok sutun, telefonda tek sutun */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 370px), 1fr)); gap: clamp(12px, 1.6vw, 22px); padding: clamp(12px, 2.4vw, 30px); max-width: 2400px; margin: auto; }
.kid { display: grid; gap: 12px; padding: 16px; border-radius: 22px; border: 1px solid var(--line); background: linear-gradient(160deg, #1d2559e6, #11163ae6); box-shadow: 0 18px 40px #0006, inset 0 1px 0 #ffffff24; transition: transform .25s, box-shadow .25s; }
@media (hover: hover) { .kid:hover { transform: perspective(900px) rotateX(1.4deg) translateY(-3px); box-shadow: 0 28px 50px #0008, inset 0 1px 0 #ffffff33; } }
.kid-head { display: flex; align-items: center; gap: 13px; }
.ring { position: relative; width: 92px; height: 92px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .track { fill: none; stroke: #ffffff14; stroke-width: 9; }
.ring .val { fill: none; stroke-width: 9; stroke-linecap: round; stroke: url(#ring-grad); transition: stroke-dashoffset .6s; }
.ring.low .val { stroke: var(--bad); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 16px; font-variant-numeric: tabular-nums; }
.kid-name { flex: 1; min-width: 0; }
.kid-name h3 { margin: 0; font-size: 21px; overflow-wrap: anywhere; }
.chip { display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; padding: 2px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; background: #ffffff14; }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip.running, .chip.always { color: var(--good); } .chip.grant { color: var(--accent2); }
.chip.break, .chip.stopped { color: var(--warn); } .chip.locked, .chip.timeup, .chip.expired { color: var(--bad); }
.yesterday { font-size: 13px; color: var(--mute); padding: 7px 10px; border-radius: 10px; background: #ffffff0a; }
.yesterday b { color: var(--accent2); }

.devices { display: grid; gap: 5px; font-size: 13px; }
.device { display: flex; align-items: center; gap: 8px; min-width: 0; }
.device .pic { width: 24px; height: 24px; flex: none; }
.device .state { width: 8px; height: 8px; flex: none; border-radius: 50%; background: #5a628a; }
.device.on .state { background: var(--good); box-shadow: 0 0 7px var(--good); }
.device span.what { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.warnline { color: var(--warn); font-size: 12px; }
.waiting { font-size: 14px; display: grid; gap: 2px; padding: 8px 10px; border-radius: 10px; background: #6f8cff1c; }
.waiting b { font-size: 26px; letter-spacing: .14em; color: var(--accent2); font-variant-numeric: tabular-nums; }

.breaks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.breaks button { display: grid; justify-items: center; gap: 2px; padding: 7px 2px 5px; border-radius: 14px; font-size: 12px; background: #ffffff0b; border: 1px solid transparent; transition: transform .12s, background .12s; }
.breaks button:hover { background: #ffffff1a; transform: translateY(-2px); }
.breaks button.on { background: #ffc53d26; border-color: var(--warn); }
.breaks .pic { width: min(52px, 100%); aspect-ratio: 1; }
.actions { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 7px; }
.actions button { position: relative; padding: 9px 3px; border-radius: 12px; font-size: 13px; font-weight: 600; background: #ffffff10; }
.actions button:hover { background: #ffffff20; }
.actions button.on { color: #300208; background: var(--bad); }
.actions button.wide { grid-column: 1 / -1; }
.actions button.keep-on { color: #04210f; background: var(--good); }
.badge { position: absolute; top: -5px; right: -3px; min-width: 19px; padding: 1px 5px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 11px; }
#children { padding-bottom: 64px; }
.stop-open { position: fixed; right: 12px; bottom: 12px; z-index: 4; padding: 9px 14px; border-radius: 12px; font-size: 13px; font-weight: 600; border: 1px solid #ff5c6c88; color: #ffd5d9; background: #2a1030e6; }
#stop-list { display: grid; gap: 7px; }
#stop-list .line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.empty { text-align: center; padding: 60px 16px; color: var(--mute); }

/* Pencereler */
dialog { width: min(calc(100vw - 24px), 470px); max-height: calc(100dvh - 24px); overflow: auto; padding: 20px; border-radius: 20px; border: 1px solid var(--line); color: var(--text); background: #171d4b; box-shadow: 0 40px 80px #000a; }
dialog::backdrop { background: #04061acc; backdrop-filter: blur(4px); }
dialog h2 { font-size: 20px; }
.row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.spacer { flex: 1; }
.code-show { display: grid; justify-items: center; gap: 6px; padding: 12px; border-radius: 14px; background: #0a0e2bb0; }
.code-show output { font-size: 34px; font-weight: 700; letter-spacing: .16em; color: var(--accent2); font-variant-numeric: tabular-nums; }
#set-devices { display: grid; gap: 6px; font-size: 14px; }
#set-devices .line { display: flex; align-items: center; gap: 8px; }
#set-devices .line span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
#chat-dlg[open] { display: flex; flex-direction: column; gap: 10px; height: min(640px, calc(100dvh - 24px)); }
.chat-head { display: flex; justify-content: space-between; align-items: center; }
.msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; padding: 6px; }
.msg { max-width: 82%; align-self: flex-start; padding: 7px 12px; border-radius: 15px; overflow-wrap: anywhere; background: #ffffff14; }
.msg.me { align-self: flex-end; background: #6f8cff55; }
.msg b { display: block; font-size: 12px; color: var(--accent2); }
.msg.big { font-size: 32px; line-height: 1.2; }
#p-chat-form { flex-wrap: nowrap; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); padding: 10px 18px; border-radius: 12px; background: #000d; z-index: 10; max-width: calc(100vw - 24px); }
