/* Base styles - Modern Design System */
:root {
    /* Color Palette */
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;
    --success: #10b981;
    --success-dark: #059669;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --light: #f8fafc;
    --border: #e2e8f0;

    /* Sidebar Colors - Light Mode (Connexio Style) */
    --sidebar-bg: #ffffff;
    --sidebar-border: #f1f5f9;
    --sidebar-hover: #f8fafc;
    --sidebar-active: #eff6ff;
    --sidebar-text: #64748b;
    --sidebar-text-active: #2563eb;
    --sidebar-icon-active: #3b82f6;

    /* Spacing */
    --sidebar-width: 260px; /* Slightly wider for the card look */

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --------------------------------------------------------------
   Helper: temporarily turn off ALL transitions
   -------------------------------------------------------------- */
.no-transition *,
.no-transition {
    transition: none !important;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: #f8fafc;
    color: #1e293b;
    line-height: 1.6;
    font-size: 14px; /* Increased base font size for better readability */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar - Professional Light Mode */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    color: var(--sidebar-text);
    position: fixed;
    height: 100vh;
    z-index: 1100;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden !important; /* STRICTLY HIDDEN */
}

html.sidebar-collapsed .sidebar {
    width: 72px;
}

/* Scrollbar styling */
/* Scrollbar styling - COMPLETELY HIDDEN */
.sidebar::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important;
    display: none !important;
    background: transparent;
}

.sidebar {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
/* End scrollbar styling */

/* Sidebar Header */
.sidebar-header {
    padding: 1.5rem 1.25rem 1rem; /* More top padding */
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: auto; /* Allow auto height */
    min-height: 60px;
    background: #fff;
    width: 100%;
}

html.sidebar-collapsed .sidebar-header {
    padding: 0;
    justify-content: center;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1rem;
    color: #0f172a;
    width: 100%; /* Ensure it takes available space */
}

.brand-content {
    display: flex;
    align-items: center;
    gap: 0.75rem; /* Space between logo and text */
}

html.sidebar-collapsed .sidebar-brand {
    display: none;
}

.sidebar-logo-icon {
    width: 28px; /* Match SVG size */
    height: 28px;
    color: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Solar Light Glow Animation */
.glowing-part {
    animation: solar-pulse 2s infinite ease-in-out;
    transform-origin: center;
    transform-box: fill-box;
}

@keyframes solar-pulse {
    0% {
        filter: brightness(1) drop-shadow(0 0 2px rgba(255, 169, 31, 0.4));
    }
    50% {
        filter: brightness(1.3) drop-shadow(0 0 8px rgba(255, 169, 31, 0.8));
    }
    100% {
        filter: brightness(1) drop-shadow(0 0 2px rgba(255, 169, 31, 0.4));
    }
}

.sidebar-toggle {
    color: #94a3b8;
    background: transparent;
    border: 1px solid #e2e8f0; /* Restored subtle border for button definition */
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.sidebar-toggle:hover {
    color: #3b82f6;
    border-color: #3b82f6;
    background: #eff6ff;
}

html.sidebar-collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

/* User Profile Card - Matches Uploaded Image */
.user-card {
    margin: 0 1.25rem 2rem 1.25rem; /* Aligned with header padding */
    padding: 0.75rem; /* increased padding for card look */
    background: #f8fafc; /* Highlight background */
    border: 1px solid #e2e8f0; /* Highlight border */
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    overflow: hidden; /* Prevent spillover */
    transition: all 0.2s;
}

.user-card:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

html.sidebar-collapsed .user-card {
    margin: 0.5rem;
    padding: 0.5rem;
    justify-content: center;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px; /* Slightly squarer */
    object-fit: cover;
    background: #f1f5f9;
}

.user-info {
    flex: 1;
    overflow: hidden;
    transition: opacity 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

html.sidebar-collapsed .user-info {
    display: none;
    opacity: 0;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 0.75rem;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-action {
    display: none; /* Hidden as requested for minimalism */
}

html.sidebar-collapsed .user-action {
    display: none;
}

/* Navigation */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 1rem;
}

html.sidebar-collapsed .sidebar-content {
    padding: 0 0.75rem;
}

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

.nav-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #94a3b8;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    padding-left: 0.75rem;
    transition: opacity 0.2s;
}

html.sidebar-collapsed .nav-label {
    opacity: 0;
    height: 0;
    margin: 0;
    overflow: hidden;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
    margin-bottom: 0.25rem;
    position: relative;
}

html.sidebar-collapsed .nav-link {
    justify-content: center;
    padding: 0.75rem;
    gap: 0;
}

.nav-link:hover {
    background-color: var(--sidebar-hover);
    color: #334155;
}

.nav-link.active {
    background-color: var(--sidebar-active);
    color: var(--sidebar-text-active);
}

.nav-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: #94a3b8;
    transition: color 0.2s;
}

.nav-link:hover svg {
    color: #64748b;
}

.nav-link.active svg {
    color: var(--sidebar-icon-active);
}

.nav-link span {
    white-space: nowrap;
    transition: opacity 0.2s;
}

html.sidebar-collapsed .nav-link span {
    display: none;
}

/* Tooltip for collapsed state */
.nav-link::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%) translateX(10px);
    background-color: #1e293b;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    pointer-events: none;
    z-index: 1200;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

html.sidebar-collapsed .nav-link:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(8px);
}

/* Promo Card */
.promo-card {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border-radius: 16px;
    padding: 1.25rem;
    color: white;
    margin-top: 2rem;
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
}

html.sidebar-collapsed .promo-card {
    display: none;
}

.promo-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 60%);
    transform: rotate(45deg);
}

.promo-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.promo-text {
    font-size: 0.75rem;
    margin-bottom: 1rem;
    opacity: 0.9;
    line-height: 1.4;
    position: relative;
}

.promo-btn {
    background: white;
    color: #2563eb;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    width: 100%;
    cursor: pointer;
    transition: transform 0.2s;
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.promo-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
}

/* Bottom Navigation */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--sidebar-border);
    background: #f8fafc;
}

html.sidebar-collapsed .sidebar-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0.5rem;
}

html.sidebar-collapsed .promo-card {
    display: none;
}

/* Cloud Integrations Tree (Visual Only) */
.nav-tree-item {
    padding-left: 2.25rem;
    position: relative;
}

.nav-tree-item::before {
    content: '';
    position: absolute;
    left: 1.25rem;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #e2e8f0;
}

/* Main content adjustments */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: #f8fafc;
    min-height: 100vh;
}

html.sidebar-collapsed .main {
    margin-left: 72px; /* Match new sidebar collapsed width */
}


.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: #fff;
    border-bottom: 1px solid var(--border);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--gray);
}

.content {
    padding: 1rem;
}

/* Cards */
.card {
    background-color: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 1rem;
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

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

.table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--gray);
    background-color: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.table tr:hover {
    background-color: #f1f5f9;
}

/* Status indicators */
.status {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-active {
    background-color: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.status-inactive {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.status-dead {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}


/* Device Status Indicators */
.device-status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    position: relative;
    cursor: pointer;
    margin-right: 4px;
    vertical-align: middle;
}

.device-status-active { background-color: var(--success); }
.device-status-inactive { background-color: var(--warning); }
.device-status-dead { background-color: var(--danger); }

/* Note: Tooltips are now handled globally via JS (see index.html) to prevent clipping */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    border: none;
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s;
}

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

.btn-primary:hover {
    background-color: #2563eb;
}

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

.btn-success:hover {
    background-color: #16a34a;
}

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

.btn-danger:hover {
    background-color: #dc2626;
}

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

.btn-secondary:hover {
    background-color: #475569;
}

/* Loading indicators */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.spinner {
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid #e2e8f0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 0.25rem;
    height: 1rem;
}

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

/* Professional Skeleton Loading Styles */
.skeleton-loader {
    position: absolute;
    inset: 0;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 0.75rem;
    opacity: 1;
    transition: opacity 0.3s ease-out;
}

.skeleton-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.skeleton-chart {
    width: 100%;
    height: 100%;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.skeleton-chart-circle {
    width: 192px;
    height: 192px;
    border-radius: 50%;
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    margin: 0 auto;
}

.skeleton-legend {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
}

.skeleton-legend-item {
    height: 2.5rem;
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 0.5rem;
}

.skeleton-map {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 0.5rem;
}

@keyframes mapShimmer {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}


/* Form elements */
.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background-color: #fff;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

/* Toggle switch */
.form-switch {
    display: flex;
    align-items: center;
}

.form-check-input {
    width: 2.5rem;
    height: 1.25rem;
    margin-right: 0.5rem;
    position: relative;
    appearance: none;
    border-radius: 2rem;
    background-color: #e2e8f0;
    transition: background-color 0.2s;
}

.form-check-input:checked {
    background-color: var(--success);
}

.form-check-input::before {
    content: '';
    position: absolute;
    top: 0.125rem;
    left: 0.125rem;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background-color: #fff;
    transition: transform 0.2s;
}

.form-check-input:checked::before {
    transform: translateX(1.25rem);
}

/* --- Professional Notification System (Minimalistic) --- */
.notification-area {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem; /* Tighter gap */
    width: 320px; /* Slighty narrower */
    max-width: 90vw;
    pointer-events: none;
}

.alert {
    display: flex;
    align-items: flex-start;
    padding: 0.75rem 1rem; /* Compact padding */
    border-radius: 6px; /* Small radius */
    color: var(--gray-800);
    background: #fff; /* Solid background for clean look */
    box-shadow:
        0 2px 5px rgba(0, 0, 0, 0.05),
        0 0 0 1px rgba(0, 0, 0, 0.03); /* Subtle border */
    font-size: 0.85rem; /* Smaller font */
    width: 100%;
    opacity: 0;
    transition: opacity 0.2s ease-in-out, margin-top 0.2s ease-in-out; /* Simple fade */
    pointer-events: auto;
    overflow: hidden;
    position: relative;
    margin-top: 0;
}

.alert::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px; /* Thinner accent line */
    background: currentColor;
    opacity: 0.8;
}

.alert.show {
    opacity: 1;
}

.alert.closing {
    opacity: 0;
    margin-top: -60px; /* Collapse */
}

.alert-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-right: 1rem;
    font-size: 1.1rem;
    flex-shrink: 0;
    border-radius: 50%;
    margin-top: 2px;
}

.alert-content {
    flex: 1;
    line-height: 1.5;
    font-weight: 500;
}

.alert-close {
    background: transparent;
    border: none;
    color: var(--gray-400);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin-left: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.2rem;
    margin-top: 0;
    padding: 0;
}

.alert-close:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--gray-600);
    transform: rotate(90deg);
}

/* Soothing Type Styles */
/* Success - Minty Fresh */
.alert-success {
    background: rgba(236, 253, 245, 0.85); /* Green-50 but glassy */
    color: #065f46; /* Green-800 */
    border-color: rgba(16, 185, 129, 0.2);
}
.alert-success .alert-icon {
    background-color: #d1fae5;
    color: #059669;
}
.alert-success::before { background-color: #10b981; }

/* Danger/Error - Soft Rose */
.alert-danger, .alert-error {
    background: rgba(255, 241, 242, 0.85); /* Rose-50 */
    color: #9f1239; /* Rose-800 */
    border-color: rgba(244, 63, 94, 0.2);
}
.alert-danger .alert-icon, .alert-error .alert-icon {
    background-color: #ffe4e6;
    color: #e11d48;
}
.alert-danger::before, .alert-error::before { background-color: #f43f5e; }

/* Warning - Warm Amber */
.alert-warning {
    background: rgba(255, 251, 235, 0.85); /* Amber-50 */
    color: #92400e; /* Amber-800 */
    border-color: rgba(245, 158, 11, 0.2);
}
.alert-warning .alert-icon {
    background-color: #fef3c7;
    color: #d97706;
}
.alert-warning::before { background-color: #f59e0b; }

/* Info - Calm Sky */
.alert-info {
    background: rgba(239, 246, 255, 0.85); /* Blue-50 */
    color: #1e40af; /* Blue-800 */
    border-color: rgba(59, 130, 246, 0.2);
}
.alert-info .alert-icon {
    background-color: #dbeafe;
    color: #2563eb;
}
.alert-info::before { background-color: #3b82f6; }

/* --- Standardized Components (Minimalistic & Professional) --- */

/* 1. Modal Dialogs */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.6); /* Slate-900 with opacity */
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease-out;
}

.modal-backdrop.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.95);
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid var(--border);
}

.modal-backdrop.show .modal-content {
    transform: scale(1);
    opacity: 1;
}

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

.modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
    line-height: 1.5;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.375rem;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--gray-700);
    background-color: var(--gray-100);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    color: var(--gray-600);
    font-size: 0.9rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background-color: var(--gray-50);
    border-bottom-left-radius: 0.75rem;
    border-bottom-right-radius: 0.75rem;
}

/* 2. Forms (Minimalistic) */
.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.375rem;
}

.form-control, .form-select, .form-input {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--gray-900);
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid var(--gray-300);
    border-radius: 0.375rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus, .form-select:focus, .form-input:focus {
    border-color: var(--primary);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* 3. Buttons (Standardized) */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.8125rem; /* 13px */
    font-weight: 500;
    line-height: 1.5;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
}

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

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

.btn-icon {
    padding: 0.5rem;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-secondary {
    background-color: #fff;
    border-color: var(--gray-300);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background-color: var(--gray-50);
    border-color: var(--gray-400);
    color: var(--gray-900);
}

.btn-success {
    background-color: var(--success);
    border-color: var(--success);
    color: #fff;
}
.btn-success:hover { background-color: var(--success-dark); }

.btn-danger {
    background-color: #fff;
    border-color: var(--danger);
    color: var(--danger);
}
.btn-danger:hover {
    background-color: var(--danger);
    color: #fff;
}

/* 4. Badges (Standardized) */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.725rem;
    font-weight: 600;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.badge-success { background-color: rgba(16, 185, 129, 0.15); color: var(--success-dark); }
.badge-danger { background-color: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-warning { background-color: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-info { background-color: rgba(59, 130, 246, 0.15); color: var(--primary-dark); }
.badge-gray { background-color: var(--gray-100); color: var(--gray-600); }

/* Utility: Flex & Grid Helpers */
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }
.font-medium { font-weight: 500; }
.text-gray-500 { color: var(--gray-500); }

/* ------------------------------------------------------------------
   Top Dashboard Header (Detached Style)
   ------------------------------------------------------------------ */
@media (max-width: 768px) {
    .content-wrapper {
        padding: 1rem;
    }
}

.main {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #f8fafc;
    display: flex;
    flex-direction: column;
}

html.sidebar-collapsed .main {
    margin-left: 72px;
    width: calc(100% - 72px);
}

.top-header {
    height: 80px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* Search Bar (Pill Shape) */
.search-wrapper {
    background: #ffffff;
    border-radius: 9999px;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 400px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
}

.search-icon {
    color: #94a3b8;
    font-size: 1rem;
}

.search-input {
    border: none;
    outline: none;
    background: transparent;
    width: 100%;
    color: #0f172a;
    font-size: 0.95rem;
}

.search-input::placeholder {
    color: #cbd5e1;
}

/* Header Actions (Right Side) */
.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0f172a;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.header-icon-btn:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
}

.notification-dot {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    border: 1px solid #ffffff;
}

.header-divider {
    width: 1px;
    height: 32px;
    background: #dfe4ea;
    margin: 0 0.5rem;
}

/* Header Profile (Detached) */
.header-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    background: transparent;
    padding: 0.5rem;
    border-radius: 9999px;
    transition: background 0.2s;
}

.header-profile:hover {
    background: #e2e8f0;
}

.header-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-username {
    font-weight: 600;
    color: #0f172a;
    font-size: 1rem;
    padding-right: 0.5rem;
}
