/* =====================================================
   RIVER PERMITS TRACKER - MISSION CONTROL THEME
   A sleek, dark, futuristic monitoring dashboard
   ===================================================== */

:root {
    /* Color palette - Deep space meets river blue */
    --bg-primary: #0a0e14;
    --bg-secondary: #0f1419;
    --bg-tertiary: #151b23;
    --bg-card: #1a2332;
    --bg-hover: #1f2937;
    
    /* Accent colors */
    --accent-primary: #00d4aa;
    --accent-secondary: #00b4d8;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --accent-success: #10b981;
    --accent-info: #3b82f6;
    
    /* Text colors */
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --text-bright: #ffffff;
    
    /* Borders & shadows */
    --border-color: #1f2937;
    --border-glow: rgba(0, 212, 170, 0.3);
    --shadow-glow: 0 0 20px rgba(0, 212, 170, 0.1);
    
    /* Spacing */
    --sidebar-width: 240px;
    --header-height: 60px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

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

html, body {
    height: 100%;
}

body {
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

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

/* =====================================================
   MOBILE HEADER
   ===================================================== */

.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    z-index: 200;
}

.mobile-header-content {
    display: flex;
    align-items: center;
    padding: 0 16px;
    height: 100%;
    gap: 16px;
}

.mobile-menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 201;
}

.hamburger-line {
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    transition: all 0.3s ease;
    border-radius: 2px;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

.mobile-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mobile-logo .logo-icon {
    font-size: 24px;
    filter: drop-shadow(0 0 8px var(--accent-primary));
}

.mobile-logo .logo-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--accent-primary);
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 150;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
}

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

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s ease;
}

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

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 32px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s ease;
}

.sidebar-close:hover {
    color: var(--accent-primary);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 28px;
    filter: drop-shadow(0 0 8px var(--accent-primary));
}

.logo-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    color: var(--accent-primary);
    line-height: 1.3;
}

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

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}
.sidebar-nav::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 3px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    padding: 8px 20px;
    text-transform: uppercase;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

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

.nav-item.active {
    background: rgba(0, 212, 170, 0.1);
    color: var(--accent-primary);
    border-left-color: var(--accent-primary);
}

.nav-icon {
    font-size: 12px;
    opacity: 0.7;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-role {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--accent-primary);
}

/* =====================================================
   MAIN CONTENT
   ===================================================== */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px;
    min-height: 100vh;
}

.main-content.full-width {
    margin-left: 0;
}

/* =====================================================
   FLASH MESSAGES
   ===================================================== */

.flash-messages {
    margin-bottom: 24px;
}

.flash {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    animation: slideIn 0.3s ease;
}

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

.flash-success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--accent-success);
}

.flash-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--accent-danger);
}

.flash-warning {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--accent-warning);
}

.flash-info {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--accent-info);
}

.flash-icon {
    font-size: 16px;
}

.flash-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 18px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.flash-close:hover {
    opacity: 1;
}

/* =====================================================
   PAGE HEADERS
   ===================================================== */

.page-header {
    margin-bottom: 32px;
}

.page-header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: 8px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

/* =====================================================
   CARDS & PANELS
   ===================================================== */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

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

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title-icon {
    color: var(--accent-primary);
}

/* =====================================================
   STAT BOXES (Mission Control)
   ===================================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.stat-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-primary);
}

.stat-box.warning::before {
    background: var(--accent-warning);
}

.stat-box.danger::before {
    background: var(--accent-danger);
}

.stat-box.success::before {
    background: var(--accent-success);
}

.stat-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-bright);
    font-family: 'JetBrains Mono', monospace;
}

.stat-subtext {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* =====================================================
   ACTIVITY FEED (Real-time)
   ===================================================== */

.activity-feed {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.activity-feed::-webkit-scrollbar {
    width: 6px;
}
.activity-feed::-webkit-scrollbar-track {
    background: var(--bg-card);
}
.activity-feed::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 3px;
}
.activity-feed::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.activity-item {
    display: flex;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
    animation: fadeIn 0.3s ease;
}

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

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

.activity-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.activity-indicator.check { background: var(--accent-info); }
.activity-indicator.found { background: var(--accent-success); box-shadow: 0 0 10px var(--accent-success); }
.activity-indicator.alert { background: var(--accent-warning); }
.activity-indicator.error { background: var(--accent-danger); }

.activity-content {
    flex: 1;
}

.activity-message {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.activity-time {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-muted);
}

.activity-river {
    font-size: 12px;
    color: var(--accent-secondary);
}

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

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

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

th, td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--text-muted);
    text-transform: uppercase;
    background: var(--bg-tertiary);
}

td {
    font-size: 14px;
    color: var(--text-primary);
}

tr:hover td {
    background: var(--bg-hover);
}

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

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
}

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

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

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

.form-help {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.form-error {
    font-size: 12px;
    color: var(--accent-danger);
    margin-top: 6px;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: #00eebb;
    box-shadow: 0 0 20px rgba(0, 212, 170, 0.4);
}

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

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

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

.btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 12px;
}

.btn-icon {
    padding: 10px;
    min-width: 40px;
}

/* =====================================================
   STATUS INDICATORS
   ===================================================== */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
}

.status-active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-success);
}

.status-inactive {
    background: rgba(107, 114, 128, 0.15);
    color: var(--text-muted);
}

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

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

/* Live indicator */
.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.live-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

/* =====================================================
   KILL SWITCH
   ===================================================== */

.kill-switch {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
}

.kill-switch-label {
    flex: 1;
}

.kill-switch-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.kill-switch-desc {
    font-size: 12px;
    color: var(--text-muted);
}

/* =====================================================
   AUTH PAGES
   ===================================================== */

.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    background: 
        radial-gradient(ellipse at top, rgba(0, 212, 170, 0.05), transparent 50%),
        var(--bg-primary);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: 8px;
}

.auth-brand {
    font-family: 'JetBrains Mono', monospace;
    font-size: 28px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--accent-primary);
    margin-bottom: 4px;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.auth-footer a {
    color: var(--accent-primary);
    text-decoration: none;
}

.auth-footer a:hover {
    text-decoration: underline;
}

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

.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* =====================================================
   GRID LAYOUTS
   ===================================================== */

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    align-items: start;
}

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

/* =====================================================
   PREFERENCE CARDS (Mobile View)
   ===================================================== */

.preference-table-view {
    display: block;
}

.preference-card-view {
    display: none;
}

.preference-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 16px;
}

.preference-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.preference-river-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-bright);
    margin-bottom: 4px;
}

.preference-river-state {
    font-size: 12px;
    color: var(--text-muted);
}

.preference-card-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.preference-detail {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.preference-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    min-width: 80px;
}

.preference-value {
    font-size: 14px;
    color: var(--text-primary);
    text-align: right;
    flex: 1;
}

.preference-card-actions {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.preference-card-actions .btn {
    flex: 1;
}

.preference-card-actions form {
    flex: 1;
}

.preference-card-actions form .btn {
    width: 100%;
}

/* =====================================================
   ALERT CARDS (Mobile View)
   ===================================================== */

.alert-table-view {
    display: block;
}

.alert-card-view {
    display: none;
}

.alert-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 16px;
}

.alert-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.alert-river-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-bright);
    margin-bottom: 4px;
}

.alert-entry-point {
    font-size: 12px;
    color: var(--text-muted);
}

.alert-card-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.alert-detail {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.alert-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    min-width: 100px;
}

.alert-value {
    font-size: 14px;
    color: var(--text-primary);
    text-align: right;
    flex: 1;
}

.alert-card-actions {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.alert-card-actions .btn {
    flex: 1;
}

.alert-card-actions form {
    flex: 1;
}

.alert-card-actions form .btn {
    width: 100%;
}

/* Pagination Controls */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 16px;
    margin-top: 16px;
    border-top: 1px solid var(--border-color);
}

.pagination-controls-mobile {
    margin-top: 16px;
}

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

/* Tablet & Below */
@media (max-width: 1024px) {
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }

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

/* Mobile & Below */
@media (max-width: 768px) {
    /* Show mobile header */
    .mobile-header {
        display: block;
    }

    /* Hide sidebar by default on mobile */
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        z-index: 200;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    }

    /* Show sidebar when active */
    .sidebar.active {
        transform: translateX(0);
    }

    /* Show close button on mobile */
    .sidebar-close {
        display: block;
    }

    /* Show overlay when sidebar is active */
    .sidebar-overlay.active {
        display: block;
    }

    /* Adjust main content for mobile header */
    .main-content {
        margin-left: 0;
        padding: 16px;
        padding-top: 76px; /* Mobile header height + spacing */
    }

    .main-content.full-width {
        padding-top: 32px;
    }

    /* Adjust grids for mobile */
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Make cards more compact on mobile */
    .card {
        padding: 16px;
        margin-bottom: 16px;
    }

    /* Adjust page headers */
    .page-header {
        margin-bottom: 20px;
    }

    .page-header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-header-content .btn {
        width: 100%;
    }

    .page-title {
        font-size: 22px;
    }

    .page-subtitle {
        font-size: 13px;
    }

    /* Hide table view, show card view on mobile for preferences and alerts */
    .preference-table-view,
    .alert-table-view {
        display: none;
    }

    .preference-card-view,
    .alert-card-view {
        display: block;
    }

    /* Make tables scrollable horizontally */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    /* Stack form elements */
    .form-group {
        margin-bottom: 16px;
    }

    /* Adjust button sizes */
    .btn {
        width: 100%;
        justify-content: center;
    }

    .btn-sm {
        width: auto;
    }

    /* Make stat boxes single column */
    .stat-box {
        padding: 16px;
    }

    .stat-value {
        font-size: 28px;
    }

    /* Adjust flash messages */
    .flash {
        padding: 12px 14px;
        font-size: 13px;
    }

    /* Make activity feed more compact */
    .activity-item {
        padding: 12px 0;
    }

    .activity-message {
        font-size: 13px;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    :root {
        --sidebar-width: 100vw;
    }

    .sidebar {
        width: 100vw;
    }

    .main-content {
        padding: 12px;
        padding-top: 72px;
    }

    .page-title {
        font-size: 20px;
    }

    .stat-value {
        font-size: 24px;
    }

    .stats-grid {
        gap: 12px;
    }

    .card {
        padding: 12px;
    }

    /* Smaller text on very small screens */
    body {
        font-size: 14px;
    }

    th, td {
        padding: 10px 12px;
        font-size: 13px;
    }
}

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

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

.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mr-2 { margin-right: 8px; }
.ml-2 { margin-left: 8px; }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }

.font-mono { font-family: 'JetBrains Mono', monospace; }

/* =====================================================
   MOBILE UX IMPROVEMENTS
   ===================================================== */

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Better touch targets on mobile */
@media (max-width: 768px) {
    button,
    a,
    .nav-item,
    .btn {
        min-height: 44px; /* iOS recommended touch target */
        min-width: 44px;
    }

    .nav-item {
        padding: 14px 20px;
    }

    /* Prevent text selection during touch */
    .mobile-menu-toggle,
    .sidebar-close,
    .nav-item {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }

    /* Better spacing for touch */
    .form-input,
    .form-select,
    .form-textarea {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Improve readability */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    /* Prevent horizontal scroll */
    body {
        overflow-x: hidden;
    }
}

/* Landscape mode adjustments for tablets */
@media (max-width: 1024px) and (orientation: landscape) {
    .sidebar {
        width: 240px;
    }

    .main-content {
        padding: 20px;
    }
}

/* Support for notched devices (iPhone X, etc) */
@supports (padding: env(safe-area-inset-top)) {
    .mobile-header {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .sidebar {
        padding-top: env(safe-area-inset-top);
    }

    .main-content {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}

/* =====================================================
   POPUP MODAL SYSTEM
   ===================================================== */

.welcome-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.welcome-modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px 32px 28px;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
    position: relative;
}

.welcome-steps {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 32px;
}

.welcome-step {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-color);
    transition: background 0.2s ease, width 0.2s ease;
}

.welcome-step.active {
    background: var(--accent-primary);
    width: 24px;
    border-radius: 4px;
}

.welcome-slide {
    display: none;
    text-align: center;
}

.welcome-slide.active {
    display: block;
}

.welcome-slide-img {
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.welcome-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: 16px;
}

.welcome-body {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
    text-align: left;
}

.welcome-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 32px;
    gap: 12px;
}

.welcome-nav .btn-primary {
    flex: 1;
}

.welcome-skip {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    padding: 4px 8px;
    transition: color 0.2s ease;
}

.welcome-skip:hover {
    color: var(--text-secondary);
}
