/* ================================================================
   LimpiaNet Cloud Dashboard - Modern Styles
   ================================================================ */

/* CSS Variables for consistent theming */
:root {
    /* Primary Colors */
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --primary-200: #bfdbfe;
    --primary-300: #93c5fd;
    --primary-400: #60a5fa;
    --primary-500: #3b82f6;
    --primary-600: #2563eb;
    --primary-700: #1d4ed8;
    --primary-800: #1e40af;
    
    /* Success Colors */
    --success-50: #f0fdf4;
    --success-500: #22c55e;
    --success-600: #16a34a;
    
    /* Warning Colors */
    --warning-50: #fffbeb;
    --warning-500: #f59e0b;
    --warning-600: #d97706;

    /* Idle Colors */
    --idle-50: #fefce8;
    --idle-500: #d4b13c;
    --idle-600: #8a7a2f;
    
    /* Error Colors */
    --error-50: #fef2f2;
    --error-500: #ef4444;
    --error-600: #dc2626;
    
    /* Neutral Colors */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Semantic Colors */
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-focus: #3b82f6;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: var(--spacing-lg);
}

/* Header Styles */
.app-header {
    background: linear-gradient(135deg, #1a2a4a 0%, #2c3e50 100%);
    color: white;
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Logo */
.app-logo-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-logo-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: linear-gradient(135deg, #1a2a4a 0%, #2563eb 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(37,99,235,.4);
    border: 1px solid rgba(255,255,255,.15);
    flex-shrink: 0;
}

.app-logo-name {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.header-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.lang-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(6px);
}

.lang-toggle button {
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.04em;
    padding: 7px 9px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.lang-toggle button.active {
    background: #ffffff;
    color: var(--primary-700);
    box-shadow: var(--shadow-sm);
}

.lang-toggle button:not(.active):hover {
    background: rgba(255, 255, 255, 0.16);
}

/* Status pill in header */
.status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: rgba(255,255,255,0.85);
    background: rgba(255,255,255,0.1);
    padding: 4px 12px;
    border-radius: var(--radius-full);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
    position: relative;
}

.status-dot-animated::before {
    content: "";
    position: absolute;
    inset: 0;
    background: inherit;
    border-radius: inherit;
    opacity: 0.6;
    animation: status-pulse 2s ease-out infinite;
    animation-delay: var(--pulse-delay, 0s);
}

@keyframes status-pulse {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    25% {
        transform: scale(2.8);
        opacity: 0;
    }
    100% {
        transform: scale(2.8);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .status-dot-animated::before {
        animation: none;
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-dot.running {
    background-color: var(--success-500);
    box-shadow: 0 0 6px var(--success-500);
    animation: pulse 2s infinite;
}

.status-dot.stopped {
    background-color: var(--error-500);
}

.status-dot.loading {
    background-color: var(--warning-500);
    animation: pulse 1s infinite;
}

/* Account badge */
.account-badge {
    font-size: 11px;
    color: rgba(255,255,255,0.7);
    background: rgba(255,255,255,0.12);
    padding: 4px 12px;
    border-radius: var(--radius-full);
}

/* Lock / logout button */
.lock-btn {
    padding: 5px 14px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255,255,255,0.3);
    background: transparent;
    color: #fff;
    font-size: 11px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: var(--transition-fast);
}

.lock-btn:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.6);
}

.setup-form .lang-toggle {
    align-self: flex-end;
    margin-bottom: 16px;
    background: var(--gray-100);
    border-color: var(--gray-200);
    backdrop-filter: none;
}

.setup-form .lang-toggle button {
    color: var(--text-secondary);
}

.setup-form .lang-toggle button.active {
    background: #ffffff;
    color: var(--primary-700);
}

.account-deletion-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    padding: 16px 18px;
    border: 1px solid #fcd34d;
    border-radius: 12px;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    box-shadow: var(--shadow-sm);
}

.account-deletion-banner-title {
    font-size: 15px;
    font-weight: 700;
    color: #92400e;
}

.account-deletion-banner-copy {
    margin-top: 4px;
    color: #78350f;
    font-size: 13px;
}

.account-deletion-banner-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.account-delete-modal {
    max-width: 640px;
}

.account-delete-warning {
    padding: 14px 16px;
    border-radius: 10px;
    background: #fff7ed;
    border: 1px solid #fdba74;
    color: #9a3412;
    margin-bottom: 14px;
}

.account-delete-warning p {
    margin-top: 6px;
    color: #7c2d12;
}

.account-delete-block {
    margin-bottom: 14px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

.account-delete-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.account-delete-list {
    margin: 0;
    padding-left: 18px;
    color: var(--text-secondary);
    font-size: 13px;
}

.account-delete-list li {
    margin: 4px 0;
}

.account-delete-phrase {
    margin: 8px 0 12px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #0f172a;
    color: #f8fafc;
    font-family: "JetBrains Mono", "Fira Code", monospace;
    white-space: pre-wrap;
}

.account-delete-help {
    color: var(--text-secondary);
    font-size: 12px;
}

@media (max-width: 720px) {
    .account-deletion-banner {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Navigation — browser-tab style */
.app-nav {
    background: linear-gradient(180deg, #243550 0%, #2c3e50 100%);
    padding: 8px 8px 0;
}

.tab-strip {
    display: flex;
    align-items: flex-end;
    position: relative;
}

.tab-baseline {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: #f8fafc;
    z-index: 0;
}

.nav-tab {
    position: relative;
    z-index: 1;
    padding: 8px 20px;
    min-width: 100px;
    background: rgba(255,255,255,0.07);
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    color: rgba(255,255,255,0.55);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 150ms ease;
    margin-right: 2px;
}

.nav-tab:hover {
    color: rgba(255,255,255,0.85);
    background: rgba(255,255,255,0.12);
}

.nav-tab.active {
    background: #f8fafc;
    color: #1e293b;
    border-color: rgba(0,0,0,0.08);
    z-index: 3;
    font-weight: 600;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.12);
}

/* Legacy nav-button kept for compatibility */
.nav-button {
    padding: var(--spacing-md) var(--spacing-lg);
    background: none;
    border: none;
    color: rgba(255,255,255,0.55);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    transition: var(--transition-base);
}

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

.nav-button.active {
    color: white;
    border-bottom: 2px solid var(--primary-500);
    background-color: rgba(59, 130, 246, 0.1);
}

/* Main Content Styles */
.app-main {
    background-color: var(--background);
    min-height: calc(100vh - 110px);
    padding: 0;
    margin-top: 0;
}

.error-message {
    background-color: var(--error-50);
    color: var(--error-600);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius);
    margin-bottom: var(--spacing-lg);
    border-left: 4px solid var(--error-500);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.success-message {
    background-color: var(--success-50);
    color: var(--success-600);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius);
    margin-bottom: var(--spacing-lg);
    border-left: 4px solid var(--success-500);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: var(--spacing-xl);
    right: var(--spacing-xl);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.toast {
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    min-width: 300px;
    max-width: 450px;
    animation: slideIn 0.3s ease;
}

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

.toast.toast-exit {
    animation: slideOut 0.3s ease forwards;
}

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

.toast-success {
    background-color: var(--success-50);
    color: var(--success-600);
    border: 1px solid var(--success-200);
}

.toast-error {
    background-color: var(--error-50);
    color: var(--error-600);
    border: 1px solid var(--error-200);
}

.toast-warning {
    background-color: var(--warning-50);
    color: var(--warning-600);
    border: 1px solid var(--warning-200);
}

.degraded-banner {
    background-color: #fff3cd;
    color: #856404;
    border-bottom: 2px solid #ffc107;
    padding: 10px 24px;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
}

.toast-info {
    background-color: var(--primary-50);
    color: var(--primary-600);
    border: 1px solid var(--primary-200);
}

/* Setup Container (Login) */
.setup-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a2a4a 0%, #2c3e50 100%);
}

.setup-form {
    width: 100%;
    max-width: 420px;
    padding: var(--spacing-xl);
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.setup-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: var(--spacing-sm);
}

.setup-logo-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #1a2a4a 0%, #2563eb 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgb(37 99 235 / .35);
}

.setup-form h1 {
    text-align: center;
    margin-bottom: var(--spacing-xs);
    color: var(--gray-900);
    font-size: 1.25rem;
}

.setup-form p {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
    font-size: 0.875rem;
}

.password-input {
    width: 100%;
    padding: var(--spacing-md);
    margin: var(--spacing-sm) 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: var(--transition-base);
}

.password-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.setup-button {
    width: 100%;
    padding: var(--spacing-md);
    background-color: var(--primary-600);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    margin-top: var(--spacing-md);
    transition: var(--transition-base);
}

.setup-button:hover:not(:disabled) {
    background-color: var(--primary-700);
}

.setup-button:disabled {
    background-color: var(--gray-300);
    cursor: not-allowed;
}

/* Loading Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--primary-600);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

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

.spinner-sm {
    width: 14px;
    height: 14px;
    border-width: 1.5px;
}

/* Buttons */
.btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-base);
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
}

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

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-700);
}

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

.btn-success:hover:not(:disabled) {
    background-color: var(--success-600);
}

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

.btn-danger:hover:not(:disabled) {
    background-color: var(--error-600);
}

.btn-secondary {
    background-color: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--gray-300);
}

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

.btn-block {
    width: 100%;
    justify-content: center;
}

/* ================================================================
   Page layout wrapper — applies inside .app-main
   ================================================================ */
.page-content {
    padding: 24px;
    max-width: 1100px;
    margin: 0 auto;
}

/* Dashboard Content */

/* Button Group for header actions */
.device-actions-header {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.dashboard-section {
    margin-bottom: var(--spacing-xl);
}

.dashboard-section h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: var(--spacing-md);
}

.section-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.section-row h2 { margin-bottom: 0; }

.status-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.status-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
    background-color: var(--surface);
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.07);
    transition: var(--transition-base);
}

.status-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.status-card h3 {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.status-text {
    font-size: 1.625rem;
    font-weight: 700;
    margin-bottom: var(--spacing-md);
    line-height: 1.2;
}

.status-text.active {
    color: var(--success-500);
}

.status-text.inactive {
    color: var(--error-500);
}

.proxy-button {
    width: 100%;
    padding: var(--spacing-md);
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-base);
}

.proxy-button.start {
    background-color: var(--success-500);
    color: white;
}

.proxy-button.start:hover:not(:disabled) {
    background-color: var(--success-600);
}

.proxy-button.stop {
    background-color: var(--error-500);
    color: white;
}

.proxy-button.stop:hover:not(:disabled) {
    background-color: var(--error-600);
}

/* ================================================================
   Content panel (generic white card with border)
   ================================================================ */
.content-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.07);
}

.content-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
}

.content-panel-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Activity Feed (legacy rows, kept for compatibility) */
.activity-feed {
    margin-top: var(--spacing-md);
}

.activity-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-time {
    width: 50px;
    color: var(--text-muted);
    font-size: 12px;
    flex-shrink: 0;
    font-family: monospace;
}

.activity-type {
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    text-transform: uppercase;
}

.activity-type.blocked {
    background-color: var(--error-50);
    color: var(--error-600);
}

.activity-type.allowed {
    background-color: var(--success-50);
    color: var(--success-600);
}

.activity-type.tamper {
    background-color: var(--warning-50);
    color: var(--warning-600);
}

.activity-details {
    flex: 1;
    color: var(--text-secondary);
    font-size: 13px;
    margin-left: 12px;
}

/* ================================================================
   Filters — 2-column card grid
   ================================================================ */
.filters-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    max-width: 1100px;
    margin: 0 auto;
}

.filter-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.07);
}

.filter-panel-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px;
}

.filter-panel-sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0 0 16px;
}

.filter-save-btn {
    width: 100%;
    margin-top: 16px;
    padding: 10px;
    background: var(--primary-600);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: var(--transition-base);
}

.filter-save-btn:hover:not(:disabled) { background: var(--primary-700); }
.filter-save-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Setting row inside filter-panel (Settings tab) */
.filter-panel .setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

.filter-panel .setting-item label:first-child {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    text-transform: none;
    letter-spacing: 0;
}

/* Filters Section (legacy) */
.filters-section {
    margin-bottom: var(--spacing-xl);
    padding: var(--spacing-lg);
    background-color: var(--gray-50);
    border-radius: var(--radius-lg);
}

.filters-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: var(--spacing-xs);
}

.filters-section > p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

.policy-scope-badge {
    display: inline-block;
    background-color: #dbeafe;
    color: #1d4ed8;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    margin-bottom: var(--spacing-lg);
}

.category-list {
    margin-top: var(--spacing-md);
}

.category-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    background-color: var(--surface);
    transition: var(--transition-base);
}

.category-item:hover {
    border-color: var(--primary-300);
    box-shadow: var(--shadow-sm);
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
}

.category-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--gray-300);
    transition: var(--transition-base);
    border-radius: var(--radius-full);
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: var(--transition-base);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

input:checked + .slider {
    background-color: var(--primary-500);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

input:focus + .slider {
    box-shadow: 0 0 0 3px var(--primary-100);
}

.category-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.category-keywords {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.category-keywords strong {
    color: var(--text-secondary);
}

/* Whitelist & Blacklist */
.whitelist-section, .blacklist-section {
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md);
    background-color: var(--surface);
    border-radius: var(--radius);
}

.whitelist-section h3, .blacklist-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: var(--spacing-md);
}

.whitelist-items, .blacklist-items {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

.whitelist-item, .blacklist-item {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background-color: var(--gray-100);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
}

.whitelist-item {
    background-color: var(--success-50);
    color: var(--success-600);
}

.blacklist-item {
    background-color: var(--error-50);
    color: var(--error-600);
}

/* System-protected always-allow entry (e.g. *.limpianet.com): pinned, not removable. */
.whitelist-item-protected {
    background-color: var(--primary-50, #eff6ff);
    color: var(--primary-700, #1d4ed8);
    border: 1px solid var(--primary-200, #bfdbfe);
}

.protected-badge {
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background-color: var(--primary-100, #dbeafe);
    color: var(--primary-700, #1d4ed8);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.whitelist-item-protected .remove-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.whitelist-item-protected .remove-button:disabled:hover {
    background-color: transparent;
}

.remove-button {
    padding: var(--spacing-xs) var(--spacing-sm);
    background-color: transparent;
    color: inherit;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    transition: var(--transition-fast);
    opacity: 0.7;
}

.remove-button:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.1);
}

.whitelist-form, .blacklist-form {
    display: flex;
    gap: var(--spacing-sm);
}

.whitelist-input, .blacklist-input {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: var(--transition-base);
}

.whitelist-input:focus, .blacklist-input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.add-button {
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--primary-500);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition-base);
}

.add-button:hover:not(:disabled) {
    background-color: var(--primary-600);
}

.update-filters-button {
    width: 100%;
    padding: var(--spacing-md);
    background-color: var(--primary-600);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    margin-top: var(--spacing-lg);
    transition: var(--transition-base);
}

.update-filters-button:hover:not(:disabled) {
    background-color: var(--primary-700);
}

.update-filters-button:disabled {
    background-color: var(--gray-300);
    cursor: not-allowed;
}

/* ================================================================
   Activity Log — table + filter chips
   ================================================================ */
.log-filter-row {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
}

.log-filter-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface);
    font-size: 12px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.log-filter-btn:hover { border-color: var(--primary-300); color: var(--primary-600); }

.log-filter-btn.active {
    background: var(--primary-50);
    color: var(--primary-600);
    border-color: var(--primary-200);
}

.log-table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.07);
}

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

.log-table thead tr {
    background: #f8fafc;
}

.log-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
}

.log-table td {
    padding: 11px 14px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
}

.log-table tr:last-child td { border-bottom: none; }

.log-table tbody tr:hover { background: var(--primary-50); }

.log-time { font-size: 12px; color: var(--text-muted); font-family: monospace; white-space: nowrap; }
.log-device { font-size: 12px; font-weight: 500; color: var(--text-primary); }
.log-detail { font-size: 12px; color: var(--text-secondary); }
.log-cat { font-size: 11px; color: var(--text-secondary); }

.audit-header {
    align-items: flex-start;
}

.audit-filters {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) 150px 190px 190px auto auto;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    align-items: center;
}

.audit-filter-input {
    min-height: 36px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 12px;
}

.audit-error {
    margin: 12px 16px;
}

.audit-table td {
    vertical-align: top;
}

.audit-row.critical {
    background: #fef2f2;
}

.audit-row.critical:hover {
    background: #fee2e2;
}

.audit-row.info {
    color: var(--gray-600);
}

.audit-severity {
    display: inline-block;
    min-width: 66px;
    padding: 2px 9px;
    border-radius: 9999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-align: center;
    text-transform: uppercase;
}

.audit-severity.critical {
    background: var(--error-50);
    color: var(--error-600);
}

.audit-severity.warning {
    background: var(--warning-50);
    color: var(--warning-600);
}

.audit-severity.info {
    background: var(--gray-100);
    color: var(--gray-600);
}

.audit-event-type {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--gray-100);
}

/* Event chip colored by meaning: green = installed, amber = removed/left,
   red = tamper, gray = everything else. */
.audit-event-type.installed {
    background: var(--success-50);
    color: var(--success-600);
}

.audit-event-type.removal {
    background: var(--warning-50);
    color: var(--warning-600);
}

.audit-event-type.tamper {
    background: var(--error-50);
    color: var(--error-600);
}

.audit-event-type.neutral {
    background: var(--gray-100);
    color: var(--gray-700, var(--gray-600));
}

.audit-empty {
    text-align: center;
    padding: 32px;
    color: var(--text-secondary);
}

/* Legacy log table */
.logs-table {
    border-collapse: collapse;
    width: 100%;
    margin-top: var(--spacing-md);
    background-color: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}

.logs-header {
    display: flex;
    background-color: var(--gray-800);
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
}

.log-column {
    padding: var(--spacing-md);
    flex: 1;
}

.log-row {
    display: flex;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.log-row:last-child {
    border-bottom: none;
}

.log-row:nth-child(even) {
    background-color: var(--gray-50);
}

.log-row:hover {
    background-color: var(--primary-50);
}

/* Settings Form */
.settings-form {
    display: grid;
    gap: var(--spacing-lg);
    max-width: 600px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.setting-item label {
    font-weight: 500;
    color: var(--gray-900);
    font-size: 0.875rem;
}

.setting-item input, 
.setting-item select {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: var(--transition-base);
}

.setting-item input:focus,
.setting-item select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

/* Device Group Management */
.device-groups-section {
    margin-bottom: var(--spacing-xl);
}

.device-groups-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.device-groups-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
}

.groups-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}

.groups-table th,
.groups-table td {
    padding: var(--spacing-md);
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.groups-table th {
    background-color: var(--gray-50);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.groups-table tr:last-child td {
    border-bottom: none;
}

.groups-table tr:hover {
    background-color: var(--gray-50);
}

.group-actions {
    display: flex;
    gap: var(--spacing-sm);
}

/* Inheritance Badge */
.inheritance-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
}

.inheritance-badge.device {
    background-color: var(--error-50);
    color: var(--error-600);
}

.inheritance-badge.group {
    background-color: var(--warning-50);
    color: var(--warning-600);
}

.inheritance-badge.user {
    background-color: var(--primary-50);
    color: var(--primary-600);
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: var(--spacing-md);
        padding: var(--spacing-md);
    }

    .header-controls {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .tab-strip {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .nav-tab {
        min-width: 80px;
        font-size: 12px;
        padding: 7px 12px;
    }

    .status-cards {
        grid-template-columns: 1fr 1fr;
    }

    .filters-grid {
        grid-template-columns: 1fr;
    }

    .activity-item {
        flex-wrap: wrap;
        gap: var(--spacing-xs);
    }

    .whitelist-form, .blacklist-form {
        flex-direction: column;
    }

    .toast-container {
        left: var(--spacing-md);
        right: var(--spacing-md);
    }

    .toast {
        min-width: 100%;
    }

    .log-table th:nth-child(3),
    .log-table td:nth-child(3),
    .log-table th:nth-child(5),
    .log-table td:nth-child(5) {
        display: none;
    }

    .audit-filters {
        grid-template-columns: 1fr;
    }

    .audit-filter-input,
    .audit-filters .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .status-cards {
        grid-template-columns: 1fr;
    }
}

/* User Management Styles */
.users-section {
    padding: 2rem;
}

.users-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.users-table table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
}

.users-table th,
.users-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.users-table th {
    background: var(--surface-dark);
    font-weight: 600;
}

.users-table tr:hover {
    background: var(--surface-hover);
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    margin-right: 0.5rem;
}

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

.btn-danger:hover {
    background: #c62828;
}

.btn-edit {
    background: var(--warning-500);
    color: white;
}

.btn-edit:hover {
    background: var(--warning-600);
}

/* Expand/Collapse Section Styles */
.expandable-section {
    margin-bottom: var(--spacing-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--surface);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--gray-50);
    cursor: pointer;
    transition: background-color var(--transition-base);
    user-select: none;
}

.section-header:hover {
    background: var(--gray-100);
}

.section-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.expand-toggle {
    background: none;
    border: none;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--spacing-xs);
    transition: transform var(--transition-base);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.expand-toggle:hover {
    background: var(--gray-200);
}

.section-content {
    overflow: hidden;
    transition: max-height var(--transition-base), opacity var(--transition-base);
}

.section-content.expanded {
    max-height: 2000px;
    opacity: 1;
}

.section-content.collapsed {
    max-height: 0;
    opacity: 0;
}

.empty-message {
    text-align: center;
    color: var(--text-muted);
    padding: var(--spacing-lg);
    font-style: italic;
}

/* Update category header to be smaller when in expanded view */
.category-item h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--surface);
    padding: 2rem;
    border-radius: 12px;
    min-width: 400px;
    max-width: 90vw;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
}

.modal-content {
    margin-bottom: 1.5rem;
}

.modal-input {
    display: block;
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--background);
    color: var(--text);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* ================================================================
   Group Selector Styles
   ================================================================ */

.group-selector {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-md);
    background-color: var(--gray-100);
    border-radius: var(--radius-md);
    flex-wrap: wrap;
}

.group-selector label {
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.group-selector select {
    flex: 1;
    min-width: 200px;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    background-color: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition-base);
}

.group-selector select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px var(--primary-100);
}

.group-selector select:hover {
    border-color: var(--primary-400);
}

/* Exception note for whitelist/blacklist */
.exception-note {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--warning-50);
    border-left: 3px solid var(--warning-500);
    border-radius: var(--radius-sm);
}

/* ================================================================
   Device Registration & Management Styles
   ================================================================ */

.devices-section {
    padding: 0;
}

.devices-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

.devices-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Devices List (Row Layout) */
.devices-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.device-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--surface);
    border-radius: var(--radius-md);
    padding: var(--spacing-md) var(--spacing-lg);
    border: 1px solid var(--border);
    transition: var(--transition-base);
}

.device-row:hover {
    border-color: var(--primary-300);
    box-shadow: var(--shadow-sm);
}

.device-row-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex: 1;
}

.device-row-icon {
    font-size: 2rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--primary-50);
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.device-row-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.device-row-details h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.device-row-meta {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.platform-badge {
    display: inline-block;
    padding: 2px 8px;
    background-color: var(--gray-100);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 500;
    color: var(--text-secondary);
}

.device-row-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.device-row-actions {
    display: flex;
    gap: var(--spacing-sm);
    margin-left: var(--spacing-lg);
}

/* Device Group Label (shown in device row) */
.device-group-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Collapsible Device Groups Styles */
.devices-grouped-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.device-group-section {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--surface);
}

.device-group-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--gray-50);
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
}

.device-group-header:hover {
    background: var(--gray-100);
}

.group-chevron {
    font-size: 0.75rem;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
    width: 1rem;
    text-align: center;
}

.group-name {
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.group-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.device-group-content {
    border-top: 1px solid var(--gray-200);
    background: var(--surface);
}

.device-group-content .device-row:first-child {
    border-top: none;
}

.device-group-content .device-row:last-child {
    border-bottom: none;
}

/* Button Styles */
.btn-sm {
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
}

.btn-secondary {
    background-color: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--gray-200);
}

.btn-danger {
    background-color: var(--error-500);
    color: white;
    border: 1px solid var(--error-600);
}

.btn-danger:hover:not(:disabled) {
    background-color: var(--error-600);
}

/* Device Header (for section title) */
.devices-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

.devices-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
}

.device-actions-header {
    display: flex;
    gap: var(--spacing-md);
}

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

.status-dot.online {
    background-color: var(--success-500);
    box-shadow: 0 0 0 3px var(--success-50);
}

.status-dot.idle {
    background-color: var(--idle-500);
    box-shadow: 0 0 0 3px var(--idle-50);
    animation: idle-breathe 2.6s ease-in-out infinite;
}

@keyframes idle-breathe {
    0%, 100% { opacity: 1;    transform: scale(1); }
    50%      { opacity: 0.55; transform: scale(1.12); }
}

@media (prefers-reduced-motion: reduce) {
    .status-dot.idle { animation: none; }
}

.status-dot.offline {
    background-color: var(--gray-400);
}

.status-dot.uninstalled {
    background-color: #f59e0b;
    box-shadow: 0 0 0 3px rgb(245 158 11 / 0.25), 0 0 7px 1px rgb(245 158 11 / 0.65);
    animation: uninstalled-pulse 2s ease-in-out infinite;
}

@keyframes uninstalled-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgb(245 158 11 / 0.20), 0 0 6px 1px rgb(245 158 11 / 0.55); }
    50%      { box-shadow: 0 0 0 4px rgb(245 158 11 / 0.32), 0 0 10px 2px rgb(245 158 11 / 0.85); }
}

/* Dim the rest of an uninstalled device's row so the amber status stands out;
   keep the status cell (4th) and the action buttons (last) at full strength. */
.device-table-row.uninstalled > td {
    opacity: 0.5;
    filter: grayscale(0.35);
}
.device-table-row.uninstalled > td:nth-child(4),
.device-table-row.uninstalled > td:last-child {
    opacity: 1;
    filter: none;
}

.status-dot.protected {
    background: #22c55e;
    box-shadow: 0 0 0 3px rgb(34 197 94 / 0.2);
}

.status-dot.degraded {
    background: #f59e0b;
    box-shadow: 0 0 0 3px rgb(245 158 11 / 0.2);
}

.status-dot.not-protected {
    background: #ef4444;
    box-shadow: 0 0 0 3px rgb(239 68 68 / 0.2);
    animation: tamper-flash 0.6s ease-in-out infinite;
}

@keyframes tamper-flash {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.25; }
}

@media (prefers-reduced-motion: reduce) {
    .status-dot.not-protected { animation: none; }
}

/* Device Details */
.device-details {
    margin-bottom: var(--spacing-lg);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) 0;
    font-size: 0.875rem;
}

.detail-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.detail-value {
    color: var(--text-primary);
    font-family: 'Consolas', 'Monaco', monospace;
    background-color: var(--gray-50);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

.device-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border);
}

.btn-sm {
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: 0.875rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--spacing-2xl);
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--border);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
}

.empty-state h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* QR Code Dialog */
.qr-registration-dialog {
    text-align: center;
    padding: var(--spacing-lg);
}

.qr-header {
    margin-bottom: var(--spacing-lg);
}

.qr-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.qr-header p {
    color: var(--text-secondary);
}

.qr-code-container {
    background-color: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin: var(--spacing-lg) 0;
    display: inline-block;
}

.qr-code-image {
    max-width: 300px;
    width: 100%;
    height: auto;
    display: block;
}

.qr-manual-entry {
    background-color: var(--gray-50);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin: var(--spacing-lg) 0;
}

.qr-manual-entry p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.registration-token {
    display: block;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 1rem;
    color: var(--text-primary);
    background-color: var(--surface);
    padding: var(--spacing-sm);
    border-radius: var(--radius);
    word-break: break-all;
    margin: var(--spacing-sm) 0;
    border: 1px solid var(--border);
}

.qr-instructions {
    text-align: left;
    background-color: var(--primary-50);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin: var(--spacing-lg) 0;
    border-left: 4px solid var(--primary-500);
}

.qr-instructions h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-700);
    margin-bottom: var(--spacing-sm);
}

.qr-instructions ol {
    margin-left: var(--spacing-lg);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.qr-instructions li {
    margin-bottom: 4px;
}

.qr-timer {
    margin: var(--spacing-md) 0;
    padding: var(--spacing-sm);
    background-color: var(--warning-50);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--warning-600);
}

#qr-timer {
    font-weight: 600;
    font-family: 'Consolas', 'Monaco', monospace;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--spacing-lg);
}

.modal {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: var(--spacing-xl);
}

.modal h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-lg);
    text-align: center;
}

.modal-content {
    margin-bottom: var(--spacing-lg);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border);
}

/* Form Styles for Device Edit/Register Modals */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.form-input,
.form-select {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text-primary);
    background-color: var(--surface);
    transition: var(--transition-base);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--spacing-sm) center;
    padding-right: var(--spacing-xl);
}

.help-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: var(--spacing-xs);
}

.edit-device-dialog,
.register-device-dialog {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .devices-list {
        overflow-x: auto;
    }
    
    .device-row {
        flex-wrap: wrap;
    }
    
    .device-row-info {
        flex-basis: 100%;
    }
    
    .device-row-meta {
        flex-basis: 100%;
        margin-bottom: var(--spacing-sm);
    }
    
    .device-row-actions {
        flex-basis: 100%;
        margin-left: 0;
        justify-content: flex-end;
    }
    
    .devices-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-md);
    }
    
    .devices-header .btn {
        width: 100%;
    }
    
    .modal {
        margin: var(--spacing-md);
        padding: var(--spacing-lg);
    }
    
    .form-input,
    .form-select {
        font-size: 1rem; /* Prevent zoom on iOS */
    }
    
    /* Responsive styles for grouped device layout */
    .device-group-header {
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .group-chevron {
        font-size: 0.625rem;
    }
    
    .device-actions-header {
        flex-wrap: wrap;
    }
    
    .device-actions-header .btn {
        width: 100%;
    }
}

/* Responsive adjustments for group selector */
@media (max-width: 768px) {
    .group-selector {
        flex-direction: column;
        align-items: stretch;
    }
    
    .group-selector select {
        width: 100%;
    }
    
    .group-selector .btn {
        width: 100%;
    }
}
