:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-sidebar: #0f172a;
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-sidebar: #cbd5e1;
    --text-sidebar-active: #ffffff;
    --border-color: #e2e8f0;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-sidebar: #020617;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-sidebar: #94a3b8;
    --text-sidebar-active: #ffffff;
    --border-color: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3);
}

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

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

.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-header .logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
    font-weight: 700;
}

.sidebar-header h1 {
    font-size: 18px;
    font-weight: 700;
    color: white;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(148,163,184,0.6);
    padding: 0 12px;
    margin-bottom: 8px;
    font-weight: 600;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-sidebar);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
    margin-bottom: 2px;
}

.nav-link:hover {
    background: rgba(255,255,255,0.06);
    color: white;
}

.nav-link.active {
    background: rgba(59,130,246,0.15);
    color: var(--text-sidebar-active);
}

.nav-link svg {
    width: 20px;
    height: 20px;
    opacity: 0.7;
}

.nav-link.active svg {
    opacity: 1;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
}

.topnav {
    height: 64px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.topnav-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topnav-left h2 {
    font-size: 20px;
    font-weight: 600;
}

.topnav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    gap: 8px;
    min-width: 240px;
}

.search-box input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    color: var(--text-primary);
    width: 100%;
}

.search-box input::placeholder {
    color: var(--text-secondary);
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-icon:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
}

.user-menu:hover { background: var(--bg-secondary); }

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: 600;
}

.user-info { font-size: 13px; }
.user-info .name { font-weight: 600; color: var(--text-primary); }
.user-info .role { color: var(--text-secondary); font-size: 12px; }

/* Page Content */
.page-content {
    padding: 32px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.card-body { padding: 24px; }

/* Stat Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.stat-card .stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.blue { background: rgba(59,130,246,0.1); color: #3b82f6; }
.stat-icon.green { background: rgba(34,197,94,0.1); color: #22c55e; }
.stat-icon.purple { background: rgba(139,92,246,0.1); color: #8b5cf6; }
.stat-icon.orange { background: rgba(245,158,11,0.1); color: #f59e0b; }

.stat-card .stat-value {
    font-size: 30px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-change {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-change.up { color: #22c55e; }
.stat-change.down { color: #ef4444; }

/* Tables */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

table td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

table tr:hover { background: var(--bg-secondary); }
table tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
    gap: 6px;
}

.badge-success { background: rgba(34,197,94,0.1); color: #16a34a; }
.badge-warning { background: rgba(245,158,11,0.1); color: #d97706; }
.badge-danger { background: rgba(239,68,68,0.1); color: #dc2626; }
.badge-info { background: rgba(59,130,246,0.1); color: #2563eb; }
.badge-gray { background: rgba(100,116,139,0.1); color: #64748b; }

.badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.badge-success .dot { background: #22c55e; }
.badge-warning .dot { background: #f59e0b; }
.badge-danger .dot { background: #ef4444; }
.badge-info .dot { background: #3b82f6; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.4;
}

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

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover { background: var(--border-color); }

.btn-danger {
    background: rgba(239,68,68,0.1);
    color: #dc2626;
    border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-success {
    background: rgba(34,197,94,0.1);
    color: #16a34a;
    border: 1px solid rgba(34,197,94,0.2);
}
.btn-success:hover { background: rgba(34,197,94,0.2); }

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

.btn-group {
    display: flex;
    gap: 8px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23475569' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-help {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--text-secondary);
}

.pagination-links {
    display: flex;
    gap: 4px;
}

.pagination-links a, .pagination-links span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.pagination-links a:hover { background: var(--bg-secondary); }
.pagination-links .active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 50;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-backdrop.show { display: flex; }

.modal {
    background: var(--bg-card);
    border-radius: 16px;
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}

.modal-header {
    padding: 24px 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 { font-size: 18px; font-weight: 600; }

.modal-body { padding: 24px; }

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Toast Messages */
.messages {
    position: fixed;
    top: 80px;
    right: 32px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message {
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 400px;
}

.message-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.message-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.message-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.message-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Grid Layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }

/* Detail Row */
.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-secondary); font-weight: 500; }
.detail-value { color: var(--text-primary); font-weight: 500; }
.detail-value code { background: var(--bg-secondary); padding: 2px 8px; border-radius: 4px; font-size: 12px; }

/* Checkbox List */
.checkbox-list { display: flex; flex-direction: column; gap: 8px; }
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}
.checkbox-item:hover { background: var(--bg-secondary); }
.checkbox-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-secondary);
}

.empty-state svg { margin: 0 auto 16px; opacity: 0.4; }
.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; color: var(--text-primary); }
.empty-state p { font-size: 14px; }

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

.status-dot.online { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.4); }
.status-dot.offline { background: #94a3b8; }

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    background: #ffffff;
}

[data-theme="dark"] .login-page {
    background: #0f172a;
}

/* Left branding panel */
.login-brand-panel {
    flex: 0 0 480px;
    background: linear-gradient(160deg, #0f172a 0%, #1e293b 40%, #1a1a3e 70%, #312e81 100%);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 48px;
    position: relative;
    overflow: hidden;
}

.login-brand-panel::before {
    content: '';
    position: absolute;
    top: -120px;
    right: -120px;
    width: 360px;
    height: 360px;
    background: radial-gradient(circle, rgba(99,102,241,0.15) 0%, transparent 70%);
    border-radius: 50%;
}

.login-brand-panel::after {
    content: '';
    position: absolute;
    bottom: -80px;
    left: -80px;
    width: 280px;
    height: 280px;
    background: radial-gradient(circle, rgba(59,130,246,0.12) 0%, transparent 70%);
    border-radius: 50%;
}

.login-brand-content {
    position: relative;
    z-index: 1;
}

.login-brand-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 32px;
    box-shadow: 0 12px 24px rgba(59,130,246,0.3);
}

.login-brand-title {
    font-size: 36px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.login-brand-tagline {
    font-size: 16px;
    color: rgba(203,213,225,0.8);
    font-weight: 400;
    margin-bottom: 48px;
    line-height: 1.6;
}

.login-brand-features {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.login-feature {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(203,213,225,0.9);
    font-size: 14px;
    font-weight: 500;
}

.login-feature svg {
    color: #60a5fa;
    flex-shrink: 0;
}

.login-brand-footer {
    position: relative;
    z-index: 1;
    font-size: 12px;
    color: rgba(148,163,184,0.6);
    border-top: 1px solid rgba(255,255,255,0.06);
    padding-top: 20px;
}

.login-brand-footer strong {
    color: rgba(203,213,225,0.8);
    font-weight: 600;
}

/* Right form panel */
.login-form-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 50%, #f5f3ff 100%);
}

[data-theme="dark"] .login-form-panel {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}

.login-card {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.login-card-inner {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}

.login-logo-mobile {
    display: none;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 12px;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 8px 16px rgba(59,130,246,0.3);
}

.login-card h1 {
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.login-card p.subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}

.login-error {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fef2f2;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 13px;
    border: 1px solid #fecaca;
}

[data-theme="dark"] .login-error {
    background: rgba(239,68,68,0.1);
    color: #fca5a5;
    border-color: rgba(239,68,68,0.2);
}

.login-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.login-input-wrap svg {
    position: absolute;
    left: 14px;
    pointer-events: none;
    z-index: 1;
}

.login-input-wrap .form-control {
    padding-left: 42px;
}

.login-btn {
    width: 100%;
    height: 46px;
    justify-content: center;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 10px;
    margin-top: 8px;
    transition: all 0.2s ease;
}

.login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(59,130,246,0.35);
}

.login-forgot {
    text-align: center;
    margin-top: 20px;
}

.login-forgot a {
    color: var(--accent);
    font-size: 13px;
    text-decoration: none;
    font-weight: 500;
}

.login-forgot a:hover {
    text-decoration: underline;
}

/* Contact section under the card */
.login-contact {
    margin-top: 24px;
    padding: 20px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.login-contact-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.login-contact-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-contact-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.login-contact-item svg {
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--accent);
}

/* Responsive: collapse brand panel on smaller screens */
@media (max-width: 960px) {
    .login-brand-panel {
        display: none;
    }
    .login-logo-mobile {
        display: flex;
    }
    .login-form-panel {
        padding: 24px 16px;
    }
}

/* Sidebar logo image */
.sidebar-logo-img {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: contain;
}

/* Branding settings page */
.branding-preview-area {
    margin-bottom: 12px;
}

.branding-current {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.branding-thumb {
    width: 120px;
    height: 60px;
    border-radius: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.branding-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.branding-thumb-sm {
    width: 48px;
    height: 48px;
}

.branding-current-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.branding-filename {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-all;
}

.branding-remove {
    font-size: 12px;
    color: var(--danger);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.branding-remove input {
    accent-color: var(--danger);
}

.branding-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px;
    background: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 13px;
}

.branding-upload-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.branding-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    white-space: nowrap;
}

/* Device grid for playback */
.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.device-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s;
}

.device-card:hover { box-shadow: var(--shadow-md); }

.device-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.device-card-header h4 {
    font-size: 15px;
    font-weight: 600;
}

/* Progress bar */
.progress-bar {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.progress-bar .fill.blue { background: #3b82f6; }
.progress-bar .fill.green { background: #22c55e; }
.progress-bar .fill.orange { background: #f59e0b; }

/* Detail info */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.info-item label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-item .value {
    font-size: 15px;
    font-weight: 600;
    margin-top: 4px;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .form-row { grid-template-columns: 1fr; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    min-width: 180px;
    padding: 4px;
    display: none;
    z-index: 10;
}

.dropdown-menu.show { display: block; }

.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 14px;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 6px;
}

.dropdown-menu a:hover { background: var(--bg-secondary); }
.dropdown-menu .divider { height: 1px; background: var(--border-color); margin: 4px 0; }

/* ========== Kill Switch ========== */
.kill-switch-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    border: 2px solid #dc2626;
    border-radius: 8px;
    background: transparent;
    color: #dc2626;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.kill-switch-btn:hover {
    background: #dc2626;
    color: #fff;
}
.kill-switch-btn.kill-switch-active {
    background: #dc2626;
    color: #fff;
    animation: kill-switch-pulse 1.5s ease-in-out infinite;
    border-color: #dc2626;
}
.kill-switch-btn.kill-switch-active:hover {
    background: #16a34a;
    border-color: #16a34a;
}

@keyframes kill-switch-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

.kill-switch-banner {
    background: #dc2626;
    color: #fff;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
}
