*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg:              #0d1117;
    --surface:         #161b27;
    --surface-2:       #1c2333;
    --surface-3:       #21283a;
    --border:          #30363d;
    --border-subtle:   #21262d;
    --accent:          #388bfd;
    --accent-hover:    #58a6ff;
    --accent-muted:    rgba(56,139,253,0.12);
    --success:         #3fb950;
    --success-muted:   rgba(63,185,80,0.12);
    --danger:          #f85149;
    --danger-muted:    rgba(248,81,73,0.12);
    --warning:         #d29922;
    --warning-muted:   rgba(210,153,34,0.12);
    --purple:          #8b5cf6;
    --purple-muted:    rgba(139,92,246,0.12);
    --orange:          #fb923c;
    --orange-muted:    rgba(251,146,60,0.12);
    --text-1:          #e6edf3;
    --text-2:          #8b949e;
    --text-3:          #484f58;
    --radius-sm:       5px;
    --radius:          8px;
    --radius-lg:       12px;
    --shadow:          0 2px 8px rgba(0,0,0,0.5);
    --shadow-lg:       0 16px 48px rgba(0,0,0,0.7);
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text-1);
    line-height: 1.5;
    min-height: 100vh;
    font-size: 14px;
}

/* ---- UTILITIES ---- */
.hidden { display: none !important; }

/* ---- LOGIN ---- */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at 50% 0%, rgba(56,139,253,0.07) 0%, var(--bg) 60%);
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header .login-icon {
    width: 42px;
    height: 42px;
    color: var(--accent);
    margin-bottom: 14px;
}

.login-header h1 {
    font-size: 21px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 5px;
}

.login-header p {
    color: var(--text-2);
    font-size: 13px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 0;
}

.form-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.form-group input {
    padding: 10px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-1);
    font-size: 14px;
    transition: border-color 0.15s;
    width: 100%;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.form-group input::placeholder {
    color: var(--text-3);
}

.login-btn {
    padding: 11px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 6px;
}

.login-btn:hover { background: var(--accent-hover); }

.error-message {
    background: var(--danger-muted);
    border: 1px solid rgba(248,81,73,0.4);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    text-align: center;
}

/* ---- DASHBOARD ---- */
.dashboard-container.hidden { display: none; }

.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 32px;
}

header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 32px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-left .header-icon {
    width: 19px;
    height: 19px;
    color: var(--accent);
}

header h1 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.device-count {
    font-size: 12px;
    color: var(--text-2);
    font-weight: 500;
    white-space: nowrap;
}

.device-count span {
    color: var(--accent);
    font-weight: 700;
}

.logout-btn {
    padding: 6px 14px;
    background: transparent;
    color: var(--text-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
}

.logout-btn:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: var(--danger-muted);
}

.logout-btn svg {
    width: 14px;
    height: 14px;
}

/* ---- MAIN CONTENT ---- */
.main-content { padding: 28px 0; }

.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.action-bar-left {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ---- BUTTONS ---- */
.btn-primary {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: background 0.15s;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
    background: var(--surface-2);
    color: var(--text-1);
    border: 1px solid var(--border);
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: all 0.15s;
}

.btn-secondary:hover {
    background: var(--surface-3);
    border-color: var(--text-2);
}

.btn-secondary-sm {
    background: var(--surface-2);
    color: var(--text-2);
    border: 1px solid var(--border);
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-secondary-sm:hover { background: var(--surface-3); }

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-success {
    background: var(--success);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ---- DEVICES CONTAINER ---- */
.devices-container {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    min-height: 400px;
}

/* ---- SEARCH BAR ---- */
.search-bar {
    position: relative;
    margin-bottom: 0;
}

.search-bar input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-1);
    transition: border-color 0.15s;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--accent);
}

.search-bar input::placeholder { color: var(--text-3); }

.search-bar .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--text-3);
    pointer-events: none;
}

/* ---- DEVICE TABLE ---- */
.devices-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.devices-table thead {
    border-bottom: 1px solid var(--border-subtle);
}

.devices-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-3);
}

.devices-table th:last-child { text-align: center; }

.devices-table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.1s;
}

.devices-table tbody tr:last-child { border-bottom: none; }
.devices-table tbody tr:hover { background: var(--surface-2); }
.devices-table tbody tr.inactive { opacity: 0.5; }

.devices-table td {
    padding: 12px 14px;
    vertical-align: middle;
}

.device-cell .device-name {
    font-weight: 600;
    color: var(--text-1);
    font-size: 13px;
    margin-bottom: 2px;
}

.device-cell .device-email {
    color: var(--text-2);
    font-size: 12px;
}

.device-type-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 3px;
    vertical-align: middle;
    margin-left: 6px;
    cursor: help;
    letter-spacing: 0.3px;
}

.device-type-badge.broker {
    background: var(--accent-muted);
    color: var(--accent-hover);
    border: 1px solid rgba(56,139,253,0.3);
}

.device-type-badge.broker-noazure {
    background: var(--warning-muted);
    color: var(--warning);
    border: 1px solid rgba(210,153,34,0.3);
    cursor: pointer;
}

.device-type-badge.office {
    background: var(--orange-muted);
    color: var(--orange);
    border: 1px solid rgba(251,146,60,0.3);
}

.user-cell {
    color: var(--text-1);
    font-size: 13px;
}

.notes-cell { max-width: 200px; }

.notes-display {
    font-size: 12px;
    color: var(--text-2);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    min-height: 20px;
    word-break: break-word;
}

.notes-display:hover { background: var(--surface-3); }
.notes-empty { color: var(--text-3); font-style: italic; }

.date-cell {
    color: var(--text-2);
    font-size: 12px;
    white-space: nowrap;
}

.expiry-cell .expiry-time {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-2);
    white-space: nowrap;
}

.expiry-cell .expiry-time.urgent {
    color: var(--danger);
    font-weight: 600;
}

.actions-cell { text-align: center; }

.action-buttons {
    display: flex;
    gap: 5px;
    justify-content: center;
}

.action-btn {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    background: transparent;
    padding: 0;
}

.action-btn:hover { transform: scale(1.1); }
.action-btn svg { display: block; }

.action-btn.sso {
    background: var(--success-muted);
    color: var(--success);
    border: 1px solid rgba(63,185,80,0.25);
}
.action-btn.sso:hover { background: rgba(63,185,80,0.2); }

.action-btn.refresh-token {
    background: rgba(34,211,238,0.08);
    color: #22d3ee;
    border: 1px solid rgba(34,211,238,0.2);
}
.action-btn.refresh-token:hover { background: rgba(34,211,238,0.16); }

.action-btn.mail {
    background: var(--accent-muted);
    color: var(--accent);
    border: 1px solid rgba(56,139,253,0.25);
}
.action-btn.mail:hover { background: rgba(56,139,253,0.2); }

.action-btn.reset {
    background: var(--surface-2);
    color: var(--text-2);
    border: 1px solid var(--border);
}
.action-btn.reset:hover { background: var(--surface-3); }

.action-btn.upgrade-ngc {
    background: var(--purple-muted);
    color: var(--purple);
    border: 1px solid rgba(139,92,246,0.25);
}
.action-btn.upgrade-ngc:hover { background: rgba(139,92,246,0.2); }

.action-btn.delete {
    background: var(--danger-muted);
    color: var(--danger);
    border: 1px solid rgba(248,81,73,0.25);
}
.action-btn.delete:hover { background: rgba(248,81,73,0.2); }

/* ---- STATUS PILLS ---- */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.status-pill::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.status-pill.active    { background: var(--success-muted); color: var(--success); }
.status-pill.inactive  { background: var(--danger-muted);  color: var(--danger); }
.status-pill.expiring  { background: var(--warning-muted); color: var(--warning); }
.status-pill.token-stale { background: var(--warning-muted); color: #e09427; }
.status-pill.password-changed { background: var(--orange-muted); color: var(--orange); }
.status-pill.device-disabled  { background: var(--warning-muted); color: var(--warning); }
.status-pill.key-missing      { background: var(--purple-muted);  color: var(--purple); }

.status-badge { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.status-badge.active   { background: var(--success-muted); color: var(--success); }
.status-badge.inactive { background: var(--danger-muted);  color: var(--danger); }
.status-badge.expiring { background: var(--warning-muted); color: var(--warning); }

.mfa-warning-badge {
    display: inline-block;
    margin-top: 3px;
    font-size: 10px;
    color: var(--warning);
    background: var(--warning-muted);
    border: 1px solid rgba(210,153,34,0.3);
    border-radius: 3px;
    padding: 1px 6px;
}

/* ---- EMPTY STATE ---- */
.empty-state {
    text-align: center;
    padding: 80px 20px;
}

.empty-icon {
    width: 44px;
    height: 44px;
    margin: 0 auto 16px;
    color: var(--text-3);
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-2);
    font-size: 13px;
}

/* ---- NO SEARCH RESULTS ---- */
.no-search-results {
    text-align: center;
    padding: 40px;
    color: var(--text-2);
    font-size: 13px;
}

/* ---- LOADING SPINNER ---- */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-2);
}

.loading-spinner .spinner {
    width: 30px;
    height: 30px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-bottom: 14px;
}

.loading-spinner p {
    font-size: 13px;
    color: var(--text-2);
}

/* ---- PAGINATION ---- */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0 0;
    border-top: 1px solid var(--border-subtle);
    margin-top: 12px;
    font-size: 12px;
}

.pagination-info { color: var(--text-2); }

.pagination-controls {
    display: flex;
    gap: 4px;
    align-items: center;
}

.page-btn {
    padding: 5px 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-1);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    min-width: 30px;
    transition: all 0.15s;
}

.page-btn:hover:not(:disabled) { background: var(--accent); color: white; border-color: var(--accent); }
.page-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.page-ellipsis {
    padding: 5px 6px;
    color: var(--text-3);
    font-size: 12px;
}

/* ---- MODAL ---- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal.hidden { display: none; }

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-large { max-width: 720px; }

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-2);
    padding: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

.close-btn:hover {
    background: var(--surface-2);
    color: var(--text-1);
}

.close-btn svg {
    width: 15px;
    height: 15px;
}

.modal-body { padding: 24px; }

/* ---- REGISTRATION MODAL ---- */
.registration-step.hidden { display: none; }
.device-code-container { text-align: center; }

.code-display {
    margin: 20px 0;
    padding: 28px;
    background: var(--surface-2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.user-code {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: 10px;
    color: var(--accent);
    font-family: 'Courier New', monospace;
}

.instructions {
    text-align: left;
    margin: 18px 0;
    padding: 14px 16px;
    background: rgba(56,139,253,0.06);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.instructions p {
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-2);
}

.instructions a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.polling-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
    color: var(--text-2);
    font-size: 13px;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.success-message {
    text-align: center;
    padding: 28px;
}

.success-icon {
    width: 60px;
    height: 60px;
    background: var(--success-muted);
    color: var(--success);
    border: 1px solid rgba(63,185,80,0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
}

.success-message h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.success-message p  { color: var(--text-2); font-size: 13px; margin-bottom: 20px; }

/* ---- SSO MODAL ---- */
.sso-status {
    padding: 10px 14px;
    background: rgba(56,139,253,0.07);
    border: 1px solid rgba(56,139,253,0.2);
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 13px;
    color: var(--accent);
}

.sso-step { margin-top: 14px; }
.sso-step h3 { margin-bottom: 8px; font-size: 15px; font-weight: 600; }
.sso-step p  { margin-bottom: 8px; color: var(--text-2); font-size: 13px; }

.sso-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.sso-device-info {
    font-family: monospace;
    font-size: 12px;
    color: var(--text-2);
}

.cookie-output { margin-bottom: 14px; }

.cookie-output textarea {
    width: 100%;
    min-height: 200px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Consolas', monospace;
    font-size: 12px;
    resize: vertical;
    background: var(--bg);
    color: var(--text-1);
}

/* ---- SETTINGS MODAL ---- */
.settings-section { margin-bottom: 0; }

.settings-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 7px;
}

.settings-section-title svg {
    width: 14px;
    height: 14px;
    color: var(--accent);
    flex-shrink: 0;
}

.settings-section-desc {
    font-size: 12px;
    color: var(--text-2);
    margin-bottom: 10px;
    line-height: 1.5;
}

.settings-divider {
    border: none;
    border-top: 1px solid var(--border-subtle);
    margin: 14px 0;
}

.mode-cards {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.mode-card {
    flex: 1;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: var(--surface-2);
}

.mode-card:hover { border-color: var(--text-2); }
.mode-card.selected-broker { border-color: var(--accent); background: var(--accent-muted); }
.mode-card.selected-office { border-color: var(--orange); background: var(--orange-muted); }
.mode-card input[type=radio] { display: none; }

.mode-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.mode-card-title svg { width: 15px; height: 15px; flex-shrink: 0; }

.mode-card-feature {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-2);
    margin-bottom: 3px;
}

.mode-card-feature.yes { color: var(--success); }
.mode-card-feature.no  { color: var(--text-3); }
.mode-card-feature svg { width: 11px; height: 11px; flex-shrink: 0; }

.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.toggle-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-1);
}

.toggle-row input[type=checkbox] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: var(--accent);
}

.proxy-mode-cards {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.proxy-mode-card {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: var(--surface-2);
    transition: border-color 0.15s;
}

.proxy-mode-card.selected { border-color: var(--accent); background: var(--accent-muted); }
.proxy-mode-card input[type=radio] { display: none; }

.proxy-mode-card-title {
    font-weight: 600;
    color: var(--text-1);
    font-size: 12px;
    margin-bottom: 3px;
}

.proxy-mode-card-desc { color: var(--text-2); font-size: 11px; }

.save-status {
    font-size: 12px;
    min-height: 16px;
    margin-bottom: 8px;
}

.proxy-list-container {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    margin-bottom: 12px;
    background: var(--surface-2);
}

/* ---- DEBUG CONSOLE ---- */
.debug-console {
    background: var(--bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    margin-top: 20px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 12px;
    overflow: hidden;
}

.debug-console.hidden { display: none; }

.debug-header {
    padding: 9px 16px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
}

.debug-header h3 {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.debug-log {
    padding: 12px 16px;
    max-height: 360px;
    overflow-y: auto;
}

.debug-entry {
    padding: 4px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.debug-timestamp { color: var(--text-3); font-size: 11px; }
.debug-message { color: var(--text-1); margin-top: 2px; }
.debug-message.error   { color: var(--danger); }
.debug-message.success { color: var(--success); }
.debug-message.warning { color: var(--warning); }

/* ---- SETTINGS SIDE DRAWER ---- */
.settings-panel {
    position: fixed;
    inset: 0;
    z-index: 500;
    visibility: hidden;
    pointer-events: none;
}
.settings-panel.open {
    visibility: visible;
    pointer-events: all;
}
.settings-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: pointer;
}
.settings-panel.open .settings-backdrop { opacity: 1; }

.settings-drawer {
    position: absolute;
    top: 0;
    right: 0;
    width: 420px;
    max-width: 100vw;
    height: 100dvh;
    background: var(--surface);
    border-left: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -8px 0 32px rgba(0,0,0,0.4);
}
.settings-panel.open .settings-drawer { transform: translateX(0); }

.settings-drawer-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.settings-drawer-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-1);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}
.settings-drawer-header h2 svg { width: 14px; height: 14px; color: var(--accent); flex-shrink: 0; }

.settings-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .container { padding: 0 16px; }
    header { padding: 0 16px; }
    .devices-container { padding: 14px; }
    .devices-table { font-size: 12px; }
    .devices-table th, .devices-table td { padding: 9px 10px; }
    .modal-content { width: 96%; }
    .mode-cards { flex-direction: column; }
    .action-buttons { flex-wrap: wrap; }
    .action-btn { width: 28px; height: 28px; }
    .pagination-controls { flex-wrap: wrap; justify-content: center; }
    .settings-drawer { width: 100vw; }
}

@keyframes spin { to { transform: rotate(360deg); } }

