/**
 * Main styles for the DAK monitoring system
 */

:root {
    /* Color palette based on UI/UX research for operator dashboards */
    /* Principles: high contrast, neutral backgrounds, clear focus accents */
    
    /* Primary colors: clear but not aggressive */
    --primary-color: #2563EB;        /* Bright blue (Material Design, GitHub) for actions */
    --primary-dark: #1D4ED8;         /* Darker blue for hover */
    --primary-light: #3B82F6;        /* Light blue */
    --secondary-color: #64748B;      /* Neutral gray-blue for secondary actions */
    --secondary-dark: #475569;       /* Darker gray-blue */
    
    /* Semantic colors: clear but not loud */
    --success-color: #10B981;        /* Green (Material Design) for successful operations */
    --success-light: #34D399;         /* Light green */
    --success-bg: #D1FAE5;            /* Background for success messages */
    --danger-color: #EF4444;          /* Red (Material Design) for errors and critical data */
    --danger-light: #F87171;          /* Light red */
    --danger-bg: #FEE2E2;             /* Background for errors */
    --warning-color: #F59E0B;         /* Orange (Material Design) for warnings */
    --warning-light: #FBBF24;         /* Light orange */
    --warning-bg: #FEF3C7;            /* Background for warnings */
    --info-color: #3B82F6;            /* Blue for informational messages */
    --info-light: #60A5FA;            /* Light blue */
    --info-bg: #DBEAFE;               /* Background for info messages */
    
    /* Backgrounds: neutral and low-distraction */
    --bg-color: #FFFFFF;              /* Pure white for maximum contrast and minimal distraction */
    --bg-secondary: #F8FAFC;          /* Very light gray for secondary elements */
    --bg-tertiary: #F1F5F9;           /* Light gray for highlights */
    --card-bg: #FFFFFF;                /* White for cards */
    --card-hover: #F8FAFC;            /* Slight hover change */
    
    /* Sidebar: dark for contrast and focus */
    --sidebar-bg: #1E293B;            /* Dark blue (Slate 800) to avoid distracting from content */
    --sidebar-hover: #334155;         /* Lighter on hover (Slate 700) */
    --sidebar-active: #2563EB;        /* Active item: bright blue for focus */
    --sidebar-text: #F1F5F9;          /* Light text for contrast */
    
    /* Text: high contrast for readability (WCAG AAA) */
    --text-color: #0F172A;            /* Almost black (Slate 900) for maximum readability */
    --text-muted: #64748B;            /* Gray (Slate 500) for secondary text */
    --text-light: #94A3B8;            /* Light gray (Slate 400) */
    --text-inverse: #FFFFFF;          /* White for dark backgrounds */
    
    /* Borders: subtle and non-distracting */
    --border-color: #E2E8F0;          /* Light gray (Slate 200) */
    --border-light: #F1F5F9;          /* Very light gray (Slate 100) */
    --border-dark: #CBD5E0;            /* Darker border (Slate 300) */
    --border-focus: #2563EB;          /* Blue for input focus */
    
    /* Shadows: minimal depth without distraction */
    --shadow-sm: rgba(15, 23, 42, 0.05);
    --shadow-md: rgba(15, 23, 42, 0.08);
    --shadow-lg: rgba(15, 23, 42, 0.12);
    --shadow-focus: rgba(37, 99, 235, 0.2);  /* Blue focus shadow */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.4;
    font-size: 0.875rem;
}

/* Language toggle (left-bottom) */
.lang-toggle {
    position: fixed;
    left: 0.75rem;
    bottom: 0.75rem;
    z-index: 3000;
    display: inline-flex;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    overflow: hidden;
    box-shadow: 0 2px 10px var(--shadow-md);
    backdrop-filter: blur(6px);
}

.lang-toggle__item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-color);
    text-decoration: none;
    min-width: 44px;
}

.lang-toggle__item:hover {
    background: var(--bg-tertiary);
}

.lang-toggle__item.active {
    background: var(--primary-color);
    color: var(--text-inverse);
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 1001;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.5rem;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px var(--shadow-sm);
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
}

.mobile-menu-toggle:focus {
    outline: none;
}

.mobile-menu-toggle:active {
    background-color: var(--primary-dark);
}

.mobile-menu-toggle:hover {
    background-color: var(--primary-dark);
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 200px;
    height: 100vh;
    background-color: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    border-right: none;
}


.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: 4px;
    margin: 0.125rem 0.5rem;
}

.nav-item:hover {
    background-color: var(--sidebar-hover);
    color: var(--sidebar-text);
}

.nav-item.active {
    background-color: var(--sidebar-active);
    color: var(--sidebar-text);
    font-weight: 500;
}

.sidebar-footer {
    border-top: none;
    padding: 0.5rem 0;
    display: flex;
    flex-direction: column;
}

.user-info {
    padding: 0.5rem 1rem;
    color: var(--sidebar-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
}

.sidebar-brand {
    padding: 0.75rem 1rem;
    color: var(--sidebar-text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    margin-top: auto;
    border-top: 1px solid rgba(245, 241, 232, 0.1);
}

/* Main Content */
.main-content {
    margin-left: 200px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}


.content-wrapper {
    flex: 1;
    padding: 0.75rem;
}

/* Dashboard */
.dashboard {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 4px;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 2px var(--shadow-sm);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-icon-blue { background: var(--info-color); color: var(--text-inverse); border: none; }
.stat-icon-green { background: var(--success-color); color: var(--text-inverse); border: none; }
.stat-icon-red { background: var(--danger-color); color: var(--text-inverse); border: none; }
.stat-icon-gray { background: var(--text-muted); color: var(--text-inverse); border: none; }

.stat-info {
    flex: 1;
    min-width: 0;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    line-height: 1.2;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 0.125rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 0.75rem;
}

/* Compact spacing between cards */
.content-card + .content-card {
    margin-top: 0.75rem;
}

.dashboard-card, .content-card {
    background: var(--card-bg);
    border-radius: 4px;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 2px var(--shadow-sm);
}

.content-card canvas {
    height: 300px !important;
}

/* Chart expand button */
.btn-chart-expand {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-chart-expand:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Chart modal */
.chart-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-modal-content {
    background: var(--card-bg);
    width: 70%;
    height: 70%;
    display: flex;
    flex-direction: column;
    border-radius: 4px;
    box-shadow: 0 4px 16px var(--shadow-md);
    border: 1px solid var(--border-color);
}

.chart-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.chart-modal-header h3 {
    font-size: 1.125rem;
    margin: 0;
    color: var(--text-color);
}

.btn-chart-close {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-chart-close:hover {
    color: var(--primary-color);
}

.chart-modal-body {
    padding: 1rem;
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.chart-modal-body canvas {
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
}

.dashboard-card h2, .content-card h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.dashboard-card h3, .content-card h3 {
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
}

.dashboard-card p, .content-card p {
    font-size: 0.8125rem;
    margin-bottom: 0.5rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background-color: var(--bg-tertiary);
}

.data-table th {
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8125rem;
}


/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-online {
    background-color: var(--success-color);
    color: var(--text-inverse);
    border: none;
}

.status-offline {
    background-color: var(--danger-color);
    color: var(--text-inverse);
    border: none;
}

.status-unknown {
    background-color: var(--text-muted);
    color: var(--text-inverse);
    border: none;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border: none;
    border-radius: 4px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--text-inverse);
    font-weight: 500;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: var(--text-inverse);
    font-weight: 500;
}

.btn-secondary:hover {
    background-color: var(--secondary-dark);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* Forms */
.form-group {
    margin-bottom: 0.75rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.8125rem;
}

.form-control {
    width: 100%;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.8125rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px var(--shadow-focus);
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--bg-color);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
}

.login-box {
    background: var(--card-bg);
    border-radius: 4px;
    padding: 3rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px var(--shadow-md);
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.login-header i {
    font-size: 3.5rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: inline-block;
}

.login-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    letter-spacing: -0.5px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

.login-form {
    margin-bottom: 0;
}

.login-form .form-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.75rem;
}

.login-form .form-group label i {
    color: var(--primary-color);
    font-size: 1rem;
}

.login-form .form-control {
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
}

.login-form .form-control:focus {
    border-color: var(--border-focus);
    outline: none;
    box-shadow: 0 0 0 2px var(--shadow-focus);
}

.login-form .btn-primary {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 0.5rem;
    margin-top: 0.5rem;
}

/* Alerts */
.alert {
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    border: none;
}

.alert-error {
    background-color: var(--danger-bg);
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

.alert-success {
    background-color: var(--success-bg);
    color: #065F46;
    border: 1px solid var(--success-color);
}

.alert-warning {
    background-color: var(--warning-bg);
    color: #92400E;
    border: 1px solid var(--warning-color);
}

.alert-info {
    background-color: var(--info-bg);
    color: #1E40AF;
    border: 1px solid var(--info-color);
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.page-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.page-actions {
    display: flex;
    gap: 0.5rem;
}

/* Filters */
.filters-bar {
    background: var(--card-bg);
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 2px var(--shadow-sm);
}

.filters-form {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-group {
    flex: 1;
    min-width: 150px;
}

.filter-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    font-size: 0.8125rem;
}

/* Quick Period Buttons */
.quick-period-buttons {
    margin-top: 0.75rem;
}

.quick-period-buttons .btn-quick-period {
    flex: 0 0 auto;
    white-space: nowrap;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.5rem;
}

/* Utilities */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.telemetry-data {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.875rem;
}

/* Devices grid: very compact device cards */
.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.5rem;
}

.device-card {
    background: var(--card-bg);
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 2px var(--shadow-sm);
}

.device-card-header {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: var(--bg-tertiary);
}

.device-card-title {
    flex: 1;
    min-width: 0;
}

.device-card-title h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0 0 0.125rem 0;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-serial {
    font-size: 0.6875rem;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
    font-weight: 500;
}

.device-card-body {
    padding: 0.5rem 0.75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Telemetry section */
.device-telemetry-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.375rem;
    padding: 0.5rem;
    background-color: var(--bg-tertiary);
    border-radius: 4px;
    margin-bottom: 0.25rem;
    border: 1px solid var(--border-light);
}

.device-telemetry-section .telemetry-item[style*="grid-column"] {
    grid-column: 1 / -1;
    border-top: 1px solid var(--border-color);
    padding-top: 0.375rem;
    margin-top: 0.125rem;
}

.telemetry-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.telemetry-label {
    font-size: 0.625rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    margin-bottom: 0.125rem;
}

.telemetry-value {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-color);
    line-height: 1.2;
}

/* Device information section */
.device-info-section {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.device-info-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border-color);
}

.device-info-row:last-of-type {
    border-bottom: none;
}

.info-label {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.6875rem;
    min-width: 90px;
    flex-shrink: 0;
}

.info-value {
    text-align: right;
    color: var(--text-color);
    font-size: 0.75rem;
    font-weight: 500;
    word-break: break-word;
    flex: 1;
}

.info-value small {
    display: block;
    font-size: 0.625rem;
    margin-top: 0.125rem;
}

.device-card-footer {
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    display: flex;
    gap: 0.375rem;
    justify-content: flex-end;
}

.device-card-footer .btn {
    flex: 1;
    justify-content: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    opacity: 0.6;
}

.empty-state p {
    font-size: 0.875rem;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 768px) {
    /* Mobile Menu Button */
    .mobile-menu-toggle {
        display: flex;
    }
    
    /* Sidebar */
    .sidebar {
        width: 250px;
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding-top: 0;
        overflow-x: hidden;
        width: 100%;
    }
    
    .content-wrapper {
        padding: 0.375rem;
        padding-top: 3.5rem; /* Space for menu button (48px + 0.75rem top + 0.75rem spacing) */
        overflow-x: hidden;
        width: 100%;
        max-width: 100%;
    }
    
    /* Page header: reduce spacing on mobile */
    .page-header {
        margin-bottom: 0.25rem;
        padding-top: 0;
    }
    
    .page-header h2 {
        font-size: 0.8125rem;
        margin-bottom: 0.125rem;
    }
    
    .page-header .text-muted {
        font-size: 0.625rem;
    }
    
    /* Reduce spacing for all sections on mobile */
    [style*="margin-top: 0.375rem"] {
        margin-top: 0.25rem !important;
    }
    
    /* Reduce card padding on mobile */
    .content-card {
        padding: 0.375rem !important;
    }
    
    /* Chart height on mobile */
    .content-card canvas {
        height: 300px !important;
        max-height: 300px !important;
    }
    
    /* Reduce stat card sizes */
    .stat-card {
        padding: 0.375rem !important;
        gap: 0.375rem !important;
    }
    
    .stat-icon {
        width: 32px !important;
        height: 32px !important;
        font-size: 1rem !important;
    }
    
    .stat-value {
        font-size: 1rem !important;
    }
    
    .stat-label {
        font-size: 0.6875rem !important;
    }
    
    /* Grids: single column */
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .devices-grid {
        grid-template-columns: 1fr;
    }
    
    /* Device Cards */
    .device-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .device-card-footer {
        flex-direction: column;
    }
    
    .device-card-footer .btn {
        width: 100%;
    }
    
    /* Device telemetry: 2 columns on mobile */
    .device-telemetry-section {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Stats grid: reduce columns */
    .stats-grid[style*="grid-template-columns: repeat(4, 1fr)"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Page Header */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        margin-bottom: 0.5rem;
    }
    
    .page-actions {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .page-actions .btn {
        flex: 1;
        min-width: 120px;
    }
    
    /* Filters */
    .filters-bar {
        padding: 0.5rem;
    }
    
    .filters-form {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .filter-group {
        min-width: 100%;
    }
    
    .filter-group .btn {
        width: 100%;
    }
    
    /* Tables */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .data-table {
        font-size: 0.75rem;
        min-width: 600px;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.375rem 0.5rem;
        white-space: nowrap;
    }
    
    /* Forms */
    .form-group {
        margin-bottom: 0.5rem;
    }
    
    /* Buttons */
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .btn-sm {
        padding: 0.375rem 0.5rem;
        font-size: 0.8125rem;
    }
    
    /* Content Cards */
    .content-card {
        padding: 0.5rem;
    }
    
    .content-card h3 {
        font-size: 0.875rem;
    }
    
    /* Charts */
    .content-card canvas {
        height: 300px !important;
    }
    
    /* Chart Modal */
    .chart-modal-content {
        width: 95% !important;
        height: 85% !important;
    }
    
    /* Two-column layouts -> single column */
    [style*="grid-template-columns: 1fr 1fr"] {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }
    
    /* Device details: move the "Input" block to a new line */
    [style*="grid-template-columns: 1fr auto"],
    div[style*="grid-template-columns: 1fr auto"] {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 0.375rem !important;
    }
    
    [style*="grid-template-columns: 1.2fr 1fr"] {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }
    
    [style*="grid-template-columns: repeat(auto-fit, minmax(400px, 1fr))"] {
        grid-template-columns: 1fr !important;
    }
    
    [style*="grid-template-columns: repeat(auto-fit, minmax(200px, 1fr))"] {
        grid-template-columns: 1fr !important;
    }
    
    [style*="grid-template-columns: repeat(auto-fit, minmax(150px, 1fr))"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    [style*="grid-template-columns: repeat(auto-fill, minmax(200px, 1fr))"] {
        grid-template-columns: 1fr !important;
    }
    
    [style*="grid-template-columns: repeat(2, 1fr)"] {
        grid-template-columns: 1fr !important;
    }
    
    /* Login */
    .login-container {
        padding: 1rem;
        max-width: 100%;
    }
    
    .login-box {
        padding: 2rem 1.5rem;
    }
    
    .login-header i {
        font-size: 2.5rem;
    }
    
    .login-header h1 {
        font-size: 1.5rem;
    }
    
    /* Alerts */
    .alert {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Stat Cards */
    .stat-card {
        padding: 0.5rem;
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
    
    /* Device Info */
    .device-info-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .info-label {
        min-width: auto;
    }
    
    .info-value {
        text-align: left;
        width: 100%;
    }
    
    /* Remove min-width constraints on mobile */
    [style*="min-width: 200px"],
    [style*="min-width: 150px"],
    [style*="min-width: 120px"] {
        min-width: auto !important;
    }
    
    /* Flex layouts - stack on mobile */
    [style*="display: flex"][style*="justify-content: space-between"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
    }
    
    /* Chart canvas */
    canvas[style*="max-height: 250px"],
    canvas[style*="max-height: 300px"] {
        max-height: 300px !important;
    }
    
    /* Page actions - full width buttons */
    .page-actions {
        width: 100%;
        gap: 0.375rem;
    }
    
    .page-actions .btn {
        flex: 1;
        justify-content: center;
        padding: 0.375rem 0.5rem !important;
        font-size: 0.75rem !important;
    }
}

