/* rdm design system. sec 5: enterprise, dense, minimal. sec 139: no neon, no matrix, no over-animation. */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #fbfcfd;
    --surface-3: #f1f3f6;
    --border: #e2e6ec;
    --border-strong: #cbd2dc;

    --text: #161b22;
    --text-2: #5b6675;
    --text-3: #868f9d;
    --text-inv: #ffffff;

    --primary: #1f5fd0;
    --primary-hover: #1a51b3;
    --primary-soft: #e8f0fd;
    --primary-ring: rgba(31, 95, 208, .32);

    --ok: #14804a;
    --ok-soft: #e4f6ec;
    --warn: #96650a;
    --warn-soft: #fdf3e2;
    --danger: #b4232b;
    --danger-hover: #9a1d24;
    --danger-soft: #fdeceb;
    --info: #0d6f8c;
    --info-soft: #e5f4f9;
    --muted-soft: #eef0f3;

    --radius: 8px;
    --radius-sm: 6px;
    --radius-lg: 12px;
    --shadow-1: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-2: 0 4px 12px rgba(16, 24, 40, .08);
    --shadow-3: 0 12px 32px rgba(16, 24, 40, .14);

    --topbar-h: 56px;
    --sidebar-w: 236px;
    --bottomnav-h: 60px;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
        "Noto Sans Bengali", sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0e1116;
        --surface: #161b22;
        --surface-2: #1b2129;
        --surface-3: #222a34;
        --border: #2a323d;
        --border-strong: #3a4553;

        --text: #e8ecf1;
        --text-2: #9aa5b3;
        --text-3: #74808f;

        --primary: #5b9bff;
        --primary-hover: #7bb0ff;
        --primary-soft: #16233a;
        --primary-ring: rgba(91, 155, 255, .34);

        --ok: #4cc38a;
        --ok-soft: #10261c;
        --warn: #e0a83a;
        --warn-soft: #2a2114;
        --danger: #f2706f;
        --danger-hover: #f58a89;
        --danger-soft: #2c1618;
        --info: #4fb3d0;
        --info-soft: #11242b;
        --muted-soft: #222a34;

        --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
        --shadow-2: 0 4px 12px rgba(0, 0, 0, .4);
        --shadow-3: 0 12px 32px rgba(0, 0, 0, .5);
    }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.011em; line-height: 1.25; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* sec 82: focus must always be visible */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 3px;
}
:focus:not(:focus-visible) { outline: none; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute; left: 12px; top: -48px; z-index: 200;
    background: var(--surface); color: var(--text); padding: 8px 14px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    transition: top .12s;
}
.skip-link:focus { top: 12px; }

/* ---------- app shell (sec 6) ---------- */

.shell { min-height: 100vh; }

.topbar {
    position: sticky; top: 0; z-index: 60;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 10px;
    padding: 0 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex; align-items: center; gap: 9px;
    font-weight: 680; font-size: 14.5px; color: var(--text);
    letter-spacing: -.01em; white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 26px; height: 26px; flex: none;
    display: grid; place-items: center;
    border-radius: 7px;
    background: var(--primary); color: #fff;
    font-size: 13px; font-weight: 700;
}

.topbar-spacer { flex: 1 1 auto; }

.icon-btn {
    position: relative;
    width: 34px; height: 34px; flex: none;
    display: grid; place-items: center;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    background: none; color: var(--text-2);
    cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

.badge-dot {
    position: absolute; top: 5px; right: 5px;
    min-width: 15px; height: 15px; padding: 0 4px;
    border-radius: 99px;
    background: var(--danger); color: #fff;
    font-size: 9.5px; font-weight: 700; line-height: 15px;
    text-align: center;
    border: 2px solid var(--surface);
    box-sizing: content-box;
}

.avatar {
    width: 30px; height: 30px; flex: none;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--primary-soft); color: var(--primary);
    font-size: 12px; font-weight: 700;
}

/* topbar dropdown, details/summary so it works without js */
.menu { position: relative; }
.menu > summary {
    display: flex; align-items: center; gap: 7px;
    padding: 3px 5px 3px 3px; border-radius: 99px;
    cursor: pointer; list-style: none;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover { background: var(--surface-3); }
.menu-name { font-size: 13px; font-weight: 570; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-pop {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 80;
    min-width: 208px; padding: 5px;
    background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-2);
}
.menu-pop-head { padding: 8px 10px 9px; border-bottom: 1px solid var(--border); margin-bottom: 5px; }
.menu-pop-head strong { display: block; font-size: 13.5px; }
.menu-pop-head span { font-size: 12px; color: var(--text-2); word-break: break-all; }
.menu-pop a, .menu-pop button {
    display: flex; align-items: center; gap: 9px; width: 100%;
    padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
    background: none; color: var(--text-2);
    font: inherit; font-size: 13.5px; text-align: left; cursor: pointer;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.menu-pop svg { width: 16px; height: 16px; flex: none; }
.menu-pop hr { margin: 5px 0; border: 0; border-top: 1px solid var(--border); }

@media (max-width: 760px) {
    .menu-name { display: none; }
}

.layout { display: flex; align-items: flex-start; }

.sidebar {
    position: sticky; top: var(--topbar-h);
    width: var(--sidebar-w); flex: none;
    height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
    padding: 12px 10px 20px;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.nav-group + .nav-group { margin-top: 16px; }
.nav-label {
    padding: 0 10px 6px;
    font-size: 10.5px; font-weight: 700; letter-spacing: .07em;
    text-transform: uppercase; color: var(--text-3);
}

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; margin-bottom: 1px;
    border-radius: var(--radius-sm);
    color: var(--text-2); font-weight: 520; font-size: 13.5px;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav-item[aria-current="page"] {
    background: var(--primary-soft); color: var(--primary); font-weight: 620;
}
.nav-item[aria-current="page"] svg { opacity: 1; }
.nav-count {
    margin-left: auto;
    padding: 1px 6px; border-radius: 99px;
    background: var(--surface-3); color: var(--text-2);
    font-size: 11px; font-weight: 700;
}

.content { flex: 1 1 auto; min-width: 0; padding: 18px 20px 40px; }
.content-narrow { max-width: 760px; }

.page-head {
    display: flex; align-items: flex-start; gap: 12px;
    flex-wrap: wrap; margin-bottom: 16px;
}
.page-head .page-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.page-sub { margin-top: 3px; color: var(--text-2); font-size: 13px; }

.bottomnav { display: none; }

/* ---------- buttons ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    min-height: 34px; padding: 0 13px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text);
    font: inherit; font-size: 13.5px; font-weight: 570;
    cursor: pointer; white-space: nowrap;
    transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }

.btn-ghost { background: none; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

.btn-sm { min-height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn-lg { min-height: 40px; padding: 0 18px; font-size: 14.5px; }
.btn-block { width: 100%; }

.btn-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn-busy::after {
    content: ""; position: absolute; inset: 0; margin: auto;
    width: 15px; height: 15px; border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff;
    animation: spin .6s linear infinite;
}
.btn-busy.btn:not(.btn-primary):not(.btn-danger)::after {
    border-color: var(--border-strong); border-top-color: var(--text-2);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- cards ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
}
.card + .card { margin-top: 14px; }
.card-head {
    display: flex; align-items: center; gap: 10px;
    padding: 13px 15px; border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 14px; }
.card-head .card-actions { margin-left: auto; display: flex; gap: 6px; }
.card-body { padding: 15px; }
.card-body-flush { padding: 0; }
.card-foot {
    padding: 11px 15px; border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius) var(--radius);
}

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-sidebar { grid-template-columns: minmax(0, 1fr) 320px; }

/* ---------- stat tiles (sec 10) ---------- */

.stat {
    padding: 13px 15px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
}
.stat-label {
    display: flex; align-items: center; gap: 6px;
    font-size: 11.5px; font-weight: 600; letter-spacing: .03em;
    text-transform: uppercase; color: var(--text-3);
}
.stat-value {
    margin-top: 5px;
    font-size: 25px; font-weight: 680; letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}
.stat-meta { margin-top: 2px; font-size: 12px; color: var(--text-2); }
.stat-value.is-ok { color: var(--ok); }
.stat-value.is-warn { color: var(--warn); }
.stat-value.is-danger { color: var(--danger); }

/* ---------- status badges (sec 109). never colour alone (sec 82). ---------- */

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 8px 2px 7px;
    border-radius: 99px;
    background: var(--muted-soft); color: var(--text-2);
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge::before {
    content: ""; width: 6px; height: 6px; flex: none;
    border-radius: 50%; background: currentColor;
}
.badge-plain::before { display: none; }

.badge.is-online, .badge.is-completed, .badge.is-active {
    background: var(--ok-soft); color: var(--ok);
}
.badge.is-offline, .badge.is-disabled, .badge.is-expired, .badge.is-cancelled {
    background: var(--muted-soft); color: var(--text-2);
}
.badge.is-locked, .badge.is-failed, .badge.is-revoked {
    background: var(--danger-soft); color: var(--danger);
}
.badge.is-pending, .badge.is-sent, .badge.is-preparing {
    background: var(--warn-soft); color: var(--warn);
}
.badge.is-running, .badge.is-received, .badge.is-uploading, .badge.is-processing {
    background: var(--info-soft); color: var(--info);
}
.badge.is-running::before { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.battery { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.battery-bar {
    width: 30px; height: 7px; flex: none;
    border-radius: 99px; background: var(--surface-3); overflow: hidden;
}
.battery-fill { height: 100%; background: var(--ok); }
.battery-fill.is-low { background: var(--warn); }
.battery-fill.is-critical { background: var(--danger); }

/* ---------- tables (sec 13) ---------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.data {
    width: 100%; border-collapse: collapse;
    font-size: 13.5px;
}
table.data th, table.data td {
    padding: 10px 14px; text-align: left; vertical-align: middle;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.data th {
    background: var(--surface-2);
    font-size: 11.5px; font-weight: 650; letter-spacing: .03em;
    text-transform: uppercase; color: var(--text-3);
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.wrap { white-space: normal; min-width: 220px; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.cell-main { font-weight: 600; }
.cell-sub { color: var(--text-3); font-size: 12px; }

/* device cards, mobile list form (sec 13) */
.device-cards { display: none; }
.device-card {
    display: block; padding: 13px 14px;
    border-bottom: 1px solid var(--border); color: inherit;
}
.device-card:hover { background: var(--surface-2); text-decoration: none; }
.device-card:last-child { border-bottom: none; }
.device-card-top { display: flex; align-items: center; gap: 8px; }
.device-card-name { font-weight: 640; }
.device-card-meta { margin-top: 5px; color: var(--text-2); font-size: 12.5px; }

/* ---------- forms ---------- */

.field { margin-bottom: 13px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1 1 200px; margin-bottom: 0; }

label.lbl {
    display: block; margin-bottom: 5px;
    font-size: 12.5px; font-weight: 600; color: var(--text);
}
.hint { margin-top: 5px; font-size: 12px; color: var(--text-3); }

.inp, select.inp, textarea.inp {
    width: 100%; min-height: 36px; padding: 7px 11px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text);
    font: inherit; font-size: 13.5px;
    transition: border-color .12s, box-shadow .12s;
}
.inp:focus, select.inp:focus, textarea.inp:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}
.inp::placeholder { color: var(--text-3); }
textarea.inp { min-height: 84px; resize: vertical; line-height: 1.5; }
.inp[aria-invalid="true"] { border-color: var(--danger); }
.inp:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; }

.field-err { margin-top: 5px; font-size: 12px; font-weight: 550; color: var(--danger); }
.field-err:empty { display: none; }

.inp-group { display: flex; gap: 8px; }
.inp-group .inp { flex: 1 1 auto; }

.code-inp {
    font-family: var(--mono); font-size: 19px; letter-spacing: .34em;
    text-align: center; padding-left: 14px;
}

.check { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; flex: none; accent-color: var(--primary); }

.switch-row {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 0; border-bottom: 1px solid var(--border);
}
.switch-row:last-child { border-bottom: none; }
.switch-row .switch-text { flex: 1 1 auto; min-width: 0; }
.switch-row .switch-text strong { display: block; font-size: 13.5px; font-weight: 600; }
.switch-row .switch-text span { font-size: 12.5px; color: var(--text-2); }

.toolbar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    margin-bottom: 13px;
}
.toolbar .search { flex: 1 1 220px; max-width: 340px; }
.toolbar select.inp { width: auto; min-width: 128px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    padding: 4px 11px; border-radius: 99px;
    border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--text-2);
    font-size: 12.5px; font-weight: 570; cursor: pointer;
}
.chip:hover { background: var(--surface-3); text-decoration: none; }
.chip[aria-pressed="true"], .chip.is-on {
    background: var(--primary); border-color: var(--primary); color: #fff;
}

/* ---------- tabs (sec 15) ---------- */

.tabs {
    display: flex; gap: 2px; overflow-x: auto;
    border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.tab {
    padding: 9px 13px;
    border-bottom: 2px solid transparent;
    color: var(--text-2); font-size: 13.5px; font-weight: 570;
    white-space: nowrap;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab[aria-current="page"] { color: var(--primary); border-bottom-color: var(--primary); font-weight: 640; }

/* ---------- empty / error / loading states (sec 78-80) ---------- */

.empty { padding: 42px 22px; text-align: center; }
.empty-icon {
    width: 42px; height: 42px; margin: 0 auto 12px;
    display: grid; place-items: center;
    border-radius: 11px; background: var(--surface-3); color: var(--text-3);
}
.empty-icon svg { width: 21px; height: 21px; }
.empty h3 { font-size: 15px; margin-bottom: 5px; }
.empty p { color: var(--text-2); max-width: 340px; margin: 0 auto 15px; }

.skel { background: var(--surface-3); border-radius: 5px; animation: shimmer 1.5s ease-in-out infinite; }
.skel-line { height: 12px; margin-bottom: 8px; }
.skel-line.w-40 { width: 40%; }
.skel-line.w-60 { width: 60%; }
.skel-line.w-80 { width: 80%; }
@keyframes shimmer { 50% { opacity: .5; } }

.alert {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 11px 13px; border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 13px;
}
.alert svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.alert-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.alert-warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.alert-ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.alert-info { background: var(--info-soft); border-color: transparent; color: var(--info); }
.alert strong { font-weight: 650; }

/* ---------- timeline (sec 111) ---------- */

.timeline { position: relative; padding-left: 21px; }
.timeline::before {
    content: ""; position: absolute; left: 4px; top: 5px; bottom: 5px;
    width: 2px; background: var(--border);
}
.tl-item { position: relative; padding: 0 0 15px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
    content: ""; position: absolute; left: -21px; top: 5px;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--border-strong);
}
.tl-item.is-ok::before { border-color: var(--ok); }
.tl-item.is-failed::before { border-color: var(--danger); }
.tl-item.is-running::before { border-color: var(--info); }
.tl-time {
    font-size: 11.5px; font-weight: 650; color: var(--text-3);
    font-variant-numeric: tabular-nums;
}
.tl-body { font-size: 13.5px; margin-top: 1px; }
.tl-meta { font-size: 12px; color: var(--text-3); margin-top: 1px; }

/* ---------- pagination (sec 84) ---------- */

.pager {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 11px 15px;
}
.pager-info { font-size: 12.5px; color: var(--text-2); }
.pager-links { margin-left: auto; display: flex; gap: 5px; }

/* ---------- map (sec 28) ---------- */

.map {
    width: 100%; height: 420px;
    border-radius: var(--radius); overflow: hidden;
    background: var(--surface-3);
    border: 1px solid var(--border);
}
.map-sm { height: 220px; }

/* ---------- progress (sec 35) ---------- */

.progress { height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); transition: width .3s; }
.progress-fill.is-ok { background: var(--ok); }
.progress-fill.is-danger { background: var(--danger); }
.progress-meta {
    display: flex; justify-content: space-between; gap: 10px;
    margin-top: 5px; font-size: 12px; color: var(--text-2);
    font-variant-numeric: tabular-nums;
}

/* ---------- key/value detail lists (sec 16) ---------- */

.kv { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 1px 14px; font-size: 13.5px; }
.kv dt { padding: 6px 0; color: var(--text-2); }
.kv dd { padding: 6px 0; margin: 0; font-weight: 550; word-break: break-word; }

.mono { font-family: var(--mono); font-size: 12.5px; }
.copy-row { display: flex; align-items: center; gap: 8px; }
.copy-row code {
    flex: 1 1 auto; min-width: 0;
    padding: 8px 11px; border-radius: var(--radius-sm);
    background: var(--surface-3); border: 1px solid var(--border);
    font-family: var(--mono); font-size: 12.5px;
    overflow-x: auto; white-space: nowrap;
}

.danger-zone { border-color: var(--danger); }
.danger-zone .card-head { border-bottom-color: var(--danger); color: var(--danger); }

.secret-grid {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px;
    font-family: var(--mono); font-size: 13px;
}
.secret-grid span {
    padding: 7px 10px; border-radius: var(--radius-sm);
    background: var(--surface-3); border: 1px solid var(--border);
    text-align: center; letter-spacing: .04em;
}

/* ---------- auth pages (sec 7) ---------- */

.auth-wrap {
    min-height: 100vh;
    display: grid; place-items: center;
    padding: 24px 16px;
}
.auth-card { width: 100%; max-width: 384px; }
.auth-head { text-align: center; margin-bottom: 20px; }
.auth-head .brand { justify-content: center; font-size: 16px; margin-bottom: 14px; }
.auth-head h1 { font-size: 19px; }
.auth-head p { margin-top: 5px; color: var(--text-2); font-size: 13.5px; }
.auth-foot { margin-top: 15px; text-align: center; font-size: 12.5px; color: var(--text-3); }

/* ---------- utilities ---------- */

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 5px; } .gap-2 { gap: 9px; } .gap-3 { gap: 14px; }
.ml-auto { margin-left: auto; }
.mt-1 { margin-top: 5px; } .mt-2 { margin-top: 10px; } .mt-3 { margin-top: 15px; } .mt-4 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 10px; } .mb-3 { margin-bottom: 15px; }
.text-2 { color: var(--text-2); } .text-3 { color: var(--text-3); }
.text-ok { color: var(--ok); } .text-danger { color: var(--danger); } .text-warn { color: var(--warn); }
.fs-12 { font-size: 12px; } .fs-13 { font-size: 13px; }
.fw-6 { font-weight: 620; }
.nowrap { white-space: nowrap; }
.tabnum { font-variant-numeric: tabular-nums; }
.hide { display: none !important; }

/* ---------- responsive (sec 81) ---------- */

@media (max-width: 1100px) {
    .grid-5, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-sidebar { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kv { grid-template-columns: 124px minmax(0, 1fr); }
}

@media (max-width: 760px) {
    :root { --topbar-h: 52px; }

    .sidebar { display: none; }
    .content { padding: 14px 13px calc(var(--bottomnav-h) + 26px); }

    .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-value { font-size: 21px; }

    /* sec 13: table collapses to cards on phones */
    .device-table { display: none; }
    .device-cards { display: block; }

    .page-head .page-actions { margin-left: 0; width: 100%; }
    .page-head .page-actions .btn { flex: 1 1 auto; }

    .kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .kv dt { padding-bottom: 0; font-size: 12px; }
    .kv dd { padding-top: 1px; padding-bottom: 9px; }

    .map { height: 320px; }

    /* sec 120: bottom navigation */
    .bottomnav {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
        display: flex;
        height: var(--bottomnav-h);
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--surface);
        border-top: 1px solid var(--border);
    }
    .bottomnav a {
        flex: 1 1 0; min-width: 0;
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        color: var(--text-3); font-size: 10.5px; font-weight: 600;
    }
    .bottomnav a:hover { text-decoration: none; }
    .bottomnav a svg { width: 21px; height: 21px; }
    .bottomnav a[aria-current="page"] { color: var(--primary); }
}

@media (max-width: 430px) {
    .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: minmax(0, 1fr); }
    .secret-grid { grid-template-columns: minmax(0, 1fr); }
    .toolbar .search { max-width: none; }
}

@media (min-width: 1500px) {
    .content { padding-left: 30px; padding-right: 30px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; }
}

/* ---------- sweetalert2 theming, so dialogs match the panel ---------- */

.swal2-popup {
    border-radius: var(--radius-lg) !important;
    background: var(--surface) !important;
    color: var(--text) !important;
    font-family: var(--font) !important;
    font-size: 14px !important;
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-3) !important;
}
.swal2-title { color: var(--text) !important; font-size: 17px !important; font-weight: 650 !important; }
.swal2-html-container { color: var(--text-2) !important; font-size: 13.5px !important; }
.swal2-actions { gap: 8px !important; }
.swal2-styled.swal2-confirm, .swal2-styled.swal2-cancel, .swal2-styled.swal2-deny {
    min-height: 36px !important; padding: 0 15px !important;
    border-radius: var(--radius-sm) !important;
    font-size: 13.5px !important; font-weight: 570 !important;
    box-shadow: none !important;
}
.swal2-styled.swal2-confirm { background: var(--primary) !important; }
.swal2-styled.swal2-confirm.swal-danger { background: var(--danger) !important; }
.swal2-styled.swal2-cancel {
    background: var(--surface) !important; color: var(--text) !important;
    border: 1px solid var(--border-strong) !important;
}
.swal2-input, .swal2-textarea {
    border: 1px solid var(--border-strong) !important;
    border-radius: var(--radius-sm) !important;
    background: var(--surface) !important; color: var(--text) !important;
    font-size: 13.5px !important; box-shadow: none !important;
}
.swal2-input:focus { border-color: var(--primary) !important; box-shadow: 0 0 0 3px var(--primary-ring) !important; }
.swal2-validation-message {
    background: var(--danger-soft) !important; color: var(--danger) !important;
    border-radius: var(--radius-sm) !important;
}
.swal2-icon.swal2-warning { border-color: var(--warn) !important; color: var(--warn) !important; }
.swal2-icon.swal2-error { border-color: var(--danger) !important; color: var(--danger) !important; }
.swal2-icon.swal2-success [class^="swal2-success-line"] { background-color: var(--ok) !important; }
.swal2-icon.swal2-success .swal2-success-ring { border-color: var(--ok) !important; }

/* toast variant (sec 110) */
.swal2-toast {
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-2) !important;
    background: var(--surface) !important;
}
.swal2-toast .swal2-title { font-size: 13.5px !important; font-weight: 570 !important; color: var(--text) !important; }
.swal2-toast .swal2-timer-progress-bar { background: var(--primary) !important; }
