:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #eef2f6;
    --text: #18212f;
    --muted: #657387;
    --line: #dce3eb;
    --blue: #2563eb;
    --green: #16834a;
    --red: #c73636;
    --amber: #a15c07;
    --shadow: 0 10px 26px rgba(24, 33, 47, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a {
    color: var(--blue);
    text-decoration: none;
}

button,
input {
    font: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 64px;
    padding: 0 28px;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
}

.brand-mark {
    width: 28px;
    height: 28px;
    border: 2px solid var(--blue);
    border-radius: 7px;
    background:
        linear-gradient(90deg, transparent 11px, var(--blue) 11px, var(--blue) 13px, transparent 13px),
        linear-gradient(0deg, transparent 11px, var(--green) 11px, var(--green) 13px, transparent 13px);
}

.nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.nav a,
.link-button {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 8px 10px;
    cursor: pointer;
}

.nav a.active,
.nav a:hover,
.link-button:hover {
    color: var(--text);
}

.page {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 56px;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-heading h1,
.login-panel h1 {
    margin: 0;
    font-size: 30px;
    line-height: 1.15;
}

.eyebrow {
    margin: 0 0 5px;
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.metric,
.panel,
.login-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.metric {
    padding: 18px;
}

.metric span {
    display: block;
    color: var(--muted);
    margin-bottom: 8px;
}

.metric strong {
    font-size: 34px;
    line-height: 1;
}

.metric.online strong {
    color: var(--green);
}

.metric.offline strong {
    color: var(--red);
}

.grid {
    display: grid;
    gap: 18px;
    margin-bottom: 18px;
}

.grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
    padding: 18px;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.section-title h2 {
    margin: 0;
    font-size: 18px;
}

.form-stack {
    display: grid;
    gap: 14px;
}

label span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 6px;
}

input {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--text);
    padding: 9px 11px;
}

input:focus {
    outline: 3px solid rgba(37, 99, 235, 0.16);
    border-color: var(--blue);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 7px;
    padding: 9px 14px;
    cursor: pointer;
    font-weight: 700;
}

.button.primary {
    background: var(--blue);
    color: #fff;
}

.button.secondary {
    background: var(--surface);
    border-color: var(--line);
    color: var(--text);
}

.button.danger {
    background: #fff1f1;
    border-color: rgba(199, 54, 54, 0.35);
    color: #962525;
}

.button.small {
    min-height: 34px;
    padding: 6px 10px;
}

.button.power {
    min-width: 118px;
    min-height: 52px;
    font-size: 17px;
}

.button.power.on {
    background: var(--green);
    color: #fff;
}

.button.power.off {
    background: var(--red);
    color: #fff;
}

.button:disabled {
    opacity: 0.6;
    cursor: wait;
}

.button-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.85;
}

.control-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.heading-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.muted,
.empty {
    color: var(--muted);
}

.empty {
    margin: 0;
}

.flash {
    border-radius: 7px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid var(--line);
    background: var(--surface);
}

.flash.success {
    border-color: rgba(22, 131, 74, 0.35);
    background: #edf8f1;
    color: #0f6337;
}

.flash.error {
    border-color: rgba(199, 54, 54, 0.35);
    background: #fff1f1;
    color: #962525;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th,
td {
    padding: 11px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.align-right {
    text-align: right;
}

.badge,
.pin-state,
.level {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 12px;
    font-weight: 700;
}

.badge.online,
.pin-state.on,
.level.info {
    background: #e9f7ef;
    color: #0f6337;
}

.badge.offline,
.pin-state.off,
.level.error {
    background: #fff1f1;
    color: #962525;
}

.level.warning {
    background: #fff7e8;
    color: var(--amber);
}

.list {
    display: grid;
    gap: 8px;
}

.list.compact {
    gap: 6px;
}

.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 11px 0;
    border-bottom: 1px solid var(--line);
    color: var(--text);
}

.list-row:last-child {
    border-bottom: 0;
}

.list-row strong,
.list-row small {
    display: block;
}

.list-row small {
    color: var(--muted);
    margin-top: 2px;
}

.details {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 10px 14px;
    margin: 0;
}

.details dt {
    color: var(--muted);
}

.details dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.login-screen {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-shell {
    width: min(420px, 100%);
}

.login-panel {
    padding: 28px;
}

.login-brand {
    margin-bottom: 22px;
}

.login-panel h1 {
    margin-bottom: 18px;
}

.auth-switch {
    margin: 18px 0 0;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 760px) {
    .topbar,
    .page-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar {
        padding: 14px 16px;
    }

    .nav {
        width: 100%;
    }

    .metrics,
    .grid.two {
        grid-template-columns: 1fr;
    }

    .page {
        width: min(100% - 24px, 1180px);
        margin-top: 20px;
    }

    .details {
        grid-template-columns: 1fr;
    }
}
