:root {
    --bg-0: #03101f;
    --bg-1: #08203f;
    --bg-2: #04305d;
    --panel: rgba(10, 20, 40, 0.85);
    --panel-strong: #ffffff;
    --text: #f4f8fc;
    --text-dark: #0d1f33;
    --muted: rgba(244, 248, 252, 0.72);
    --muted-dark: #54667a;
    --border: rgba(255, 255, 255, 0.16);
    --border-dark: rgba(13, 31, 51, 0.12);
    --accent: #0b65c2;
    --accent-hover: #1475d6;
    --accent-soft: #dfeaf8;
    --good: #5ed0a5;
    --warn: #f3c969;
    --critical: #ef7b7b;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.42);
    --shadow-soft: 0 16px 35px rgba(0, 0, 0, 0.22);
    --font-head: "Segoe UI Semibold", "Trebuchet MS", sans-serif;
    --font-body: "Segoe UI", Tahoma, sans-serif;
}

[data-theme="light"] {
    --bg-0: #edf2f7;
    --bg-1: #dfe7f1;
    --bg-2: #cfdbea;
    --panel: rgba(255, 255, 255, 0.9);
    --panel-strong: #ffffff;
    --text: #102033;
    --text-dark: #102033;
    --muted: rgba(16, 32, 51, 0.72);
    --muted-dark: #536579;
    --border: rgba(16, 32, 51, 0.12);
    --border-dark: rgba(16, 32, 51, 0.12);
    --accent-soft: #d8e8fb;
    --shadow: 0 20px 50px rgba(16, 32, 51, 0.12);
    --shadow-soft: 0 14px 30px rgba(16, 32, 51, 0.08);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    color: var(--text);
    background:
        radial-gradient(circle at 14% 84%, rgba(255, 255, 255, 0.08) 0 1px, transparent 2px),
        linear-gradient(120deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 48px),
        linear-gradient(60deg, rgba(255, 255, 255, 0.03) 0 1px, transparent 1px 48px),
        linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 56%, #062449 100%);
    background-size: auto, 56px 97px, 56px 97px, auto;
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.06;
    background-image:
        linear-gradient(30deg, transparent 47%, #ffffff 48%, #ffffff 52%, transparent 53%),
        linear-gradient(150deg, transparent 47%, #ffffff 48%, #ffffff 52%, transparent 53%),
        linear-gradient(90deg, transparent 47%, #ffffff 48%, #ffffff 52%, transparent 53%);
    background-size: 92px 52px;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

.shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 290px;
    padding: 28px;
    background: rgba(5, 14, 28, 0.84);
    border-right: 1px solid rgba(255, 255, 255, 0.09);
    backdrop-filter: blur(18px);
}

.brand {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 34px;
}

.brand h1,
.page-header h2,
.panel h3 {
    margin: 0;
    font-family: var(--font-head);
}

.brand h1 { font-size: 1.12rem; letter-spacing: 0.02em; }
.brand p,
.page-header p,
.support-copy {
    margin: 6px 0 0;
    color: var(--muted);
}

.brand-mark {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: linear-gradient(145deg, #d6dfe8, #6d8296);
    color: #07111f;
    font-weight: 800;
    letter-spacing: 0.08em;
    box-shadow: var(--shadow-soft);
}

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

.nav a,
.theme-toggle,
.search-bar button,
.login-form button,
.stack-form button,
.inline-actions button {
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    padding: 12px 14px;
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.nav a:hover,
.theme-toggle:hover,
.search-bar button:hover,
.login-form button:hover,
.stack-form button:hover,
.inline-actions button:hover {
    background: rgba(11, 101, 194, 0.92);
    border-color: rgba(255, 255, 255, 0.22);
    transform: translateY(-1px);
    text-decoration: none;
}

.theme-toggle {
    margin-top: 20px;
    width: 100%;
    cursor: pointer;
}

.primary-link,
.secondary-button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 44px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    font: 600 0.95rem/1 var(--font-body);
    cursor: pointer;
    text-decoration: none;
}

.primary-link {
    background: rgba(11, 101, 194, 0.96);
    color: #ffffff;
}

.secondary-button {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.content {
    flex: 1;
    padding: 32px;
}

.content--full {
    padding: 0;
}

.page-header {
    margin-bottom: 28px;
}

.device-header {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
}

.device-actions {
    display: grid;
    justify-items: end;
    gap: 8px;
}

.meshcentral-slot {
    min-width: 220px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px dashed rgba(255, 255, 255, 0.24);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.5);
    font: 700 0.95rem/1.2 var(--font-head);
    cursor: not-allowed;
}

.meshcentral-note {
    color: var(--muted);
    font-size: 0.85rem;
}

.page-header-inline {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: end;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 10px;
    color: rgba(223, 234, 248, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.72rem;
}

.stats-grid,
.panel-grid,
.detail-grid,
.feature-grid {
    display: grid;
    gap: 20px;
}

.stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: 24px;
}

.panel-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.detail-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-bottom: 24px; }
.detail-grid--single { grid-template-columns: 1fr; }
.feature-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.install-panel {
    margin-top: 0;
    max-width: none;
}

.install-panel--compact {
    padding: 18px 20px;
}

.install-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 16px 0;
}

.command-shell {
    overflow-x: auto;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    background: rgba(255, 255, 255, 0.04);
}

.command-shell code {
    color: #f6fbff;
    white-space: pre-wrap;
    word-break: break-word;
}

.enrollment-token {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.enrollment-label {
    color: var(--muted);
    font-size: 0.9rem;
}

.tab-shell {
    display: grid;
    gap: 20px;
}

.tab-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tab-button {
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    padding: 12px 16px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
}

.tab-button.is-active {
    background: rgba(11, 101, 194, 0.96);
    border-color: rgba(255, 255, 255, 0.22);
}

.tab-panel {
    display: none;
}

.tab-panel.is-active {
    display: block;
}

.stacked-volume-list {
    display: grid;
    gap: 14px;
}

.volume-card {
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.09);
}

.volume-head,
.volume-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.volume-head {
    margin-bottom: 10px;
}

.volume-meter {
    height: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.volume-meter span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #0b65c2, #4b9be8);
}

.volume-meta {
    margin-top: 10px;
    color: var(--muted);
    font-size: 0.9rem;
}

.stat-card,
.panel,
.feature-card,
.login-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.stat-card,
.panel,
.feature-card {
    padding: 22px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    margin-bottom: 10px;
}

.stat-card strong {
    font-size: 2rem;
    line-height: 1;
}

.panel-wide {
    grid-column: 1 / -1;
}

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

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    vertical-align: top;
}

[data-theme="light"] th,
[data-theme="light"] td {
    border-bottom-color: rgba(16, 32, 51, 0.1);
}

th {
    color: var(--muted);
    font-weight: 600;
}

.badge {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
}

.badge-good { background: rgba(94, 208, 165, 0.18); color: #9cf1cf; }
.badge-critical { background: rgba(239, 123, 123, 0.18); color: #ffb9b9; }

.alert-list {
    display: grid;
    gap: 10px;
}

.alert-item,
.empty-state {
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.09);
}

[data-theme="light"] .alert-item,
[data-theme="light"] .empty-state {
    border-color: rgba(16, 32, 51, 0.1);
}

.search-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.search-bar input,
.login-form input,
.stack-form input {
    min-width: 240px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-dark);
}

.search-bar a {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
}

[data-theme="light"] .search-bar a {
    background: rgba(255, 255, 255, 0.72);
}

.detail-list {
    display: grid;
    gap: 14px;
    margin: 0;
}

.detail-list div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    padding-bottom: 10px;
}

[data-theme="light"] .detail-list div {
    border-bottom-color: rgba(16, 32, 51, 0.1);
}

.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; text-align: right; }

.login-stage {
    position: relative;
    min-height: 100vh;
    display: grid;
    place-items: center;
    overflow: hidden;
    padding: 28px 16px 40px;
}

.login-stage--compact {
    padding: 32px;
}

.login-stack {
    position: relative;
    z-index: 2;
    width: min(92vw, 520px);
    display: grid;
    gap: 14px;
}

.login-branding {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: min(92vw, 640px);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    z-index: 2;
}

.beltran-portal-title {
    margin: 0 0 8px;
    color: #ffffff;
    font: 700 22px/1.2 Arial, Helvetica, sans-serif;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    width: 100%;
}

.beltran-brand-name {
    margin: 0;
    color: #ffffff;
    font: 800 30px/1.05 Arial, Helvetica, sans-serif;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.38);
    width: 100%;
}

.beltran-brand-tagline {
    margin: 6px 0 0;
    color: rgba(255, 255, 255, 0.82);
    font: 600 14px/1.4 Arial, Helvetica, sans-serif;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    width: 100%;
}

.login-stage .login-card {
    position: relative;
    z-index: 2;
    width: 100%;
    padding: 30px;
}

.beltran-security-line {
    position: absolute;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    width: min(92vw, 640px);
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 14px;
    text-align: center;
    z-index: 2;
    color: rgba(255, 255, 255, 0.88);
    font: 600 11px/1.4 Arial, Helvetica, sans-serif;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.beltran-security-line span {
    display: inline-block;
}

.login-form {
    display: grid;
    gap: 16px;
    margin-top: 0;
}

.login-form label,
.stack-form label {
    display: grid;
    gap: 8px;
}

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

.stack-form input,
.stack-form button,
.inline-actions button {
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-dark);
}

.inline-actions {
    margin-top: 14px;
}

.inline-actions button {
    cursor: pointer;
}

.mfa-setup {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(180px, 220px) 1fr;
    align-items: start;
    margin: 18px 0;
}

.mfa-qr {
    width: 100%;
    max-width: 220px;
    background: #fff;
    padding: 10px;
    border-radius: 16px;
}

.mfa-manual code,
.wrap-code {
    display: block;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.09);
    overflow-wrap: anywhere;
}

.form-error {
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(239, 123, 123, 0.18);
    color: #ffd0d0;
}

.message-panel {
    color: var(--good);
}

.error-panel {
    color: var(--critical);
}

.aurora {
    position: absolute;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    filter: blur(18px);
    opacity: 0.42;
    animation: drift 16s ease-in-out infinite alternate;
}

.aurora-one {
    top: -60px;
    left: -100px;
    background: rgba(97, 132, 168, 0.32);
}

.aurora-two {
    right: -80px;
    bottom: -90px;
    background: rgba(219, 229, 241, 0.18);
    animation-delay: 3s;
}

@keyframes drift {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to { transform: translate3d(40px, -28px, 0) scale(1.08); }
}

@media (max-width: 960px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; }
    .page-header-inline { align-items: start; flex-direction: column; }
    .device-header { flex-direction: column; }
    .device-actions { justify-items: start; }
}

@media (max-width: 720px) {
    .content { padding: 20px; }
    th:nth-child(n+5), td:nth-child(n+5) { display: none; }
    .detail-list div { flex-direction: column; }
    .detail-list dd { text-align: left; }
    .mfa-setup { grid-template-columns: 1fr; }
    .install-actions { flex-direction: column; align-items: stretch; }
    .install-panel { max-width: none; }
    .login-branding { top: 20px; }
    .beltran-brand-name { font-size: 22px; }
    .beltran-portal-title { font-size: 18px; }
    .beltran-security-line {
        bottom: 14px;
        width: min(92vw, 620px);
    }
    .volume-head,
    .volume-meta {
        flex-direction: column;
        align-items: flex-start;
    }
}
