:root {
    color-scheme: light;
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-soft: #f0f3f8;
    --text: #151922;
    --muted: #6f7683;
    --line: #e6e9ef;
    --primary: #366af3;
    --violet: #8758e7;
    --success: #30b475;
    --shadow: 0 12px 36px rgba(24, 38, 66, .09);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); }
button, a { font: inherit; }
button { color: inherit; }

.app-shell {
    width: min(100%, 720px);
    min-height: 100dvh;
    margin: 0 auto;
    background: var(--bg);
    position: relative;
    padding-bottom: calc(82px + env(safe-area-inset-bottom));
}

.app-header {
    height: calc(68px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 20px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, .9);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(18px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand { display: flex; gap: 11px; align-items: center; color: inherit; text-decoration: none; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 1px; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center;
    background: linear-gradient(145deg, #5485ff, #7451dc); color: white; font-weight: 800;
    box-shadow: 0 7px 18px rgba(72, 99, 225, .28);
}
.brand-mark--large { width: 72px; height: 72px; border-radius: 24px; font-size: 28px; }
.connection-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px rgba(48, 180, 117, .12); }

.app-content { padding: 20px; }
.page { animation: enter .22s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(4px); } }
.eyebrow { color: var(--primary); text-transform: uppercase; letter-spacing: .1em; font-size: 11px; font-weight: 800; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(27px, 8vw, 38px); line-height: 1.08; letter-spacing: -.035em; margin-bottom: 12px; }
h2 { font-size: 18px; }
p { color: var(--muted); line-height: 1.55; }

.hero-card {
    padding: 28px 24px; border-radius: 26px; color: white;
    background: radial-gradient(circle at 90% 10%, rgba(255,255,255,.22), transparent 32%), linear-gradient(145deg, #326bf4, #724fd8);
    box-shadow: 0 18px 42px rgba(66, 86, 203, .22);
}
.hero-card .eyebrow, .hero-card p { color: rgba(255,255,255,.78); }
.hero-card h1 { margin-top: 12px; }
.hero-card p { margin-bottom: 0; }
.section-heading { margin: 28px 2px 12px; }
.section-heading h2 { margin-bottom: 0; }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.action-card {
    appearance: none; border: 1px solid var(--line); border-radius: 20px; padding: 17px;
    background: var(--surface); text-align: left; box-shadow: 0 5px 18px rgba(26, 34, 53, .04);
    cursor: pointer; transition: transform .15s ease, box-shadow .15s ease;
}
.action-card:active { transform: scale(.98); }
.action-card strong, .action-card small { display: block; }
.action-card strong { margin-top: 13px; }
.action-card small { color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.35; }
.action-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; font-size: 20px; }
.action-icon--blue { background: #e9f0ff; color: var(--primary); }
.action-icon--violet { background: #f1ebff; color: var(--violet); }

.result-card { margin-top: 12px; padding: 17px; border-radius: 17px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.result-card .result-label { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.result-card strong { color: var(--text); display: block; margin-top: 4px; font-size: 19px; }

.auth-card { text-align: center; padding: 54px 24px; background: var(--surface); border-radius: 26px; box-shadow: var(--shadow); }
.auth-illustration { display: flex; justify-content: center; margin-bottom: 28px; }
.auth-card h1 { font-size: 25px; }
.auth-card p { max-width: 360px; margin: 0 auto 22px; }
.spinner { width: 23px; height: 23px; border: 3px solid #dce4fa; border-top-color: var(--primary); border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; margin-bottom: 18px; }
@keyframes spin { to { transform: rotate(360deg); } }
.is-hidden { display: none !important; }
.primary-button { border: 0; border-radius: 14px; padding: 13px 22px; background: var(--primary); color: white; font-weight: 700; cursor: pointer; }

.page-title { padding: 18px 4px 8px; }
.page-title .eyebrow { display: block; margin-bottom: 10px; }
.feature-list { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; overflow: hidden; }
.feature-row { display: flex; gap: 15px; padding: 18px; border-bottom: 1px solid var(--line); }
.feature-row:last-child { border-bottom: 0; }
.feature-row strong { display: block; margin: 2px 0 5px; }
.feature-row p { font-size: 13px; margin: 0; }
.feature-icon { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: #ecf1ff; color: var(--primary); font-weight: 800; }

.bottom-nav {
    position: fixed; z-index: 20; bottom: 0; left: 50%; transform: translateX(-50%);
    width: min(100%, 720px); height: calc(68px + env(safe-area-inset-bottom));
    padding: 7px 14px env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5, 1fr);
    background: rgba(255, 255, 255, .94); backdrop-filter: blur(18px); border-top: 1px solid var(--line);
}
.nav-item { display: flex; flex-direction: column; gap: 2px; align-items: center; justify-content: center; text-decoration: none; color: #89909c; font-size: 11px; font-weight: 650; }
.nav-icon { font-size: 20px; line-height: 1; }
.nav-item.is-active { color: var(--primary); }
.toast { position: fixed; left: 50%; bottom: 95px; transform: translateX(-50%); }

/* ── Экраны пульта: сводка, списки, кнопки действий ───────────────────────────── */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0 4px 12px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
        font-size: 12px; font-weight: 700; background: var(--surface-soft); color: var(--muted); }
.pill--ok { background: #e6f7ee; color: #1c7f52; }
.pill--off { background: #fdeaea; color: #a33; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 8px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 21px; font-weight: 800; margin-top: 4px; }
.stat-note { font-size: 12px; color: var(--muted); margin-top: 3px; }
.bar { height: 6px; border-radius: 999px; background: var(--surface-soft); overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; background: var(--primary); }
.bar--hot > span { background: #e2603f; }
.rows { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row--card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; margin-bottom: 8px; }
.row--card:last-child { border-bottom: 1px solid var(--line); }
.row-main { flex: 1 1 200px; min-width: 0; }
.row-title { font-weight: 700; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.row-sub { font-size: 12px; color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }
.row-sub--error { color: #c0392b; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; flex: 0 0 auto; }
.button { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 12px;
          padding: 8px 13px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
          text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.button:hover { border-color: var(--primary); color: var(--primary); }
.button small { color: var(--muted); font-weight: 600; }
.button--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.button--primary:hover { color: #fff; }
.button--active { border-color: var(--primary); color: var(--primary); }
.button--danger:hover { border-color: #d14343; color: #d14343; }
.button--ghost { border-style: dashed; }
.link-button { border: 0; background: none; color: var(--primary); font: inherit; font-weight: 700;
               padding: 0; cursor: pointer; text-align: left; }
.empty { padding: 18px; color: var(--muted); font-size: 13px; text-align: center; }
.muted { color: var(--muted); font-size: 13px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 4px; }
.crumb { border: 0; background: none; color: var(--primary); font: inherit; font-size: 13px;
         font-weight: 700; padding: 0; cursor: pointer; }
.crumb-sep { color: var(--muted); font-size: 13px; }
.upload-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--surface);
              border: 1px solid var(--line); border-radius: 16px; padding: 12px; margin-bottom: 10px; }
.upload-row input[type="file"] { flex: 1 1 180px; font-size: 13px; }
.report-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.report-text { margin: 10px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px;
               line-height: 1.5; max-height: 60vh; overflow: auto; }
.section-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
                   gap: 8px; padding: 18px 4px 8px; }

@media (prefers-color-scheme: dark) {
    :root { color-scheme: dark; --bg: #111319; --surface: #1b1e26; --surface-soft: #232733; --text: #f3f5f9; --muted: #9ca3af; --line: #2c303a; --shadow: none; }
    .app-header, .bottom-nav { background: rgba(27, 30, 38, .9); }
    .action-icon--blue { background: #24345c; }
    .action-icon--violet { background: #372b57; }
    .pill--ok { background: #1d3b2c; color: #63d69b; }
    .pill--off { background: #3a2326; color: #f0a1a1; }
    .row-sub--error { color: #f0a1a1; }
}

@media (min-width: 721px) {
    body { padding: 24px 0; }
    .app-shell { min-height: calc(100dvh - 48px); border-radius: 28px; overflow: hidden; box-shadow: var(--shadow); }
    .bottom-nav { bottom: 24px; border-radius: 0 0 28px 28px; }
}
