:root {
    --cream: #f4efe6;
    --paper: #fffdf8;
    --ink: #1c2b2a;
    --muted: #5e6f6c;
    --teal: #0e7c74;
    --teal-dark: #0a5c56;
    --amber: #e39b12;
    --coral: #e15a45;
    --line: #eadfce;
    --ok: #1f8a4c;
    --shadow: 0 18px 50px rgba(28, 43, 42, 0.08);
    --radius: 22px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: "Segoe UI", "Avenir Next", "Trebuchet MS", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(900px 420px at 10% -10%, rgba(227, 155, 18, 0.18), transparent 60%),
        radial-gradient(800px 480px at 100% 0%, rgba(14, 124, 116, 0.14), transparent 55%),
        var(--cream);
    line-height: 1.5;
}
img { max-width: 100%; height: auto; }
a { color: var(--teal-dark); }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(1.8rem, 3vw, 3rem); line-height: 1.15; letter-spacing: -0.03em; }
h2 { font-size: 1.25rem; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
[hidden] { display: none !important; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    text-decoration: none;
    cursor: pointer;
    background: var(--paper);
    color: var(--ink);
    box-shadow: inset 0 0 0 1px var(--line);
}
.btn-teal { background: var(--teal); color: white; box-shadow: none; }
.btn-coral { background: var(--coral); color: white; box-shadow: none; }
.btn-amber { background: var(--amber); color: #2a2110; box-shadow: none; }
.btn-ghost { background: transparent; }

.topbar, .side {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.topbar { padding: 18px 7vw; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 750; }
.brand img { width: 42px; height: 42px; border-radius: 14px; }
.top-actions { display: flex; gap: 12px; align-items: center; }
.wrap { width: min(1080px, calc(100% - 32px)); margin: 0 auto 48px; }
.hero { padding: 12px 0 28px; }
.hero-logo { width: min(420px, 100%); background: transparent; }
.eyebrow { color: var(--teal); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; font-size: 0.82rem; }
.lead, .muted, .hint { color: var(--muted); }
.hero-actions, .row-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 22px 0; }
.card, .auth-card, .note {
    background: var(--paper);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}
.auth-card { width: min(460px, 100%); margin: 12px auto 40px; display: grid; gap: 8px; }
.auth-card img { border-radius: 22px; }
.note { margin-top: 8px; }
.form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-weight: 650; }
label.check { display: flex; align-items: flex-start; font-weight: 500; }
label.check input { width: auto; margin-top: 4px; }
input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: white;
}
.flash { padding: 12px 14px; border-radius: 14px; margin-bottom: 14px; }
.flash-ok { background: #e5f6ec; color: #145c32; }
.flash-error { background: #fde8e4; color: #8d2e22; }
.flash-inset { margin: 12px; }
.code-big {
    font-size: 2rem;
    letter-spacing: 0.12em;
    font-weight: 800;
    color: var(--teal-dark);
}
.prose { width: min(760px, 100%); }
.prose li { margin: 6px 0; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
.side {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 18px 14px;
    background: rgba(255, 253, 248, 0.9);
    border-right: 1px solid var(--line);
    height: 100vh;
    position: sticky;
    top: 0;
    overflow: auto;
}
body.map-page .shell { height: 100vh; overflow: hidden; }
.nav { display: grid; gap: 6px; margin-top: 22px; }
.nav a {
    text-decoration: none;
    color: var(--ink);
    padding: 10px 12px;
    border-radius: 12px;
}
.nav a.active, .nav a:hover { background: rgba(14, 124, 116, 0.12); }
.side-user { margin-top: auto; display: grid; gap: 4px; padding-top: 18px; }
.side-user span, .hint { font-size: 0.92rem; }
.stage { min-width: 0; }
.page-head, .split, .card, .table-wrap { margin: 18px; }
.page-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-end; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 0; }
.child-list, .device-list, .app-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.child-list a { display: block; background: var(--paper); padding: 14px 16px; border-radius: 16px; text-decoration: none; font-weight: 700; }
.device-list li, .app-list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    border-top: 1px solid var(--line);
}
.app-list li.is-blocked { background: #fff4f1; border-radius: 12px; padding: 10px; }
.pill { border-radius: 999px; padding: 2px 8px; font-size: 0.8rem; }
.pill.on { background: #e5f6ec; color: var(--ok); }
.pill.off { background: #f3eee6; color: var(--muted); }
.table-wrap { overflow: auto; background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.danger-zone { box-shadow: inset 0 0 0 1px #f0c7bf; }
.test-card { box-shadow: inset 0 0 0 1px #f3ddaa; }
.qr-box { min-height: 220px; }
.qr-box img, .qr-box canvas { border-radius: 12px; }

body.map-page { overflow: hidden; background: var(--cream); }
body.map-page .stage { position: relative; height: 100vh; }
#map { position: absolute; inset: 0; background: #d7e3df; }
.map-ui { position: absolute; left: 0; right: 0; bottom: 0; z-index: 500; padding: 12px; display: grid; gap: 8px; pointer-events: none; }
.map-ui > * { pointer-events: auto; }
.sheet {
    background: rgba(255, 253, 248, 0.96);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 12px;
    max-height: 42vh;
    overflow: auto;
}
.chips { display: flex; gap: 8px; overflow: auto; padding-bottom: 8px; }
.chip {
    border: 0;
    background: white;
    border-radius: 999px;
    padding: 8px 12px;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px var(--line);
    white-space: nowrap;
}
.chip.selected { background: var(--teal); color: white; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #b7c4c1; margin-left: 6px; }
.dot.on { background: #2ea86a; }
.sos { background: var(--coral); color: white; border-radius: 16px; padding: 12px; display: grid; gap: 6px; }
.sos a { color: white; }
.kid-marker { border-radius: 14px; box-shadow: 0 8px 18px rgba(28, 43, 42, 0.28); background: white; }
.map-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.map-actions a, .map-actions button { text-decoration: none; }

@media (max-width: 900px) {
    .cards, .split { grid-template-columns: 1fr; }
    .shell { grid-template-columns: 1fr; height: 100vh; overflow: hidden; }
    .side { height: auto; position: sticky; top: 0; z-index: 30; flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); }
    .nav { display: flex; margin-top: 0; overflow: auto; }
    .side-user { display: flex; align-items: center; gap: 8px; margin-top: 0; margin-left: auto; padding-top: 0; }
    .side-user strong, .side-user span { display: none; }
    .page-head, .split, .card, .table-wrap { margin: 12px; }
    body.map-page .stage { height: calc(100vh - 74px); }
    .brand span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; }
}
