:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-hover: #232736;
    --border: #2a2e3d;
    --text: #e4e4e7;
    --text-dim: #8b8d98;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --danger: #ef4444;
    --danger-hover: #f87171;
    --success: #22c55e;
    --warning: #f59e0b;
    --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* Header */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

header .subtitle {
    color: var(--text-dim);
    font-size: 14px;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Auth Section */
.auth-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    margin-bottom: 24px;
}

.auth-section h2 {
    margin-bottom: 12px;
    font-size: 20px;
}

.auth-section p {
    color: var(--text-dim);
    margin-bottom: 20px;
    line-height: 1.6;
}

.auth-section ol {
    text-align: left;
    max-width: 500px;
    margin: 0 auto 20px;
    color: var(--text-dim);
    line-height: 1.8;
}

.auth-section ol code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

/* Inputs */
input[type="text"], input[type="password"] {
    width: 100%;
    max-width: 500px;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

input:focus {
    border-color: var(--accent);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Device List */
.device-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.device-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    transition: background 0.2s;
}

.device-card:hover {
    background: var(--surface-hover);
}

.device-info {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.device-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.device-details h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-meta {
    font-size: 12px;
    color: var(--text-dim);
    display: flex;
    gap: 12px;
}

.device-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

/* Status indicators */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--text-dim); }
.status-dot.paused { background: var(--warning); }

.device-card.paused {
    opacity: 0.6;
    border-color: var(--warning);
}

/* Toggle switch */
.toggle {
    position: relative;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--success);
    border-radius: 24px;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

.toggle input:checked + .toggle-slider {
    background: var(--warning);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* Section headers */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.device-count {
    color: var(--text-dim);
    font-size: 14px;
}

/* Loading */
.loading {
    text-align: center;
    padding: 48px;
    color: var(--text-dim);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 100;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }

/* Responsive */
@media (max-width: 600px) {
    .device-card {
        padding: 12px 14px;
    }
    .device-meta {
        flex-direction: column;
        gap: 2px;
    }
}
