:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --line: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --accent: #0f766e;
    --accent-soft: #ccfbf1;
    --ok: #047857;
    --ok-bg: #d1fae5;
    --warn: #b45309;
    --warn-bg: #fef3c7;
    --alarm: #b91c1c;
    --alarm-bg: #fee2e2;
    --info: #1d4ed8;
    --info-bg: #dbeafe;
    --sidebar-w: 248px;
    --radius: 10px;
    --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}

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

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.45;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.guest-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, #ccfbf1 0, transparent 42%),
        var(--bg);
}

.guest-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 32px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 700;
}

.muted { color: var(--muted); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    color: var(--text);
}
.field textarea { min-height: 90px; resize: vertical; }
.field .error { color: var(--alarm); font-size: 13px; }

.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 9px 14px;
    font-weight: 600;
    font-size: 14px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #0d9488; }
.btn-secondary { background: #fff; border-color: var(--line); color: var(--text); }
.btn-danger { background: var(--alarm-bg); color: var(--alarm); border-color: #fecaca; }
.btn-block { width: 100%; }

.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #0b1220;
    color: #e2e8f0;
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.sidebar .brand { color: #fff; padding: 4px 10px 12px; }
.sidebar .brand-mark { background: var(--accent); }

.nav-section {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
    padding: 8px 12px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: #cbd5e1;
    font-size: 14px;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.is-active { background: rgba(15, 118, 110, 0.35); color: #fff; }
.nav-item.is-soon { opacity: 0.55; }
.nav-count {
    margin-left: auto;
    background: var(--alarm);
    color: #fff;
    border-radius: 999px;
    font-size: 11px;
    min-width: 18px;
    padding: 1px 6px;
    text-align: center;
}
table.data tr.is-unread td { background: #fff7ed; }

.sidebar-footer {
    margin-top: auto;
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 13px;
}

.main { min-width: 0; }
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.topbar-title { font-weight: 700; font-size: 16px; }
.content { padding: 24px; }

.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.kpi {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
}
.kpi .label { font-size: 12px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 6px; line-height: 1.1; }
.kpi.ok .value { color: var(--ok); }
.kpi.warn .value { color: var(--warn); }
.kpi.alarm .value { color: var(--alarm); }
a.kpi { color: inherit; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.card-h {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-weight: 650;
}
.card-b { padding: 16px; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
    align-items: center;
}
.toolbar input, .toolbar select {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    background: #fff;
    min-width: 180px;
}

.table-wrap { overflow-x: auto; }
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
table.data th {
    text-align: left;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.data td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
table.data tr:hover td { background: #f8fafc; }

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-alarm { background: var(--alarm-bg); color: var(--alarm); }
.badge-muted { background: #e2e8f0; color: #475569; }
.badge-info { background: var(--info-bg); color: var(--info); }

.flash {
    background: var(--ok-bg);
    color: var(--ok);
    border: 1px solid #a7f3d0;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.page-h {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
}
.page-h h1 { margin: 0; font-size: 22px; }
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px 16px;
}

.device-hero {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.device-hero h1 { margin: 0 0 4px; }
.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.tile {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
}
.tile .k { font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.tile .v { font-size: 18px; font-weight: 700; margin-top: 6px; }

.placeholder {
    padding: 48px 24px;
    text-align: center;
    color: var(--muted);
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn-warn { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }

.timeline { display: flex; flex-direction: column; }
.timeline-item {
    display: grid;
    grid-template-columns: 16px 1fr;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.timeline-item:last-child { border-bottom: 0; }
.timeline-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: 6px;
}
.timeline-dot.badge-alarm { background: var(--alarm); }
.timeline-dot.badge-warn { background: var(--warn); }
.timeline-dot.badge-info { background: var(--info); }

.mobile-toggle { display: none; background: none; border: 0; color: var(--text); font-weight: 700; }

@media (max-width: 960px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .sidebar.is-open {
        display: flex;
        position: fixed;
        inset: 0 auto 0 0;
        width: min(84vw, var(--sidebar-w));
        z-index: 40;
    }
    .mobile-toggle { display: inline-flex; }
    .content { padding: 16px; }
    .kpis { grid-template-columns: repeat(2, 1fr); }
}

.switcher select {
    background: #111827;
    color: #fff;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 7px 10px;
    width: 100%;
}

.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.geo-map {
    width: 100%;
    min-height: 240px;
    border-radius: 0 0 var(--radius) var(--radius);
    z-index: 1;
}
.defi-marker {
    background: transparent;
    border: 0;
}
.defi-marker span {
    display: block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.35);
}
.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 13px;
    color: var(--muted);
}
.map-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}
.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
.chart-card { min-width: 0; }
.chart-h {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}
.chart-svg {
    width: 100%;
    height: 168px;
    display: block;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.chart-axis { font-size: 11px; fill: #64748b; }
.chart-empty { padding: 28px 8px; text-align: center; }
.segmented {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}
.segmented button {
    background: #fff;
    border: 0;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}
.segmented button.is-on { background: var(--accent-soft); color: var(--accent); }
.qr-wrap { margin: 0 0 12px; }
.qr-canvas { display: block; width: 180px; height: 180px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.code-block {
    margin: 12px 0 0;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 12px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 960px) {
    .split, .chart-grid { grid-template-columns: 1fr; }
    .geo-map { min-height: 280px; }
}
