/* ============================================
   Clawdbot Dashboard - Mobile-First Styles
   ============================================ */

/* ============================================
   Global Theme System
   A unified CSS variable system supporting:
   - Dark theme (default)
   - Light theme
   - OLED theme (pure black)
   - Midnight theme (blue-tinted dark)
   - System preference auto-detection
   ============================================ */

/* CSS Variables for Theming */
:root {
    /* --------------------------------
       Dark Theme (Default)
       Deep purple-blue tones for comfortable viewing
       WCAG AA compliant contrast ratios
       -------------------------------- */

    /* Background colors - darkest to lightest */
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f1729;
    --bg-card: #242444;
    --bg-card-hover: #2d2d52;
    --bg-elevated: #2a2a4a;
    --bg-overlay: rgba(0, 0, 0, 0.6);
    --bg-backdrop: rgba(0, 0, 0, 0.8);

    /* Text colors - WCAG AA compliant */
    --text-primary: #ffffff;
    --text-secondary: #a0a0b8;
    --text-muted: #6b6b80;
    --text-inverse: #1a1a2e;
    --text-on-accent: #000000;

    /* Accent colors - Green (default) */
    --accent: #4ade80;
    --accent-hover: #22c55e;
    --accent-active: #16a34a;
    --accent-muted: rgba(74, 222, 128, 0.15);
    --accent-rgb: 74, 222, 128;

    /* Semantic colors with full state support */
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-active: #b91c1c;
    --danger-muted: rgba(239, 68, 68, 0.15);
    --danger-rgb: 239, 68, 68;

    --warning: #f59e0b;
    --warning-hover: #d97706;
    --warning-active: #b45309;
    --warning-muted: rgba(245, 158, 11, 0.15);
    --warning-rgb: 245, 158, 11;

    --info: #3b82f6;
    --info-hover: #2563eb;
    --info-active: #1d4ed8;
    --info-muted: rgba(59, 130, 246, 0.15);
    --info-rgb: 59, 130, 246;

    --success: #10b981;
    --success-hover: #059669;
    --success-active: #047857;
    --success-muted: rgba(16, 185, 129, 0.15);
    --success-rgb: 16, 185, 129;

    --purple: #a855f7;
    --purple-hover: #9333ea;
    --purple-active: #7e22ce;
    --purple-muted: rgba(168, 85, 247, 0.15);
    --purple-rgb: 168, 85, 247;

    /* Border colors */
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-light: rgba(255, 255, 255, 0.12);
    --border-color-strong: rgba(255, 255, 255, 0.2);

    /* Shadow system */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);
    --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.2);

    /* Focus ring for accessibility */
    --focus-ring: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--accent);
    --focus-ring-danger: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--danger);
    --focus-ring-offset: 2px;

    /* Input and form styles */
    --input-bg: var(--bg-card);
    --input-border: var(--border-color-light);
    --input-focus: var(--accent);
    --input-placeholder: var(--text-muted);
    --input-disabled-bg: var(--bg-tertiary);
    --input-disabled-text: var(--text-muted);

    /* --------------------------------
       Border Radius Scale
       -------------------------------- */
    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;
    --radius-full: 9999px;

    /* --------------------------------
       Spacing Scale
       Consistent spacing values for margins, padding, and gaps
       -------------------------------- */
    --space-0: 0;
    --space-1: 0.25rem;   /* 4px */
    --space-2: 0.5rem;    /* 8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.25rem;   /* 20px */
    --space-6: 1.5rem;    /* 24px */
    --space-8: 2rem;      /* 32px */
    --space-10: 2.5rem;   /* 40px */
    --space-12: 3rem;     /* 48px */

    /* Layout */
    --nav-height: 64px;
    --header-height: 56px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-top: env(safe-area-inset-top, 0px);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
    --transition-theme: 300ms ease-in-out;

    --tap-target: 44px;

    /* --------------------------------
       Typography Scale
       Font families, sizes, weights, and line heights for consistent text styling
       -------------------------------- */
    --font-family-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    --font-family-mono: 'SF Mono', Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;

    --font-size-xs: 0.75rem;    /* 12px */
    --font-size-sm: 0.875rem;   /* 14px */
    --font-size-base: 1rem;     /* 16px */
    --font-size-lg: 1.125rem;   /* 18px */
    --font-size-xl: 1.25rem;    /* 20px */
    --font-size-2xl: 1.5rem;    /* 24px */
    --font-size-3xl: 1.75rem;   /* 28px */

    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    --line-height-tight: 1.25;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.625;

    --letter-spacing-tight: -0.025em;
    --letter-spacing-normal: 0;
    --letter-spacing-wide: 0.025em;

    /* Code/terminal styling */
    --code-bg: #0f1729;
    --code-text: #e2e8f0;
    --code-border: var(--border-color);
    --code-comment: #6b7280;
    --code-keyword: #f472b6;
    --code-string: #a5f3fc;
    --code-number: #fcd34d;
    --code-function: #93c5fd;

    /* Chart Colors */
    --chart-primary: #667eea;
    --chart-secondary: #764ba2;
    --chart-tertiary: #8b5cf6;
    --chart-quaternary: #ec4899;

    /* Scrollbar styling */
    --scrollbar-track: var(--bg-tertiary);
    --scrollbar-thumb: var(--border-color-strong);
    --scrollbar-thumb-hover: var(--text-muted);
}

/* --------------------------------
   Light Theme
   Clean, bright theme with excellent contrast
   WCAG AA compliant (4.5:1 for normal text)
   -------------------------------- */
[data-theme="light"] {
    /* Background colors */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-elevated: #ffffff;
    --bg-overlay: rgba(0, 0, 0, 0.4);
    --bg-backdrop: rgba(0, 0, 0, 0.5);

    /* Text colors - high contrast for accessibility */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-inverse: #ffffff;
    --text-on-accent: #ffffff;

    /* Adjusted semantic colors for light mode contrast */
    --accent: #16a34a;
    --accent-hover: #15803d;
    --accent-active: #166534;
    --accent-muted: rgba(22, 163, 74, 0.12);
    --accent-rgb: 22, 163, 74;

    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-active: #991b1b;
    --danger-muted: rgba(220, 38, 38, 0.1);
    --danger-rgb: 220, 38, 38;

    --warning: #d97706;
    --warning-hover: #b45309;
    --warning-active: #92400e;
    --warning-muted: rgba(217, 119, 6, 0.1);
    --warning-rgb: 217, 119, 6;

    --info: #2563eb;
    --info-hover: #1d4ed8;
    --info-active: #1e40af;
    --info-muted: rgba(37, 99, 235, 0.1);
    --info-rgb: 37, 99, 235;

    --success: #059669;
    --success-hover: #047857;
    --success-active: #065f46;
    --success-muted: rgba(5, 150, 105, 0.1);
    --success-rgb: 5, 150, 105;

    --purple: #7c3aed;
    --purple-hover: #6d28d9;
    --purple-active: #5b21b6;
    --purple-muted: rgba(124, 58, 237, 0.1);
    --purple-rgb: 124, 58, 237;

    /* Border colors */
    --border-color: rgba(0, 0, 0, 0.08);
    --border-color-light: rgba(0, 0, 0, 0.06);
    --border-color-strong: rgba(0, 0, 0, 0.15);

    /* Shadows - softer for light theme */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12), 0 4px 8px rgba(0, 0, 0, 0.06);
    --shadow-xl: 0 16px 40px rgba(0, 0, 0, 0.14), 0 8px 16px rgba(0, 0, 0, 0.08);
    --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.06);

    /* Focus rings */
    --focus-ring: 0 0 0 2px var(--bg-secondary), 0 0 0 4px var(--accent);
    --focus-ring-danger: 0 0 0 2px var(--bg-secondary), 0 0 0 4px var(--danger);

    /* Input styles */
    --input-bg: #ffffff;
    --input-border: rgba(0, 0, 0, 0.15);
    --input-focus: var(--accent);
    --input-placeholder: var(--text-muted);
    --input-disabled-bg: #f1f5f9;
    --input-disabled-text: var(--text-muted);

    /* Code styling - keep dark for readability */
    --code-bg: #1e293b;
    --code-text: #e2e8f0;
    --code-border: rgba(0, 0, 0, 0.1);
    --code-comment: #6b7280;
    --code-keyword: #f472b6;
    --code-string: #a5f3fc;
    --code-number: #fcd34d;
    --code-function: #93c5fd;

    /* Chart colors */
    --chart-primary: #667eea;
    --chart-secondary: #764ba2;
    --chart-tertiary: #8b5cf6;
    --chart-quaternary: #ec4899;

    /* Scrollbar */
    --scrollbar-track: #f1f5f9;
    --scrollbar-thumb: #cbd5e1;
    --scrollbar-thumb-hover: #94a3b8;
}

/* Accent Color Themes */
[data-accent="green"] {
    --accent: #4ade80;
    --accent-hover: #22c55e;
    --accent-active: #16a34a;
    --accent-muted: rgba(74, 222, 128, 0.15);
    --accent-rgb: 74, 222, 128;
}

[data-accent="blue"] {
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-active: #1d4ed8;
    --accent-muted: rgba(59, 130, 246, 0.15);
    --accent-rgb: 59, 130, 246;
}

[data-accent="purple"] {
    --accent: #a855f7;
    --accent-hover: #9333ea;
    --accent-active: #7e22ce;
    --accent-muted: rgba(168, 85, 247, 0.15);
    --accent-rgb: 168, 85, 247;
}

[data-accent="pink"] {
    --accent: #ec4899;
    --accent-hover: #db2777;
    --accent-active: #be185d;
    --accent-muted: rgba(236, 72, 153, 0.15);
    --accent-rgb: 236, 72, 153;
}

[data-accent="orange"] {
    --accent: #f97316;
    --accent-hover: #ea580c;
    --accent-active: #c2410c;
    --accent-muted: rgba(249, 115, 22, 0.15);
    --accent-rgb: 249, 115, 22;
}

[data-accent="cyan"] {
    --accent: #06b6d4;
    --accent-hover: #0891b2;
    --accent-active: #0e7490;
    --accent-muted: rgba(6, 182, 212, 0.15);
    --accent-rgb: 6, 182, 212;
}

/* --------------------------------
   OLED Theme (True Black)
   Pure black backgrounds for AMOLED/OLED displays
   Maximizes battery life and reduces eye strain
   -------------------------------- */
[data-theme="oled"] {
    /* Pure black backgrounds */
    --bg-primary: #000000;
    --bg-secondary: #000000;
    --bg-tertiary: #000000;
    --bg-card: #0a0a0a;
    --bg-card-hover: #141414;
    --bg-elevated: #1a1a1a;
    --bg-overlay: rgba(0, 0, 0, 0.85);
    --bg-backdrop: rgba(0, 0, 0, 0.95);

    /* High contrast text for readability - WCAG AA compliant */
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-muted: #8a8a8a; /* Improved from #707070 for WCAG AA (4.5:1 contrast) */
    --text-inverse: #000000;
    --text-on-accent: #000000;

    /* Slightly brighter semantic colors for OLED contrast */
    --accent: #5eead4;
    --accent-hover: #2dd4bf;
    --accent-active: #14b8a6;
    --accent-muted: rgba(94, 234, 212, 0.12);
    --accent-rgb: 94, 234, 212;

    /* Semantic colors - brighter for OLED visibility */
    --danger: #f87171;
    --danger-hover: #ef4444;
    --danger-active: #dc2626;
    --danger-muted: rgba(248, 113, 113, 0.12);
    --danger-rgb: 248, 113, 113;

    --warning: #fbbf24;
    --warning-hover: #f59e0b;
    --warning-active: #d97706;
    --warning-muted: rgba(251, 191, 36, 0.12);
    --warning-rgb: 251, 191, 36;

    --info: #60a5fa;
    --info-hover: #3b82f6;
    --info-active: #2563eb;
    --info-muted: rgba(96, 165, 250, 0.12);
    --info-rgb: 96, 165, 250;

    --success: #34d399;
    --success-hover: #10b981;
    --success-active: #059669;
    --success-muted: rgba(52, 211, 153, 0.12);
    --success-rgb: 52, 211, 153;

    --purple: #c084fc;
    --purple-hover: #a855f7;
    --purple-active: #9333ea;
    --purple-muted: rgba(192, 132, 252, 0.12);
    --purple-rgb: 192, 132, 252;

    /* Subtle borders to define edges without glow */
    --border-color: rgba(255, 255, 255, 0.06);
    --border-color-light: rgba(255, 255, 255, 0.04);
    --border-color-strong: rgba(255, 255, 255, 0.12);

    /* Minimal shadows - OLED doesn't need depth */
    --shadow-sm: 0 0 0 1px rgba(255, 255, 255, 0.05);
    --shadow-md: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 4px 16px rgba(0, 0, 0, 0.9);
    --shadow-lg: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 8px 32px rgba(0, 0, 0, 1);
    --shadow-xl: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 16px 48px rgba(0, 0, 0, 1);
    --shadow-inner: inset 0 1px 2px rgba(0, 0, 0, 0.5);

    /* Focus rings with glow effect */
    --focus-ring: 0 0 0 2px #000000, 0 0 0 4px var(--accent), 0 0 12px var(--accent);
    --focus-ring-danger: 0 0 0 2px #000000, 0 0 0 4px var(--danger), 0 0 12px var(--danger);

    /* Input styles */
    --input-bg: #0a0a0a;
    --input-border: rgba(255, 255, 255, 0.08);
    --input-focus: var(--accent);
    --input-placeholder: var(--text-muted);
    --input-disabled-bg: #000000;
    --input-disabled-text: var(--text-muted);

    /* Code styling */
    --code-bg: #000000;
    --code-text: #e2e8f0;
    --code-border: rgba(255, 255, 255, 0.08);
    --code-comment: #8a8a8a;
    --code-keyword: #f472b6;
    --code-string: #a5f3fc;
    --code-number: #fcd34d;
    --code-function: #93c5fd;

    /* Chart colors */
    --chart-primary: #818cf8;
    --chart-secondary: #a78bfa;
    --chart-tertiary: #c084fc;
    --chart-quaternary: #f472b6;

    /* Scrollbar */
    --scrollbar-track: #000000;
    --scrollbar-thumb: rgba(255, 255, 255, 0.15);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.25);
}

/* --------------------------------
   Midnight Theme (Blue-Tinted Dark)
   Deep blue tones for a calm, focused experience
   Perfect for late-night coding sessions
   -------------------------------- */
[data-theme="midnight"] {
    /* Cool blue-gray backgrounds */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #0c1424;
    --bg-card: #1e3a5f;
    --bg-card-hover: #264a70;
    --bg-elevated: #2d4a6f;
    --bg-overlay: rgba(15, 23, 42, 0.7);
    --bg-backdrop: rgba(15, 23, 42, 0.9);

    /* Soft blue-tinted text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0f172a;
    --text-on-accent: #000000;

    /* Sky blue accent for midnight theme */
    --accent: #38bdf8;
    --accent-hover: #0ea5e9;
    --accent-active: #0284c7;
    --accent-muted: rgba(56, 189, 248, 0.15);
    --accent-rgb: 56, 189, 248;

    /* Semantic colors - blue-tinted for midnight theme */
    --danger: #f87171;
    --danger-hover: #ef4444;
    --danger-active: #dc2626;
    --danger-muted: rgba(248, 113, 113, 0.15);
    --danger-rgb: 248, 113, 113;

    --warning: #fbbf24;
    --warning-hover: #f59e0b;
    --warning-active: #d97706;
    --warning-muted: rgba(251, 191, 36, 0.15);
    --warning-rgb: 251, 191, 36;

    --info: #60a5fa;
    --info-hover: #3b82f6;
    --info-active: #2563eb;
    --info-muted: rgba(96, 165, 250, 0.15);
    --info-rgb: 96, 165, 250;

    --success: #34d399;
    --success-hover: #10b981;
    --success-active: #059669;
    --success-muted: rgba(52, 211, 153, 0.15);
    --success-rgb: 52, 211, 153;

    --purple: #c4b5fd;
    --purple-hover: #a78bfa;
    --purple-active: #8b5cf6;
    --purple-muted: rgba(196, 181, 253, 0.15);
    --purple-rgb: 196, 181, 253;

    /* Blue-tinted borders */
    --border-color: rgba(148, 163, 184, 0.1);
    --border-color-light: rgba(148, 163, 184, 0.08);
    --border-color-strong: rgba(148, 163, 184, 0.2);

    /* Blue-tinted shadows */
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.4);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.5);
    --shadow-lg: 0 8px 32px rgba(15, 23, 42, 0.6);
    --shadow-xl: 0 16px 48px rgba(15, 23, 42, 0.7);
    --shadow-inner: inset 0 2px 4px rgba(15, 23, 42, 0.3);

    /* Focus rings */
    --focus-ring: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--accent);
    --focus-ring-danger: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--danger);

    /* Input styles */
    --input-bg: #1e3a5f;
    --input-border: rgba(148, 163, 184, 0.15);
    --input-focus: var(--accent);
    --input-placeholder: var(--text-muted);
    --input-disabled-bg: #0c1424;
    --input-disabled-text: var(--text-muted);

    /* Code styling */
    --code-bg: #0c1424;
    --code-text: #e2e8f0;
    --code-border: rgba(148, 163, 184, 0.1);
    --code-comment: #64748b;
    --code-keyword: #f472b6;
    --code-string: #a5f3fc;
    --code-number: #fcd34d;
    --code-function: #93c5fd;

    /* Chart colors */
    --chart-primary: #38bdf8;
    --chart-secondary: #818cf8;
    --chart-tertiary: #a78bfa;
    --chart-quaternary: #f472b6;

    /* Scrollbar */
    --scrollbar-track: #0f172a;
    --scrollbar-thumb: rgba(148, 163, 184, 0.2);
    --scrollbar-thumb-hover: rgba(148, 163, 184, 0.3);
}

/* --------------------------------
   System Preference Auto-Detection
   Respects user's OS-level preference when no theme is set
   -------------------------------- */
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) {
        /* Inherit light theme values */
        --bg-primary: #f8fafc;
        --bg-secondary: #ffffff;
        --bg-tertiary: #f1f5f9;
        --bg-card: #ffffff;
        --bg-card-hover: #f8fafc;
        --bg-elevated: #ffffff;
        --bg-overlay: rgba(0, 0, 0, 0.4);
        --bg-backdrop: rgba(0, 0, 0, 0.5);

        --text-primary: #0f172a;
        --text-secondary: #475569;
        --text-muted: #64748b;
        --text-inverse: #ffffff;
        --text-on-accent: #ffffff;

        --accent: #16a34a;
        --accent-hover: #15803d;
        --accent-active: #166534;
        --accent-muted: rgba(22, 163, 74, 0.12);
        --accent-rgb: 22, 163, 74;

        --danger: #dc2626;
        --danger-hover: #b91c1c;
        --danger-active: #991b1b;
        --danger-muted: rgba(220, 38, 38, 0.1);
        --danger-rgb: 220, 38, 38;

        --warning: #d97706;
        --warning-hover: #b45309;
        --warning-active: #92400e;
        --warning-muted: rgba(217, 119, 6, 0.1);
        --warning-rgb: 217, 119, 6;

        --info: #2563eb;
        --info-hover: #1d4ed8;
        --info-active: #1e40af;
        --info-muted: rgba(37, 99, 235, 0.1);
        --info-rgb: 37, 99, 235;

        --success: #059669;
        --success-hover: #047857;
        --success-active: #065f46;
        --success-muted: rgba(5, 150, 105, 0.1);
        --success-rgb: 5, 150, 105;

        --purple: #7c3aed;
        --purple-hover: #6d28d9;
        --purple-active: #5b21b6;
        --purple-muted: rgba(124, 58, 237, 0.1);
        --purple-rgb: 124, 58, 237;

        --border-color: rgba(0, 0, 0, 0.08);
        --border-color-light: rgba(0, 0, 0, 0.06);
        --border-color-strong: rgba(0, 0, 0, 0.15);

        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
        --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
        --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12), 0 4px 8px rgba(0, 0, 0, 0.06);
        --shadow-xl: 0 16px 40px rgba(0, 0, 0, 0.14), 0 8px 16px rgba(0, 0, 0, 0.08);
        --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.06);

        /* Focus rings */
        --focus-ring: 0 0 0 2px var(--bg-secondary), 0 0 0 4px var(--accent);
        --focus-ring-danger: 0 0 0 2px var(--bg-secondary), 0 0 0 4px var(--danger);

        /* Input styles */
        --input-bg: #ffffff;
        --input-border: rgba(0, 0, 0, 0.15);
        --input-focus: var(--accent);
        --input-placeholder: var(--text-muted);
        --input-disabled-bg: #f1f5f9;
        --input-disabled-text: var(--text-muted);

        /* Code styling */
        --code-bg: #1e293b;
        --code-text: #e2e8f0;
        --code-border: rgba(0, 0, 0, 0.1);
        --code-comment: #6b7280;
        --code-keyword: #f472b6;
        --code-string: #a5f3fc;
        --code-number: #fcd34d;
        --code-function: #93c5fd;

        /* Chart colors */
        --chart-primary: #667eea;
        --chart-secondary: #764ba2;
        --chart-tertiary: #8b5cf6;
        --chart-quaternary: #ec4899;

        --scrollbar-track: #f1f5f9;
        --scrollbar-thumb: #cbd5e1;
        --scrollbar-thumb-hover: #94a3b8;
    }
}

/* --------------------------------
   Theme Transition Support
   Smooth transitions when switching themes
   -------------------------------- */
.theme-transitioning,
.theme-transitioning *,
.theme-transitioning *::before,
.theme-transitioning *::after {
    transition:
        background-color var(--transition-theme),
        border-color var(--transition-theme),
        color var(--transition-theme),
        box-shadow var(--transition-theme),
        fill var(--transition-theme),
        stroke var(--transition-theme),
        opacity var(--transition-theme) !important;
}

/* Disable transitions on page load to prevent flash */
.no-transitions,
.no-transitions *,
.no-transitions *::before,
.no-transitions *::after {
    transition: none !important;
}

/* --------------------------------
   Custom Scrollbar Styling
   Consistent scrollbar appearance across themes
   -------------------------------- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--radius-full);
    border: 2px solid var(--scrollbar-track);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

::-webkit-scrollbar-corner {
    background: var(--scrollbar-track);
}

/* Firefox scrollbar support */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* ============================================
   Reset & Base Styles
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    max-width: 100vw; /* Prevent horizontal overflow */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--accent);
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, select, textarea {
    font-family: inherit;
    font-size: 1rem;
}

/* ============================================
   App Container
   ============================================ */
.app {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom));
}

/* ============================================
   Pull to Refresh
   ============================================ */
.pull-refresh {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.875rem;
    transform: translateY(-100%);
    transition: transform var(--transition-normal);
    z-index: 100;
}

.pull-refresh.active {
    transform: translateY(0);
}

.pull-refresh-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================
   Header
   ============================================ */
.header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    padding: 0 16px;
    padding-top: var(--safe-area-top);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.header-brand {
    flex-shrink: 0;
}

.header-workspace {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    max-width: 40vw;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-card);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.online {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

.status-dot.offline {
    background: var(--text-muted);
}

.status-dot.error {
    background: var(--danger);
    box-shadow: 0 0 8px var(--danger);
}

.status-dot.connecting {
    background: var(--warning);
    animation: pulse 1.5s ease-in-out infinite;
}

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

.icon-btn {
    width: var(--tap-target);
    height: var(--tap-target);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast), color var(--transition-fast);
}

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

.icon {
    width: 24px;
    height: 24px;
}

/* ============================================
   Page Container & Pages
   ============================================ */
.page-container {
    flex: 1;
    position: relative;
}

.page {
    display: none;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.page.active {
    display: block;
    opacity: 1;
}

.page-content {
    padding: 16px;
    padding-bottom: 24px;
    max-width: 600px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

/* ============================================
   Greeting
   ============================================ */
.greeting {
    margin-bottom: 24px;
}

.greeting h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

.demo-badge {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--warning);
    background: rgba(var(--warning-rgb, 255, 193, 7), 0.15);
    border: 1px solid var(--warning);
    border-radius: var(--radius-sm);
    letter-spacing: 0.02em;
}

/* ============================================
   Stats Grid
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.stat-card:active {
    transform: scale(0.98);
    background: var(--bg-card-hover);
}

.stat-card-clickable {
    cursor: pointer;
}

.stat-card-clickable:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 22px;
    height: 22px;
}

.stat-icon.instances {
    background: var(--accent-muted);
    color: var(--accent);
}

.stat-icon.tasks {
    background: var(--info-muted);
    color: var(--info);
}

.stat-icon.uptime {
    background: var(--warning-muted);
    color: var(--warning);
}

.stat-icon.messages {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
}

.stat-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   Sections
   ============================================ */
.section {
    margin-bottom: 24px;
}

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

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

.link {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--accent);
}

/* ============================================
   Activity List
   ============================================ */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.activity-item {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-icon svg {
    width: 18px;
    height: 18px;
}

.activity-icon.success {
    background: var(--accent-muted);
    color: var(--accent);
}

.activity-icon.error {
    background: var(--danger-muted);
    color: var(--danger);
}

.activity-icon.info {
    background: var(--info-muted);
    color: var(--info);
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-title {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

/* ============================================
   Action Grid
   ============================================ */
.action-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px 8px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    min-height: var(--tap-target);
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.action-btn:active {
    transform: scale(0.95);
    background: var(--bg-card-hover);
}

.action-btn svg {
    width: 24px;
    height: 24px;
    color: var(--accent);
}

.action-btn span {
    font-size: 0.7rem;
    font-weight: 500;
    text-align: center;
}

/* ============================================
   Filter Bar
   ============================================ */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar {
    display: none;
}

.filter-btn {
    padding: 8px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    min-height: var(--tap-target);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.filter-btn.active {
    background: var(--accent);
    color: var(--bg-primary);
}

.filter-btn:active:not(.active) {
    background: var(--bg-card-hover);
}

/* ============================================
   Instance List & Cards
   ============================================ */
.instance-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.instance-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    border-left: 4px solid var(--accent);
    transition: background var(--transition-fast);
}

.instance-card:active {
    background: var(--bg-card-hover);
}

.instance-card.stopped {
    border-left-color: var(--text-muted);
}

.instance-card.error {
    border-left-color: var(--danger);
}

.instance-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.instance-name {
    font-size: 1rem;
    font-weight: 600;
}

.instance-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.instance-status.running {
    background: var(--accent-muted);
    color: var(--accent);
}

.instance-status.stopped {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.instance-status.error {
    background: var(--danger-muted);
    color: var(--danger);
}

.instance-meta {
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ============================================
   Chart Cards
   ============================================ */
.chart-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
}

.chart-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.chart-placeholder {
    height: 150px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    width: 100%;
    height: 100%;
    gap: 8px;
}

.chart-bar {
    flex: 1;
    background: linear-gradient(to top, var(--accent), var(--accent-hover));
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    height: var(--height, 50%);
    position: relative;
    min-width: 24px;
    max-width: 40px;
    transition: height var(--transition-normal);
}

.chart-bar span {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--text-muted);
}

.chart-line {
    width: 100%;
    height: 100%;
}

.chart-line svg {
    width: 100%;
    height: 100%;
}

/* ============================================
   Metrics Grid
   ============================================ */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.metric-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
}

.metric-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 4px;
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ============================================
   Settings
   ============================================ */
.settings-group {
    margin-bottom: 24px;
}

.settings-group-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-card);
    margin-bottom: 1px;
    min-height: 56px;
}

.settings-item:first-of-type {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.settings-item:last-of-type {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    margin-bottom: 0;
}

.settings-item:only-of-type {
    border-radius: var(--radius-md);
}

.settings-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.settings-item-label {
    font-size: 1rem;
    font-weight: 500;
}

.settings-item-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 32px;
    flex-shrink: 0;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    transition: background var(--transition-fast);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 26px;
    width: 26px;
    left: 3px;
    bottom: 3px;
    background: var(--text-primary);
    border-radius: 50%;
    transition: transform var(--transition-fast);
}

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

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

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 600;
    min-height: var(--tap-target);
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.btn:active {
    transform: scale(0.97);
}

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

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

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

.btn-secondary:hover, .btn-secondary:active {
    background: var(--bg-card-hover);
}

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

.btn-sm {
    padding: 8px 14px;
    font-size: 0.8125rem;
    min-height: 44px; /* Touch target minimum */
}

/* ============================================
   Select
   ============================================ */
.select {
    appearance: none;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 36px 10px 14px;
    color: var(--text-primary);
    font-size: 0.875rem;
    min-height: var(--tap-target);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a0a0b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.select:focus {
    outline: none;
    border-color: var(--accent);
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    margin-bottom: 16px;
    font-size: 0.9375rem;
}

/* ============================================
   Bottom Navigation
   ============================================ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-height) + var(--safe-area-bottom));
    padding-bottom: var(--safe-area-bottom);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-muted);
    text-decoration: none;
    min-height: var(--tap-target);
    transition: color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.nav-item.active {
    color: var(--accent);
}

.nav-icon {
    width: 24px;
    height: 24px;
}

.nav-label {
    font-size: 0.7rem;
    font-weight: 500;
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
    position: fixed;
    bottom: calc(var(--nav-height) + var(--safe-area-bottom) + 16px);
    left: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 200;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: slideUp 0.3s ease;
}

.toast.success {
    border-left: 4px solid var(--accent);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

.toast.info {
    border-left: 4px solid var(--info);
}

.toast-message {
    flex: 1;
    font-size: 0.9375rem;
}

.toast-close {
    color: var(--text-muted);
    padding: 4px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 300;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

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

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    width: var(--tap-target);
    height: var(--tap-target);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text-muted);
    border-radius: var(--radius-md);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    padding-bottom: calc(16px + var(--safe-area-bottom));
    border-top: 1px solid var(--border-color);
}

.modal-footer .btn {
    flex: 1;
}

/* ============================================
   Status Pills/Badges
   ============================================ */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-pill.online {
    background: var(--accent-muted);
    color: var(--accent);
}

.status-pill.offline {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.status-pill.error {
    background: var(--danger-muted);
    color: var(--danger);
}

.status-pill.warning {
    background: var(--warning-muted);
    color: var(--warning);
}

.status-pill .status-dot {
    width: 6px;
    height: 6px;
}

/* ============================================
   Responsive Breakpoints

   Standardized breakpoint system:
   - max-width: 400px    -> Extra small (iPhone SE, small phones)
   - 401px-599px         -> Small phones
   - 600px-767px         -> Large phones
   - 768px-1023px        -> Tablets
   - 1024px+             -> Desktop
   - 1200px+             -> Large desktop

   Touch target minimum: 44px (var(--tap-target))
   ============================================ */

/* Tablet and up */
@media (min-width: 768px) {
    .page-content {
        max-width: 720px;
        padding: 24px;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .action-grid {
        gap: 12px;
    }

    .action-btn {
        padding: 20px 12px;
    }

    .action-btn span {
        font-size: 0.8rem;
    }

    .modal {
        border-radius: var(--radius-lg);
        max-width: 500px;
        margin: auto;
    }

    .modal-footer {
        padding-bottom: 16px;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    :root {
        --nav-height: 0px;
    }

    .app {
        flex-direction: row;
        padding-bottom: 0;
    }

    .bottom-nav {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        right: auto;
        width: 80px;
        height: 100%;
        flex-direction: column;
        justify-content: flex-start;
        padding: 20px 0;
        padding-top: calc(20px + var(--safe-area-top));
        border-top: none;
        border-right: 1px solid var(--border-color);
    }

    .nav-item {
        padding: 16px 0;
    }

    .header {
        position: fixed;
        top: 0;
        left: 80px;
        right: 0;
    }

    .page-container {
        margin-left: 80px;
        margin-top: var(--header-height);
    }

    .page-content {
        max-width: 900px;
    }

    .toast-container {
        bottom: 24px;
        left: auto;
        right: 24px;
        width: 360px;
    }
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Loading skeleton animation */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-card) 25%,
        var(--bg-card-hover) 50%,
        var(--bg-card) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Compact mode */
[data-compact="true"] .stat-card {
    padding: 12px;
}

[data-compact="true"] .stat-value {
    font-size: 1.25rem;
}

[data-compact="true"] .activity-item {
    padding: 10px 12px;
}

[data-compact="true"] .settings-item {
    min-height: 48px;
    padding: 10px 14px;
}

/* ============================================
   Theme Customization UI
   ============================================ */

/* Theme Selector */
.theme-selector {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    margin-top: 8px;
}

.theme-selector-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* Theme Cards */
.theme-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.theme-card {
    position: relative;
    padding: 16px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.theme-card:hover {
    border-color: var(--border-color-light);
    background: var(--bg-card-hover);
}

.theme-card.active {
    border-color: var(--accent);
    background: var(--accent-muted);
}

.theme-card-preview {
    width: 40px;
    height: 28px;
    border-radius: 4px;
    display: flex;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.1);
}

.theme-card-preview .preview-bg {
    flex: 1;
}

/* Theme preview colors - match actual theme values */
.theme-card[data-theme="dark"] .preview-bg {
    background: linear-gradient(135deg, #1a1a2e 50%, #242444 50%);
}

.theme-card[data-theme="light"] .preview-bg {
    background: linear-gradient(135deg, #f8fafc 50%, #ffffff 50%);
}

.theme-card[data-theme="oled"] .preview-bg {
    background: linear-gradient(135deg, #000000 50%, #0a0a0a 50%);
}

.theme-card[data-theme="midnight"] .preview-bg {
    background: linear-gradient(135deg, #0f172a 50%, #1e3a5f 50%);
}

.theme-card-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.theme-card-check {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--bg-primary);
    font-size: 0.75rem;
}

.theme-card.active .theme-card-check {
    display: flex;
}

/* Accent Color Picker */
.accent-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.accent-swatch {
    width: 44px; /* Touch target minimum */
    height: 44px; /* Touch target minimum */
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all var(--transition-fast);
    position: relative;
}

.accent-swatch:hover {
    transform: scale(1.1);
}

.accent-swatch.active {
    border-color: var(--text-primary);
}

.accent-swatch::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.accent-swatch.active::after {
    opacity: 1;
}

.accent-swatch[data-accent="green"] {
    background: #4ade80;
}

.accent-swatch[data-accent="blue"] {
    background: #3b82f6;
}

.accent-swatch[data-accent="purple"] {
    background: #a855f7;
}

.accent-swatch[data-accent="pink"] {
    background: #ec4899;
}

.accent-swatch[data-accent="orange"] {
    background: #f97316;
}

.accent-swatch[data-accent="cyan"] {
    background: #06b6d4;
}

/* Theme Toggle Button (in header) */
.theme-toggle-btn,
#themeToggle {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle-btn .theme-icon,
#themeToggle .theme-icon,
.theme-toggle-btn .icon,
#themeToggle .icon {
    width: 20px;
    height: 20px;
    transition: transform var(--transition-normal), opacity var(--transition-normal);
}

.theme-toggle-btn .sun-icon,
#themeToggle .sun-icon {
    position: absolute;
}

.theme-toggle-btn .moon-icon,
#themeToggle .moon-icon {
    position: absolute;
}

/* Light theme - show sun, hide moon */
[data-theme="light"] .theme-toggle-btn .sun-icon,
[data-theme="light"] #themeToggle .sun-icon {
    transform: rotate(0deg);
    opacity: 1;
}

[data-theme="light"] .theme-toggle-btn .moon-icon,
[data-theme="light"] #themeToggle .moon-icon {
    transform: rotate(-90deg);
    opacity: 0;
}

/* Dark themes - show moon, hide sun */
[data-theme="dark"] .theme-toggle-btn .sun-icon,
[data-theme="oled"] .theme-toggle-btn .sun-icon,
[data-theme="midnight"] .theme-toggle-btn .sun-icon,
:root:not([data-theme]) .theme-toggle-btn .sun-icon,
[data-theme="dark"] #themeToggle .sun-icon,
[data-theme="oled"] #themeToggle .sun-icon,
[data-theme="midnight"] #themeToggle .sun-icon,
:root:not([data-theme]) #themeToggle .sun-icon {
    transform: rotate(90deg);
    opacity: 0;
}

[data-theme="dark"] .theme-toggle-btn .moon-icon,
[data-theme="oled"] .theme-toggle-btn .moon-icon,
[data-theme="midnight"] .theme-toggle-btn .moon-icon,
:root:not([data-theme]) .theme-toggle-btn .moon-icon,
[data-theme="dark"] #themeToggle .moon-icon,
[data-theme="oled"] #themeToggle .moon-icon,
[data-theme="midnight"] #themeToggle .moon-icon,
:root:not([data-theme]) #themeToggle .moon-icon {
    transform: rotate(0deg);
    opacity: 1;
}

/* Theme indicator badge (optional - shows current theme name) */
.theme-indicator {
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    background: var(--accent-muted);
    color: var(--accent);
    border-radius: var(--radius-full);
    margin-left: 4px;
}

/* Settings Appearance Section Enhancement */

/* Settings Appearance Section Enhancement */
.appearance-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.appearance-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.appearance-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.appearance-description {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: -4px;
}

/* System preference indicator */
.system-theme-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    margin-left: 8px;
}

/* Smooth theme transition for html element */
html {
    transition: background-color var(--transition-theme);
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    html.theme-transitioning,
    html.theme-transitioning *,
    html.theme-transitioning *::before,
    html.theme-transitioning *::after {
        transition: none !important;
    }
}

/* ============================================
   Form Elements (Enhanced for theming)
   ============================================ */

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--input-bg);
    border: 2px solid var(--input-border);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    min-height: var(--tap-target);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

.form-input::placeholder {
    color: var(--text-muted);
}

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

/* Code/Pre blocks */
pre, code {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
}

pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 16px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-size: 0.8125rem;
    line-height: 1.6;
}

code {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.875em;
}

pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    color: inherit;
}

/* ============================================
   Focus Visible Styles (Accessibility)
   Enhanced focus indicators for keyboard navigation
   Uses focus-ring variable for consistent styling
   ============================================ */

:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Interactive elements with focus ring */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Form inputs maintain outline style for better visibility */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: var(--focus-ring-offset);
    box-shadow: 0 0 0 4px var(--accent-muted);
}

/* Danger focus state for delete/destructive actions */
.btn-danger:focus-visible,
[data-action="delete"]:focus-visible {
    box-shadow: var(--focus-ring-danger);
}

/* ============================================
   Mobile-First Responsive Enhancements (375px)
   ============================================ */

/* Extra small screens (375px - iPhone SE, etc.) */
@media (max-width: 400px) {
    html {
        font-size: 14px;
    }

    .header {
        padding: 0 12px;
    }

    .header-title {
        font-size: 1.125rem;
    }

    .connection-status {
        padding: 4px 8px;
        font-size: 0.7rem;
    }

    .page-content {
        padding: 12px;
        padding-bottom: 20px;
    }

    .greeting h2 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.875rem;
    }

    .stats-grid {
        gap: 8px;
        margin-bottom: 20px;
    }

    .stat-card {
        padding: 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
    }

    .stat-icon svg {
        width: 18px;
        height: 18px;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    .section-header h3 {
        font-size: 0.875rem;
    }

    .link {
        font-size: 0.8rem;
    }

    .activity-item {
        padding: 10px 12px;
        gap: 10px;
    }

    .activity-icon {
        width: 32px;
        height: 32px;
    }

    .activity-icon svg {
        width: 16px;
        height: 16px;
    }

    .activity-title {
        font-size: 0.8125rem;
    }

    .activity-time {
        font-size: 0.6875rem;
    }

    .action-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .action-btn {
        padding: 14px 8px;
        gap: 4px;
    }

    .action-btn svg {
        width: 20px;
        height: 20px;
    }

    .action-btn span {
        font-size: 0.65rem;
    }

    .page-header h2 {
        font-size: 1.25rem;
    }

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

    .filter-bar {
        margin-bottom: 12px;
    }

    .filter-btn {
        padding: 8px 12px;
        font-size: 0.8125rem;
        min-height: 44px; /* Touch target minimum */
    }

    .instance-card {
        padding: 12px;
    }

    .instance-name {
        font-size: 0.9375rem;
    }

    .instance-status {
        padding: 3px 8px;
        font-size: 0.6875rem;
    }

    .instance-meta {
        gap: 12px;
        font-size: 0.75rem;
        flex-wrap: wrap;
    }

    .bottom-nav {
        height: calc(56px + var(--safe-area-bottom));
    }

    .nav-icon {
        width: 22px;
        height: 22px;
    }

    .nav-label {
        font-size: 0.65rem;
    }

    .modal-header {
        padding: 14px 16px;
    }

    .modal-title {
        font-size: 1rem;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 14px 16px;
        gap: 10px;
    }

    .settings-item {
        padding: 10px 12px;
    }

    .settings-item-label {
        font-size: 0.9375rem;
    }

    .settings-item-desc {
        font-size: 0.75rem;
    }

    .toggle {
        width: 46px;
        height: 28px;
    }

    .toggle-slider::before {
        height: 22px;
        width: 22px;
    }

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

    .chart-card {
        padding: 12px;
    }

    .chart-title {
        font-size: 0.8125rem;
        margin-bottom: 12px;
    }

    .chart-placeholder {
        height: 120px;
    }

    .chart-bar span {
        font-size: 0.625rem;
        bottom: -20px;
    }

    .metrics-grid {
        gap: 8px;
    }

    .metric-card {
        padding: 12px;
    }

    .metric-value {
        font-size: 1.25rem;
    }

    .metric-label {
        font-size: 0.6875rem;
    }
}

/* Small phones landscape & larger phones (401px-599px) */
@media (min-width: 401px) and (max-width: 599px) {
    .page-content {
        padding: 14px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    /* Gradual transition: 3 columns on medium-small screens */
    .action-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    /* Communication channels - 2 column grid */
    .comm-channels-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .instance-meta {
        flex-wrap: wrap;
    }
}

/* Larger phones (600px-767px) */
@media (min-width: 600px) and (max-width: 767px) {
    .page-content {
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    /* Full 4 columns on larger phones */
    .action-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }

    /* Communication channels - 3 columns */
    .comm-channels-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .instance-meta {
        flex-wrap: wrap;
    }
}

/* Touch-friendly enhancements */
@media (hover: none) and (pointer: coarse) {
    .stat-card:active,
    .action-btn:active,
    .filter-btn:active,
    .instance-card:active,
    .settings-item:active,
    .nav-item:active {
        transform: scale(0.98);
    }

    .btn:active {
        transform: scale(0.97);
    }

    /* Remove hover effects on touch devices */
    .stat-card:hover,
    .instance-card:hover,
    .action-btn:hover,
    .icon-btn:hover {
        transform: none;
    }

    /* Add touch feedback */
    .tap-target {
        min-height: var(--tap-target);
        min-width: var(--tap-target);
    }
}

/* ============================================
   Instance Grid - Mobile Optimized
   ============================================ */
.instances-grid-mobile {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    grid-auto-rows: 1fr;
}

@media (min-width: 600px) {
    .instances-grid-mobile {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .instances-grid-mobile {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Instance Card - Mobile Enhanced */
.instance-card-mobile {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    border-left: 4px solid var(--accent);
    cursor: pointer;
    transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
    display: flex;
    flex-direction: column;
    gap: 12px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    height: 185px;
    overflow: hidden;
    min-width: 0;
}

.instance-card-mobile:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.instance-card-mobile:active {
    transform: scale(0.98);
    background: var(--bg-card-hover);
}

.instance-card-mobile.offline {
    border-left-color: var(--text-muted);
}

.instance-card-mobile.error {
    border-left-color: var(--danger);
}

.instance-card-mobile.degraded {
    border-left-color: var(--warning);
}

.instance-card-mobile .card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.instance-card-mobile .instance-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.instance-card-mobile .instance-emoji {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.instance-card-mobile .instance-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.instance-card-mobile .instance-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

.instance-card-mobile .instance-status.online {
    background: var(--accent-muted);
    color: var(--accent);
}

.instance-card-mobile .instance-status.offline {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.instance-card-mobile .instance-status.error {
    background: var(--danger-muted);
    color: var(--danger);
}

.instance-card-mobile .instance-status.degraded {
    background: var(--warning-muted);
    color: var(--warning);
}

.instance-card-mobile .card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.instance-card-mobile .meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.instance-card-mobile .meta-label {
    color: var(--text-muted);
}

.instance-card-mobile .meta-value {
    color: var(--text-primary);
    font-weight: 500;
}

.instance-card-mobile .meta-value.model {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.6875rem;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.instance-card-mobile .card-stats {
    display: flex;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.instance-card-mobile .stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.instance-card-mobile .stat-value {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.instance-card-mobile .stat-label {
    font-size: 0.625rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.instance-card-mobile .stat.error .stat-value {
    color: var(--danger);
}

@media (max-width: 400px) {
    .instance-card-mobile {
        padding: 12px;
        gap: 10px;
    }

    .instance-card-mobile .instance-emoji {
        font-size: 1.25rem;
    }

    .instance-card-mobile .instance-name {
        font-size: 0.9375rem;
    }

    .instance-card-mobile .instance-status {
        padding: 3px 8px;
        font-size: 0.625rem;
    }

    .instance-card-mobile .card-meta {
        gap: 6px 12px;
        font-size: 0.6875rem;
    }

    .instance-card-mobile .meta-value.model {
        max-width: 100px;
        font-size: 0.625rem;
    }

    .instance-card-mobile .card-stats {
        padding-top: 10px;
    }

    .instance-card-mobile .stat-value {
        font-size: 1rem;
    }

    .instance-card-mobile .stat-label {
        font-size: 0.5625rem;
    }
}

/* ============================================
   Instance Detail - Mobile Optimized
   ============================================ */
.detail-header-mobile {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.detail-header-mobile .header-top {
    display: flex;
    align-items: center;
    gap: 12px;
}

.detail-header-mobile .btn-back {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    flex-shrink: 0;
    border: none;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.detail-header-mobile .btn-back:active {
    background: var(--bg-card-hover);
    transform: scale(0.95);
}

.detail-header-mobile .instance-info {
    flex: 1;
    min-width: 0;
}

.detail-header-mobile .instance-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-header-mobile .instance-emoji {
    font-size: 1.75rem;
}

.detail-header-mobile .instance-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-header-mobile .header-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.detail-header-mobile .status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.detail-header-mobile .status-badge.online {
    background: var(--accent-muted);
    color: var(--accent);
}

.detail-header-mobile .status-badge.offline {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.detail-header-mobile .status-badge.error {
    background: var(--danger-muted);
    color: var(--danger);
}

.detail-header-mobile .status-badge .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.detail-header-mobile .status-badge.online .status-dot {
    animation: pulse 2s ease-in-out infinite;
}

.detail-header-mobile .provider-tag {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.detail-header-mobile .header-actions {
    display: flex;
    gap: 8px;
}

.detail-header-mobile .btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.detail-header-mobile .btn-icon:active {
    background: var(--bg-card-hover);
    transform: scale(0.95);
}

.detail-header-mobile .btn-icon.danger:active {
    background: var(--danger-muted);
    color: var(--danger);
}

/* Detail Quick Stats */
.detail-stats-mobile {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
}

.detail-stats-mobile::-webkit-scrollbar {
    display: none;
}

.detail-stats-mobile .stat-item {
    flex: 1;
    min-width: 100px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 14px 12px;
    text-align: center;
}

.detail-stats-mobile .stat-value {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
    display: block;
}

.detail-stats-mobile .stat-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.detail-stats-mobile .stat-item.error .stat-value {
    color: var(--danger);
}

/* Detail Tabs */
.detail-tabs-mobile {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
}

.detail-tabs-mobile::-webkit-scrollbar {
    display: none;
}

.detail-tabs-mobile .tab-btn {
    flex: 1;
    min-width: 80px;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: all var(--transition-fast);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.detail-tabs-mobile .tab-btn.active {
    background: var(--accent-muted);
    border-color: var(--accent);
    color: var(--accent);
}

.detail-tabs-mobile .tab-btn:active:not(.active) {
    background: var(--bg-card);
}

/* Detail Sections */
.detail-section-mobile {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    overflow: hidden;
}

.detail-section-mobile .section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--bg-card-hover);
    border-bottom: 1px solid var(--border-color);
}

.detail-section-mobile .section-header svg {
    width: 18px;
    height: 18px;
    color: var(--accent);
}

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

.detail-section-mobile .section-content {
    padding: 16px;
}

/* Info Grid Mobile */
.info-grid-mobile {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.info-grid-mobile .info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-grid-mobile .info-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.info-grid-mobile .info-value {
    font-size: 0.875rem;
    color: var(--text-primary);
    word-break: break-word;
}

.info-grid-mobile .info-value.code {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.75rem;
    background: var(--bg-tertiary);
    padding: 4px 8px;
    border-radius: 4px;
}

@media (max-width: 400px) {
    .info-grid-mobile {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

/* Model Card Mobile */
.model-card-mobile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 8px;
}

.model-card-mobile:last-child {
    margin-bottom: 0;
}

.model-card-mobile.primary {
    border-color: var(--accent);
    background: var(--accent-muted);
}

.model-card-mobile .model-badge {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 3px 6px;
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--text-muted);
    flex-shrink: 0;
}

.model-card-mobile.primary .model-badge {
    background: var(--accent);
    color: var(--bg-primary);
}

.model-card-mobile .model-name {
    flex: 1;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.75rem;
    color: var(--text-primary);
    word-break: break-all;
}

.model-card-mobile .model-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6875rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.model-card-mobile .model-status .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.model-card-mobile .model-status.active {
    color: var(--accent);
}

/* Resource Bars Mobile */
.resource-bar-mobile {
    margin-bottom: 16px;
}

.resource-bar-mobile:last-child {
    margin-bottom: 0;
}

.resource-bar-mobile .resource-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.resource-bar-mobile .resource-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.resource-bar-mobile .resource-value {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.resource-bar-mobile .bar-track {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.resource-bar-mobile .bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width var(--transition-normal);
}

.resource-bar-mobile .bar-fill.cpu {
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
}

.resource-bar-mobile .bar-fill.memory {
    background: linear-gradient(90deg, var(--warning), #ff9500);
}

.resource-bar-mobile .bar-fill.disk {
    background: linear-gradient(90deg, var(--info), #5856d6);
}

/* Channel List Mobile */
.channel-list-mobile {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.channel-item-mobile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.channel-item-mobile .channel-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.channel-item-mobile .channel-icon.slack {
    background: rgba(74, 21, 75, 0.2);
    color: #E01E5A;
}

.channel-item-mobile .channel-icon.discord {
    background: rgba(88, 101, 242, 0.2);
    color: #5865F2;
}

.channel-item-mobile .channel-info {
    flex: 1;
    min-width: 0;
}

.channel-item-mobile .channel-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    display: block;
}

.channel-item-mobile .channel-type {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

.channel-item-mobile .channel-status {
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.channel-item-mobile .channel-status.connected {
    background: var(--accent-muted);
    color: var(--accent);
}

.channel-item-mobile .channel-status.disconnected {
    background: var(--danger-muted);
    color: var(--danger);
}

/* Logs Mobile */
.logs-container-mobile {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.logs-toolbar-mobile {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    background: var(--bg-card-hover);
    border-bottom: 1px solid var(--border-color);
}

.logs-toolbar-mobile .toolbar-row {
    display: flex;
    gap: 8px;
}

.logs-toolbar-mobile .log-select {
    flex: 1;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8125rem;
}

.logs-toolbar-mobile .log-search {
    flex: 2;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8125rem;
}

.logs-toolbar-mobile .log-search::placeholder {
    color: var(--text-muted);
}

.logs-toolbar-mobile .toolbar-actions {
    display: flex;
    gap: 8px;
}

.logs-toolbar-mobile .btn-sm {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    touch-action: manipulation;
}

.logs-toolbar-mobile .btn-sm:active {
    background: var(--bg-card);
}

.logs-list-mobile {
    max-height: 400px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.log-entry-mobile {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.75rem;
}

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

.log-entry-mobile .log-time {
    color: var(--text-muted);
    flex-shrink: 0;
}

.log-entry-mobile .log-level {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

.log-entry-mobile.info .log-level {
    background: var(--info-muted);
    color: var(--info);
}

.log-entry-mobile.warn .log-level {
    background: var(--warning-muted);
    color: var(--warning);
}

.log-entry-mobile.error .log-level {
    background: var(--danger-muted);
    color: var(--danger);
}

.log-entry-mobile.debug .log-level {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.log-entry-mobile .log-message {
    flex: 1 1 100%;
    color: var(--text-secondary);
    word-break: break-word;
    margin-top: 4px;
}

@media (min-width: 600px) {
    .log-entry-mobile {
        flex-wrap: nowrap;
    }

    .log-entry-mobile .log-message {
        flex: 1 1 auto;
        margin-top: 0;
    }
}

/* Landscape mode optimizations */
@media (orientation: landscape) and (max-height: 500px) {
    :root {
        --header-height: 48px;
        --nav-height: 52px;
    }

    .header {
        height: var(--header-height);
    }

    .header-title {
        font-size: 1.125rem;
    }

    .bottom-nav {
        height: calc(var(--nav-height) + var(--safe-area-bottom));
    }

    .page-content {
        padding: 12px 16px;
    }

    .modal {
        max-height: 80vh;
    }
}

/* ============================================
   Notification Preferences UI
   ============================================ */

.notification-preferences {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Status Banner */
.notification-status-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
}

.notification-status-banner.granted {
    background: var(--accent-muted);
    color: var(--accent);
}

.notification-status-banner.denied {
    background: var(--danger-muted);
    color: var(--danger);
}

.notification-status-banner.default {
    background: var(--warning-muted);
    color: var(--warning);
}

.notification-status-banner svg {
    flex-shrink: 0;
}

/* Preference Sections */
.pref-section {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: opacity var(--transition-fast);
}

.pref-section.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.pref-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Main Toggle */
.pref-main-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.pref-toggle-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.pref-toggle-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.pref-toggle-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Category Cards */
.pref-categories {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pref-category-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: background var(--transition-fast);
}

.pref-category-card:hover {
    background: var(--bg-card-hover);
}

.pref-category-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
}

.pref-category-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    color: var(--accent);
    flex-shrink: 0;
}

.pref-category-info {
    flex: 1;
    min-width: 0;
}

.pref-category-label {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    display: block;
}

.pref-category-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

/* Category Types (expandable) */
.pref-category-types {
    display: none;
    padding: 0 16px 14px;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    margin-top: -2px;
}

.pref-category-card.expanded .pref-category-types {
    display: flex;
}

.pref-type-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px; /* Increased for touch targets */
    min-height: 44px; /* Touch target minimum */
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.pref-type-item:hover {
    background: var(--bg-card-hover);
}

.pref-type-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.pref-type-name {
    flex: 1;
    font-size: 0.8125rem;
    color: var(--text-primary);
}

.pref-type-priority {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
}

.pref-type-priority.critical {
    background: var(--danger-muted);
    color: var(--danger);
}

.pref-type-priority.high {
    background: var(--warning-muted);
    color: var(--warning);
}

.pref-type-priority.normal {
    background: var(--info-muted);
    color: var(--info);
}

.pref-type-priority.low {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

/* Quiet Hours */
.pref-quiet-hours {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pref-quiet-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.pref-time-range {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    transition: opacity var(--transition-fast);
}

.pref-time-range.disabled {
    opacity: 0.5;
}

.pref-time-input {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pref-time-input label {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.pref-time-input input[type="time"] {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.pref-time-input input[type="time"]:focus {
    outline: none;
    border-color: var(--accent);
}

/* Options */
.pref-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pref-option-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.pref-option-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* Help Text */
.pref-help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-top: 8px;
}

/* Action Buttons */
.pref-actions {
    display: flex;
    gap: 12px;
}

.pref-actions .btn {
    flex: 1;
}

.btn-full {
    width: 100%;
}

/* Danger Zone */
.pref-danger-zone {
    border: 1px solid var(--danger-muted);
}

.pref-danger-zone .pref-section-title {
    color: var(--danger);
}

/* Small Toggle Variant */
.toggle-sm {
    width: 44px;
    height: 26px;
}

.toggle-sm .toggle-slider::before {
    height: 20px;
    width: 20px;
}

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

/* Notification Toast (from notificationManager) */
.notification-toast {
    position: fixed;
    bottom: calc(var(--nav-height) + var(--safe-area-bottom) + 100px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 400;
}

.notification-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Responsive adjustments */
@media (max-width: 400px) {
    .pref-section {
        padding: 12px;
    }

    .pref-category-header {
        padding: 12px;
    }

    .pref-category-icon {
        width: 36px;
        height: 36px;
    }

    .pref-category-label {
        font-size: 0.875rem;
    }

    .pref-time-range {
        flex-direction: column;
        gap: 8px;
    }

    .pref-time-input {
        width: 100%;
    }

    .pref-actions {
        flex-direction: column;
    }
}

/* ============================================
   Setup Page Styles
   ============================================ */

.setup-intro {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.setup-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 20px;
    overflow: hidden;
}

.setup-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.setup-icon {
    font-size: 28px;
}

.setup-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.setup-card-title h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.setup-badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--accent);
    color: white;
}

.setup-badge.secondary {
    background: var(--text-muted);
}

.setup-badge.info {
    background: #0ea5e9;
}

/* Checkbox labels for feature selection */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px; /* Increased for touch targets */
    min-height: 44px; /* Touch target minimum */
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.checkbox-label:hover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.05);
}

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

.checkbox-label input[type="checkbox"]:disabled {
    opacity: 0.7;
}

.checkbox-label span {
    flex: 1;
    font-size: 0.9rem;
}

/* MoltWorker Status Card */
.moltworker-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    gap: 1rem;
}

.moltworker-info {
    flex: 1;
    min-width: 0;
}

.moltworker-status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.moltworker-status-indicator .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.moltworker-status-indicator .status-dot.online {
    background: #22c55e;
}

.moltworker-status-indicator .status-dot.offline {
    background: #ef4444;
}

.moltworker-status-indicator .status-dot.warning {
    background: #f59e0b;
}

.moltworker-url {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.moltworker-actions {
    flex-shrink: 0;
}

/* Communication Channels Section */
.comm-channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.comm-channel-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.comm-channel-card:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.comm-channel-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.comm-channel-icon.slack {
    background: linear-gradient(135deg, #4a154b 0%, #611f69 100%);
    color: white;
}

.comm-channel-icon.whatsapp {
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    color: white;
}

.comm-channel-icon.web {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
}

.comm-channel-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.comm-channel-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text);
}

.comm-channel-target {
    font-size: 0.75rem;
    color: var(--primary);
    background: var(--primary-bg);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    width: fit-content;
}

.comm-channel-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.comm-channel-status {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.comm-channel-status.online {
    background: #10b981;
    box-shadow: 0 0 4px #10b981;
}

.comm-channel-status.offline {
    background: #ef4444;
}

/* Gateway Status Card */
.gateway-status {
    margin-bottom: 1rem;
}

.gateway-card {
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.gateway-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.gateway-status-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gateway-status-row .status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
}

.gateway-status-row .status-dot.online {
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.gateway-status-row .status-dot.offline {
    background: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.gateway-status-row .status-dot.error {
    background: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

.gateway-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.gateway-detail {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
}

.gateway-detail .detail-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.gateway-detail .detail-value {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

#gatewayBadge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 9999px;
    background: var(--border);
    color: var(--text-secondary);
}

#gatewayBadge.online {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

#gatewayBadge.offline {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

#gatewayBadge.error {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

/* Gateway Actions and Restart Button */
.gateway-card {
    position: relative;
}

.gateway-actions {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.btn-danger:hover:not(:disabled) {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    transform: translateY(-1px);
}

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

/* Gateway Restart Overlay */
.gateway-restart-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.restart-countdown {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    color: white;
    font-size: 0.95rem;
    font-weight: 500;
}

.countdown-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #f97316;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.setup-desc {
    padding: 16px 20px;
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    border-bottom: 1px solid var(--border);
}

.setup-details {
    padding: 20px;
}

.setup-details h4 {
    margin: 0 0 12px 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.setup-details h4:not(:first-child) {
    margin-top: 24px;
}

/* Provider Grid */
.provider-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 8px;
}

.provider-option {
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-primary);
}

.provider-option:hover {
    border-color: var(--accent);
}

.provider-option.selected {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.05);
}

.provider-logo {
    margin-bottom: 8px;
}

.provider-info {
    margin-bottom: 12px;
}

.provider-info strong {
    display: block;
    font-size: 1rem;
    margin-bottom: 2px;
}

.provider-info span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.provider-features {
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.provider-features li {
    padding: 2px 0;
}

/* Command Box */
.command-box {
    position: relative;
    background: #1a1a2e;
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden; /* Prevent overflow from child elements */
    max-width: 100%;
}

.command-box code {
    display: block;
    padding: 14px 16px;
    padding-right: 80px;
    color: #00ff88;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.9rem;
    overflow-x: auto;
    white-space: nowrap;
    max-width: 100%; /* Contain within parent */
}

.command-box.compact {
    margin-bottom: 0;
}

.command-box.compact code {
    padding: 10px 14px;
    font-size: 0.85rem;
}

.copy-btn {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.copy-btn.copied {
    background: var(--success);
}

/* Feature List */
.feature-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.feature-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.feature-list li svg {
    color: var(--success);
    flex-shrink: 0;
}

/* Requirements List */
.requirements-list {
    margin: 0;
    padding-left: 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.requirements-list li {
    padding: 4px 0;
}

/* Steps List */
.steps-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.step {
    display: flex;
    gap: 14px;
}

.step-num {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

.step-content {
    flex: 1;
}

.step-content strong {
    display: block;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

/* Register Form */
.register-form {
    max-width: 400px;
}

.form-group {
    margin-bottom: 18px;
}

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

.form-group label .optional {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.form-group small {
    display: block;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.form-row {
    display: flex;
    gap: 16px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* Back Button */
.btn-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px; /* Touch target minimum */
    height: 44px; /* Touch target minimum */
    border: none;
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    margin-right: 12px;
}

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

.page-header:has(.btn-back) {
    display: flex;
    align-items: center;
}

/* Mobile Adjustments - Setup Page */
@media (max-width: 400px) {
    .setup-card-header {
        padding: 14px 16px;
    }

    .setup-icon {
        font-size: 24px;
    }

    .setup-card-title h3 {
        font-size: 1rem;
    }

    .setup-desc,
    .setup-details {
        padding: 14px 16px;
    }

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

    .command-box code {
        font-size: 0.8rem;
        padding-right: 70px;
    }

    .feature-list li {
        font-size: 0.85rem;
    }
}

/* ============================================
   Setup Wizard Styles
   ============================================ */

/* Wizard Progress Bar */
.wizard-progress {
    display: flex;
    justify-content: space-between;
    margin-bottom: 32px;
    padding: 0 10px;
    position: relative;
}

.wizard-progress::before {
    content: '';
    position: absolute;
    top: 14px;
    left: 40px;
    right: 40px;
    height: 2px;
    background: var(--border-color);
    z-index: 0;
}

.wizard-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.wizard-step-num {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.wizard-step-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.3s ease;
}

.wizard-step.active .wizard-step-num {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.wizard-step.active .wizard-step-label {
    color: var(--accent);
}

.wizard-step.completed .wizard-step-num {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.wizard-step.completed .wizard-step-num::after {
    content: '✓';
}

/* Wizard Panels */
.wizard-panel {
    display: none;
}

.wizard-panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.wizard-panel h4 {
    font-size: 1.1rem !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    color: var(--text-primary) !important;
    margin-bottom: 8px !important;
}

.wizard-help {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 24px;
    line-height: 1.5;
}

/* Provider Grid Enhancements */
.provider-option {
    position: relative;
}

.provider-check {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: bold;
}

.best-value {
    color: var(--accent) !important;
    font-weight: 600;
}

/* Wizard Actions */
.wizard-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.wizard-actions .btn:only-child {
    margin-left: auto;
}

/* Existing Instances Modal */
.existing-instances-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.existing-instances-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 24px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
}

.existing-instances-content h3 {
    margin: 0 0 8px 0;
    color: var(--accent-primary);
}

.existing-instances-content > p {
    margin: 0 0 20px 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.existing-instances-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
    max-height: 300px;
    overflow-y: auto;
}

.existing-instance-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.existing-instance-card:hover {
    border-color: var(--border-color);
}

.existing-instance-card.selected {
    border-color: var(--accent-primary);
    background: rgba(74, 222, 128, 0.1);
}

.existing-instance-card .instance-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.existing-instance-card .instance-info strong {
    color: var(--text-primary);
}

.existing-instance-card .instance-ip {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
}

.existing-instance-card .instance-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.existing-instance-card .instance-status {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    font-weight: 600;
}

.existing-instance-card .instance-status.online {
    background: rgba(74, 222, 128, 0.2);
    color: #4ade80;
}

.existing-instance-card .instance-status.offline {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.existing-instance-card .instance-region {
    font-size: 11px;
    color: var(--text-muted);
}

.existing-instances-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.existing-instances-actions .btn {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Info Box */
.wizard-info-box {
    display: flex;
    gap: 14px;
    padding: 16px;
    background: var(--accent-muted);
    border-radius: 10px;
    margin-bottom: 24px;
    border: 1px solid rgba(74, 222, 128, 0.2);
}

.wizard-info-box .info-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.wizard-info-box .info-content strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.wizard-info-box .info-content p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Account Steps */
.account-steps {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.account-step {
    display: flex;
    gap: 14px;
}

.account-step-num {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 50%;
    font-size: 0.9rem;
    font-weight: 600;
    flex-shrink: 0;
}

.account-step-content {
    flex: 1;
}

.account-step-content strong {
    display: block;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.account-step-content p {
    margin: 0 0 12px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Token Guide */
.token-guide {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.token-step {
    display: flex;
    gap: 14px;
}

.token-step-num {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    font-size: 0.9rem;
    font-weight: 600;
    flex-shrink: 0;
}

.token-step-content {
    flex: 1;
}

.token-step-content strong {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 1rem;
}

.token-instructions-detail {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 16px;
    margin-top: 12px;
}

.token-instructions-detail p {
    margin: 0 0 10px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.token-instructions-detail ol {
    margin: 0;
    padding-left: 20px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.token-instructions-detail ol li {
    padding: 4px 0;
}

.token-instructions-detail ol li strong {
    display: inline;
    color: var(--accent);
}

/* Token Input */
.input-lg {
    width: 100%;
    padding: 14px 50px 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    transition: border-color 0.2s;
}

.input-lg:focus {
    outline: none;
    border-color: var(--accent);
}

.input-lg::placeholder {
    color: var(--text-muted);
    font-family: inherit;
}

.form-group:has(.input-lg) {
    position: relative;
}

.btn-show-token {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
}

.btn-show-token:hover {
    color: var(--text-primary);
}

.token-security-note {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.token-security-note svg {
    color: var(--success);
}

/* Config Form */
.config-form {
    max-width: 500px;
}

.config-form .form-group {
    margin-bottom: 24px;
}

.config-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.config-form select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
}

.config-form select:focus {
    outline: none;
    border-color: var(--accent);
}

.config-form input[type="text"] {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.config-form input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

/* Size Options */
.size-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.size-option {
    cursor: pointer;
}

.size-option input {
    display: none;
}

.size-card {
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-secondary);
    transition: all 0.2s ease;
}

.size-option:hover .size-card {
    border-color: var(--accent);
}

.size-option input:checked + .size-card {
    border-color: var(--accent);
    background: var(--accent-muted);
}

.size-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.size-header strong {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.size-price {
    color: var(--accent);
    font-weight: 600;
}

.size-specs {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.size-badge {
    display: inline-block;
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.size-option input:checked + .size-card .size-badge {
    background: var(--accent);
    color: white;
}

/* Config Summary */
.config-summary {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 16px;
    margin-top: 24px;
}

.config-summary h5 {
    margin: 0 0 12px 0;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.summary-row span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.summary-row strong {
    color: var(--accent);
}

/* Deploy Review */
.deploy-review {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.deploy-review h5 {
    margin: 0 0 16px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.review-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.review-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.review-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.review-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* Deploy Warning */
.deploy-warning {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--warning-muted);
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.deploy-warning svg {
    color: var(--warning);
    flex-shrink: 0;
}

.deploy-warning span {
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* Deploy Progress */
.deploy-progress {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.progress-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.progress-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

#deployStatus {
    font-weight: 500;
    color: var(--text-primary);
}

.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--success));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-log {
    max-height: 150px;
    overflow-y: auto;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.8rem;
    background: var(--bg-tertiary);
    border-radius: 6px;
    padding: 12px;
}

.log-entry {
    padding: 4px 0;
    color: var(--text-secondary);
}

.log-entry.success {
    color: var(--success);
}

.log-entry.error {
    color: var(--danger);
}

/* Deploy Success */
.deploy-success {
    text-align: center;
    padding: 40px 20px;
}

.success-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.deploy-success h4 {
    margin: 0 0 8px 0 !important;
    font-size: 1.5rem !important;
    color: var(--success) !important;
}

.deploy-success p {
    margin: 0 0 24px 0;
    color: var(--text-secondary);
}

.success-details {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 24px;
    text-align: left;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.detail-row span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.detail-row code {
    background: var(--bg-tertiary);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--accent);
    word-break: break-all;
    max-width: 250px;
    text-align: right;
}

/* Security Badges */
.security-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 24px;
}

.security-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.security-badge::before {
    content: '✓';
    font-size: 0.7rem;
}

/* Button Styles */
.btn-success {
    background: var(--success);
    color: white;
    border: none;
}

.btn-success:hover {
    background: #0ea572;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--accent);
    color: var(--accent);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

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

/* Mobile Wizard Adjustments */
@media (max-width: 600px) {
    .wizard-progress {
        padding: 0;
    }

    .wizard-progress::before {
        left: 20px;
        right: 20px;
    }

    .wizard-step-label {
        font-size: 0.6rem;
    }

    .wizard-step-num {
        width: 26px;
        height: 26px;
        font-size: 0.75rem;
    }

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

    .size-options {
        grid-template-columns: 1fr;
    }

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

    .token-instructions-detail {
        padding: 12px;
    }

    .token-instructions-detail ol {
        padding-left: 16px;
    }

    .wizard-actions {
        flex-direction: column-reverse;
        gap: 12px;
    }

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

/* ============================================
   Tailscale Network Page
   ============================================ */

.tailscale-status {
    padding: 16px;
}

.tailscale-status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 500;
}

.tailscale-info {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.info-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.info-value {
    color: var(--text-primary);
    font-weight: 500;
}

.info-value code,
code.info-value {
    background: var(--bg-tertiary);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.85rem;
}

/* Device Cards */
.device-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    margin-bottom: 8px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.device-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-color-light);
}

.device-card.self {
    border-color: var(--accent);
    border-width: 2px;
}

.device-info {
    flex: 1;
    min-width: 0;
}

.device-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

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

.device-details {
    display: flex;
    align-items: center;
    gap: 12px;
}

.device-ip {
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.device-os {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: capitalize;
}

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

/* Badge small variant */
.badge-small {
    font-size: 0.65rem;
    padding: 2px 6px;
    background: var(--accent-muted);
    color: var(--accent);
    border-radius: 4px;
}

/* Action buttons */
.action-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.action-buttons .btn {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-icon {
    width: 18px;
    height: 18px;
}

/* Responsive adjustments for Network page */
@media (max-width: 600px) {
    .device-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .device-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .device-details {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .action-buttons {
        flex-direction: column;
    }

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

/* ============================================
   Fleet Management Styles
   ============================================ */

/* Fleet Stats Row */
.stats-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.stat-mini {
    flex: 1;
    min-width: 70px;
    text-align: center;
    padding: 12px 8px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.stat-mini-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-mini-label {
    display: block;
    font-size: 0.625rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* Fleet Instance Card */
.instance-card {
    margin-bottom: 12px;
}

.instance-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.instance-emoji {
    font-size: 1.5rem;
}

.instance-info {
    flex: 1;
}

.instance-name {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
}

.instance-meta {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.instance-card-stats {
    display: flex;
    gap: 8px;
}

.instance-card-stats .mini-stat {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.mini-stat-value {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.mini-stat-label {
    display: block;
    font-size: 0.625rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Workload Bars */
.workload-item {
    margin-bottom: 12px;
}

.workload-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    margin-bottom: 4px;
}

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

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--info));
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-fill.warning {
    background: linear-gradient(90deg, var(--warning), #fb923c);
}

.progress-fill.danger {
    background: linear-gradient(90deg, var(--danger), #f87171);
}

/* Alert boxes */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
}

.alert-success {
    background: var(--success-muted);
    color: var(--success);
    border: 1px solid var(--success);
}

.alert-error {
    background: var(--danger-muted);
    color: var(--danger);
    border: 1px solid var(--danger);
}

/* Badge variants */
.badge-success {
    background: var(--success-muted);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-muted);
    color: var(--warning);
}

.badge-error {
    background: var(--danger-muted);
    color: var(--danger);
}

/* Security check list */
.check-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.check-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.check-icon.pass {
    background: var(--success-muted);
    color: var(--success);
}

.check-icon.warn {
    background: var(--warning-muted);
    color: var(--warning);
}

.check-icon.fail {
    background: var(--danger-muted);
    color: var(--danger);
}

.check-info {
    flex: 1;
    min-width: 0;
}

.check-name {
    font-weight: 500;
    margin-bottom: 2px;
}

.check-detail {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-family: monospace;
}

/* Form group */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

/* Text utilities */
.text-muted {
    color: var(--text-muted);
}

/* Clickable cards */
.clickable {
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

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

.clickable:active {
    transform: translateY(0);
}

.instance-card.clickable:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
}

/* ============================================
   Responsive Design Improvements (Audit 2026-02)
   ============================================ */

/* Mobile Small (320px-400px) - Extra refinements */
@media (max-width: 400px) {
    /* Communication channels - stack vertically */
    .comm-channels-grid {
        grid-template-columns: 1fr;
    }

    /* Gateway card layout */
    .gateway-card {
        flex-direction: column;
        gap: 12px;
    }

    .gateway-actions {
        width: 100%;
    }

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

    /* MoltWorker card layout */
    .moltworker-card {
        flex-direction: column;
        gap: 12px;
    }

    .moltworker-actions {
        width: 100%;
        display: flex;
        gap: 8px;
    }

    .moltworker-actions .btn {
        flex: 1;
        justify-content: center;
    }

    /* Ensure search input is full width */
    .search-container {
        width: 100%;
    }

    .search-input,
    #instanceSearch {
        width: 100%;
        min-width: 0;
    }
}

/* Note: 401px-599px and 600px-767px breakpoints consolidated earlier in file */

/* Tablet (768px-1023px) - Sidebar-like bottom nav */
@media (min-width: 768px) and (max-width: 1023px) {
    /* Communication channels - 3 columns */
    .comm-channels-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Bottom nav improvements */
    .bottom-nav {
        justify-content: center;
        gap: 8px;
        padding: 0 16px;
    }

    .nav-item {
        flex: 0 0 auto;
        min-width: 64px;
        padding: 8px 12px;
    }

    /* Instances grid - 2 columns */
    .instances-grid-mobile {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Page content wider */
    .page-content {
        max-width: 800px;
    }
}

/* Touch Target Improvements - ensure 44px minimum */
@media (hover: none) and (pointer: coarse) {
    /* Filter buttons */
    .filter-btn {
        min-height: 44px;
        padding: 10px 16px;
    }

    /* Search input */
    .search-input,
    #instanceSearch,
    .form-input {
        min-height: 44px;
    }

    /* Settings items */
    .settings-item {
        min-height: 56px;
    }

    /* Instance cards */
    .instance-card,
    .instance-card-mobile {
        min-height: 60px;
    }

    /* All buttons */
    .btn,
    .btn-sm,
    .btn-primary,
    .btn-secondary,
    .btn-outline {
        min-height: 44px;
    }

    /* Nav items */
    .nav-item {
        min-height: 48px;
    }

    /* Stat cards */
    .stat-card-clickable {
        min-height: 60px;
    }

    /* Activity items */
    .activity-item {
        min-height: 56px;
    }

    /* Communication channel cards */
    .comm-channel-card {
        min-height: 56px;
    }
}

/* Prevent horizontal scroll - overflow containment */
.page-content {
    overflow-x: hidden;
}

.stats-grid,
.action-grid,
.metrics-grid,
.comm-channels-grid,
.instances-grid-mobile,
.provider-grid,
.size-options,
.review-grid,
.info-grid-mobile {
    max-width: 100%;
}

/* Filter bar - ensure it doesn't cause horizontal scroll on body */
.filter-bar {
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
}

/* Desktop Large (1200px+) - Wider content area */
@media (min-width: 1200px) {
    .page-content {
        max-width: 1000px;
    }

    /* Communication channels - up to 4 columns */
    .comm-channels-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Landscape mode on mobile - reduce padding */
@media (orientation: landscape) and (max-height: 500px) {
    .page-content {
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .greeting {
        margin-bottom: 12px;
    }

    .stats-grid {
        margin-bottom: 16px;
    }

    .section {
        margin-bottom: 16px;
    }

    /* Smaller nav in landscape */
    .bottom-nav {
        height: calc(48px + var(--safe-area-bottom));
    }

    .nav-icon {
        width: 20px;
        height: 20px;
    }

    .nav-label {
        display: none;
    }
}
