/* XFOG Telegram Dashboard — styles ("Liquid Glass")
   Tokens on :root. Light is the default; dark is opt-in via the topbar toggle
   ([data-theme="dark"] on <html>), remembered per browser in localStorage.
   Glass = translucent fill + backdrop blur + a bright rim on the top edge, over a
   soft colored backdrop (body::before) so there is something to refract.
   prefers-reduced-transparency and browsers without backdrop-filter get solid panels. */

:root {
    color-scheme: light;
    --font: system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;

    --bg: #eef2f8;
    --blob-1: rgba(42, 120, 214, .30);
    --blob-2: rgba(98, 80, 214, .22);
    --blob-3: rgba(20, 184, 166, .20);

    /* glass material */
    --glass: rgba(255, 255, 255, .58);
    --glass-strong: rgba(255, 255, 255, .80);
    --glass-solid: #ffffff;
    --glass-sheen: linear-gradient(180deg, rgba(255, 255, 255, .45), rgba(255, 255, 255, 0) 42%);
    --glass-edge: rgba(255, 255, 255, .75);
    --glass-rim: inset 0 1px 0 rgba(255, 255, 255, .95), inset 0 -1px 1px rgba(255, 255, 255, .35);
    --blur: blur(24px) saturate(180%);

    --surface: rgba(255, 255, 255, .66);
    --surface-2: rgba(255, 255, 255, .42);
    --border: rgba(15, 22, 35, .09);
    --text: #0f1623;
    --text-2: #444e60;
    --text-3: #6e788b;
    --accent: #2a78d6;
    --accent-soft: rgba(42, 120, 214, .14);
    --accent-text: #ffffff;
    --fill: rgba(120, 120, 128, .2);

    /* chart: categorical slots 1-2 + recessive grid */
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --grid: rgba(15, 22, 35, .08);

    /* status palette (reserved, always shown with an icon/label) */
    --good: #0ca30c;
    --warning: #fab219;
    --serious: #ec835a;
    --critical: #d03b3b;
    --good-soft: rgba(12, 163, 12, .13);
    --warning-soft: rgba(250, 178, 25, .2);
    --serious-soft: rgba(236, 131, 90, .18);
    --critical-soft: rgba(208, 59, 59, .13);
    --good-ink: #0a6e0a;
    --warning-ink: #7a4f00;
    --serious-ink: #9a4019;
    --critical-ink: #a42727;
    --neutral-soft: rgba(15, 22, 35, .06);

    --radius: 22px;
    --radius-sm: 12px;
    --shadow: 0 1px 2px rgba(15, 22, 35, .04), 0 10px 32px rgba(15, 22, 35, .08);
    --shadow-hover: 0 2px 4px rgba(15, 22, 35, .05), 0 18px 48px rgba(15, 22, 35, .14);
    --t: .25s cubic-bezier(.3, .7, .2, 1);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #06080d;
    --blob-1: rgba(57, 135, 229, .32);
    --blob-2: rgba(124, 92, 255, .24);
    --blob-3: rgba(13, 148, 136, .18);
    --glass: rgba(24, 29, 40, .52);
    --glass-strong: rgba(24, 29, 40, .80);
    --glass-solid: #161b24;
    --glass-sheen: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, 0) 42%);
    --glass-edge: rgba(255, 255, 255, .12);
    --glass-rim: inset 0 1px 0 rgba(255, 255, 255, .14), inset 0 -1px 1px rgba(255, 255, 255, .04);
    --surface: rgba(255, 255, 255, .07);
    --surface-2: rgba(255, 255, 255, .045);
    --border: rgba(255, 255, 255, .09);
    --text: #eef1f6;
    --text-2: #b9c1cf;
    --text-3: #8790a2;
    --accent: #3987e5;
    --accent-soft: rgba(57, 135, 229, .2);
    --fill: rgba(120, 120, 128, .36);
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: rgba(255, 255, 255, .07);
    --good-soft: rgba(12, 163, 12, .18);
    --warning-soft: rgba(250, 178, 25, .16);
    --serious-soft: rgba(236, 131, 90, .17);
    --critical-soft: rgba(208, 59, 59, .2);
    --good-ink: #5fd35f;
    --warning-ink: #fac552;
    --serious-ink: #f2a483;
    --critical-ink: #f08080;
    --neutral-soft: rgba(255, 255, 255, .07);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 32px rgba(0, 0, 0, .3);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, .35), 0 18px 48px rgba(0, 0, 0, .5);
}

/* ── Base ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    font: 14px/1.5 var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}
/* ambient color field behind the glass */
body::before {
    content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background:
        radial-gradient(42% 52% at 8% 6%, var(--blob-1), transparent 70%),
        radial-gradient(38% 48% at 92% 14%, var(--blob-2), transparent 70%),
        radial-gradient(48% 56% at 72% 100%, var(--blob-3), transparent 72%),
        radial-gradient(30% 40% at 20% 90%, var(--blob-2), transparent 70%);
}
a { color: var(--accent); text-decoration: none; }
code, .mono { font-family: var(--mono); font-size: .92em; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
.muted { color: var(--text-3); }
.icon { width: 18px; height: 18px; flex-shrink: 0; }
[hidden] { display: none !important; }

/* ── Glass material ─────────────────────────────────────────────────────── */
.sidebar, .topbar, .card, .login-card, .chart-tip, .toast, .seg, .modal-backdrop {
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
}
.sidebar, .topbar, .card, .login-card {
    background: var(--glass-sheen), var(--glass);
    border: 1px solid var(--glass-edge);
    box-shadow: var(--glass-rim), var(--shadow);
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; flex-shrink: 0; color: var(--text-2);
    display: flex; flex-direction: column; position: sticky; top: 12px;
    height: calc(100vh - 24px); margin: 12px 0 12px 12px; border-radius: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 22px; color: var(--text); font-size: 16px; }
.brand__logo {
    width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; color: #fff;
    background: linear-gradient(180deg, rgba(255, 255, 255, .35), rgba(255, 255, 255, 0) 55%), linear-gradient(135deg, #2a78d6, #6250d6);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 4px 12px rgba(42, 120, 214, .35);
}
.brand__logo .icon { width: 17px; height: 17px; }
.brand__img { display: none; } /* xfog-design only */
.nav { display: flex; flex-direction: column; gap: 3px; padding: 0 10px; flex: 1; overflow-y: auto; }
.nav__item {
    display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 99px;
    color: var(--text-2); font-weight: 500; border: 1px solid transparent;
    transition: background var(--t), color var(--t), box-shadow var(--t);
}
.nav__item:hover { background: var(--neutral-soft); color: var(--text); }
.nav__item.is-active {
    background: linear-gradient(180deg, rgba(255, 255, 255, .28), rgba(255, 255, 255, 0) 60%), var(--accent);
    color: #fff; border-color: rgba(255, 255, 255, .25);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 4px 14px color-mix(in srgb, var(--accent) 40%, transparent);
}
.nav__badge {
    margin-left: auto; background: var(--critical); color: #fff; border-radius: 99px;
    font-size: 11px; font-weight: 700; padding: 1px 7px;
}
.sidebar__foot { padding: 16px 22px 20px; border-top: 1px solid var(--border); display: grid; gap: 6px; font-size: 12.5px; }
.sidebar__version { color: var(--text-3); font-size: 11px; margin-top: 6px; }
.conn { display: flex; align-items: center; gap: 8px; }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.conn.is-ok .dot { background: var(--good); box-shadow: 0 0 0 3px rgba(12, 163, 12, .18), 0 0 8px rgba(12, 163, 12, .5); }
.conn.is-bad .dot { background: var(--critical); box-shadow: 0 0 0 3px rgba(208, 59, 59, .2), 0 0 8px rgba(208, 59, 59, .5); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 12px; z-index: 5; height: 56px; display: flex; align-items: center; gap: 12px;
    margin: 12px 16px 0; padding: 0 10px 0 22px; border-radius: 99px;
    background: var(--glass-sheen), var(--glass-strong);
}
.topbar__title { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.topbar__user { color: var(--text-2); font-weight: 500; padding: 0 6px; }
.topbar .topbar__menu { display: none; } /* beats .icon-btn's display: grid */
.content { padding: 24px 28px 48px; max-width: 1440px; width: 100%; }
.scrim { display: none; }

/* ── Buttons & form controls ────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 16px;
    border-radius: 99px; border: 1px solid var(--glass-edge); color: var(--text);
    background: var(--glass-sheen), var(--surface); box-shadow: var(--glass-rim), 0 1px 3px rgba(15, 22, 35, .06);
    font: 500 13.5px var(--font); cursor: pointer; white-space: nowrap;
    transition: background var(--t), border-color var(--t), box-shadow var(--t), transform var(--t);
}
.btn:hover { background: var(--glass-sheen), var(--glass-strong); box-shadow: var(--glass-rim), 0 4px 14px rgba(15, 22, 35, .1); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn--primary {
    background: linear-gradient(180deg, rgba(255, 255, 255, .28), rgba(255, 255, 255, 0) 60%), var(--accent);
    border-color: rgba(255, 255, 255, .25); color: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn--primary:hover {
    background: linear-gradient(180deg, rgba(255, 255, 255, .34), rgba(255, 255, 255, 0) 60%), var(--accent);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 6px 20px color-mix(in srgb, var(--accent) 45%, transparent);
}
.btn--danger { color: var(--critical-ink); }
.btn--danger:hover { background: var(--critical-soft); border-color: color-mix(in srgb, var(--critical) 45%, transparent); }
.btn--ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn--ghost:hover { background: var(--neutral-soft); border-color: transparent; box-shadow: none; }
.btn--sm { height: 30px; padding: 0 12px; font-size: 12.5px; }
.btn--block { width: 100%; height: 42px; font-size: 14.5px; }
.icon-btn {
    width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%;
    border: 0; background: transparent; color: var(--text-2); cursor: pointer;
    transition: background var(--t), color var(--t), transform var(--t);
}
.icon-btn:hover { background: var(--neutral-soft); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
/* language picker (topbar and login card) */
.lang-select {
    width: auto; min-height: 32px; height: 32px; padding: 0 28px 0 12px; border-radius: 99px;
    font-size: 12.5px; font-weight: 600; color: var(--text-2); cursor: pointer;
    background: var(--neutral-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d8799' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 12px;
    border-color: transparent; box-shadow: none; -webkit-appearance: none; appearance: none;
}
.lang-select:hover { color: var(--text); }
.brand--login .lang-select { margin-left: auto; }
.theme-sun, [data-theme="dark"] .theme-moon { display: none; }
[data-theme="dark"] .theme-sun { display: block; }

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field small { font-weight: 400; color: var(--text-3); }
input, select, textarea {
    font: 14px var(--font); color: var(--text); background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 8px 12px; min-height: 36px; width: 100%;
    box-shadow: inset 0 1px 2px rgba(15, 22, 35, .05);
    transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
input[type="search"] { border-radius: 99px; padding-left: 16px; }
select option { background: var(--glass-solid); color: var(--text); }
textarea { resize: vertical; min-height: 72px; }
input:focus, select:focus, textarea:focus { background: var(--glass-strong); }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .icon-btn:focus-visible {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 160px; }

/* iOS-style switch with a glass knob */
.switch { position: relative; display: inline-flex; width: 44px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span {
    position: absolute; inset: 0; background: var(--fill); border-radius: 99px; cursor: pointer;
    transition: background var(--t); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .08);
}
.switch span::after {
    content: ""; position: absolute; width: 22px; height: 22px; left: 2px; top: 2px; border-radius: 99px;
    background: linear-gradient(180deg, #fff, #f2f4f8);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .2), 0 0 0 .5px rgba(0, 0, 0, .06), inset 0 1px 0 #fff;
    transition: transform var(--t), width var(--t);
}
.switch span:active::after { width: 27px; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:checked + span:active::after { transform: translateX(13px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 4px var(--accent-soft); }

/* ── Cards / sections ───────────────────────────────────────────────────── */
.card { border-radius: var(--radius); }
.card__head { display: flex; align-items: center; gap: 10px; padding: 18px 22px 0; }
.card__head h2 { font-size: 15px; font-weight: 650; }
.card__head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card__body { padding: 16px 22px 22px; }
.section-gap { display: grid; gap: 20px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; color: var(--text-3); }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ── KPI tiles ──────────────────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { padding: 18px 20px; }
.kpi__label { color: var(--text-3); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi__value { font-size: 30px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi__value small { font-size: 15px; color: var(--text-3); font-weight: 600; letter-spacing: 0; }
.kpi__sub { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }

/* ── Pills / badges ─────────────────────────────────────────────────────── */
.pill {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px;
    font-size: 12px; font-weight: 600; background: var(--neutral-soft); color: var(--text-2); white-space: nowrap;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 14%, transparent);
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .9; }
.pill--plain::before { display: none; }
.pill--good { background: var(--good-soft); color: var(--good-ink); }
.pill--warning { background: var(--warning-soft); color: var(--warning-ink); }
.pill--serious { background: var(--serious-soft); color: var(--serious-ink); }
.pill--critical { background: var(--critical-soft); color: var(--critical-ink); }
.pill--info { background: var(--accent-soft); color: var(--accent); }
.tag {
    display: inline-flex; align-items: center; padding: 1px 9px; border-radius: 99px; font-size: 11.5px;
    font-weight: 600; background: var(--neutral-soft); color: var(--text-2);
}

/* ── Device cards ───────────────────────────────────────────────────────── */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type="search"] { max-width: 280px; }
.seg {
    display: inline-flex; background: var(--neutral-soft); border-radius: 99px; padding: 3px; gap: 2px;
    box-shadow: inset 0 1px 2px rgba(15, 22, 35, .06);
}
.seg button {
    border: 0; background: transparent; color: var(--text-2); font: 600 12.5px var(--font); padding: 6px 14px;
    border-radius: 99px; cursor: pointer; transition: background var(--t), color var(--t), box-shadow var(--t);
}
.seg button:hover { color: var(--text); }
.seg button.is-active {
    background: var(--glass-sheen), var(--glass-strong); color: var(--text);
    box-shadow: var(--glass-rim), 0 2px 8px rgba(15, 22, 35, .12);
}
.devices { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.device-card {
    padding: 20px 20px 18px 22px; cursor: pointer; display: grid; gap: 14px; position: relative; overflow: hidden; color: inherit;
    transition: box-shadow var(--t), transform var(--t), background var(--t);
}
.device-card:hover {
    background: var(--glass-sheen), var(--glass-strong);
    box-shadow: var(--glass-rim), var(--shadow-hover); transform: translateY(-3px);
}
.device-card:active { transform: translateY(-1px) scale(.99); }
.device-card::before {
    content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 4px;
    border-radius: 0 4px 4px 0; background: var(--fill);
}
.device-card.is-good::before { background: var(--good); box-shadow: 0 0 12px var(--good); }
.device-card.is-alarm::before { background: var(--serious); box-shadow: 0 0 12px var(--serious); }
.device-card.is-critical::before { background: var(--critical); box-shadow: 0 0 12px var(--critical); }
.device-card__head { display: flex; gap: 10px; align-items: flex-start; }
.device-card__name { font-weight: 650; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-card__id { color: var(--text-3); font-family: var(--mono); font-size: 11.5px; }
.device-card__head .pill { margin-left: auto; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.metric__label { color: var(--text-3); font-size: 11.5px; font-weight: 600; }
.metric__value { font-weight: 650; font-size: 15px; font-variant-numeric: tabular-nums; }
.metric__value small { color: var(--text-3); font-weight: 500; font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.device-card__foot { display: flex; justify-content: space-between; color: var(--text-3); font-size: 12px; gap: 8px; }
.temp-bar { height: 5px; border-radius: 99px; background: var(--neutral-soft); margin-top: 6px; position: relative; overflow: hidden; }
.temp-bar > span { position: absolute; inset: 0 auto 0 0; border-radius: 99px; }

/* ── Device detail ──────────────────────────────────────────────────────── */
.device-hero { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.device-hero h1 { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.device-hero .meta { color: var(--text-3); display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; margin-top: 4px; }
.device-hero .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.back {
    display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 500; margin-bottom: 12px;
    padding: 4px 12px 4px 8px; border-radius: 99px; transition: background var(--t), color var(--t);
}
.back:hover { color: var(--text); background: var(--neutral-soft); }
.banner {
    display: flex; gap: 12px; align-items: flex-start; padding: 14px 18px; border-radius: var(--radius);
    margin-bottom: 20px; border: 1px solid transparent;
    -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.banner--critical { background: var(--critical-soft); color: var(--critical-ink); border-color: color-mix(in srgb, var(--critical) 35%, transparent); }
.banner--good { background: var(--good-soft); color: var(--good-ink); border-color: color-mix(in srgb, var(--good) 25%, transparent); }
.banner strong { display: block; }
.banner ul { margin: 4px 0 0; padding-left: 18px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-weight: 550; text-align: right; font-variant-numeric: tabular-nums; }
.io { display: grid; gap: 14px; }
.io__row { display: flex; align-items: center; gap: 12px; }
.io__label { width: 64px; color: var(--text-3); font-size: 12.5px; font-weight: 600; }
.io__bits { display: flex; gap: 6px; flex-wrap: wrap; }
.bit {
    width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; font-size: 11px; font-weight: 700;
    background: var(--neutral-soft); color: var(--text-3); font-family: var(--mono);
    box-shadow: inset 0 1px 2px rgba(15, 22, 35, .06);
}
.bit.is-on {
    background: linear-gradient(180deg, rgba(255, 255, 255, .3), rgba(255, 255, 255, 0) 60%), var(--accent); color: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 2px 8px color-mix(in srgb, var(--accent) 40%, transparent);
}

/* ── Chart ──────────────────────────────────────────────────────────────── */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .crosshair { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 16px; height: 0; border-top: 2px solid; display: inline-block; }
.chart-legend i.dashed { border-top-style: dashed; }
.chart-tip {
    position: absolute; pointer-events: none; background: var(--glass-sheen), var(--glass-strong);
    border: 1px solid var(--glass-edge); box-shadow: var(--glass-rim), var(--shadow-hover);
    border-radius: 14px; padding: 9px 12px; font-size: 12px;
    min-width: 140px; transform: translate(-50%, -100%); white-space: nowrap; z-index: 2;
}
.chart-tip b { display: block; margin-bottom: 3px; color: var(--text-2); font-weight: 600; }
.chart-tip div { display: flex; justify-content: space-between; gap: 14px; }
.chart-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.chart-empty { padding: 40px 0; text-align: center; color: var(--text-3); }

/* ── Tables / lists ─────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
    text-align: left; color: var(--text-3); font-weight: 600; font-size: 11.5px; text-transform: uppercase;
    letter-spacing: .05em; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr td { transition: background var(--t); }
tbody tr:hover td { background: var(--neutral-soft); }
tbody tr:hover td:first-child { border-radius: 10px 0 0 10px; }
tbody tr:hover td:last-child { border-radius: 0 10px 10px 0; }
.cell-actions { text-align: right; white-space: nowrap; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.timeline li { display: grid; grid-template-columns: 74px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--text-3); font-variant-numeric: tabular-nums; font-size: 12px; padding-top: 1px; }

.cat-toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-toggle {
    border: 1px solid var(--border); background: var(--surface); color: var(--text-3); border-radius: 99px;
    padding: 4px 12px; font: 600 12px var(--font); cursor: pointer; transition: all var(--t);
}
.cat-toggle:hover { color: var(--text-2); }
.cat-toggle.is-on {
    background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
}

.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty h3 { color: var(--text); font-size: 16px; margin-bottom: 6px; }
.alert { padding: 11px 15px; border-radius: 14px; font-size: 13px; margin-bottom: 14px; border: 1px solid transparent; }
.alert--critical { background: var(--critical-soft); color: var(--critical-ink); border-color: color-mix(in srgb, var(--critical) 25%, transparent); }
.alert--warning { background: var(--warning-soft); color: var(--warning-ink); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.alert--info { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.alert code { word-break: break-all; }

/* ── Messages page ──────────────────────────────────────────────────────── */
.msg-table { table-layout: fixed; min-width: 760px; }
.msg-table th:nth-child(2), .msg-table th:nth-child(3) { width: 104px; }
.msg-table th:nth-child(4) { width: 220px; }
.msg-table th:nth-child(5) { width: 130px; }
.msg-table th.c, .msg-table td.c { text-align: center; }
.msg-table tr.is-off td:first-child strong { color: var(--text-3); }
.cond { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--text-2); font-weight: 600; }
.cond input { width: 92px; min-height: 32px; padding: 5px 10px; }
.tg-bubble {
    background: var(--surface); border: 1px solid var(--glass-edge); border-radius: 18px 18px 18px 6px;
    box-shadow: var(--glass-rim);
    padding: 12px 14px; white-space: pre-wrap; font-size: 13.5px; line-height: 1.45; max-height: 60vh; overflow: auto;
}
.tg-bubble code { background: var(--neutral-soft); padding: 0 4px; border-radius: 4px; }

/* ── Chat log ───────────────────────────────────────────────────────────── */
.chatlog { display: flex; flex-direction: column; gap: 10px; }
.chatlog__day { align-self: center; font-size: 12px; font-weight: 600; color: var(--text-3); background: var(--neutral-soft); padding: 2px 12px; border-radius: 99px; margin: 6px 0; }
.chatlog__msg {
    max-width: min(680px, 88%); border: 1px solid var(--glass-edge); border-radius: 18px; padding: 9px 13px;
    background: var(--surface); box-shadow: var(--glass-rim);
}
.chatlog__msg--in { align-self: flex-start; border-bottom-left-radius: 6px; }
.chatlog__msg--out {
    align-self: flex-end; border-bottom-right-radius: 6px; background: var(--accent-soft);
    border-color: color-mix(in srgb, var(--accent) 25%, transparent);
}
.chatlog__msg.is-error { border-color: var(--critical); background: var(--critical-soft); }
.chatlog__head { display: flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 600; color: var(--text-3); margin-bottom: 4px; flex-wrap: wrap; }
.chatlog__head time { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 500; }
.chatlog__text { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; max-height: 320px; overflow: auto; }
.chatlog__error { margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--critical-ink); }

/* ── Toasts & modal ─────────────────────────────────────────────────────── */
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 50; }
.toast {
    background: color-mix(in srgb, var(--text) 82%, transparent); color: var(--bg); padding: 12px 18px; border-radius: 99px;
    border: 1px solid rgba(255, 255, 255, .14); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), var(--shadow-hover);
    font-weight: 500; max-width: 380px; animation: toast-in .35s cubic-bezier(.3, 1.4, .5, 1);
}
.toast--error { background: color-mix(in srgb, var(--critical) 90%, transparent); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.94); } }
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(8, 12, 20, .28); display: grid; place-items: center; z-index: 40; padding: 16px;
    -webkit-backdrop-filter: blur(6px) saturate(140%); backdrop-filter: blur(6px) saturate(140%);
    animation: fade-in .2s ease-out;
}
.modal {
    width: min(460px, 100%); padding: 24px; display: grid; gap: 16px; border-radius: 28px;
    background: var(--glass-sheen), var(--glass-strong);
    animation: modal-in .35s cubic-bezier(.3, 1.3, .5, 1);
}
.modal h2 { font-size: 18px; }
.modal .row { justify-content: flex-end; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: scale(.92) translateY(8px); } }

.skeleton {
    background: linear-gradient(90deg, var(--neutral-soft), var(--surface), var(--neutral-soft)); background-size: 200% 100%;
    animation: shimmer 1.2s infinite; border-radius: var(--radius); height: 160px; border: 1px solid var(--glass-edge);
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Login ──────────────────────────────────────────────────────────────── */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: min(390px, 100%); border-radius: 32px; padding: 34px 30px; box-shadow: var(--glass-rim), var(--shadow-hover); }
.login-card h1 { font-size: 26px; margin-top: 24px; letter-spacing: -.02em; }
.login-card p { margin: 4px 0 22px; }
.brand--login { padding: 0; color: var(--text); }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 44px; }
.password-toggle {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 34px; height: 30px;
    display: grid; place-items: center; border: 0; border-radius: 99px; background: transparent;
    color: var(--text-3); cursor: pointer;
}
.password-toggle:hover { color: var(--text); background: var(--neutral-soft); }
.password-toggle:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); color: var(--text); }
.password-toggle svg { width: 18px; height: 18px; }
.password-toggle .eye-closed, .password-toggle[aria-pressed="true"] .eye-open { display: none; }
.password-toggle[aria-pressed="true"] .eye-closed { display: block; }

/* ── Accessibility / fallbacks: solid panels instead of glass ───────────── */
@media (prefers-reduced-transparency: reduce) {
    .sidebar, .topbar, .card, .login-card, .chart-tip, .modal, .seg button.is-active, .device-card:hover {
        background: var(--glass-solid);
        -webkit-backdrop-filter: none; backdrop-filter: none;
    }
    .modal-backdrop { background: rgba(8, 12, 20, .55); -webkit-backdrop-filter: none; backdrop-filter: none; }
    .toast { background: var(--text); }
    .toast--error { background: var(--critical); }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .sidebar, .topbar, .card, .login-card, .chart-tip, .modal { background: var(--glass-solid); }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
    .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .sidebar {
        position: fixed; left: 0; top: 0; z-index: 30; height: calc(100vh - 24px);
        background: var(--glass-sheen), var(--glass-strong);
        transform: translateX(calc(-100% - 16px)); transition: transform var(--t);
    }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .scrim {
        display: block; position: fixed; inset: 0; background: rgba(8, 12, 20, .3); z-index: 20;
        -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    }
    .topbar { margin: 10px 10px 0; top: 10px; padding: 0 8px 0 6px; }
    .topbar .topbar__menu { display: grid; }
    .topbar__user { display: none; }
    .content { padding: 18px 16px 40px; }
    .devices { grid-template-columns: 1fr; }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .kpi { padding: 14px 16px; }
    .kpi__value { font-size: 23px; }
    .toolbar input[type="search"] { max-width: none; flex: 1; }
    .toasts { left: 16px; right: 16px; bottom: 16px; justify-items: center; }
}

/* ══ Material Design 3 style ═══════════════════════════════════════════════
   Opt-in per browser: <html data-style="material"> (localStorage xfog-style).
   Re-maps the glass tokens to flat M3 tonal surfaces (blue seed #2a78d6), then
   restyles the components whose M3 shape differs: navigation drawer, top app
   bar, outlined text fields, segmented buttons, switch, snackbar, dialog.
   Status colors (--good/--warning/--serious/--critical) are shared with glass. */
:root[data-style="material"] {
    --font: Roboto, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    --md-primary: #0061a4;
    --md-on-primary: #ffffff;
    --md-primary-container: #d1e4ff;
    --md-on-primary-container: #001d36;
    --md-secondary-container: #d7e3f7;
    --md-on-secondary-container: #101c2b;
    --md-surface: #f8f9ff;
    --md-surface-low: #f2f3fa;
    --md-surface-container: #eceef4;
    --md-surface-high: #e6e8ee;
    --md-surface-highest: #e0e2e8;
    --md-outline: #73777f;
    --md-outline-variant: #c3c7cf;
    --md-inverse-surface: #2e3135;
    --md-inverse-on-surface: #eff0f7;
    --md-state: rgba(25, 28, 32, .08);
    --md-elev-1: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 3px 1px rgba(0, 0, 0, .15);
    --md-elev-2: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 6px 2px rgba(0, 0, 0, .15);
    --md-elev-3: 0 4px 8px 3px rgba(0, 0, 0, .15), 0 1px 3px rgba(0, 0, 0, .3);

    --bg: var(--md-surface);
    --glass: var(--md-surface-low);
    --glass-strong: var(--md-surface-high);
    --glass-solid: var(--md-surface-low);
    --glass-sheen: linear-gradient(transparent, transparent);
    --glass-edge: transparent;
    --glass-rim: 0 0 #0000;
    --blur: none;
    --surface: var(--md-surface);
    --surface-2: var(--md-surface-container);
    --border: var(--md-outline-variant);
    --text: #191c20;
    --text-2: #43474e;
    --text-3: #5d6168;
    --accent: var(--md-primary);
    --accent-soft: var(--md-primary-container);
    --fill: var(--md-surface-highest);
    --series-1: #2a78d6;
    --grid: var(--md-outline-variant);
    --neutral-soft: var(--md-surface-high);
    --radius: 12px;
    --radius-sm: 4px;
    --shadow: var(--md-elev-1);
    --shadow-hover: var(--md-elev-2);
    --t: .2s cubic-bezier(.2, 0, 0, 1);
}
:root[data-style="material"][data-theme="dark"] {
    --md-primary: #9ecaff;
    --md-on-primary: #003258;
    --md-primary-container: #00497d;
    --md-on-primary-container: #d1e4ff;
    --md-secondary-container: #3b4858;
    --md-on-secondary-container: #d7e3f7;
    --md-surface: #111418;
    --md-surface-low: #191c20;
    --md-surface-container: #1d2024;
    --md-surface-high: #272a2f;
    --md-surface-highest: #32353a;
    --md-outline: #8d9199;
    --md-outline-variant: #43474e;
    --md-inverse-surface: #e1e2e8;
    --md-inverse-on-surface: #2e3135;
    --md-state: rgba(225, 226, 232, .08);
    --text: #e1e2e8;
    --text-2: #c3c7cf;
    --text-3: #a3a7af;
    --series-1: #3987e5;
}
[data-style="material"] body::before { display: none; }
[data-style="material"] h1, [data-style="material"] h2, [data-style="material"] h3 { letter-spacing: 0; font-weight: 500; }
[data-style="material"] .page-head h1, [data-style="material"] .device-hero h1 { font-size: 28px; font-weight: 400; }
[data-style="material"] .card__head h2 { font-size: 16px; }
[data-style="material"] .pill--info, [data-style="material"] .cat-toggle.is-on,
[data-style="material"] .alert--info, [data-style="material"] .chatlog__msg--out { color: var(--md-on-primary-container); }

/* navigation drawer + top app bar: flush, no floating panels */
[data-style="material"] .sidebar {
    margin: 0; top: 0; height: 100vh; border-radius: 0 16px 16px 0; border: 0; box-shadow: none;
    background: var(--md-surface-low); width: 256px;
}
[data-style="material"] .brand { padding: 20px 28px 16px; }
[data-style="material"] .brand__logo { border-radius: 12px; background: var(--md-primary); color: var(--md-on-primary); box-shadow: none; }
[data-style="material"] .nav { padding: 0 12px; gap: 0; }
[data-style="material"] .nav__item { height: 56px; padding: 0 16px; border: 0; color: var(--text-2); font-weight: 500; letter-spacing: .01em; }
[data-style="material"] .nav__item:hover { background: var(--md-state); color: var(--text); }
[data-style="material"] .nav__item.is-active {
    background: var(--md-secondary-container); color: var(--md-on-secondary-container); box-shadow: none; font-weight: 700;
}
[data-style="material"] .sidebar__foot { border-top: 1px solid var(--md-outline-variant); padding: 16px 28px 20px; }
[data-style="material"] .topbar {
    margin: 0; top: 0; height: 64px; border-radius: 0; border: 0; box-shadow: none; padding: 0 16px 0 24px;
    background: var(--md-surface);
}
[data-style="material"] .topbar__title { font-size: 22px; font-weight: 400; }

/* cards: filled, low elevation */
[data-style="material"] .card { box-shadow: none; border: 0; }
[data-style="material"] .kpi { background: var(--md-surface-container); }
[data-style="material"] .device-card:hover { background: var(--md-surface-container); box-shadow: var(--md-elev-1); transform: none; }
[data-style="material"] .device-card:active { transform: none; background: var(--md-surface-high); }
[data-style="material"] .device-card::before { top: 0; bottom: 0; border-radius: 0; box-shadow: none; }

/* buttons: filled / outlined / text, 40 px, full radius */
[data-style="material"] .btn {
    height: 40px; padding: 0 24px; font-weight: 500; font-size: 14px; letter-spacing: .01em;
    background: transparent; border: 1px solid var(--md-outline); color: var(--md-primary); box-shadow: none;
}
[data-style="material"] .btn:hover { background: var(--md-state); box-shadow: none; }
[data-style="material"] .btn:active { transform: none; }
[data-style="material"] .btn--primary { background: var(--md-primary); border-color: var(--md-primary); color: var(--md-on-primary); }
[data-style="material"] .btn--primary:hover { background: var(--md-primary); box-shadow: var(--md-elev-1); filter: brightness(1.06); }
[data-style="material"] .btn--danger { color: var(--critical-ink); }
[data-style="material"] .btn--ghost { border-color: transparent; padding: 0 12px; }
[data-style="material"] .btn--sm { height: 32px; padding: 0 16px; font-size: 13px; }
[data-style="material"] .btn--block { height: 40px; }
[data-style="material"] .icon-btn { width: 40px; height: 40px; }
[data-style="material"] .icon-btn:hover { background: var(--md-state); }

/* outlined text fields */
[data-style="material"] input, [data-style="material"] select, [data-style="material"] textarea {
    background: transparent; border: 1px solid var(--md-outline); border-radius: 4px; box-shadow: none;
    min-height: 40px; padding: 8px 14px;
}
[data-style="material"] input:hover, [data-style="material"] select:hover, [data-style="material"] textarea:hover { border-color: var(--text); }
[data-style="material"] input:focus, [data-style="material"] select:focus, [data-style="material"] textarea:focus {
    background: transparent; border-color: var(--md-primary); box-shadow: inset 0 0 0 1px var(--md-primary);
}
[data-style="material"] input[type="search"] { border-radius: 28px; background: var(--md-surface-high); border-color: transparent; padding-left: 20px; }
[data-style="material"] input:disabled { border-color: var(--md-outline-variant); color: var(--text-3); }
[data-style="material"] .btn:focus-visible, [data-style="material"] .icon-btn:focus-visible {
    outline: 3px solid var(--md-primary); outline-offset: 2px; box-shadow: none;
}
[data-style="material"] .lang-select {
    border-radius: 8px; min-height: 32px; height: 32px; padding: 0 28px 0 12px; border: 1px solid var(--md-outline);
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d8799' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 12px;
}

/* segmented buttons */
[data-style="material"] .seg { background: transparent; padding: 0; gap: 0; border-radius: 20px; box-shadow: none; border: 1px solid var(--md-outline); overflow: hidden; }
[data-style="material"] .seg button { border-radius: 0; padding: 0 14px; height: 38px; border-left: 1px solid var(--md-outline); color: var(--text); font-weight: 500; }
[data-style="material"] .seg button:first-child { border-left: 0; }
[data-style="material"] .seg button:hover { background: var(--md-state); }
[data-style="material"] .seg button.is-active { background: var(--md-secondary-container); color: var(--md-on-secondary-container); box-shadow: none; }
[data-style="material"] .seg button.is-active::before { content: "✓ "; }

/* chips, tags, pills */
[data-style="material"] .pill { border-radius: 8px; box-shadow: none; padding: 3px 10px; }
[data-style="material"] .tag { border-radius: 8px; }
[data-style="material"] .cat-toggle { border-radius: 8px; height: 32px; padding: 0 12px; background: transparent; border-color: var(--md-outline); color: var(--text-2); }
[data-style="material"] .cat-toggle.is-on { background: var(--md-secondary-container); border-color: transparent; color: var(--md-on-secondary-container); box-shadow: none; }
[data-style="material"] .bit { border-radius: 8px; box-shadow: none; }
[data-style="material"] .bit.is-on { background: var(--md-primary); color: var(--md-on-primary); box-shadow: none; }
[data-style="material"] .back { padding: 6px 12px 6px 8px; }

/* M3 switch: 52x32 track, 16 -> 24 px thumb */
[data-style="material"] .switch { width: 52px; height: 32px; }
[data-style="material"] .switch span { background: var(--md-surface-highest); box-shadow: inset 0 0 0 2px var(--md-outline); }
[data-style="material"] .switch span::after {
    width: 16px; height: 16px; left: 8px; top: 8px; background: var(--md-outline); box-shadow: none;
    transition: transform var(--t), width var(--t), height var(--t), left var(--t), top var(--t);
}
[data-style="material"] .switch span:active::after { width: 28px; height: 28px; left: 2px; top: 2px; }
[data-style="material"] .switch input:checked + span { background: var(--md-primary); box-shadow: none; }
[data-style="material"] .switch input:checked + span::after { width: 24px; height: 24px; left: 4px; top: 4px; transform: translateX(20px); background: var(--md-on-primary); }
[data-style="material"] .switch input:checked + span:active::after { width: 28px; height: 28px; left: 2px; top: 2px; transform: translateX(20px); }
[data-style="material"] .switch input:focus-visible + span { outline: 3px solid var(--md-primary); outline-offset: 2px; }
[data-style="material"] .switch input:disabled + span { opacity: .38; }

/* tables, lists */
[data-style="material"] th { text-transform: none; letter-spacing: .01em; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
[data-style="material"] tbody tr:hover td { background: var(--md-state); border-radius: 0 !important; }

/* chat bubbles, alerts, banners */
[data-style="material"] .chatlog__msg, [data-style="material"] .tg-bubble { border-color: transparent; box-shadow: none; background: var(--md-surface-high); }
[data-style="material"] .chatlog__msg--out { background: var(--md-primary-container); }
[data-style="material"] .chatlog__msg.is-error { background: var(--critical-soft); border-color: var(--critical); }
[data-style="material"] .alert, [data-style="material"] .banner { border-radius: 12px; border-color: transparent; }
[data-style="material"] .banner { -webkit-backdrop-filter: none; backdrop-filter: none; }

/* snackbar, dialog, tooltip */
[data-style="material"] .toasts { left: 24px; right: auto; bottom: 24px; }
[data-style="material"] .toast {
    background: var(--md-inverse-surface); color: var(--md-inverse-on-surface); border: 0; border-radius: 4px;
    box-shadow: var(--md-elev-3); padding: 14px 16px; min-width: 288px; animation: toast-in .2s ease-out;
    -webkit-backdrop-filter: none; backdrop-filter: none;
}
[data-style="material"] .toast--error { background: var(--critical); color: #fff; }
[data-style="material"] .modal-backdrop { background: rgba(0, 0, 0, .32); -webkit-backdrop-filter: none; backdrop-filter: none; }
[data-style="material"] .modal { border-radius: 28px; background: var(--md-surface-high); box-shadow: var(--md-elev-3); padding: 24px; animation: fade-in .2s ease-out; }
[data-style="material"] .modal h2 { font-size: 24px; font-weight: 400; }
[data-style="material"] .chart-tip { background: var(--md-inverse-surface); color: var(--md-inverse-on-surface); border: 0; border-radius: 4px; box-shadow: var(--md-elev-2); }
[data-style="material"] .chart-tip b { color: var(--md-inverse-on-surface); }
[data-style="material"] .skeleton { border: 0; background: linear-gradient(90deg, var(--md-surface-container), var(--md-surface-high), var(--md-surface-container)); background-size: 200% 100%; }

/* login */
[data-style="material"] .login-card { border-radius: 28px; background: var(--md-surface-low); box-shadow: var(--md-elev-1); }
[data-style="material"] .login-card h1 { font-size: 28px; font-weight: 400; }

@media (max-width: 860px) {
    [data-style="material"] .sidebar { height: 100vh; transform: translateX(calc(-100% - 16px)); box-shadow: var(--md-elev-3); }
    [data-style="material"] body.nav-open .sidebar { transform: none; }
    [data-style="material"] body.nav-open .scrim { background: rgba(0, 0, 0, .32); -webkit-backdrop-filter: none; backdrop-filter: none; }
    [data-style="material"] .topbar { margin: 0; top: 0; padding: 0 8px; }
    [data-style="material"] .toasts { left: 16px; right: 16px; bottom: 16px; }
    [data-style="material"] .toast { min-width: 0; }
}

/* ══ xfog-design style ═══════════════════════════════════════════════════
   Opt-in per browser: <html data-style="xfog-design"> (localStorage xfog-style).
   Mirrors xfog.support: white pages, Barlow, brand blue #0560df, hairline
   #e4e8ed borders, small 3-6 px radii, no shadows or blur, a flush white header
   bar (brand + topbar share its height) and a flat sidebar with soft-blue active
   links. The site has no dark theme; the dark tokens are the same system on ink.
   Status colors (--good/--warning/--serious/--critical) are shared with glass. */
:root[data-style="xfog-design"] {
    --font: Barlow, Arial, sans-serif;
    --xf-blue: #0560df;
    --xf-btn: #0560df;
    --xf-btn-hover: #004cab;
    --xf-blue-soft: #edf4ff;
    --xf-hover: #eef3fa;
    --xf-line: #e4e8ed;
    --xf-input: #cdd3dd;
    --xf-btn-line: #c3d4ec;
    --xf-btn-line-hover: #98b8e5;
    --xf-soft: #f6f8fb;
    --xf-head: #f4f7fb;
    --xf-ink: #20252e;
    --xf-focus: rgba(5, 96, 223, .14);
    --xf-header: 72px;

    --bg: #ffffff;
    --glass: #ffffff;
    --glass-strong: #ffffff;
    --glass-solid: #ffffff;
    --glass-sheen: linear-gradient(transparent, transparent);
    --glass-edge: var(--xf-line);
    --glass-rim: 0 0 #0000;
    --blur: none;
    --surface: #ffffff;
    --surface-2: var(--xf-soft);
    --border: var(--xf-line);
    --text: var(--xf-ink);
    --text-2: #505b6a;
    --text-3: #68717f;
    --accent: var(--xf-blue);
    --accent-soft: var(--xf-blue-soft);
    --fill: #d5dbe3;
    --grid: var(--xf-line);
    --neutral-soft: #f0f3f7;
    --radius: 6px;
    --radius-sm: 4px;
    --shadow: 0 0 #0000;
    --shadow-hover: 0 3px 13px rgba(8, 97, 201, .08);
    --t: .18s ease;
}
:root[data-style="xfog-design"][data-theme="dark"] {
    --xf-blue: #5c9dff;
    --xf-btn: #1f6fe5;
    --xf-btn-hover: #3580f0;
    --xf-blue-soft: rgba(92, 157, 255, .14);
    --xf-hover: rgba(255, 255, 255, .05);
    --xf-line: #262c36;
    --xf-input: #353c48;
    --xf-btn-line: #2f4566;
    --xf-btn-line-hover: #46679a;
    --xf-soft: #11151b;
    --xf-head: #161b22;
    --xf-ink: #e8ebf0;
    --xf-focus: rgba(92, 157, 255, .22);

    --bg: #0d1015;
    --glass: #14181e;
    --glass-strong: #1a1f27;
    --glass-solid: #14181e;
    --surface: #14181e;
    --text-2: #b6bfcc;
    --text-3: #8b95a3;
    --fill: #39404b;
    --neutral-soft: rgba(255, 255, 255, .06);
    --shadow-hover: 0 3px 13px rgba(0, 0, 0, .35);
}
[data-style="xfog-design"] body { font-size: 15px; line-height: 1.6; }
[data-style="xfog-design"] body::before { display: none; }
[data-style="xfog-design"] h1, [data-style="xfog-design"] h2, [data-style="xfog-design"] h3 { font-weight: 600; letter-spacing: -.01em; }
[data-style="xfog-design"] .page-head h1, [data-style="xfog-design"] .device-hero h1 { font-size: 32px; font-weight: 700; letter-spacing: -1px; }
[data-style="xfog-design"] .page-head p { font-size: 15px; }
[data-style="xfog-design"] .card__head h2 { font-size: 17px; font-weight: 600; }
[data-style="xfog-design"] .alert--info, [data-style="xfog-design"] .chatlog__msg--out { color: var(--xf-ink); }

/* header bar: brand (in the sidebar) and topbar line up at the same height */
[data-style="xfog-design"] .sidebar {
    margin: 0; top: 0; height: 100vh; width: 248px; border: 0; border-right: 1px solid var(--xf-line);
    border-radius: 0; box-shadow: none; background: var(--glass);
}
[data-style="xfog-design"] .brand {
    height: var(--xf-header); padding: 0 20px; margin-bottom: 14px; border-bottom: 1px solid var(--xf-line); gap: 12px;
    color: var(--text-3); font-size: 12px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase;
}
[data-style="xfog-design"] .brand__logo, [data-style="xfog-design"] .brand__name strong { display: none; }
[data-style="xfog-design"] .brand__img { display: block; width: 100px; height: auto; flex-shrink: 0; }
[data-style="xfog-design"] .brand__img--dark,
[data-style="xfog-design"][data-theme="dark"] .brand__img { display: none; }
[data-style="xfog-design"][data-theme="dark"] .brand__img--dark { display: block; }
[data-style="xfog-design"] .brand__name { padding-left: 12px; border-left: 1px solid var(--xf-line); line-height: 29px; white-space: nowrap; }
[data-style="xfog-design"] .nav { padding: 0 12px; gap: 1px; }
[data-style="xfog-design"] .nav__item {
    min-height: 40px; padding: 8px 12px; border: 0; border-radius: 4px; color: var(--text-2);
    font-size: 14px; font-weight: 500;
}
[data-style="xfog-design"] .nav__item .icon { color: var(--text-3); width: 17px; height: 17px; }
[data-style="xfog-design"] .nav__item:hover { background: var(--xf-hover); color: var(--xf-blue); }
[data-style="xfog-design"] .nav__item.is-active { background: var(--xf-blue-soft); color: var(--xf-blue); box-shadow: none; font-weight: 600; }
[data-style="xfog-design"] .nav__item:hover .icon, [data-style="xfog-design"] .nav__item.is-active .icon { color: var(--xf-blue); }
[data-style="xfog-design"] .nav__badge { border-radius: 3px; }
[data-style="xfog-design"] .sidebar__foot { margin: 0 12px; padding: 18px 10px 20px; border-top: 1px solid var(--xf-line); font-size: 12.5px; }
[data-style="xfog-design"] .conn .dot, [data-style="xfog-design"] .conn.is-ok .dot, [data-style="xfog-design"] .conn.is-bad .dot { box-shadow: none; }
[data-style="xfog-design"] .topbar {
    margin: 0; top: 0; height: var(--xf-header); border: 0; border-bottom: 1px solid var(--xf-line);
    border-radius: 0; box-shadow: none; padding: 0 24px 0 36px; background: var(--glass);
}
[data-style="xfog-design"] .topbar__title { font-size: 17px; font-weight: 600; }
[data-style="xfog-design"] .content { padding: 34px clamp(24px, 3vw, 52px) 56px; }

/* cards: white, hairline border, no elevation */
[data-style="xfog-design"] .card { border: 1px solid var(--xf-line); box-shadow: none; }
[data-style="xfog-design"] .kpi__label, [data-style="xfog-design"] .metric__label { font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; font-weight: 600; }
[data-style="xfog-design"] .device-card:hover { border-color: var(--xf-btn-line-hover); background: var(--glass); box-shadow: var(--shadow-hover); transform: none; }
[data-style="xfog-design"] .device-card:active { transform: none; }
[data-style="xfog-design"] .device-card::before { top: 0; bottom: 0; width: 3px; border-radius: 0; }
[data-style="xfog-design"] .device-card.is-good::before, [data-style="xfog-design"] .device-card.is-alarm::before,
[data-style="xfog-design"] .device-card.is-critical::before { box-shadow: none; }
[data-style="xfog-design"] .temp-bar, [data-style="xfog-design"] .temp-bar > span { border-radius: 2px; }

/* buttons: solid brand blue, outlined blue secondary */
[data-style="xfog-design"] .btn {
    height: 38px; padding: 0 17px; border-radius: 4px; font-weight: 500; font-size: 14px;
    background: var(--surface); border: 1px solid var(--xf-btn-line); color: var(--xf-blue); box-shadow: none;
}
[data-style="xfog-design"] .btn:hover { background: var(--xf-hover); border-color: var(--xf-btn-line-hover); box-shadow: none; }
[data-style="xfog-design"] .btn:active { transform: none; }
[data-style="xfog-design"] .btn--primary { background: var(--xf-btn); border-color: var(--xf-btn); color: #fff; }
[data-style="xfog-design"] .btn--primary:hover { background: var(--xf-btn-hover); border-color: var(--xf-btn-hover); box-shadow: none; }
[data-style="xfog-design"] .btn--danger { color: var(--critical-ink); border-color: color-mix(in srgb, var(--critical) 35%, transparent); }
[data-style="xfog-design"] .btn--danger:hover { background: var(--critical-soft); border-color: var(--critical); }
[data-style="xfog-design"] .btn--ghost { background: transparent; border-color: transparent; }
[data-style="xfog-design"] .btn--ghost:hover { background: var(--xf-hover); border-color: transparent; }
[data-style="xfog-design"] .btn--sm { height: 30px; padding: 0 11px; font-size: 13px; border-radius: 3px; }
[data-style="xfog-design"] .btn--block { height: 44px; font-size: 15px; }
[data-style="xfog-design"] .icon-btn { border-radius: 4px; }
[data-style="xfog-design"] .icon-btn:hover { background: var(--xf-hover); color: var(--xf-blue); }
[data-style="xfog-design"] .icon-btn:active { transform: none; }

/* inputs: hairline field, blue border + soft ring on focus */
[data-style="xfog-design"] input, [data-style="xfog-design"] select, [data-style="xfog-design"] textarea {
    background: var(--surface); border: 1px solid var(--xf-input); border-radius: 5px; box-shadow: none; min-height: 38px;
}
[data-style="xfog-design"] input[type="search"] { border-radius: 5px; padding-left: 12px; border-color: var(--xf-btn-line); }
[data-style="xfog-design"] input:focus, [data-style="xfog-design"] select:focus, [data-style="xfog-design"] textarea:focus {
    background: var(--surface); border-color: var(--xf-blue); box-shadow: 0 0 0 2px var(--xf-focus);
}
[data-style="xfog-design"] .btn:focus-visible, [data-style="xfog-design"] .icon-btn:focus-visible {
    border-color: var(--xf-blue); box-shadow: 0 0 0 2px var(--xf-focus);
}
[data-style="xfog-design"] .lang-select {
    border-radius: 4px; height: 32px; min-height: 32px; border: 1px solid var(--xf-line); font-weight: 500;
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d8799' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 12px;
}
[data-style="xfog-design"] .brand .lang-select { text-transform: none; letter-spacing: 0; }
[data-style="xfog-design"] .lang-select:hover { border-color: var(--xf-btn-line-hover); color: var(--xf-blue); }

/* segmented control: joined buttons, active = solid blue */
[data-style="xfog-design"] .seg { background: transparent; padding: 0; gap: 0; border: 1px solid var(--xf-line); border-radius: 4px; box-shadow: none; overflow: hidden; }
[data-style="xfog-design"] .seg button { border-radius: 0; padding: 0 14px; height: 34px; border-left: 1px solid var(--xf-line); font-weight: 500; font-size: 13px; }
[data-style="xfog-design"] .seg button:first-child { border-left: 0; }
[data-style="xfog-design"] .seg button:hover { color: var(--xf-blue); background: var(--xf-hover); }
[data-style="xfog-design"] .seg button.is-active { background: var(--xf-btn); color: #fff; box-shadow: none; }

/* chips, tags, pills: small squared labels like the site's quick links */
[data-style="xfog-design"] .pill { border-radius: 3px; box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 18%, transparent); font-weight: 600; }
[data-style="xfog-design"] .tag { border-radius: 3px; background: var(--xf-soft); box-shadow: inset 0 0 0 1px var(--xf-line); font-weight: 500; }
[data-style="xfog-design"] .cat-toggle { border-radius: 3px; background: var(--xf-soft); border-color: var(--xf-line); color: var(--text-2); font-weight: 500; }
[data-style="xfog-design"] .cat-toggle:hover { border-color: var(--xf-btn-line-hover); color: var(--xf-blue); }
[data-style="xfog-design"] .cat-toggle.is-on { background: var(--xf-blue-soft); border-color: var(--xf-btn-line-hover); color: var(--xf-blue); box-shadow: none; }
[data-style="xfog-design"] .bit { border-radius: 4px; box-shadow: inset 0 0 0 1px var(--xf-line); background: var(--xf-soft); }
[data-style="xfog-design"] .bit.is-on { background: var(--xf-btn); color: #fff; box-shadow: none; }
[data-style="xfog-design"] .back { border-radius: 4px; color: var(--xf-blue); }
[data-style="xfog-design"] .back:hover { background: var(--xf-hover); color: var(--xf-blue); }

/* flat switch */
[data-style="xfog-design"] .switch span { box-shadow: none; }
[data-style="xfog-design"] .switch span::after { background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
[data-style="xfog-design"] .switch input:checked + span { background: var(--xf-btn); }
[data-style="xfog-design"] .switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--xf-focus); }

/* tables: tinted header row, hairline rows */
[data-style="xfog-design"] th {
    background: var(--xf-head); color: var(--text); text-transform: none; letter-spacing: 0;
    font-size: 13px; font-weight: 600; padding: 11px 14px; border-bottom: 1px solid var(--xf-line);
}
[data-style="xfog-design"] td { padding: 11px 14px; }
[data-style="xfog-design"] tbody tr:hover td { background: var(--xf-hover); border-radius: 0 !important; }

/* chat bubbles, alerts, banners */
[data-style="xfog-design"] .chatlog__day { border-radius: 3px; background: var(--xf-soft); box-shadow: inset 0 0 0 1px var(--xf-line); }
[data-style="xfog-design"] .chatlog__msg, [data-style="xfog-design"] .tg-bubble { border-radius: 6px; border-color: var(--xf-line); background: var(--xf-soft); box-shadow: none; }
[data-style="xfog-design"] .chatlog__msg--out { background: var(--xf-blue-soft); border-color: var(--xf-btn-line); }
[data-style="xfog-design"] .chatlog__msg.is-error { background: var(--critical-soft); border-color: var(--critical); }
[data-style="xfog-design"] .alert, [data-style="xfog-design"] .banner { border-radius: 4px; }
[data-style="xfog-design"] .alert--info { background: var(--xf-soft); border-color: var(--xf-line); }
[data-style="xfog-design"] .banner { -webkit-backdrop-filter: none; backdrop-filter: none; }

/* toast, dialog, tooltip */
[data-style="xfog-design"] .toast {
    background: #20252e; color: #fff; border: 0; border-radius: 4px; box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
    animation: toast-in .2s ease-out; -webkit-backdrop-filter: none; backdrop-filter: none;
}
[data-style="xfog-design"][data-theme="dark"] .toast { background: #2a313c; }
[data-style="xfog-design"] .toast--error, [data-style="xfog-design"][data-theme="dark"] .toast--error { background: var(--critical); }
[data-style="xfog-design"] .modal-backdrop { background: rgba(24, 38, 59, .44); -webkit-backdrop-filter: none; backdrop-filter: none; }
[data-style="xfog-design"] .modal { border-radius: 6px; padding: 22px; animation: fade-in .18s ease-out; }
[data-style="xfog-design"] .modal h2 { font-size: 20px; }
[data-style="xfog-design"] .chart-tip { border-radius: 4px; border-color: var(--xf-line); box-shadow: var(--shadow-hover); }
[data-style="xfog-design"] .skeleton { border-radius: 6px; border-color: var(--xf-line); }

/* login: white card on the soft page tone, blue rule on top */
[data-style="xfog-design"] .login-body { background: var(--xf-soft); }
[data-style="xfog-design"] .login-card { border-radius: 6px; border: 1px solid var(--xf-line); border-top: 3px solid var(--xf-btn); box-shadow: none; padding: 32px 30px; }
[data-style="xfog-design"] .login-card h1 { font-size: 30px; font-weight: 700; letter-spacing: -1px; }
[data-style="xfog-design"] .brand--login { height: auto; padding: 0 0 18px; margin: 0; }
[data-style="xfog-design"] .brand--login .brand__img { width: 130px; }
[data-style="xfog-design"] .password-toggle { border-radius: 4px; }

@media (max-width: 860px) {
    [data-style="xfog-design"] .sidebar { height: 100vh; box-shadow: 0 0 24px rgba(0, 0, 0, .14); }
    [data-style="xfog-design"] body.nav-open .scrim { background: rgba(24, 38, 59, .44); -webkit-backdrop-filter: none; backdrop-filter: none; }
    [data-style="xfog-design"] .topbar { --xf-header: 64px; padding: 0 12px 0 8px; }
    [data-style="xfog-design"] .content { padding: 22px 16px 40px; }
    [data-style="xfog-design"] .page-head h1, [data-style="xfog-design"] .device-hero h1 { font-size: 27px; }
}
