/* ============================================================
   NETSENSE IOT PLATFORM - DESIGN SYSTEM V2.0
   Inspired by: Siemens MindSphere + GE Predix
   Philosophy: Industrial Elegance
   Date: January 28, 2026
   ============================================================ */

/* ==================== CSS RESET ==================== */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    padding: 0;
}

img, picture, video, canvas, svg {
    display: block;
    max-width: 100%;
}

input, button, textarea, select {
    font: inherit;
}

p, h1, h2, h3, h4, h5, h6 {
    overflow-wrap: break-word;
}

/* ==================== DARK THEME (DEFAULT) ==================== */

:root[data-theme="dark"] {
    /* Backgrounds - GE Predix inspired deep navy palette */
    --bg-primary: #0b1120;
    --bg-secondary: #151d2e;
    --bg-tertiary: #1e293b;
    --bg-elevated: #2d3a52;
    --bg-hover: rgba(59, 130, 246, 0.08);
    --bg-active: rgba(59, 130, 246, 0.12);
    
    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-disabled: #64748b;
    
    /* Brand Colors - Siemens-inspired cyan */
    --primary: #06b6d4;
    --primary-hover: #0891b2;
    --primary-light: rgba(6, 182, 212, 0.1);
    --primary-dark: #0e7490;
    
    /* Status Colors - Professional palette */
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.15);
    --success-hover: #059669;
    
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.15);
    --warning-hover: #d97706;
    
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.15);
    --danger-hover: #dc2626;
    
    --info: #3b82f6;
    --info-light: rgba(59, 130, 246, 0.15);
    --info-hover: #2563eb;
    
    /* Borders & Dividers */
    --border-primary: #334155;
    --border-secondary: #475569;
    --border-focus: var(--primary);
    --border-error: var(--danger);
    
    /* Shadows - Subtle elevation for dark theme */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    
    /* Chart Colors - Professional 8-color palette */
    --chart-1: #06b6d4;  /* Cyan */
    --chart-2: #8b5cf6;  /* Violet */
    --chart-3: #10b981;  /* Emerald */
    --chart-4: #f59e0b;  /* Amber */
    --chart-5: #ef4444;  /* Red */
    --chart-6: #ec4899;  /* Pink */
    --chart-7: #14b8a6;  /* Teal */
    --chart-8: #6366f1;  /* Indigo */
}

/* ==================== LIGHT THEME ==================== */

:root[data-theme="light"] {
    /* Backgrounds - Clean Siemens MindSphere whites */
    --bg-primary: #ffffff;
    --bg-secondary: #fafafac5;
    --bg-tertiary: #f5f5f5;
    --bg-elevated: #ffffff;
    --bg-hover: rgba(6, 182, 212, 0.05);
    --bg-active: rgba(6, 182, 212, 0.1);
    
    /* Text Colors */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-disabled: #94a3b8;
    
    /* Brand Colors - Adjusted for light background */
    --primary: #0891b2;
    --primary-hover: #0e7490;
    --primary-light: rgba(6, 182, 212, 0.08);
    --primary-dark: #155e75;
    
    /* Status Colors */
    --success: #059669;
    --success-light: rgba(16, 185, 129, 0.1);
    --success-hover: #047857;
    
    --warning: #d97706;
    --warning-light: rgba(245, 158, 11, 0.1);
    --warning-hover: #b45309;
    
    --danger: #dc2626;
    --danger-light: rgba(239, 68, 68, 0.1);
    --danger-hover: #b91c1c;
    
    --info: #2563eb;
    --info-light: rgba(59, 130, 246, 0.1);
    --info-hover: #1d4ed8;
    
    /* Borders */
    --border-primary: #e5e5e5;
    --border-secondary: #d4d4d4;
    --border-focus: var(--primary);
    --border-error: var(--danger);
    
    /* Shadows - Lighter for light theme */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    
    /* Chart Colors - Same as dark theme */
}

/* ==================== SPACING SYSTEM (8px base) ==================== */

:root {
    --space-1: 4px;     /* 0.5 units */
    --space-2: 8px;     /* 1 unit - BASE */
    --space-3: 12px;    /* 1.5 units */
    --space-4: 16px;    /* 2 units */
    --space-5: 20px;    /* 2.5 units */
    --space-6: 24px;    /* 3 units */
    --space-8: 32px;    /* 4 units */
    --space-10: 40px;   /* 5 units */
    --space-12: 48px;   /* 6 units */
    --space-16: 64px;   /* 8 units */
    --space-20: 80px;   /* 10 units */
}

/* ==================== TYPOGRAPHY SYSTEM ==================== */

:root {
    /* Font Families */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Monaco', monospace;
    
    /* Display - Hero numbers, big stats */
    --text-display: 48px;
    --text-display-weight: 600;
    --text-display-line: 1.1;
    
    /* Headings */
    --text-h1: 32px;
    --text-h1-weight: 600;
    --text-h1-line: 1.2;
    
    --text-h2: 24px;
    --text-h2-weight: 600;
    --text-h2-line: 1.3;
    
    --text-h3: 20px;
    --text-h3-weight: 600;
    --text-h3-line: 1.4;
    
    --text-h4: 16px;
    --text-h4-weight: 600;
    --text-h4-line: 1.5;
    
    /* Body */
    --text-body-lg: 16px;
    --text-body: 14px;        /* Default */
    --text-body-sm: 13px;
    --text-body-weight: 400;
    --text-body-line: 1.5;
    
    /* Labels & Captions */
    --text-label: 12px;
    --text-label-weight: 500;
    --text-label-line: 1.4;
    
    --text-caption: 11px;
    --text-caption-weight: 400;
    --text-caption-line: 1.4;
}

/* ==================== RESPONSIVE BREAKPOINTS ==================== */

:root {
    --breakpoint-sm: 640px;
    --breakpoint-md: 768px;
    --breakpoint-lg: 1024px;
    --breakpoint-xl: 1280px;
    --breakpoint-2xl: 1536px;
    
    /* Layout */
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 72px;
    --header-height: 64px;
}

/* ==================== BASE STYLES ==================== */

body {
    font-family: var(--font-primary);
    font-size: var(--text-body);
    font-weight: var(--text-body-weight);
    line-height: var(--text-body-line);
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ==================== TYPOGRAPHY CLASSES ==================== */

.text-display {
    font-size: var(--text-display);
    font-weight: var(--text-display-weight);
    line-height: var(--text-display-line);
    color: var(--text-primary);
}

.text-h1, h1 {
    font-size: var(--text-h1);
    font-weight: var(--text-h1-weight);
    line-height: var(--text-h1-line);
    color: var(--text-primary);
}

.text-h2, h2 {
    font-size: var(--text-h2);
    font-weight: var(--text-h2-weight);
    line-height: var(--text-h2-line);
    color: var(--text-primary);
}

.text-h3, h3 {
    font-size: var(--text-h3);
    font-weight: var(--text-h3-weight);
    line-height: var(--text-h3-line);
    color: var(--text-primary);
}

.text-h4, h4 {
    font-size: var(--text-h4);
    font-weight: var(--text-h4-weight);
    line-height: var(--text-h4-line);
    color: var(--text-primary);
}

.text-body-lg {
    font-size: var(--text-body-lg);
}

.text-body {
    font-size: var(--text-body);
}

.text-body-sm {
    font-size: var(--text-body-sm);
}

.text-label {
    font-size: var(--text-label);
    font-weight: var(--text-label-weight);
    line-height: var(--text-label-line);
}

.text-caption {
    font-size: var(--text-caption);
    font-weight: var(--text-caption-weight);
    line-height: var(--text-caption-line);
}

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-disabled { color: var(--text-disabled); }

.font-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 600; }
.font-semibold { font-weight: 500; }
.font-normal { font-weight: 400; }

/* ==================== LAYOUT ==================== */

.container {
    width: 100%;
    margin: 0 auto;
    padding: 0 var(--space-4);
}

@media (min-width: 768px) {
    .container {
        padding: 0 var(--space-6);
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: 1280px;
    }
}

.section {
    margin-bottom: var(--space-8);
}

.page-header {
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-primary);
}

.page-title {
    font-size: var(--text-h1);
    font-weight: var(--text-h1-weight);
    color: var(--text-primary);
    margin: 0;
}

.page-subtitle {
    font-size: var(--text-body);
    color: var(--text-muted);
    margin-top: var(--space-2);
}

/* ==================== COMPONENTS: CARDS ==================== */

.card {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-primary);
    transition: all 0.2s ease;
}

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

.card-elevated {
    background: var(--bg-elevated);
    box-shadow: var(--shadow-lg);
}

.card-flat {
    box-shadow: none;
    border: 1px solid var(--border-primary);
}

.card-header {
    padding-bottom: var(--space-4);
    margin-bottom: var(--space-6);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: var(--text-h3);
    font-weight: var(--text-h3-weight);
    color: var(--text-primary);
    margin: 0;
}

.card-subtitle {
    font-size: var(--text-body-sm);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

.card-body {
    /* Main content area */
}

.card-footer {
    padding-top: var(--space-4);
    margin-top: var(--space-6);
    border-top: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ==================== COMPONENTS: STAT CARDS (KPI Style) ==================== */

.stat-card {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: var(--space-6);
    border: 1px solid var(--border-primary);
    transition: all 0.2s ease;
}

.stat-card:hover {
    border-color: var(--border-secondary);
    box-shadow: var(--shadow-md);
}

.stat-label {
    font-size: var(--text-label);
    font-weight: var(--text-label-weight);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}

.stat-value {
    font-size: var(--text-display);
    font-weight: var(--text-display-weight);
    line-height: var(--text-display-line);
    font-family: var(--font-mono);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.stat-trend {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--text-body-sm);
    padding: var(--space-1) var(--space-2);
    border-radius: 4px;
}

.stat-trend.positive {
    color: var(--success);
    background: var(--success-light);
}

.stat-trend.negative {
    color: var(--danger);
    background: var(--danger-light);
}

.stat-trend.neutral {
    color: var(--text-muted);
    background: var(--bg-hover);
}

.stat-trend-icon {
    font-size: 14px;
}

.stat-subtitle {
    font-size: var(--text-caption);
    color: var(--text-muted);
    margin-top: var(--space-2);
}

/* ==================== COMPONENTS: BUTTONS ==================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-body);
    font-weight: 500;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}

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

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

/* Button Variants */
.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 0 0 4px var(--primary-light);
}

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

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

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

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

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

.btn-danger:hover:not(:disabled) {
    background: var(--danger-hover);
    box-shadow: 0 0 0 4px var(--danger-light);
}

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

.btn-success:hover:not(:disabled) {
    background: var(--success-hover);
    box-shadow: 0 0 0 4px var(--success-light);
}

/* Button Sizes */
.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-body-sm);
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--text-body-lg);
}

/* Button States */
.btn-loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ==================== COMPONENTS: BADGES ==================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-label);
    font-weight: 500;
    border-radius: 12px;
    white-space: nowrap;
}

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

/* Badge Variants */
.badge-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid var(--success);
}

.badge-success .badge-dot {
    background: var(--success);
}

.badge-warning {
    background: var(--warning-light);
    color: var(--warning);
    border: 1px solid var(--warning);
}

.badge-warning .badge-dot {
    background: var(--warning);
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.badge-danger .badge-dot {
    background: var(--danger);
}

.badge-info {
    background: var(--info-light);
    color: var(--info);
    border: 1px solid var(--info);
}

.badge-info .badge-dot {
    background: var(--info);
}

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

.badge-neutral .badge-dot {
    background: var(--text-secondary);
}

/* Badge Sizes */
.badge-sm {
    padding: 2px var(--space-2);
    font-size: var(--text-caption);
}

.badge-lg {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-body-sm);
}

/* ==================== COMPONENTS: FORMS ==================== */

.form-group {
    margin-bottom: var(--space-6);
}

.form-label {
    display: block;
    font-size: var(--text-label);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-body);
    font-family: var(--font-primary);
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    transition: all 0.15s ease;
}

.form-input:hover:not(:disabled),
.form-select:hover:not(:disabled),
.form-textarea:hover:not(:disabled) {
    border-color: var(--border-secondary);
}

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

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--bg-tertiary);
}

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

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

.form-hint {
    font-size: var(--text-caption);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

.form-error {
    font-size: var(--text-caption);
    color: var(--danger);
    margin-top: var(--space-1);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
    border-color: var(--border-error);
}

.form-input.error:focus,
.form-select.error:focus,
.form-textarea.error:focus {
    box-shadow: 0 0 0 3px var(--danger-light);
}

/* Input with icon */
.input-group {
    position: relative;
}

.input-icon {
    position: absolute;
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 18px;
    pointer-events: none;
}

.input-group .form-input {
    padding-left: var(--space-10);
}

/* ==================== COMPONENTS: TABLES ==================== */

.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border-primary);
    background: var(--bg-tertiary);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-body);
}

.table thead {
    background: var(--bg-secondary);
}

.table th {
    padding: var(--space-4) var(--space-4);
    text-align: left;
    font-size: var(--text-label);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-primary);
}

.table td {
    padding: var(--space-4) var(--space-4);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-primary);
}

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

.table tbody tr {
    transition: background-color 0.15s ease;
}

.table tbody tr:hover {
    background: var(--bg-hover);
    cursor: pointer;
}

/* Table Variants */
.table-striped tbody tr:nth-child(even) {
    background: var(--bg-secondary);
}

.table-compact td,
.table-compact th {
    padding: var(--space-2) var(--space-3);
}

/* ==================== COMPONENTS: MODALS (Fixed Height 85vh) ==================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    overflow: hidden;
}

.modal.active {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal-card {
    position: relative;
    width: 100%;
    max-width: 900px;
    max-height: 85vh;
    background: var(--bg-elevated);
    border-radius: 12px;
    box-shadow: var(--shadow-2xl);
    border: 1px solid var(--border-secondary);
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
    z-index: 10000;
}

.modal-header {
    flex-shrink: 0;
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: var(--text-h2);
    font-weight: var(--text-h2-weight);
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s ease;
    font-size: 24px;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-6);
}

/* Custom scrollbar for modal body */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--border-secondary);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.modal-footer {
    flex-shrink: 0;
    padding: var(--space-6);
    border-top: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
}

/* Modal Sizes */
.modal-sm .modal-card {
    max-width: 500px;
}

.modal-lg .modal-card {
    max-width: 1200px;
}

.modal-full .modal-card {
    max-width: calc(100vw - var(--space-8));
    max-height: calc(100vh - var(--space-8));
}

/* ==================== COMPONENTS: ALERTS ==================== */

.alert {
    padding: var(--space-4) var(--space-6);
    border-radius: 6px;
    border-left: 4px solid;
    margin-bottom: var(--space-4);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

.alert-icon {
    flex-shrink: 0;
    font-size: 20px;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 600;
    margin-bottom: var(--space-1);
}

.alert-message {
    font-size: var(--text-body-sm);
}

.alert-success {
    background: var(--success-light);
    border-color: var(--success);
    color: var(--success);
}

.alert-warning {
    background: var(--warning-light);
    border-color: var(--warning);
    color: var(--warning);
}

.alert-danger {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
}

.alert-info {
    background: var(--info-light);
    border-color: var(--info);
    color: var(--info);
}

/* ==================== COMPONENTS: LOADING STATES ==================== */

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-primary);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner-lg {
    width: 60px;
    height: 60px;
    border-width: 6px;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 0%,
        var(--bg-secondary) 50%,
        var(--bg-tertiary) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

.skeleton-text {
    height: 16px;
    margin-bottom: var(--space-2);
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: var(--space-4);
}

.skeleton-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

/* ==================== ANIMATIONS ==================== */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

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

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

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

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

/* Animation Utilities */
.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-up {
    animation: slideUp 0.3s ease;
}

.slide-down {
    animation: slideDown 0.3s ease;
}

/* ==================== UTILITY CLASSES ==================== */

/* Display */
.hidden { display: none !important; }
.block { display: block; }
.inline-block { display: inline-block; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }

/* Flexbox */
.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* Grid */
.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Spacing */
.m-0 { margin: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.ml-2 { margin-left: var(--space-2); }
.mr-2 { margin-right: var(--space-2); }

.p-0 { padding: 0; }
.p-2 { padding: var(--space-2); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }

/* Text Alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Text Transform */
.uppercase { text-transform: uppercase; }
.lowercase { text-transform: lowercase; }
.capitalize { text-transform: capitalize; }

/* Text Truncation */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Borders */
.rounded { border-radius: 6px; }
.rounded-lg { border-radius: 8px; }
.rounded-full { border-radius: 9999px; }
.border { border: 1px solid var(--border-primary); }
.border-t { border-top: 1px solid var(--border-primary); }
.border-b { border-bottom: 1px solid var(--border-primary); }

/* Width */
.w-full { width: 100%; }
.w-auto { width: auto; }

/* Cursor */
.cursor-pointer { cursor: pointer; }
.cursor-not-allowed { cursor: not-allowed; }

/* Opacity */
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }

/* ==================== LOGIN SCREEN ==================== */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.login-box {
    background: var(--bg-tertiary);
    padding: var(--space-12);
    border-radius: 12px;
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--border-primary);
    box-shadow: var(--shadow-xl);
}

.login-logo {
    font-size: var(--text-body);
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: var(--space-2);
    text-align: center;
}

.login-title {
    font-size: var(--text-h2);
    font-weight: 300;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: var(--space-10);
}

/* ==================== APP LAYOUT ==================== */

.app-container {
    display: flex;
    min-height: 100vh;
    background: var(--bg-primary);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-primary);
}

.sidebar-logo {
    font-size: var(--text-h4);
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--primary);
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-4);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-1);
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.15s ease;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
}

.nav-icon {
    font-size: 20px;
}

.sidebar-footer {
    padding: var(--space-4);
    border-top: 1px solid var(--border-primary);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
    padding: var(--space-4) var(--space-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-title {
    font-size: var(--text-h3);
    font-weight: var(--text-h3-weight);
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.main-body {
    flex: 1;
    padding: var(--space-6);
}

/* ==================== RESPONSIVE DESIGN ==================== */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1000;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .modal-card {
        max-height: 90vh;
    }
    
    .login-box {
        padding: var(--space-8);
    }
    
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }
}

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

@media (min-width: 1024px) {
    .grid-responsive {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .grid-responsive-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ==================== THEME TOGGLE BUTTON ==================== */

#theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: var(--text-body-sm);
}

#theme-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--border-secondary);
    color: var(--text-primary);
}

/* ==================== PRINT STYLES ==================== */

@media print {
    .sidebar,
    .main-header,
    .btn,
    #theme-toggle {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .card {
        break-inside: avoid;
    }
}

/* ==================== EVENTS PAGE ==================== */
.events-filters {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-primary);
}

.events-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 20px;
    min-height: 600px;
}

.events-list-panel {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-primary);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.events-list {
    flex: 1;
    overflow-y: auto;
    max-height: 700px;
}

.event-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-primary);
    cursor: pointer;
    transition: background 0.15s ease;
}

.event-item:hover {
    background: var(--bg-secondary);
}

.event-item.active {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--color-primary);
}

.event-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.event-type-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.event-type-icon.refill {
    background: rgba(34, 197, 94, 0.15);
    color: var(--color-success);
}

.event-type-icon.anomaly {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-danger);
}

.event-item-title {
    font-weight: 500;
    font-size: var(--text-body-sm);
    color: var(--text-primary);
}

.event-item-asset {
    font-size: var(--text-caption);
    color: var(--text-secondary);
}

.event-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
}

.event-item-volume {
    font-weight: 600;
    font-size: var(--text-body-sm);
}

.event-item-volume.positive {
    color: var(--color-success);
}

.event-item-volume.negative {
    color: var(--color-danger);
}

.event-item-status {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.event-item-status.pending {
    background: rgba(251, 191, 36, 0.15);
    color: var(--color-warning);
}

.event-item-status.closed {
    background: rgba(34, 197, 94, 0.15);
    color: var(--color-success);
}

.events-detail-panel {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-primary);
    padding: 20px;
    overflow-y: auto;
}

.events-detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: var(--text-muted);
}

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

.events-detail-content.hidden {
    display: none;
}

.event-detail-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-primary);
}

.event-detail-type {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: var(--text-body-sm);
    margin-bottom: 8px;
}

.event-detail-type.refill {
    background: rgba(34, 197, 94, 0.15);
    color: var(--color-success);
}

.event-detail-type.anomaly {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-danger);
}

.event-detail-asset {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.event-detail-date {
    font-size: var(--text-body-sm);
    color: var(--text-secondary);
}

.event-detail-chart {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 20px;
    height: 200px;
}

.event-detail-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

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

.event-metric-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.event-metric-label {
    font-size: var(--text-caption);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.event-detail-timeline {
    margin-bottom: 20px;
    max-height: 200px;
    overflow-y: auto;
}

.timeline-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-primary);
}

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

.timeline-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.timeline-content {
    flex: 1;
}

.timeline-author {
    font-weight: 500;
    font-size: var(--text-body-sm);
    color: var(--text-primary);
}

.timeline-text {
    font-size: var(--text-body-sm);
    color: var(--text-secondary);
    margin-top: 2px;
}

.timeline-date {
    font-size: var(--text-caption);
    color: var(--text-muted);
    margin-top: 4px;
}

.event-detail-actions {
    border-top: 1px solid var(--border-primary);
    padding-top: 16px;
}

.event-detail-actions textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: var(--text-body-sm);
    resize: none;
    margin-bottom: 12px;
}

.event-detail-actions textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

.event-actions-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.event-classifications {
    display: flex;
    gap: 6px;
}

.btn-classify {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-primary);
    background: var(--bg-secondary);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.15s ease;
}

.btn-classify:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-secondary);
}

.btn-classify.selected {
    border-color: var(--color-primary);
    background: rgba(59, 130, 246, 0.1);
}

.event-action-buttons {
    display: flex;
    gap: 8px;
}

/* ==================== REPORTS PAGE ==================== */
.reports-filters {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 24px;
    padding: 20px;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-primary);
}

.reports-filters .filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.reports-filters .filter-group label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table-filter-input {
    padding: 8px 12px;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: var(--text-body-sm);
}

.table-filter-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.reports-results {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-primary);
    overflow: hidden;
}

.reports-results.hidden {
    display: none;
}

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

.reports-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.reports-count {
    font-size: var(--text-body-sm);
    color: var(--text-secondary);
    font-weight: 400;
    margin-left: 8px;
}

.reports-export {
    display: flex;
    gap: 8px;
}

.btn-export {
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border-primary);
    background: var(--bg-primary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.btn-export:hover {
    background: var(--bg-secondary);
    border-color: var(--border-secondary);
}

.reports-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--text-muted);
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-primary);
}

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

#reports-table tfoot td {
    font-weight: 600;
    background: var(--bg-secondary);
    border-top: 2px solid var(--border-primary);
}

/* Responsive Events */
@media (max-width: 1024px) {
    .events-layout {
        grid-template-columns: 1fr;
    }

    .events-list-panel {
        max-height: 300px;
    }
}

/* ==================== END DESIGN SYSTEM ==================== */

/* --- Force page router behavior (only active page visible) --- */
.page {
    display: none !important;
}

.page.active {
    display: block !important;
}

/* --- Page routing visibility --- */
.page-content.hidden {
    display: none !important;
}

.page-content {
    display: block;
}
/* ===========================
   V4 – Assets Page Polish
=========================== */

/* Header más limpio */
#page-assets .page-header {
    margin-bottom: 20px;
}

#page-assets .page-title {
    font-size: 20px;
    font-weight: 600;
}

#page-assets .page-subtitle {
    font-size: 13px;
    color: #6b7280;
}

/* Container más contenido */
#page-assets .container {
    max-width: 100%;
}

/* Controles más compactos */
#page-assets .table-enhanced-controls {
    gap: 10px;
}

#page-assets .table-search-input,
#page-assets .table-filter-select {
    height: 36px;
    font-size: 13px;
}

/* Tabla más limpia */
#page-assets .table-enhanced {
    font-size: 13px;
}

#page-assets .table-enhanced th {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

#page-assets .table-enhanced td {
    padding: 10px 12px;
}
/* ===========================
   V4 – Alerts Page Polish
=========================== */

#page-alerts .alerts-summary-bar {
    background: #f8fafc;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

#page-alerts .alert-summary-pill {
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
}

#page-alerts .alert-summary-count {
    font-weight: 600;
}

#page-alerts .table-enhanced {
    font-size: 13px;
}

#page-alerts .table-enhanced th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

#page-alerts .empty-state {
    margin-top: 24px;
}

#page-alerts .empty-state-icon {
    font-size: 28px;
    opacity: 0.7;
}