/* ========================================
   XMADE Systems Dashboard - Main Styles
   Color Scheme: Blue + Dark Mode Support
======================================== */

:root {
    /* Light Mode Colors */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #3b82f6;
    --secondary-color: #64748b;
    
    --bg-color: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-sidebar: #94a3b8;
    --text-sidebar-active: #f1f5f9;
    
    --border-color: #e2e8f0;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.08);
    
    /* Status Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #0ea5e9;
    
    /* Sidebar */
    --sidebar-width: 250px;
    --sidebar-collapsed: 70px;
    
    /* Compact sizing */
    --font-size-base: 0.875rem;
    --font-size-sm: 0.75rem;
    --font-size-xs: 0.6875rem;
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 0.75rem;
    --spacing-lg: 1rem;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-color: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #020617;
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-sidebar: #64748b;
    --text-sidebar-active: #f1f5f9;
    
    --border-color: #1e293b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* ========================================
   Base Styles
======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    line-height: 1.5;
    transition: background-color 0.2s ease, color 0.2s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

a:hover {
    color: var(--primary-hover);
}

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

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 1.5rem 2.5rem;
    transition: margin-left 0.2s ease;
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100% - var(--sidebar-width));
    overflow-x: hidden;
}

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

/* ========================================
   Sidebar
======================================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    z-index: 1000;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header {
    padding: 1rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    color: white;
    flex-shrink: 0;
}

.sidebar-brand {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #f1f5f9;
    letter-spacing: -0.01em;
}

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

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

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

.nav-section-title {
    padding: 0.5rem 1rem 0.375rem;
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #475569;
    font-weight: 600;
}

.nav-item {
    position: relative;
    margin: 0 0.5rem 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    color: var(--text-sidebar);
    transition: all 0.15s ease;
    gap: 0.625rem;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-sidebar-active);
}

.nav-link.active {
    background: rgba(37, 99, 235, 0.15);
    color: #60a5fa;
}

.nav-link i {
    width: 18px;
    text-align: center;
    font-size: 0.875rem;
    opacity: 0.7;
}

.nav-link:hover i,
.nav-link.active i {
    opacity: 1;
}

.nav-link .badge {
    margin-left: auto;
    padding: 0.125rem 0.375rem;
    border-radius: 50px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    background: var(--primary-color);
    color: white;
    min-width: 18px;
    text-align: center;
}

/* Submenu */
.nav-submenu {
    display: none;
    margin-top: 2px;
    padding-left: 0.5rem;
}

.nav-item.open .nav-submenu {
    display: block;
}

.nav-submenu .nav-link {
    padding: 0.375rem 0.75rem 0.375rem 2rem;
    font-size: var(--font-size-xs);
    color: #64748b;
    position: relative;
}

.nav-submenu .nav-link::before {
    content: '';
    position: absolute;
    left: 1.125rem;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.4;
}

.nav-submenu .nav-link:hover,
.nav-submenu .nav-link.active {
    color: #60a5fa;
    background: transparent;
}

.nav-submenu .nav-link.active::before {
    background: #60a5fa;
    opacity: 1;
}

.nav-toggle {
    margin-left: auto;
    transition: transform 0.2s ease;
    font-size: 0.625rem;
    opacity: 0.5;
}

.nav-item.open .nav-toggle {
    transform: rotate(180deg);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-version {
    padding: 0.375rem 0.75rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-version span {
    font-size: var(--font-size-xs);
    color: #475569;
}

.sidebar-version .version-badge {
    background: rgba(37, 99, 235, 0.1);
    color: #60a5fa;
    padding: 0.125rem 0.5rem;
    border-radius: 50px;
    font-size: var(--font-size-xs);
    font-weight: 600;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    transition: background 0.15s ease;
}

.user-menu:hover {
    background: rgba(255, 255, 255, 0.03);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--font-size-xs);
    color: white;
    flex-shrink: 0;
}

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

.user-name {
    font-weight: 500;
    font-size: var(--font-size-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #e2e8f0;
}

.user-role {
    font-size: var(--font-size-xs);
    color: #64748b;
}

.logout-btn {
    color: #64748b;
    padding: 0.375rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    font-size: 0.875rem;
}

.logout-btn:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* ========================================
   Header / Topbar
======================================== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-title h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.page-title p {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    margin-top: 0.125rem;
}

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

/* Theme Toggle */
.theme-toggle {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    font-size: 0.875rem;
}

.theme-toggle:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 1001;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    font-size: 1rem;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* ========================================
   Cards
======================================== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.card-title {
    font-size: var(--font-size-base);
    font-weight: 600;
}

.card-body {
    padding: 1rem;
}

.card-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.01);
}

/* Stat Cards */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    width: 100%;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

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

.stat-icon.blue {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
}

.stat-icon.green {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stat-icon.orange {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.stat-icon.red {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.stat-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.125rem;
    line-height: 1.2;
}

.stat-content p {
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
}

/* ========================================
   Grid Layout
======================================== */
.grid {
    display: grid;
    gap: 1rem;
    width: 100%;
}

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

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

.grid-3-1 {
    grid-template-columns: 2fr 1fr;
}

/* ========================================
   Tables
======================================== */
.table-container {
    overflow-x: auto;
}

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

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

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(0, 0, 0, 0.02);
}

.table tbody tr {
    transition: background 0.2s ease;
}

.table tbody tr:hover {
    background: rgba(37, 99, 235, 0.02);
}

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

/* ========================================
   Badges
======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: 50px;
    font-size: var(--font-size-xs);
    font-weight: 500;
}

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

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

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

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

.badge-primary {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
}

.badge-secondary {
    background: rgba(100, 116, 139, 0.1);
    color: var(--secondary-color);
}

/* ========================================
   Buttons
======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    text-decoration: none;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: var(--font-size-xs);
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: var(--font-size-base);
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    color: white;
    transform: translateY(-1px);
}

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

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

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

.btn-success:hover {
    background: #0d9668;
    color: white;
}

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

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

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

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

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
}

/* ========================================
   Forms
======================================== */
.form-group {
    margin-bottom: 1.5rem;
}

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

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    transition: all 0.15s ease;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

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

select.form-control {
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-text {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ========================================
   Alerts
======================================== */
.alert {
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--font-size-sm);
}

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

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

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

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

/* ========================================
   Empty State
======================================== */
.empty-state {
    text-align: center;
    padding: 2rem 1.5rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    opacity: 0.4;
}

.empty-state h3 {
    margin-bottom: 0.375rem;
    color: var(--text-primary);
    font-size: var(--font-size-base);
}

/* ========================================
   Pagination
======================================== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    margin-top: 1.25rem;
}

.pagination a,
.pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    transition: all 0.15s ease;
    font-size: var(--font-size-sm);
}

.pagination a:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination .active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ========================================
   Auth Pages
======================================== */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.auth-card.wide {
    max-width: 440px;
}

.auth-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-logo {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.5rem;
    color: white;
    margin: 0 auto 1rem;
}

.auth-header h1 {
    font-size: 1.25rem;
    margin-bottom: 0.375rem;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.auth-form .form-group {
    margin-bottom: 1rem;
}

.auth-form .form-control {
    padding: 0.625rem 0.875rem;
}

.auth-form .btn {
    width: 100%;
    padding: 0.625rem;
    font-size: var(--font-size-sm);
    margin-top: 0.375rem;
}

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

.auth-footer a {
    color: var(--primary-color);
    font-weight: 500;
}

.password-toggle {
    position: relative;
}

.password-toggle .toggle-btn {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
}

.password-toggle .toggle-btn:hover {
    color: var(--primary-color);
}

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-wrapper input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ========================================
   Utilities
======================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* ========================================
   Responsive
======================================== */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .stat-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .stat-cards {
        grid-template-columns: 1fr;
    }
    
    .main-content {
        padding: 1.25rem 1.5rem;
        padding-top: 5rem;
    }
    
    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .auth-card {
        padding: 2rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }
}

/* ========================================
   PWA / Mobile App Styles
======================================== */

/* iOS Safe Areas */
@supports (padding-top: env(safe-area-inset-top)) {
    .main-content {
        padding-top: calc(1.5rem + env(safe-area-inset-top));
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
        padding-left: max(2.5rem, env(safe-area-inset-left));
        padding-right: max(2.5rem, env(safe-area-inset-right));
    }
    
    .sidebar {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .mobile-menu-toggle {
        top: calc(0.75rem + env(safe-area-inset-top));
    }
}

/* iOS Install Prompt */
.ios-install-prompt {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    z-index: 10000;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.ios-install-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 500px;
    margin: 0 auto;
    position: relative;
}

.ios-install-close {
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    background: var(--danger);
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.ios-install-icon {
    flex-shrink: 0;
}

.ios-install-text {
    flex: 1;
}

.ios-install-text strong {
    display: block;
    margin-bottom: 0.25rem;
}

.ios-install-text p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.ios-install-text svg {
    vertical-align: middle;
}

/* Mobile Bottom Navigation (optional) */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border-color);
    padding: 0.5rem;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    z-index: 1000;
}

@media (max-width: 768px) {
    /* Show bottom nav on mobile */
    .mobile-bottom-nav {
        display: flex;
        justify-content: space-around;
    }
    
    .mobile-bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 0.5rem;
        color: var(--text-sidebar);
        text-decoration: none;
        font-size: 0.625rem;
        gap: 0.25rem;
        flex: 1;
        text-align: center;
    }
    
    .mobile-bottom-nav a.active {
        color: var(--primary-color);
    }
    
    .mobile-bottom-nav a i {
        font-size: 1.25rem;
    }
    
    /* Adjust main content for bottom nav */
    .main-content {
        padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
    }
    
    /* Better mobile topbar */
    .topbar {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }
    
    .topbar h1 {
        font-size: 1.125rem;
    }
    
    .topbar p {
        font-size: 0.75rem;
    }
    
    /* Better mobile buttons */
    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.8125rem;
    }
    
    .btn-sm {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }
    
    /* Touch-friendly spacing */
    .card {
        margin-bottom: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* Mobile action buttons in tables */
    .table-actions {
        display: flex;
        gap: 0.5rem;
    }
    
    .table-actions .btn {
        padding: 0.5rem;
        min-width: 36px;
    }
    
    .table-actions .btn span {
        display: none;
    }
}

/* Standalone mode (when installed as app) */
@media (display-mode: standalone) {
    .main-content {
        padding-top: calc(1rem + env(safe-area-inset-top));
    }
    
    /* Hide browser-specific elements */
    .browser-only {
        display: none;
    }
}

/* Touch feedback */
@media (hover: none) {
    .btn:active,
    .nav-link:active,
    .card:active {
        opacity: 0.8;
        transform: scale(0.98);
    }
}

