:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-soft: #f1f5f9;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --primary: #10b981;
    --primary-dark: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    color: var(--text);
    background: var(--bg);
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
input, button, textarea, select {
    font: inherit;
}
input {
    width: 100%;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fff;
    margin-top: 0.35rem;
}
label {
    display: block;
    font-size: 0.95rem;
    color: var(--muted);
}
button {
    cursor: pointer;
    border: none;
    border-radius: 12px;
    padding: 0.85rem 1.1rem;
}
code {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    border-radius: 8px;
    background: #0f172a;
    color: #d1fae5;
}
.app-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}
.sidebar {
    background: #0f172a;
    color: #cbd5e1;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #10b981, #0f766e);
    color: white;
    font-weight: 800;
}
.brand small, .cell-muted, .muted, .label { color: var(--muted); }
.nav { display: grid; gap: 0.5rem; }
.nav-link {
    padding: 0.9rem 1rem;
    border-radius: 14px;
    transition: 0.2s ease;
}
.nav-link:hover, .nav-link.is-active {
    background: rgba(16, 185, 129, 0.15);
    color: #d1fae5;
}
.sidebar-footer { margin-top: auto; display: grid; gap: 1rem; }
.user-badge {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 1rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
}
.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #10b981;
    color: white;
    font-weight: 700;
}
.content {
    padding: 2rem;
}
.topbar h1, .section-header h2, .card-header h2, .login-card h1 { margin: 0; }
.topbar p, .section-header p, .card-header p, .login-card p { color: var(--muted); }
.stack-xl { display: grid; gap: 1.5rem; }
.stack-lg { display: grid; gap: 1rem; }
.grid { display: grid; gap: 1.5rem; }
.two-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.card, .stat-card, .login-card, .modal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
}
.card, .login-card, .modal-card, .stat-card { padding: 1.25rem; }
.card.subtle { background: var(--surface-soft); box-shadow: none; }
.stat-card strong { font-size: 2rem; display: block; margin-top: 0.5rem; }
.section-header, .card-header, .modal-header, .actions-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 1rem 0.75rem; border-bottom: 1px solid var(--border); }
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 700;
    text-transform: capitalize;
}
.badge-connected { background: #dcfce7; color: #166534; }
.badge-pending_qr { background: #fef3c7; color: #92400e; }
.badge-starting { background: #dbeafe; color: #1d4ed8; }
.badge-stopped { background: #e5e7eb; color: #374151; }
.badge-disconnected { background: #fee2e2; color: #991b1b; }
.badge-failed { background: #fecaca; color: #991b1b; }
.primary-button {
    background: var(--primary);
    color: white;
}
.primary-button:hover { background: var(--primary-dark); }
.ghost-button {
    background: var(--surface-soft);
    color: var(--text);
}
.danger-button {
    background: var(--danger);
    color: white;
}
.danger-button:hover { background: #b91c1c; }
.btn-sm { padding: 0.45rem 0.75rem; font-size: 0.85rem; }
.flash {
    padding: 1rem 1.1rem;
    border-radius: 16px;
    font-weight: 600;
    margin-bottom: 1rem;
}
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }
.event-list { display: grid; gap: 1rem; }
.event-item {
    display: flex;
    gap: 0.85rem;
    padding: 0.85rem;
    border-radius: 18px;
    background: var(--surface-soft);
}
.event-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--primary);
    margin-top: 0.35rem;
}
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
}
.login-card {
    width: min(100%, 480px);
    display: grid;
    gap: 1.25rem;
}
.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.8rem;
    color: var(--primary-dark);
    font-weight: 700;
}
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: grid;
    place-items: center;
    padding: 1rem;
    overflow-y: auto;
    align-items: start;
}
.modal-card {
    width: min(100%, 720px);
    margin: auto;
    max-height: calc(100dvh - 2rem);
    display: flex;
    flex-direction: column;
    padding: 0;
}
.modal-wide { width: min(100%, 1020px); }
.modal-grid { align-items: start; }
.modal-header { padding: .875rem 1.25rem; flex-shrink: 0; border-bottom: 1px solid var(--border); }
.modal-body { overflow-y: auto; flex: 1; padding: 1.25rem; }
.qr-wrap {
    padding: 1rem;
    background: white;
    border-radius: 18px;
    width: fit-content;
}
.qr-image {
    width: 240px;
    height: 240px;
    object-fit: cover;
}
.secret-box {
    padding: 1rem;
    border-radius: 16px;
    background: #0f172a;
    color: #d1fae5;
}
.settings-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.list-clean {
    margin: 0;
    padding-left: 1.1rem;
    display: grid;
    gap: 0.6rem;
}
@media (max-width: 960px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { padding-bottom: 0; }
    .two-cols, .three-cols, .stats-grid, .settings-grid { grid-template-columns: 1fr; }
}
