:root {
    color-scheme: light;
    --bg: #eef3f1;
    --panel: #ffffff;
    --ink: #15201c;
    --muted: #5d6b66;
    --line: #d5e0db;
    --accent: #0c7a6a;
    --accent-soft: rgba(12, 122, 106, 0.12);
    --danger: #b42318;
    --online: #117a45;
    --offline: #8a8f94;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", sans-serif;
    color: var(--ink);
    background: linear-gradient(180deg, #f7fbf9 0%, var(--bg) 100%);
}

a {
    color: var(--accent);
    text-decoration: none;
}

.app-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    padding: 24px 18px;
    border-right: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(8px);
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 28px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--accent);
    color: white;
    font-weight: 700;
}

.brand small {
    display: block;
    color: var(--muted);
}

.sidebar nav {
    display: grid;
    gap: 8px;
}

.sidebar nav a {
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--ink);
}

.sidebar nav a.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.content {
    padding: 28px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.page-header h1 {
    margin: 0 0 8px;
    font-size: 2rem;
}

.page-header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.script-preview {
    margin-top: 16px;
}

.script-preview pre {
    margin: 8px 0 0;
    padding: 12px;
    border-radius: 10px;
    background: #102019;
    color: #d7ffe8;
    overflow: auto;
    max-height: 280px;
    font-size: 12px;
}

.eyebrow {
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
}

.lead, .muted {
    color: var(--muted);
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 16px 40px rgba(21, 32, 28, 0.05);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    margin-bottom: 8px;
}

.stat-card strong {
    font-size: 2rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.mono {
    font-family: Consolas, monospace;
    font-size: 0.92rem;
}

.status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
}

.status.online {
    background: rgba(17, 122, 69, 0.12);
    color: var(--online);
}

.status.offline {
    background: rgba(138, 143, 148, 0.16);
    color: var(--offline);
}

.status.connecting {
    background: rgba(12, 122, 106, 0.12);
    color: var(--accent);
}

.btn {
    border: 1px solid var(--line);
    background: white;
    color: var(--ink);
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
}

.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.btn.small {
    padding: 6px 10px;
    font-size: 0.85rem;
}

.btn.danger {
    color: var(--danger);
    border-color: rgba(180, 35, 24, 0.35);
    background: rgba(180, 35, 24, 0.06);
}

.btn.danger:hover {
    background: rgba(180, 35, 24, 0.12);
}

.inline-success {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 12px;
}

.actions-cell {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.form-panel .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}

label {
    display: grid;
    gap: 6px;
    font-size: 0.92rem;
}

input, select {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.error {
    color: var(--danger);
}

.success-panel {
    margin-bottom: 16px;
    border-color: rgba(17, 122, 69, 0.25);
    background: rgba(17, 122, 69, 0.06);
}

.token-code {
    display: inline-block;
    padding: 10px 14px;
    border-radius: 10px;
    background: #102019;
    color: #d7ffe8;
    font-size: 1.1rem;
}

.download-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.download-link-row {
    margin-bottom: 14px;
}

.download-link-row label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.download-link-copy {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.download-link-copy input {
    flex: 1 1 320px;
    min-width: 240px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    font-family: Consolas, monospace;
    font-size: 0.92rem;
}

.topology-panel {
    overflow: hidden;
}

.topology-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    color: var(--muted);
}

.topology-canvas {
    background: radial-gradient(circle at center, rgba(12, 122, 106, 0.08), transparent 60%);
    border: 1px dashed var(--line);
    border-radius: 16px;
    padding: 12px;
    min-height: 420px;
    position: relative;
}

.html-topology {
    overflow: hidden;
}

.topology-center {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.topology-spoke {
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 1;
}

.node-card {
    min-width: 120px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 2px solid var(--line);
    background: white;
    text-align: center;
    box-shadow: 0 8px 24px rgba(21, 32, 28, 0.08);
}

.node-card strong {
    display: block;
    margin-bottom: 4px;
}

.node-card span,
.node-card small {
    display: block;
    color: var(--muted);
    font-size: 0.85rem;
}

.node-card.gateway {
    border-color: var(--accent);
    background: rgba(12, 122, 106, 0.08);
}

.node-card.client.online {
    border-color: var(--online);
}

.node-card.client.offline {
    border-color: var(--offline);
}

.legend {
    display: flex;
    gap: 18px;
    margin-top: 12px;
    color: var(--muted);
}

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}

.dot.online { background: var(--online); }
.dot.offline { background: var(--offline); }
.dot.gateway { background: var(--accent); }

.inline-select {
    display: grid;
    gap: 6px;
}

.settings-tabs {
    padding-top: 0;
}

.tab-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 20px 0;
    border-bottom: 1px solid var(--line);
}

.tab {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 12px 16px;
    border-radius: 12px 12px 0 0;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
}

.tab.active {
    background: rgba(12, 122, 106, 0.10);
    color: var(--accent);
}

.tab-panel {
    padding: 20px;
}

.checks-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 12px 0 18px;
}

.facts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.provider-picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin: 16px 0 20px;
}

.provider-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 16px 18px;
    border-radius: 16px;
    border: 2px solid var(--line);
    background: #fafcfb;
    color: inherit;
    text-align: left;
    cursor: pointer;
    font: inherit;
    text-decoration: none;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

a.provider-card:hover {
    color: inherit;
}

.provider-card strong {
    font-size: 1.05rem;
}

.provider-card span {
    color: var(--muted);
    font-size: 0.92rem;
}

.provider-card small {
    color: var(--accent);
    font-size: 0.82rem;
    margin-top: 4px;
}

.provider-card:hover {
    border-color: rgba(12, 122, 106, 0.35);
}

.provider-card.active {
    border-color: var(--accent);
    background: rgba(12, 122, 106, 0.08);
    box-shadow: 0 0 0 1px rgba(12, 122, 106, 0.12);
}

.fact-card {
    padding: 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fafcfb;
}

.fact-card span {
    display: block;
    color: var(--muted);
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.hint-box {
    margin: 16px 0;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid rgba(12, 122, 106, 0.18);
    background: rgba(12, 122, 106, 0.06);
}

.hint-box p {
    margin: 6px 0 0;
    color: var(--muted);
}

.status-panel.ok {
    border-color: rgba(17, 122, 69, 0.25);
    background: rgba(17, 122, 69, 0.08);
}

.status-panel.warn {
    border-color: rgba(217, 119, 6, 0.25);
    background: rgba(217, 119, 6, 0.08);
}

.status-panel.bad {
    border-color: rgba(180, 35, 24, 0.25);
    background: rgba(180, 35, 24, 0.08);
}

.inline-success {
    margin-top: 12px;
}

.monitor-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.monitor-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.live-indicator {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
}

.live-indicator.live-on {
    color: var(--online);
    border-color: rgba(17, 122, 69, 0.35);
    background: rgba(17, 122, 69, 0.08);
}

.live-indicator.live-off {
    color: var(--muted);
}

.monitor-local-node {
    margin-bottom: 16px;
}

.monitor-tree {
    padding: 0;
    overflow: hidden;
}

.monitor-network + .monitor-network {
    border-top: 1px solid var(--line);
}

.monitor-network-header,
.monitor-node-row,
.monitor-client {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    gap: 12px;
    align-items: center;
    width: 100%;
    text-align: left;
}

.monitor-network-header {
    padding: 14px 18px;
    border: none;
    background: transparent;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.monitor-network-header:hover {
    background: rgba(12, 122, 106, 0.05);
}

.monitor-node-row {
    padding: 14px 18px;
}

.monitor-client {
    grid-template-columns: 32px auto 1fr auto;
    padding: 10px 18px 10px 52px;
    border-top: 1px solid rgba(213, 224, 219, 0.7);
    background: rgba(247, 251, 249, 0.65);
}

.monitor-client.empty-client {
    grid-template-columns: 1fr auto;
    padding-left: 52px;
}

.monitor-chevron {
    display: inline-block;
    width: 14px;
    color: var(--muted);
    transition: transform 0.15s ease;
}

.monitor-chevron.expanded {
    transform: rotate(90deg);
}

.monitor-status-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 28px;
}

.presence-dot.wg-online {
    background: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.15);
}

.presence-dot.wg-offline {
    background: #f3f4f6;
    border: 2px solid #8a8f94;
}

.presence-dot.wg-unknown {
    background: #d9d9d9;
    border: 1px solid #bdbdbd;
}

.presence-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    background: var(--offline);
}

.presence-dot.online {
    background: var(--online);
    box-shadow: 0 0 0 3px rgba(17, 122, 69, 0.15);
}

.presence-dot.connecting {
    background: #d97706;
}

.monitor-network-name {
    font-weight: 700;
}

.monitor-network-count {
    font-weight: 700;
    color: var(--accent);
    min-width: 48px;
    text-align: right;
}

.monitor-network-subnet {
    font-size: 12px;
}

.monitor-node-main,
.monitor-client-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.monitor-node-meta,
.monitor-client-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    font-size: 12px;
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--line);
    }
}

.warning {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(180, 35, 24, 0.08);
    color: var(--danger);
    font-size: 14px;
}

.mobile-qr-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.wireguard-qr {
    width: 280px;
    height: 280px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: white;
    padding: 12px;
}

.mobile-qr-actions {
    display: grid;
    gap: 10px;
    align-content: start;
    min-width: 240px;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(12, 122, 106, 0.16), transparent 34%),
        radial-gradient(circle at bottom right, rgba(12, 122, 106, 0.1), transparent 28%),
        linear-gradient(180deg, #f7fbf9 0%, var(--bg) 100%);
}

.login-panel {
    width: min(440px, 100%);
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 32px;
    box-shadow: 0 24px 60px rgba(21, 32, 28, 0.12);
}

.login-brand {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.login-brand strong {
    display: block;
    font-size: 1.08rem;
}

.login-brand small {
    display: block;
    color: var(--muted);
    margin-top: 2px;
}

.login-intro {
    margin-bottom: 8px;
}

.login-intro h1 {
    margin: 4px 0 8px;
    font-size: 1.8rem;
}

.login-form {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

.login-field {
    display: grid;
    gap: 8px;
    font-size: 0.92rem;
    font-weight: 600;
}

.login-field input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    font: inherit;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-field input:focus {
    outline: none;
    border-color: rgba(12, 122, 106, 0.55);
    box-shadow: 0 0 0 4px rgba(12, 122, 106, 0.12);
}

.login-remember {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 2px 0 4px;
    font-weight: 500;
}

.login-submit {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    font-weight: 600;
    margin-top: 4px;
}

.login-submit:disabled {
    opacity: 0.72;
    cursor: wait;
}

.login-error {
    margin: 14px 0 0;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(180, 35, 24, 0.08);
    color: var(--danger);
    border: 1px solid rgba(180, 35, 24, 0.18);
}

.login-hint {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    font-size: 0.9rem;
    text-align: center;
}

.login-hint code {
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 24px;
}

.user-chip {
    display: grid;
    gap: 10px;
    padding: 12px;
    border-radius: 12px;
    background: var(--accent-soft);
}

.user-label {
    font-size: 0.92rem;
    word-break: break-word;
}

.role-picker {
    margin: 16px 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
}

.role-picker legend {
    padding: 0 6px;
    font-weight: 600;
}

.role-picker .checkbox {
    display: inline-flex;
    margin-right: 16px;
    margin-bottom: 8px;
}

.current-user-row {
    background: rgba(12, 122, 106, 0.05);
}

.twofa-setup-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 20px;
    align-items: start;
    margin-bottom: 18px;
}

.twofa-shared-key {
    display: inline-block;
    margin-top: 8px;
    font-size: 0.95rem;
    word-break: break-word;
}

.recovery-code-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px 16px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.recovery-code-list code {
    display: block;
    padding: 8px 10px;
    border-radius: 8px;
    background: #102019;
    color: #d7ffe8;
}

.sidebar {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.network-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0 6px 4px 0;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
}

.network-chip .btn.tiny {
    padding: 0 4px;
    min-width: 1.4rem;
    line-height: 1.2;
}

.monitor-grant-list {
    margin-top: 12px;
    display: grid;
    gap: 6px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
