:root {
    --bg: #f3f6f4;
    --surface: #ffffff;
    --ink: #13231b;
    --muted: #6d7b72;
    --line: #dde7df;
    --green: #178a4b;
    --gold: #f2b84b;
    --blue: #2477b3;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
}

.sidebar {
    background: #10251a;
    color: #e8f4ed;
    padding: 24px;
}

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

.brand-mark {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--green), var(--gold));
    color: #fff;
    font-weight: 800;
}

.brand small,
.topbar p,
.metric-card small,
.panel-title span,
.status-row {
    color: var(--muted);
}

.sidebar .brand small {
    color: #a8c3b2;
    display: block;
}

.sidebar .nav-link {
    color: #cde3d5;
    border-radius: 8px;
    margin-bottom: 6px;
    padding: 10px 12px;
}

.sidebar .nav-link:hover {
    background: rgba(255,255,255,.09);
    color: #fff;
}

.main {
    padding: 28px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-bottom: 22px;
}

.topbar h1 {
    font-size: 28px;
    line-height: 1.2;
    margin: 0 0 4px;
}

.user-chip,
.mode-pill {
    border-radius: 999px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    white-space: nowrap;
}

.status-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.mode-pill.demo {
    color: #815313;
    background: #fff4dc;
    border-color: #f5d188;
}

.mode-pill.live {
    color: #0d6a38;
    background: #e3f7eb;
    border-color: #a8e1bf;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.metric-card,
.panel,
.installer-panel,
.login-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 45px rgba(16, 37, 26, .06);
}

.metric-card {
    padding: 18px;
}

.metric-card span {
    display: block;
    color: var(--muted);
    font-size: 14px;
}

.metric-card strong {
    display: block;
    font-size: 34px;
    line-height: 1.1;
    margin: 10px 0 4px;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
    gap: 16px;
    margin-bottom: 16px;
}

.panel {
    padding: 20px;
}

.panel.narrow {
    max-width: 860px;
}

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

.panel-title h2,
.install-grid h2 {
    font-size: 18px;
    margin: 0;
}

.flow {
    display: grid;
    gap: 10px;
}

.flow div {
    display: flex;
    justify-content: space-between;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.connector-section {
    border-top: 1px solid var(--line);
    padding-top: 14px;
    margin-top: 4px;
}

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

.connector-section p {
    color: var(--muted);
    margin: 0;
}

.settings-dump {
    max-height: 360px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: rgba(0, 0, 0, .03);
    font-size: 12px;
}

.login-body,
.installer-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(rgba(243, 246, 244, .86), rgba(243, 246, 244, .96)),
        url("https://images.unsplash.com/photo-1509391366360-2e959784a276?auto=format&fit=crop&w=1600&q=80") center/cover;
}

.login-panel,
.installer-panel {
    width: min(100%, 520px);
    padding: 28px;
}

.installer-panel {
    width: min(100%, 860px);
}

.login-brand {
    color: var(--ink);
}

.login-brand small {
    display: block;
}

.eyebrow {
    color: var(--green);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: .08em;
}

.install-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.install-grid h2,
.install-grid button,
.install-grid .alert {
    grid-column: 1 / -1;
}

[data-bs-theme="dark"] body {
    --bg: #101512;
    --surface: #18211c;
    --ink: #edf7f0;
    --muted: #a9b9af;
    --line: #2e4236;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: static;
    }
    .metric-grid,
    .content-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 640px) {
    .main {
        padding: 18px;
    }
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }
    .metric-grid,
    .content-grid,
    .install-grid {
        grid-template-columns: 1fr;
    }
}
