/* emi.css — extracted verbatim from emi.html's original inline <style>; logic/behavior unchanged, only relocated */
/* ==========================================================================
           1. DESIGN SYSTEM & VARIABLES (Synced with Suite Ecosystem)
           ========================================================================== */
        :root {
            --font-main: 'Plus Jakarta Sans', sans-serif;
            --transition-speed: 0.4s;
            --transition-smooth: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
            
            --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
            --calc-bg: #ffffff;
            --calc-border: rgba(15, 23, 42, 0.06);
            --calc-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.04);
            --text-main: #0f172a;
            --text-secondary: #64748b;
            
            --input-bg: rgba(241, 245, 249, 0.8);
            --accent-color: #007bff; /* EMI Calculator Royal Blue Accent */
            --accent-hover: #0056b3;
            --toggle-bg: #fd7e14;
            --table-stripe: #f8fafc;
            --panel-bg: #ffffff;
            --scrollbar-thumb: rgba(15, 23, 42, 0.15);
            --danger: #f43f5e;
            --success: #10b981;
        }

        body.dark-mode {
            --bg-gradient: linear-gradient(135deg, #020617 0%, #0f172a 100%);
            --calc-bg: rgba(15, 23, 42, 0.6);
            --calc-border: rgba(255, 255, 255, 0.06);
            --calc-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
            --text-main: #f8fafc;
            --text-secondary: #94a3b8;
            
            --input-bg: rgba(30, 41, 59, 0.5);
            --accent-color: #3b82f6;
            --accent-hover: #2563eb;
            --table-stripe: rgba(255, 255, 255, 0.02);
            --panel-bg: rgba(15, 23, 42, 0.95);
            --scrollbar-thumb: rgba(255, 255, 255, 0.1);
        }

        /* ==========================================================================
           2. GLOBAL STYLES & RESET
           ========================================================================== */
        * { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-user-select: none; }
        body {
            font-family: var(--font-main); background: var(--bg-gradient); min-height: 100vh;
            display: flex; justify-content: center; align-items: center; padding: 40px 20px;
            color: var(--text-main); transition: background var(--transition-speed) ease, color var(--transition-speed) ease;
            overflow-x: hidden; position: relative;
        }
        body::before {
            content: ''; position: absolute; width: 400px; height: 400px; border-radius: 50%;
            filter: blur(150px); opacity: 0.1; z-index: -1; top: -10%; left: -10%; background: #007bff;
        }

        /* ==========================================================================
           3. CONTAINER & FIXED VIEWPORTS WORKSPACE
           ========================================================================== */
        .calc-container {
            position: relative; width: 100%; max-width: 950px; 
            height: calc(100vh - 40px);
            background: var(--calc-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
            border: 1px solid var(--calc-border); border-radius: 28px; box-shadow: var(--calc-shadow);
            display: flex; flex-direction: column; overflow: hidden; transition: var(--transition-smooth);
        }
        .calc-header {
            display: flex; justify-content: space-between; align-items: center;
            padding: 20px 24px 14px 24px; z-index: 10; flex-shrink: 0; border-bottom: 1px solid var(--calc-border);
        }
        .calc-title { font-family: 'Space Grotesk', sans-serif; font-size: 1.25rem; font-weight: 700; letter-spacing: -0.5px; }
        .header-controls { display: flex; gap: 10px; align-items: center; }
        
        .icon-btn {
            background: var(--input-bg); border: 1px solid var(--calc-border);
            width: 38px; height: 38px; border-radius: 12px; cursor: pointer;
            display: flex; justify-content: center; align-items: center;
            color: var(--text-main); transition: var(--transition-smooth);
        }
        .icon-btn:hover { transform: scale(1.05); border-color: var(--accent-color); }
        .icon-btn:active { transform: scale(0.95); }
        .icon-btn svg { width: 18px; height: 18px; fill: currentColor; }

        .theme-btn .sun-icon, body.dark-mode .theme-btn .moon-icon { display: none; }
        body.dark-mode .theme-btn .sun-icon { display: block; }

        /* Scroller Body Dynamic Frame Workspace */
        .calc-body-workspace {
            padding: 20px 24px 24px 24px; flex-grow: 1; display: flex;
            flex-direction: column; gap: 24px; overflow-y: auto;
        }
        .calc-body-workspace::-webkit-scrollbar { width: 5px; }
        .calc-body-workspace::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 10px; }

        .calculator-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
        .form-group-item { display: flex; flex-direction: column; gap: 6px; position: relative; }
        label { font-size: 0.8rem; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.3px; }
        
        .input-wrapper { position: relative; display: flex; align-items: center; }
        .input-wrapper span { position: absolute; left: 14px; font-weight: 700; color: var(--text-secondary); }
        
        input[type="number"] { width: 100%; background: var(--input-bg); border: 1px solid var(--calc-border); padding: 12px 14px 12px 32px; border-radius: 12px; font-family: var(--font-main); font-size: 0.95rem; font-weight: 600; color: var(--text-main); outline: none; transition: var(--transition-smooth); }
        input:focus { border-color: var(--accent-color); background: var(--calc-bg); }
        .error-msg { color: var(--danger); font-size: 0.78rem; margin-top: 4px; display: none; font-weight: 600; }

        .toggle-container { display: flex; align-items: center; justify-content: space-between; background: var(--input-bg); padding: 12px 14px; border-radius: 14px; border: 1px solid var(--calc-border); }
        .switch { position: relative; display: inline-block; width: 48px; height: 24px; }
        .switch input { opacity: 0; width: 0; height: 0; }
        .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #cbd5e1; transition: .4s; border-radius: 24px; }
        .slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 4px; bottom: 4px; background-color: white; transition: .4s; border-radius: 50%; }
        
        body.dark-mode .slider { background-color: #475569; }
        .tenure-switch input:checked + .slider { background-color: var(--toggle-bg); }
        input:checked + .slider:before { transform: translateX(24px); }

        .btn-reset { width: 100%; padding: 12px; background: #64748b; color: white; border: none; border-radius: 12px; font-family: var(--font-main); font-size: 0.92rem; font-weight: 700; cursor: pointer; transition: var(--transition-smooth); margin-top: 6px; }
        .btn-reset:hover { background: #475569; transform: translateY(-1px); }

        /* Output presentation metrics panels mapping */
        .output-panel { display: flex; flex-direction: column; gap: 16px; justify-content: space-between; }
        .metrics-container { display: flex; flex-direction: column; gap: 12px; }
        .metric-card { background: var(--input-bg); border-left: 4px solid var(--accent-color); padding: 14px; border-radius: 0 12px 12px 0; border-top: 1px solid var(--calc-border); border-right: 1px solid var(--calc-border); border-bottom: 1px solid var(--calc-border); }
        .metric-card p { font-size: 0.78rem; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; }
        .metric-card h3 { font-family: 'Space Grotesk', sans-serif; font-size: 1.6rem; font-weight: 700; color: var(--text-main); margin-top: 2px; }
        .chart-box { max-height: 180px; display: flex; justify-content: center; align-items: center; }

        /* Amortization Segment Frame Sheets */
        .table-responsive { overflow-x: auto; max-height: 280px; border-radius: 14px; border: 1px solid var(--calc-border); }
        table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.9rem; }
        th { background: var(--accent-color); color: white; padding: 12px; font-weight: 700; position: sticky; top: 0; z-index: 5; }
        td { padding: 12px; border-bottom: 1px solid var(--calc-border); color: var(--text-main); }
        tr:nth-child(even) { background: var(--table-stripe); }

        /* Slideout History Panel Architecture */
        .history-panel {
            position: absolute; top: 0; right: -100%; width: 100%; max-width: 380px; height: 100%;
            background: var(--panel-bg); backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px);
            z-index: 100; transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1); display: flex; flex-direction: column;
            border-left: 1px solid var(--calc-border);
        }
        .history-panel.open { right: 0; }
        .history-header { display: flex; justify-content: space-between; align-items: center; padding: 24px; border-bottom: 1px solid var(--calc-border); }
        .history-title { font-family: 'Space Grotesk', sans-serif; font-size: 1.2rem; font-weight: 700; }
        .history-list { flex-grow: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 12px; }
        .history-list::-webkit-scrollbar { width: 4px; }
        .history-list::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }
        
        .history-item { text-align: left; padding: 12px 14px; border-radius: 14px; background: var(--input-bg); border: 1px solid var(--calc-border); cursor: pointer; transition: var(--transition-smooth); display: flex; justify-content: space-between; align-items: center; }
        .history-item:hover { border-color: var(--accent-color); transform: translateY(-1px); }
        .hist-type { font-size: 0.75rem; font-weight: 700; color: var(--accent-color); text-transform: uppercase; }
        .hist-expr { font-size: 0.85rem; color: var(--text-secondary); margin: 2px 0; }
        .hist-res { font-family: 'Space Grotesk', sans-serif; font-size: 1.05rem; font-weight: 700; }
        
        .history-footer { padding: 20px 24px; border-top: 1px solid var(--calc-border); display: flex; justify-content: flex-end; }
        .clear-hist-btn { background: transparent; border: none; color: var(--accent-color); font-size: 0.9rem; font-weight: 700; cursor: pointer; }

        /* Toast Component */
        .toast {
            position: fixed; bottom: 35px; left: 50%; transform: translate(-50%, 40px);
            background: #0f172a; color: #ffffff; padding: 12px 24px; border-radius: 50px;
            font-size: 0.85rem; font-weight: 600; opacity: 0; pointer-events: none;
            transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease; z-index: 9999;
        }
        body.dark-mode .toast { background: #f8fafc; color: #0f172a; }
        .toast.show { transform: translate(-50%, 0); opacity: 1; }

        @media (max-width: 820px) {
            .calculator-grid { grid-template-columns: 1fr; }
            .calc-container { height: 100vh; max-height: 100vh; border-radius: 0; border: none; }
            body { padding: 0; }
        }
