/**
 * GenWorks IoT Platform - Industrial Theme
 * Corporate / Enterprise Dark Theme
 */

/* ============================================================================
   CSS VARIABLES
   ============================================================================ */

:root {
    /* Primary Colors - Dark Blue Industrial */
    --primary-900: #0d1b2a;
    --primary-800: #1b263b;
    --primary-700: #283845;
    --primary-600: #3d5a73;
    --primary-500: #415a77;
    --primary-400: #778da9;
    --primary-300: #a8c0d6;

    /* Accent - Industrial Orange */
    --accent-600: #c45000;
    --accent-500: #e85d04;
    --accent-400: #f48c06;
    --accent-300: #ffba08;

    /* Status Colors */
    --success-600: #059669;
    --success-500: #10b981;
    --success-400: #34d399;
    --success-300: #6ee7b7;

    --warning-600: #d97706;
    --warning-500: #f59e0b;
    --warning-400: #fbbf24;
    --warning-300: #fcd34d;

    --danger-600: #dc2626;
    --danger-500: #ef4444;
    --danger-400: #f87171;
    --danger-300: #fca5a5;

    --info-600: #0284c7;
    --info-500: #0ea5e9;
    --info-400: #38bdf8;
    --info-300: #7dd3fc;

    /* Neutrals */
    --gray-900: #111827;
    --gray-800: #1f2937;
    --gray-700: #374151;
    --gray-600: #4b5563;
    --gray-500: #6b7280;
    --gray-400: #9ca3af;
    --gray-300: #d1d5db;
    --gray-200: #e5e7eb;
    --gray-100: #f3f4f6;
    --gray-50: #f9fafb;

    /* Background Colors */
    --bg-body: #0d1117;
    --bg-sidebar: #0d1117;
    --bg-card: #161b22;
    --bg-card-hover: #1c2128;
    --bg-input: #21262d;
    --bg-input-focus: #2d333b;

    /* Text Colors */
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --text-link: #58a6ff;
    --text-link-hover: #79c0ff;

    /* Border Colors */
    --border-default: #30363d;
    --border-muted: #21262d;
    --border-emphasis: #484f58;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px -1px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.3);

    /* Spacing */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --header-height: 60px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition: 200ms ease;
    --transition-slow: 300ms ease;

    /* Border Radius */
    --radius-sm: 4px;
    --radius: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

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

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-body);
}

a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--text-link-hover);
}

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 1rem 0;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-primary);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
    margin: 0 0 1rem 0;
}

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

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

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition);
    /* flex items default to min-width:auto, which lets a wide table push the
       whole column (and the page) wider than the screen instead of scrolling
       inside .table-responsive */
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
}

.page-content { min-width: 0; }
.card, .card-body, .col, .col-12, .col-6, .col-4, .col-3 { min-width: 0; }
.table-responsive { max-width: 100%; }
img, canvas, svg, video { max-width: 100%; height: auto; }

.main-content.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

.page-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-default);
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.page-title i {
    color: var(--accent-500);
}

.page-content {
    flex: 1;
    padding: 2rem;
}

/* ============================================================================
   SIDEBAR
   ============================================================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-default);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: width var(--transition);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--border-default);
}

.sidebar-brand .logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.sidebar-brand .logo i {
    font-size: 1.5rem;
    color: var(--accent-500);
}

.sidebar-brand .logo-text {
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition), width var(--transition);
}

.sidebar.collapsed .logo-text {
    opacity: 0;
    width: 0;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-title {
    padding: 0.5rem 1.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.sidebar.collapsed .nav-section-title {
    opacity: 0;
    height: 0;
    padding: 0;
    overflow: hidden;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.25rem;
    color: var(--text-secondary);
    border-left: 3px solid transparent;
    transition: all var(--transition-fast);
    cursor: pointer;
}

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

.nav-item.active {
    background: rgba(232, 93, 4, 0.1);
    border-left-color: var(--accent-500);
    color: var(--accent-400);
}

.nav-item i {
    width: 20px;
    text-align: center;
    margin-right: 0.75rem;
    font-size: 1.125rem;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar.collapsed .nav-item i {
    margin-right: 0;
}

.nav-item-text {
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition), width var(--transition);
}

.sidebar.collapsed .nav-item-text {
    opacity: 0;
    width: 0;
}

.nav-item .badge {
    margin-left: auto;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 10px;
    background: var(--accent-500);
    color: white;
}

.sidebar.collapsed .nav-item .badge {
    display: none;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-default);
}

.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--bg-input-focus);
    color: var(--text-primary);
}

/* ============================================================================
   TOP HEADER
   ============================================================================ */

.top-header {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-search {
    position: relative;
    width: 300px;
}

.header-search input {
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.header-search input:focus {
    outline: none;
    background: var(--bg-input-focus);
    border-color: var(--accent-500);
}

.header-search i {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-btn {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.header-btn .notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
    background: var(--danger-500);
    color: white;
    border-radius: 9px;
}

.user-dropdown {
    position: relative;
}

.user-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.375rem 0.75rem;
    background: transparent;
    border: 1px solid var(--border-default);
    border-radius: var(--radius);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.user-dropdown-toggle:hover {
    background: var(--bg-input);
    border-color: var(--border-emphasis);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-500);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
}

.user-info {
    text-align: left;
}

.user-name {
    font-weight: 500;
    font-size: 0.875rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

.user-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-fast);
    z-index: 1000;
}

.user-dropdown.open .user-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

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

.dropdown-item i {
    width: 16px;
    text-align: center;
}

.dropdown-divider {
    height: 1px;
    margin: 0.5rem 0;
    background: var(--border-default);
}

.dropdown-item.danger {
    color: var(--danger-400);
}

.dropdown-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* ============================================================================
   CARDS
   ============================================================================ */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    overflow: hidden;
}

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

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title i {
    color: var(--accent-500);
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-default);
    background: var(--bg-input);
}

/* Stat Cards */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-card .stat-icon.primary {
    background: rgba(232, 93, 4, 0.15);
    color: var(--accent-500);
}

.stat-card .stat-icon.success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success-500);
}

.stat-card .stat-icon.danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger-500);
}

.stat-card .stat-icon.warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning-500);
}

.stat-card .stat-icon.info {
    background: rgba(14, 165, 233, 0.15);
    color: var(--info-500);
}

.stat-card .stat-content {
    text-align: right;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.stat-card .stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.stat-card .stat-change {
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

.stat-card .stat-change.positive {
    color: var(--success-500);
}

.stat-card .stat-change.negative {
    color: var(--danger-500);
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--accent-600);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-input-focus);
    border-color: var(--border-emphasis);
}

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

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

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

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

.btn-outline-primary {
    background: transparent;
    border-color: var(--accent-500);
    color: var(--accent-500);
}

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

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
}

.btn-icon.btn-sm {
    width: 28px;
    height: 28px;
}

/* ============================================================================
   FORMS
   ============================================================================ */

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-label.required::after {
    content: ' *';
    color: var(--danger-500);
}

.form-control,
.form-select {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius);
    transition: all var(--transition-fast);
}

.form-control:focus,
.form-select:focus {
    outline: none;
    background: var(--bg-input-focus);
    border-color: var(--accent-500);
    box-shadow: 0 0 0 3px rgba(232, 93, 4, 0.1);
}

.form-select.is-invalid {
    border-color: var(--danger-500);
}

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

.form-control.is-invalid {
    border-color: var(--danger-500);
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.invalid-feedback {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: var(--danger-500);
}

.form-text {
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%236b7280'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 20px;
    padding-right: 2.5rem;
}

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

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.form-check-input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--accent-500);
}

.form-check-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.input-group {
    display: flex;
}

.input-group .form-control {
    border-radius: 0;
}

.input-group .form-control:first-child {
    border-radius: var(--radius) 0 0 var(--radius);
}

.input-group .form-control:last-child {
    border-radius: 0 var(--radius) var(--radius) 0;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0 0.875rem;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.input-group-text:first-child {
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
}

.input-group-text:last-child {
    border-left: none;
    border-radius: 0 var(--radius) var(--radius) 0;
}

/* ============================================================================
   TABLES
   ============================================================================ */

.table-responsive {
    overflow-x: auto;
}

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

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

.table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-input);
}

.table tbody tr {
    transition: background var(--transition-fast);
}

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

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

.table-striped tbody tr:nth-child(odd) {
    background: rgba(255, 255, 255, 0.02);
}

/* ============================================================================
   BADGES & STATUS
   ============================================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 20px;
}

.badge-primary {
    background: rgba(232, 93, 4, 0.15);
    color: var(--accent-400);
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success-400);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger-400);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning-400);
}

.badge-info {
    background: rgba(14, 165, 233, 0.15);
    color: var(--info-400);
}

.badge-secondary {
    background: var(--bg-input);
    color: var(--text-secondary);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.online {
    background: var(--success-500);
    box-shadow: 0 0 8px var(--success-500);
}

.status-indicator.offline {
    background: var(--gray-500);
}

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

/* ============================================================================
   ALERTS
   ============================================================================ */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.alert i {
    font-size: 1.125rem;
    margin-top: 0.125rem;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.alert-message {
    font-size: 0.875rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success-400);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger-400);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--warning-400);
}

.alert-info {
    background: rgba(14, 165, 233, 0.1);
    border: 1px solid rgba(14, 165, 233, 0.3);
    color: var(--info-400);
}

/* ============================================================================
   LOGIN PAGE
   ============================================================================ */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-900) 0%, var(--primary-800) 100%);
    padding: 2rem;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.login-logo i {
    font-size: 2.5rem;
    color: var(--accent-500);
}

.login-logo span {
    font-size: 2rem;
    font-weight: 700;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.login-form .form-group {
    margin-bottom: 1.5rem;
}

.login-form .btn {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
}

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-default);
    color: var(--text-muted);
    font-size: 0.8125rem;
}

/* ============================================================================
   UTILITIES
   ============================================================================ */

.text-primary { color: var(--accent-500) !important; }
.text-success { color: var(--success-500) !important; }
.text-danger { color: var(--danger-500) !important; }
.text-warning { color: var(--warning-500) !important; }
.text-info { color: var(--info-500) !important; }
.text-muted { color: var(--text-muted) !important; }

.bg-primary { background-color: var(--accent-500) !important; }
.bg-success { background-color: var(--success-500) !important; }
.bg-danger { background-color: var(--danger-500) !important; }
.bg-warning { background-color: var(--warning-500) !important; }

.d-flex { display: flex !important; }
.d-none { display: none !important; }
.d-block { display: block !important; }

.align-items-center { align-items: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center { justify-content: center !important; }

.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }
.gap-4 { gap: 1.5rem !important; }

.m-0 { margin: 0 !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }

.p-0 { padding: 0 !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 1rem !important; }
.p-4 { padding: 1.5rem !important; }

.w-100 { width: 100% !important; }

.text-center { text-align: center !important; }
.text-right { text-align: right !important; }

.fw-bold { font-weight: 700 !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-normal { font-weight: 400 !important; }

.fs-sm { font-size: 0.875rem !important; }
.fs-xs { font-size: 0.75rem !important; }

.rounded { border-radius: var(--radius) !important; }
.rounded-lg { border-radius: var(--radius-lg) !important; }

.shadow { box-shadow: var(--shadow) !important; }
.shadow-lg { box-shadow: var(--shadow-lg) !important; }

/* Grid */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -0.75rem;
}

.col {
    flex: 1;
    padding: 0 0.75rem;
}

.col-12 { width: 100%; padding: 0 0.75rem; }
.col-6 { width: 50%; padding: 0 0.75rem; }
.col-4 { width: 33.333%; padding: 0 0.75rem; }
.col-3 { width: 25%; padding: 0 0.75rem; }

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

/* Mobile menu button and backdrop exist in the markup at every size; they are
   shown only when the sidebar becomes an off-canvas drawer. */
.mobile-menu-btn { display: none; }
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}
.sidebar-backdrop.show { display: block; }

/* Tablets and phones: sidebar as a drawer, full-width content */
@media (max-width: 992px) {
    .sidebar {
        width: var(--sidebar-width) !important;
        transform: translateX(-100%);
        transition: transform var(--transition);
        box-shadow: none;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
    }
    .sidebar.collapsed .logo-text,
    .sidebar.collapsed .nav-item-text,
    .sidebar.collapsed .nav-section-title { display: inline; }
    .sidebar-toggle { display: none; }
    .main-content,
    .main-content.sidebar-collapsed { margin-left: 0; }
    .mobile-menu-btn { display: flex; }
    .top-header { padding: 0 1rem; gap: 0.5rem; }
    .header-search { flex: 1; width: auto; max-width: 320px; }
}

@media (max-width: 768px) {
    .col-md-12 { width: 100%; }
    .col-md-6 { width: 50%; }

    .page-header {
        flex-wrap: wrap;
        gap: 0.75rem;
        padding: 1rem;
    }
    .page-header .page-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        width: 100%;
    }
    .page-header .page-actions .btn { flex: 1 1 auto; justify-content: center; }
    .page-title { font-size: 1.25rem; }
    .page-content { padding: 1rem; }
    .header-search { display: none; }
    .card-body { padding: 1rem; }
    .table th, .table td { white-space: nowrap; }
    body { -webkit-text-size-adjust: 100%; }
}

@media (max-width: 576px) {
    .col-sm-12 { width: 100%; }
    .col-sm-6 { width: 50%; }

    /* Device list: UUID, Template, IP are visible on the device page anyway */
    .tbl-devices th:nth-child(3), .tbl-devices td:nth-child(3),
    .tbl-devices th:nth-child(5), .tbl-devices td:nth-child(5),
    .tbl-devices th:nth-child(6), .tbl-devices td:nth-child(6) { display: none; }
    /* Dashboard recent devices: Model, Template */
    .tbl-recent th:nth-child(3), .tbl-recent td:nth-child(3),
    .tbl-recent th:nth-child(4), .tbl-recent td:nth-child(4) { display: none; }

    .stat-card { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .stat-card .stat-icon { width: 36px; height: 36px; font-size: 1rem; }
    .user-info { display: none; }
    .user-dropdown-toggle .fa-chevron-down { display: none; }
    .stat-card { padding: 1rem; }
    .stat-card .stat-value { font-size: 1.25rem; }
    .page-content { padding: 0.75rem; }
    .btn { padding: 0.5rem 0.75rem; }
    .modal-dialog, .card { border-radius: var(--radius-md); }
    input, select, textarea { font-size: 16px; }   /* stops iOS from zooming on focus */
}

/* ============================================================================
   LOADING & SPINNERS
   ============================================================================ */

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-default);
    border-top-color: var(--accent-500);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

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

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 17, 23, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* ============================================================================
   EMPTY STATES
   ============================================================================ */

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
}

.empty-state i {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.empty-state h4 {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

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

.fade-in {
    animation: fadeIn var(--transition);
}

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

.slide-up {
    animation: slideUp var(--transition);
}

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

/* Pulse animation for live indicators */
.pulse {
    animation: pulse 2s infinite;
}

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

/* ==========================================================================
   Modal (hidden until .show is added; used by Users > Add Device Access)
   ========================================================================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.55);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal.show { display: flex; }
.modal-content {
    width: 100%;
    max-width: 440px;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-default);
}
.modal-title { margin: 0; font-size: 1rem; font-weight: 600; }
.modal-body { padding: 1.25rem; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-default);
}
.btn-close {
    background: none;
    border: 0;
    color: var(--text-muted);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.25rem;
}
.btn-close::before { content: "\00d7"; }
.btn-close:hover { color: var(--text-primary, #fff); }
