/* ============================================
   FITNEEZ - Design System
   Aesthetic: Luxury Fintech meets Supercar Dashboard
   ============================================ */

/* Import Fonts */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ============================================
   CSS Variables
   ============================================ */
:root {
    /* Colors - Dark Luxury Palette */
    --bg-primary: #0a0a0b;
    --bg-secondary: #111113;
    --bg-card: #161618;
    --bg-card-hover: #1a1a1d;
    --bg-elevated: #1e1e21;
    
    /* Accent - Electric Green (Supercar Gauge) */
    --accent-primary: #00ff88;
    --accent-secondary: #00cc6a;
    --accent-glow: rgba(0, 255, 136, 0.15);
    --accent-glow-strong: rgba(0, 255, 136, 0.3);
    
    /* Status Colors */
    --positive: #00ff88;
    --negative: #ff4757;
    --warning: #ffa502;
    --neutral: #747481;
    
    /* Text */
    --text-primary: #ffffff;
    --text-secondary: #a0a0ab;
    --text-muted: #5c5c66;
    
    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.1);
    --border-accent: rgba(0, 255, 136, 0.3);
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(0, 255, 136, 0.15);
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
    
    /* Typography */
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

/* ============================================
   Reset & Base
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Subtle grid background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: -1;
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

.text-gradient {
    background: linear-gradient(135deg, var(--accent-primary), #00ffcc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-positive { color: var(--positive); }
.text-negative { color: var(--negative); }
.text-warning { color: var(--warning); }

.mono { font-family: var(--font-mono); }

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

.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform var(--transition-normal);
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: var(--space-xl);
    min-height: 100vh;
}

.page-header {
    margin-bottom: var(--space-xl);
}

.page-title {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

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

/* ============================================
   Sidebar / Navigation
   ============================================ */
.logo {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding-bottom: var(--space-xl);
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: var(--space-xl);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--bg-primary);
}

.logo-text {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    flex: 1;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-md);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all var(--transition-fast);
}

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

.nav-item.active a {
    background: var(--accent-glow);
    color: var(--accent-primary);
    border: 1px solid var(--border-accent);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    opacity: 0.7;
}

.nav-item.active svg,
.nav-item a:hover svg {
    opacity: 1;
}

.nav-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: var(--space-md) 0;
}

.user-section {
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-subtle);
    margin-top: auto;
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.user-info:hover {
    background: var(--bg-card);
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.user-details {
    flex: 1;
}

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

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

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: all var(--transition-fast);
}

.card:hover {
    border-color: var(--border-default);
    background: var(--bg-card-hover);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

.card-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-value {
    font-size: 2rem;
    font-weight: 600;
    font-family: var(--font-mono);
    letter-spacing: -0.02em;
}

.card-change {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.85rem;
    font-weight: 500;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
}

.card-change.positive {
    color: var(--positive);
    background: rgba(0, 255, 136, 0.1);
}

.card-change.negative {
    color: var(--negative);
    background: rgba(255, 71, 87, 0.1);
}

/* Glass Card Variant */
.card-glass {
    background: rgba(22, 22, 24, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* Accent Card Variant */
.card-accent {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-glow);
}

/* ============================================
   Grid Layouts
   ============================================ */
.grid {
    display: grid;
    gap: var(--space-lg);
}

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

.grid-auto-fit {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--accent-secondary);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
}

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

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

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

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

.btn-sm {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.8rem;
}

.btn-lg {
    padding: var(--space-lg) var(--space-xl);
    font-size: 1rem;
}

/* ============================================
   Form Elements
   ============================================ */
.form-group {
    margin-bottom: var(--space-lg);
}

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

.form-input,
.form-select {
    width: 100%;
    padding: var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: all var(--transition-fast);
}

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

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

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

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

.table th,
.table td {
    padding: var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}

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

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

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

/* ============================================
   Speedometer / Gauge
   ============================================ */
.speedometer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
}

.speedometer {
    position: relative;
    width: 320px;
    height: 180px;
}

.speedometer-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.speedometer-track {
    fill: none;
    stroke: var(--bg-elevated);
    stroke-width: 20;
    stroke-linecap: round;
}

.speedometer-progress {
    fill: none;
    stroke: url(#gaugeGradient);
    stroke-width: 20;
    stroke-linecap: round;
    filter: drop-shadow(0 0 10px rgba(0, 255, 136, 0.5));
    transition: stroke-dashoffset 1s ease-out;
}

.speedometer-ticks {
    fill: none;
    stroke: var(--text-muted);
    stroke-width: 2;
}

.speedometer-needle {
    fill: var(--accent-primary);
    filter: drop-shadow(0 0 8px rgba(0, 255, 136, 0.6));
    transform-origin: center bottom;
    transition: transform 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.speedometer-center {
    fill: var(--bg-card);
    stroke: var(--border-default);
    stroke-width: 2;
}

.speedometer-value {
    font-family: var(--font-mono);
    font-size: 2.5rem;
    font-weight: 600;
    text-align: center;
    margin-top: var(--space-lg);
    letter-spacing: -0.02em;
}

.speedometer-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: var(--space-xs);
}

/* ============================================
   Calendar
   ============================================ */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    background: var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.calendar-header-cell {
    background: var(--bg-elevated);
    padding: var(--space-md);
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.calendar-cell {
    background: var(--bg-card);
    min-height: 120px;
    padding: var(--space-sm);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.calendar-cell:hover {
    background: var(--bg-card-hover);
}

.calendar-cell.empty {
    background: var(--bg-secondary);
    cursor: default;
}

.calendar-cell.today {
    box-shadow: inset 0 0 0 2px var(--accent-primary);
}

.calendar-cell.warning {
    box-shadow: inset 0 0 0 2px var(--warning);
}

.calendar-cell.danger {
    box-shadow: inset 0 0 0 2px var(--negative);
}

.calendar-day {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: var(--space-sm);
}

.calendar-balance {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: auto;
}

.calendar-transaction {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calendar-transaction.credit {
    background: rgba(0, 255, 136, 0.15);
    color: var(--positive);
}

.calendar-transaction.debit {
    background: rgba(255, 71, 87, 0.15);
    color: var(--negative);
}

/* ============================================
   Drag & Drop
   ============================================ */
.drag-item {
    padding: var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    cursor: grab;
    transition: all var(--transition-fast);
}

.drag-item:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.drag-item:active {
    cursor: grabbing;
}

.drag-item.dragging {
    opacity: 0.5;
    transform: scale(1.02);
}

.drop-zone {
    border: 2px dashed var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    text-align: center;
    transition: all var(--transition-fast);
}

.drop-zone.drag-over {
    border-color: var(--accent-primary);
    background: var(--accent-glow);
}

/* ============================================
   Badges & Tags
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-success {
    background: rgba(0, 255, 136, 0.15);
    color: var(--positive);
}

.badge-danger {
    background: rgba(255, 71, 87, 0.15);
    color: var(--negative);
}

.badge-warning {
    background: rgba(255, 165, 2, 0.15);
    color: var(--warning);
}

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

/* ============================================
   Loading States
   ============================================ */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-elevated) 25%,
        var(--bg-card-hover) 50%,
        var(--bg-elevated) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-md);
}

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

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

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

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

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

@keyframes glow {
    0%, 100% { box-shadow: 0 0 20px rgba(0, 255, 136, 0.2); }
    50% { box-shadow: 0 0 40px rgba(0, 255, 136, 0.4); }
}

.animate-fade-in { animation: fadeIn 0.5s ease-out; }
.animate-slide-up { animation: slideUp 0.5s ease-out; }
.animate-slide-in { animation: slideIn 0.5s ease-out; }
.animate-pulse { animation: pulse 2s ease-in-out infinite; }
.animate-glow { animation: glow 2s ease-in-out infinite; }

/* Staggered animations */
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.1s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.2s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.3s; }

/* ============================================
   Mobile Responsive
   ============================================ */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 100%;
        max-width: 300px;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: var(--space-md);
    }
    
    .grid-4,
    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr;
    }
    
    .speedometer {
        width: 260px;
        height: 150px;
    }
    
    .speedometer-value {
        font-size: 2rem;
    }
    
    .calendar-cell {
        min-height: 80px;
    }
    
    .mobile-menu-toggle {
        display: flex;
        position: fixed;
        bottom: var(--space-lg);
        right: var(--space-lg);
        z-index: 101;
        width: 56px;
        height: 56px;
        background: var(--accent-primary);
        color: var(--bg-primary);
        border-radius: var(--radius-full);
        align-items: center;
        justify-content: center;
        box-shadow: var(--shadow-lg);
    }
    
    .overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
    }
    
    .overlay.active {
        display: block;
    }
}

@media (min-width: 769px) {
    .mobile-menu-toggle,
    .overlay {
        display: none !important;
    }
}

/* ============================================
   Utility Classes
   ============================================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.p-xl { padding: var(--space-xl); }

.w-full { width: 100%; }
.h-full { height: 100%; }

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

.hidden { display: none; }
.visible { visibility: visible; }
.invisible { visibility: hidden; }

.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }

.relative { position: relative; }
.absolute { position: absolute; }

.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-full { border-radius: var(--radius-full); }

/* ============================================
   Enhanced Mobile Styles
   ============================================ */
@media (max-width: 768px) {
    /* Typography scaling */
    html { font-size: 14px; }
    
    /* Page headers */
    .page-header h1,
    .balance-header h1 { font-size: 1.5rem; }
    
    /* Dashboard gauges */
    .gauge-row { 
        flex-direction: column; 
        gap: var(--space-lg);
        padding: var(--space-md);
    }
    .gauge-item { width: 100%; max-width: 280px; margin: 0 auto; }
    .gauge-center .gauge-value { font-size: 1.75rem; }
    .gauge-center .gauge-label { font-size: 0.7rem; }
    
    /* Stats below gauges */
    .gauge-stats { 
        flex-direction: row; 
        justify-content: space-around;
        width: 100%;
        margin-top: var(--space-md);
    }
    
    /* Info cards */
    .info-card { padding: var(--space-md); }
    .info-title { font-size: 0.85rem; }
    
    /* Summary cards */
    .summary-card,
    .stat-card { padding: var(--space-md); }
    .summary-value,
    .stat-value { font-size: 1.25rem; }
    
    /* Balance sheet */
    .balance-grid { grid-template-columns: 1fr; gap: var(--space-md); }
    .net-worth-value { font-size: 2rem; }
    .balance-item { 
        flex-wrap: wrap; 
        gap: var(--space-sm);
        padding: var(--space-md);
    }
    .item-actions { 
        width: 100%; 
        justify-content: flex-end;
        margin-top: var(--space-xs);
    }
    .action-btn {
        width: 40px;
        height: 40px;
    }
    
    /* Category headers */
    .category-header { padding: var(--space-md); }
    
    /* Calendar - make it scrollable */
    .calendar-container { overflow-x: auto; }
    .calendar-grid { 
        min-width: 600px;
        font-size: 0.8rem;
    }
    .calendar-cell { 
        min-height: 70px; 
        padding: var(--space-xs);
    }
    .day-pnl { font-size: 0.9rem; }
    .day-trades { font-size: 0.65rem; }
    .calendar-header { padding: var(--space-sm); font-size: 0.75rem; }
    
    /* Trading page header */
    .trading-header { 
        flex-direction: column; 
        align-items: flex-start;
        gap: var(--space-md);
    }
    .header-stats { 
        flex-direction: column; 
        gap: var(--space-sm);
        width: 100%;
    }
    .monthly-pnl { font-size: 0.95rem; }
    .account-value-input { width: 100%; }
    .account-value-input input { flex: 1; }
    
    /* Summary row */
    .summary-row { 
        grid-template-columns: repeat(2, 1fr); 
        gap: var(--space-sm);
    }
    
    /* Charts */
    .charts-section { 
        grid-template-columns: 1fr !important; 
    }
    .chart-card { margin-bottom: var(--space-sm); }
    .chart-card[style*="grid-column: span"] {
        grid-column: span 1 !important;
    }
    
    /* Cash flow page */
    .cashflow-header { flex-direction: column; gap: var(--space-md); }
    .balance-display { width: 100%; text-align: center; }
    
    /* Tables */
    table { font-size: 0.85rem; }
    th, td { padding: var(--space-sm); }
    
    /* Modals */
    .modal { 
        width: 95%; 
        max-width: none;
        margin: var(--space-md);
        max-height: 90vh;
        overflow-y: auto;
    }
    .modal-header { padding: var(--space-md); }
    .modal-body { padding: var(--space-md); }
    .modal-footer { 
        padding: var(--space-md);
        flex-direction: column;
        gap: var(--space-sm);
    }
    .modal-footer .btn { width: 100%; }
    
    /* Form inputs - larger touch targets */
    .form-input,
    .form-select,
    select,
    input[type="text"],
    input[type="number"],
    input[type="date"],
    textarea {
        min-height: 48px;
        font-size: 16px; /* Prevents iOS zoom */
        padding: var(--space-md);
    }
    
    /* Buttons - larger touch targets */
    .btn {
        min-height: 48px;
        padding: var(--space-md) var(--space-lg);
        font-size: 1rem;
    }
    
    /* Add item buttons */
    .add-item-btn {
        padding: var(--space-md);
        min-height: 48px;
    }
    
    /* Real estate cards */
    .property-card { padding: var(--space-md); }
    .property-stats { grid-template-columns: repeat(2, 1fr); gap: var(--space-sm); }
    
    /* Tabs */
    .tabs { overflow-x: auto; flex-wrap: nowrap; }
    .tab-btn { 
        white-space: nowrap; 
        padding: var(--space-sm) var(--space-md);
        min-height: 44px;
    }
    
    /* Hide non-essential on mobile */
    .hide-mobile { display: none !important; }
}

/* Extra small screens */
@media (max-width: 380px) {
    html { font-size: 13px; }
    
    .summary-row { grid-template-columns: 1fr; }
    
    .month-nav { width: 100%; justify-content: space-between; }
    .month-display { font-size: 1.2rem; min-width: auto; }
    
    .gauge-item { max-width: 240px; }
}
