:root {
    --bg-dark: #0f172a;
    --bg-panel: #1e293b;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent: #8b5cf6;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --success: #10b981;
    --danger: #ef4444;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    margin: 0;
    background-image: radial-gradient(circle at top right, #1e293b 0%, #0f172a 60%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Navigation --- */
nav {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    box-sizing: border-box;
}

.logo { 
    font-weight: 800; font-size: 18px; color: white; 
    text-decoration: none; margin-right: 15px; flex-shrink: 0; 
}

.nav-links { 
    display: flex; gap: 5px; overflow-x: auto; 
    padding: 4px 0; flex-shrink: 0; 
    -webkit-overflow-scrolling: touch; /* Smooth scroll iOS */
    scrollbar-width: none; /* Firefox */
}
.nav-links::-webkit-scrollbar { display: none; } /* Hide scrollbar */

.nav-links a { 
    text-decoration: none; color: var(--text-muted); 
    padding: 8px 12px; font-weight: 600; font-size: 13px; 
    border-radius: 6px; transition: all 0.2s ease; 
    border: 1px solid transparent; white-space: nowrap; 
}
.nav-links a:hover { color: white; background: rgba(255,255,255,0.1); }
.active-link { 
    background: var(--primary) !important; color: white !important; 
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5); border-color: #60a5fa !important; 
}

/* --- Layout --- */
.container { 
    max-width: 1200px; width: 100%; margin: 0 auto; 
    padding: 20px; box-sizing: border-box; flex-grow: 1; 
}
.center-view { text-align: center; width: 100%; }
.center-margin { margin: 0 auto 20px auto; display: flex; justify-content: center; }

/* --- Elements --- */
.action-btn { 
    background: var(--primary); color: white; border: none; 
    padding: 10px 18px; border-radius: 6px; cursor: pointer; 
    font-weight: 600; font-size: 14px; transition: 0.2s; 
}
.action-btn:hover { background: var(--primary-hover); }
.action-btn.outline { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.action-btn.outline:hover { border-color: var(--text-main); color: var(--text-main); }
.action-btn.small { padding: 6px 10px; font-size: 12px; }
.action-btn.large { padding: 12px 24px; font-size: 16px; }
.hidden { display: none !important; }

/* --- Inputs & Editors --- */
.input-row { display: flex; gap: 15px; margin-bottom: 15px; }
.input-row textarea { 
    width: 50%; height: 150px; background: var(--bg-panel); 
    border: 1px solid var(--border); color: white; padding: 15px; 
    border-radius: 8px; font-family: 'JetBrains Mono', monospace; 
    font-size: 12px; resize: vertical; 
}

.editor-box-large { height: 70vh; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.editor-box { height: 600px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }

/* --- Panels (Finance/Tools) --- */
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.panel { background: var(--bg-panel); border: 1px solid var(--border); padding: 20px; border-radius: 12px; text-align: left; }
.row-group { display: flex; gap: 15px; margin-bottom: 15px; }
.form-group { flex: 1; }
.form-group label { font-size: 11px; color: var(--text-muted); margin-bottom: 5px; font-weight: bold; display: block; }
.form-group input { width: 100%; background: #0f172a; border: 1px solid var(--border); padding: 10px; color: white; border-radius: 4px; box-sizing: border-box; font-family: 'JetBrains Mono'; }

/* --- Tooltips --- */
.info-icon { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; background: var(--accent); color: white; border-radius: 50%; font-size: 11px; font-weight: bold; cursor: help; margin-left: 6px; position: relative; }
.info-icon:hover::after { content: attr(data-tooltip); position: absolute; bottom: 135%; left: 50%; transform: translateX(-50%); background: #1e293b; color: #f1f5f9; padding: 10px; border-radius: 6px; font-size: 12px; width: 200px; z-index: 9999; text-align: left; border: 1px solid var(--primary); pointer-events: none; }

/* =========================================
   📱 MOBILE OPTIMIZATIONS
   ========================================= */
@media (max-width: 768px) {
    /* General */
    .container { padding: 15px 10px; }
    nav { padding: 10px 15px; flex-direction: column; gap: 10px; align-items: flex-start; }
    .nav-links { width: 100%; padding-bottom: 5px; }
    
    /* Layout Stacking */
    .panel-grid, .input-row, .dev-layout, .editor-layout, .row-group { 
        flex-direction: column !important; 
        gap: 15px !important; 
    }
    
    /* Sidebar Navigation (Tools/PDF/Images) */
    .dev-sidebar, .editor-sidebar { 
        width: 100%; flex-direction: row; overflow-x: auto; 
        border-right: none; border-bottom: 1px solid var(--border); 
        padding-bottom: 10px; flex-shrink: 0; 
    }
    .sidebar-btn { white-space: nowrap; padding: 8px 12px; font-size: 13px; }

    /* Inputs */
    .input-row textarea, .full-text { width: 100% !important; height: 120px; }
    .calc-body { width: 100%; }
    .calc-grid button { padding: 15px 0; font-size: 18px; } /* Bigger tap target */

    /* Editors */
    .editor-box-large, .editor-box, .editor-canvas-area { height: 50vh !important; }

    /* Tables */
    #amortTableContainer { overflow-x: auto; }
    .amort-table { min-width: 400px; } /* Force scroll if table too wide */
}