/* ===== CSS Variables & Reset ===== */
:root,
[data-theme="dark"] {
    color-scheme: dark;
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(24, 34, 56, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.04);
    --bg-input-prefix: rgba(255, 255, 255, 0.04);
    --header-bg: rgba(10, 14, 26, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(110, 231, 183, 0.3);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-green: #6EE7B7;
    --accent-blue: #3B82F6;
    --accent-purple: #A78BFA;
    --accent-pink: #F472B6;
    --accent-amber: #FBBF24;
    --gradient-primary: linear-gradient(135deg, #6EE7B7, #3B82F6);
    --gradient-warm: linear-gradient(135deg, #FBBF24, #F472B6);
    --gradient-cool: linear-gradient(135deg, #A78BFA, #3B82F6);
    --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 30px rgba(110, 231, 183, 0.15);
    --table-head-bg: rgba(110, 231, 183, 0.1);
    --table-head-solid: #111827;
    --table-head-group-solid: #121c31;
    --table-head-interest-solid: #1a1630;
    --table-head-total-solid: #252015;
    --table-head-group-bg: rgba(59, 130, 246, 0.12);
    --table-head-interest-bg: rgba(167, 139, 250, 0.12);
    --table-head-total-bg: rgba(251, 191, 36, 0.12);
    --table-head-row1-h: 2.6rem;
    --table-interest-border: rgba(167, 139, 250, 0.28);
    --table-row-hover: rgba(110, 231, 183, 0.04);
    --table-row-highlight: rgba(110, 231, 183, 0.08);
    --table-border-row: rgba(255, 255, 255, 0.03);
    --table-total-border: rgba(251, 191, 36, 0.25);
    --select-bg: #151c2e;
    --select-text: #e2e8f0;
    --particle-opacity: 0.3;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --font-main: 'Noto Sans Thai', 'Inter', sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    color-scheme: light;
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.92);
    --bg-card-hover: #ffffff;
    --bg-glass: rgba(15, 23, 42, 0.04);
    --bg-input-prefix: rgba(15, 23, 42, 0.05);
    --header-bg: rgba(255, 255, 255, 0.92);
    --border-color: rgba(15, 23, 42, 0.1);
    --border-glow: rgba(16, 185, 129, 0.35);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --accent-green: #059669;
    --accent-blue: #2563eb;
    --accent-purple: #7c3aed;
    --accent-pink: #db2777;
    --accent-amber: #d97706;
    --gradient-primary: linear-gradient(135deg, #34d399, #3b82f6);
    --gradient-warm: linear-gradient(135deg, #fbbf24, #f472b6);
    --gradient-cool: linear-gradient(135deg, #a78bfa, #3b82f6);
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 20px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 8px 40px rgba(15, 23, 42, 0.1);
    --shadow-glow: 0 0 30px rgba(16, 185, 129, 0.12);
    --table-head-bg: rgba(16, 185, 129, 0.12);
    --table-head-solid: #f8fafc;
    --table-head-group-solid: #eff6ff;
    --table-head-interest-solid: #f5f3ff;
    --table-head-total-solid: #fffbeb;
    --table-head-group-bg: rgba(37, 99, 235, 0.1);
    --table-head-interest-bg: rgba(124, 58, 237, 0.1);
    --table-head-total-bg: rgba(217, 119, 6, 0.12);
    --table-head-row1-h: 2.6rem;
    --table-interest-border: rgba(124, 58, 237, 0.3);
    --table-row-hover: rgba(16, 185, 129, 0.06);
    --table-row-highlight: rgba(16, 185, 129, 0.12);
    --table-border-row: rgba(15, 23, 42, 0.06);
    --table-total-border: rgba(217, 119, 6, 0.35);
    --select-bg: #ffffff;
    --select-text: #0f172a;
    --particle-opacity: 0.18;
}

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

html { scroll-behavior: smooth; }

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

/* ===== Background Particles ===== */
.bg-particles {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 0; overflow: hidden;
}
.bg-particles .particle {
    position: absolute; border-radius: 50%;
    animation: floatParticle linear infinite;
    opacity: 0;
}
[data-theme="light"] .bg-particles { opacity: 0.55; }
@keyframes floatParticle {
    0% { transform: translateY(100vh) scale(0); opacity: 0; }
    10% { opacity: var(--particle-opacity); }
    90% { opacity: var(--particle-opacity); }
    100% { transform: translateY(-10vh) scale(1); opacity: 0; }
}

/* ===== Header ===== */
.header {
    position: sticky; top: 0; z-index: 100;
    background: var(--header-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 24px;
}
.header-content {
    max-width: 1200px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon svg { width: 40px; height: 40px; }
.logo-title {
    font-size: 1.4rem; font-weight: 800;
    background: var(--gradient-primary); -webkit-background-clip: text;
    -webkit-text-fill-color: transparent; background-clip: text;
    letter-spacing: -0.5px;
}
.logo-subtitle { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; }

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

.rate-status-bar {
    max-width: 1200px;
    margin: 10px auto 0;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}
.rate-status {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: right;
    line-height: 1.5;
    flex: 1;
    min-width: 200px;
}
.rate-status.loading { color: var(--accent-amber); }
.rate-status.live,
.rate-status.fallback { color: var(--text-secondary); }
.rate-status .rate-sep {
    margin: 0 6px;
    color: var(--text-muted);
    font-weight: 400;
}
.rate-status .rate-chip {
    font-weight: 600;
    white-space: nowrap;
}
.rate-status .rate-chip strong {
    font-weight: 800;
}
.rate-status .rate-chip-usd { color: var(--accent-blue); }
.rate-status .rate-chip-sgd { color: var(--accent-amber); }
.rate-status .rate-chip-jpy { color: var(--accent-pink); }
.rate-status .rate-chip-cny { color: var(--accent-purple); }
.btn-icon-sm { width: 28px; height: 28px; flex-shrink: 0; }
.btn-icon-sm svg { width: 14px; height: 14px; }
.btn-icon:disabled { opacity: 0.45; cursor: not-allowed; }

.theme-icon { width: 18px; height: 18px; }
[data-theme="dark"] .theme-icon-moon,
[data-theme="light"] .theme-icon-sun { display: none; }
[data-theme="dark"] .theme-icon-sun,
[data-theme="light"] .theme-icon-moon { display: block; }

.currency-select,
.currency-select-account {
    color-scheme: dark;
    background-color: var(--select-bg);
    border: 1px solid var(--border-color);
    color: var(--select-text);
    padding: 8px 28px 8px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}
.currency-select-account {
    padding: 6px 24px 6px 10px;
    font-size: 0.8rem;
}
.currency-select:hover,
.currency-select:focus,
.currency-select-account:hover,
.currency-select-account:focus {
    border-color: var(--accent-green);
    background-color: var(--select-bg);
    color: var(--select-text);
}
[data-theme="dark"] .currency-select,
[data-theme="dark"] .currency-select-account { color-scheme: dark; }
[data-theme="light"] .currency-select,
[data-theme="light"] .currency-select-account { color-scheme: light; }
.currency-select option,
.currency-select-account option {
    background-color: var(--select-bg);
    color: var(--select-text);
}

.btn-icon {
    background: var(--bg-glass); border: 1px solid var(--border-color);
    color: var(--text-secondary); width: 40px; height: 40px;
    border-radius: var(--radius-sm); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.btn-icon svg { width: 18px; height: 18px; }
.btn-icon:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); border-color: var(--border-glow); }

/* ===== Main Content ===== */
.main-content {
    max-width: 1200px; margin: 0 auto;
    padding: 32px 24px 60px; position: relative; z-index: 1;
}

/* ===== Section ===== */
.section { margin-bottom: 40px; }
.section-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin-bottom: 20px; flex-wrap: wrap; gap: 16px;
}
.section-title-group { display: flex; align-items: flex-start; gap: 14px; }
.section-icon {
    width: 44px; height: 44px; border-radius: var(--radius-md);
    background: var(--gradient-primary); display: flex;
    align-items: center; justify-content: center; flex-shrink: 0;
}
.section-icon.target-icon { background: var(--gradient-warm); }
.section-icon.results-icon { background: var(--gradient-cool); }
.section-icon svg { width: 22px; height: 22px; stroke: #0a0e1a; }
.section-title { font-size: 1.25rem; font-weight: 700; color: var(--text-primary); }
.section-desc { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; border-radius: var(--radius-sm);
    font-family: var(--font-main); font-size: 0.9rem; font-weight: 600;
    cursor: pointer; border: none; transition: var(--transition);
    white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary {
    background: var(--gradient-primary); color: #0a0e1a;
    box-shadow: 0 4px 15px rgba(110, 231, 183, 0.25);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 25px rgba(110, 231, 183, 0.35); }
.btn-calculate {
    background: var(--gradient-primary); color: #0a0e1a;
    padding: 14px 36px; font-size: 1rem; border-radius: var(--radius-md);
    box-shadow: 0 4px 20px rgba(110, 231, 183, 0.3);
}
.btn-calculate:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(110, 231, 183, 0.4); }
.btn-danger {
    background: rgba(239, 68, 68, 0.15); color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-outline {
    background: var(--bg-glass); color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.btn-outline:hover { border-color: var(--border-glow); color: var(--text-primary); }

/* ===== Accounts Grid ===== */
.accounts-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

/* ===== Account Card ===== */
.account-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    backdrop-filter: blur(10px);
    transition: var(--transition);
    animation: cardSlideIn 0.4s ease-out;
    position: relative;
    overflow: hidden;
}
.account-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 3px; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.account-card:nth-child(6n+1)::before { background: var(--gradient-primary); }
.account-card:nth-child(6n+2)::before { background: var(--gradient-warm); }
.account-card:nth-child(6n+3)::before { background: var(--gradient-cool); }
.account-card:nth-child(6n+4)::before { background: linear-gradient(135deg, #F472B6, #EF4444); }
.account-card:nth-child(6n+5)::before { background: linear-gradient(135deg, #FBBF24, #6EE7B7); }
.account-card:nth-child(6n+6)::before { background: linear-gradient(135deg, #3B82F6, #A78BFA); }
.account-card:hover { border-color: var(--border-glow); box-shadow: var(--shadow-glow); }

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

.account-card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.account-name-group { display: flex; align-items: center; gap: 10px; }
.account-badge {
    width: 32px; height: 32px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 0.85rem; color: #0a0e1a;
}
.account-card:nth-child(6n+1) .account-badge { background: var(--accent-green); }
.account-card:nth-child(6n+2) .account-badge { background: var(--accent-amber); }
.account-card:nth-child(6n+3) .account-badge { background: var(--accent-purple); }
.account-card:nth-child(6n+4) .account-badge { background: var(--accent-pink); }
.account-card:nth-child(6n+5) .account-badge { background: var(--accent-green); }
.account-card:nth-child(6n+6) .account-badge { background: var(--accent-blue); }

.account-name-input {
    background: transparent; border: none; color: var(--text-primary);
    font-size: 1rem; font-weight: 600; font-family: var(--font-main);
    width: 160px; outline: none; border-bottom: 1px solid transparent;
    padding-bottom: 2px; transition: var(--transition);
}
.account-name-input:focus { border-bottom-color: var(--accent-green); }

.btn-remove {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 4px; border-radius: 6px; transition: var(--transition);
    display: flex; align-items: center; justify-content: center;
}
.btn-remove svg { width: 18px; height: 18px; }
.btn-remove:hover { color: #f87171; background: rgba(239,68,68,0.1); }

/* ===== Form Groups ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-size: 0.8rem; font-weight: 500;
    color: var(--text-secondary); margin-bottom: 6px;
}
/* Money input: prefix column + field (no overlap) */
.input-with-icon:has(.input-icon) {
    display: flex;
    align-items: stretch;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    overflow: hidden;
}
.input-with-icon:has(.input-icon):focus-within {
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px rgba(110, 231, 183, 0.1);
}
.input-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 3rem;
    padding: 0 10px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    pointer-events: none;
    border-right: 1px solid var(--border-color);
    background: var(--bg-input-prefix);
}
.input-with-icon:has(.input-icon) input {
    flex: 1;
    min-width: 0;
    width: auto;
    padding: 12px 14px;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}
.input-with-icon:has(.input-icon) input:focus {
    border: none;
    box-shadow: none;
}

/* Rate / suffix-only inputs */
.input-with-icon:not(:has(.input-icon)) {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.input-with-icon:not(:has(.input-icon)):focus-within {
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px rgba(110, 231, 183, 0.1);
}
.input-with-icon:not(:has(.input-icon)) input {
    width: 100%;
    padding: 12px 44px 12px 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    box-shadow: none;
}
.input-with-icon:not(:has(.input-icon)) input:focus {
    border: none;
    box-shadow: none;
}
.input-suffix {
    position: absolute;
    right: 14px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    pointer-events: none;
}

input[type="text"], input[type="number"] {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
    outline: none;
}
.input-with-icon input {
    font-variant-numeric: tabular-nums;
}
input:focus { border-color: var(--accent-green); box-shadow: 0 0 0 3px rgba(110, 231, 183, 0.1); }
input::placeholder { color: var(--text-muted); font-weight: 400; }

/* ===== Rate Toggle ===== */
.rate-row { display: flex; gap: 10px; align-items: flex-end; }
.rate-input-wrap { flex: 1; }
.rate-toggle {
    display: flex; background: var(--bg-glass); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); overflow: hidden; height: 44px; flex-shrink: 0;
}
.rate-toggle button {
    padding: 0 14px; background: none; border: none; color: var(--text-muted);
    font-family: var(--font-main); font-size: 0.78rem; font-weight: 500;
    cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.rate-toggle button.active {
    background: var(--gradient-primary); color: #0a0e1a; font-weight: 700;
}

/* ===== Initial Deposit Row ===== */
.initial-deposit-group { margin-bottom: 16px; }

/* ===== Target Card ===== */
.target-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); padding: 28px;
    backdrop-filter: blur(10px);
    display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap;
}
.target-input-group { flex: 1; min-width: 260px; }
.target-input-group label {
    display: block; font-size: 0.85rem; font-weight: 500;
    color: var(--text-secondary); margin-bottom: 8px;
}
.target-card .input-with-icon:has(.input-icon) input {
    font-size: 1.2rem;
    padding: 14px 16px;
}
.target-card .input-icon { min-width: 3.25rem; font-size: 0.95rem; }

.target-presets {
    display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px;
}

/* ===== Results Section ===== */
.results-section { animation: fadeInUp 0.5s ease-out; }
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Summary Cards ===== */
.summary-cards {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px; margin-bottom: 28px;
}
.summary-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); padding: 22px;
    backdrop-filter: blur(10px); position: relative; overflow: hidden;
}
.summary-card::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 3px;
}
.summary-card:nth-child(1)::after { background: var(--gradient-primary); }
.summary-card:nth-child(2)::after { background: var(--gradient-warm); }
.summary-card:nth-child(3)::after { background: var(--gradient-cool); }
.summary-card:nth-child(4)::after { background: linear-gradient(135deg, #F472B6, #EF4444); }
.summary-card-label {
    font-size: 0.8rem; color: var(--text-muted); font-weight: 500; margin-bottom: 8px;
}
.summary-card-value {
    font-size: 1.5rem; font-weight: 800; letter-spacing: -0.5px;
}
.summary-card:nth-child(1) .summary-card-value { color: var(--accent-green); }
.summary-card:nth-child(2) .summary-card-value { color: var(--accent-amber); }
.summary-card:nth-child(3) .summary-card-value { color: var(--accent-purple); }
.summary-card:nth-child(4) .summary-card-value { color: var(--accent-pink); }
.summary-card-sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

/* ===== Chart Card ===== */
.chart-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); padding: 24px; margin-bottom: 28px;
    backdrop-filter: blur(10px);
}
.chart-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; flex-wrap: wrap; gap: 12px;
}
.chart-header h3 { font-size: 1rem; font-weight: 600; }
.chart-legend { display: flex; gap: 18px; flex-wrap: wrap; }
.legend-item {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.78rem; color: var(--text-secondary);
}
.legend-dot {
    width: 10px; height: 10px; border-radius: 50%;
}
.legend-dot.deposit { background: var(--accent-blue); }
.legend-dot.total { background: var(--accent-green); }
.legend-dot.target { background: var(--accent-pink); }
.chart-container { position: relative; height: 320px; }
.chart-container canvas { width: 100% !important; height: 100% !important; }

/* ===== Breakdown Card ===== */
.breakdown-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); padding: 24px; margin-bottom: 28px;
    backdrop-filter: blur(10px);
}
.breakdown-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px;
}
.breakdown-header h3 { font-size: 1rem; font-weight: 600; }
.table-wrapper {
    overflow-x: auto; max-height: 500px; overflow-y: auto;
    border-radius: var(--radius-sm);
}
.table-wrapper.collapsed { max-height: 200px; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.85rem; }
.data-table th {
    color: var(--accent-green);
    padding: 10px 12px;
    text-align: right;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    vertical-align: bottom;
}

/* Sticky header (2 rows) — opaque bg + z-index above body */
.data-table-breakdown thead th {
    position: sticky;
    background-color: var(--table-head-solid);
    z-index: 5;
}
.data-table-breakdown thead tr.th-group-row th {
    top: 0;
    z-index: 6;
}
.data-table-breakdown thead tr.th-detail-row th {
    top: var(--table-head-row1-h);
    z-index: 7;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
}
.data-table-breakdown thead th.th-group:not(.th-group-totals):not(.th-group-interest) {
    background-color: var(--table-head-group-solid);
}
.data-table-breakdown thead th.th-group-interest {
    background-color: var(--table-head-interest-solid);
}
.data-table-breakdown thead th.th-group-totals,
.data-table-breakdown thead th.col-total {
    background-color: var(--table-head-total-solid);
}

.data-table th.col-month,
.data-table td.col-month {
    text-align: center;
}
.data-table-breakdown thead th.col-month {
    left: 0;
    z-index: 12;
    top: 0;
    background-color: var(--table-head-solid);
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
}
.data-table-breakdown tbody td.col-month {
    position: sticky;
    left: 0;
    z-index: 2;
    background-color: var(--bg-secondary);
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.06);
}
.data-table th.th-group { text-align: center; font-size: 0.78rem; }
.data-table th.th-group-interest { color: var(--accent-purple); }
.data-table th.th-group-totals { color: var(--accent-amber); }
.data-table th.col-account {
    color: var(--acc-color, var(--accent-blue));
    min-width: 7.5rem;
}
.data-table th.col-interest,
.data-table td.col-interest {
    color: var(--acc-color, var(--accent-purple));
}
.data-table th.col-interest-start,
.data-table td.col-interest-start {
    border-left: 2px solid var(--table-interest-border);
}
.data-table th.col-total {
    color: var(--accent-amber);
    min-width: 6.5rem;
}
.data-table th .th-sub {
    display: block;
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 2px;
}
.data-table td {
    padding: 10px 12px;
    text-align: right;
    border-bottom: 1px solid var(--table-border-row);
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}
.data-table td.col-account { color: var(--text-primary); }
.data-table td.col-total-start {
    border-left: 2px solid var(--table-total-border);
}
.data-table td.col-total { font-weight: 600; color: var(--text-primary); }
.data-table tbody tr:hover { background: var(--table-row-hover); }
.data-table-breakdown tbody tr:hover td.col-month { background-color: var(--bg-secondary); }
.data-table .highlight-row { background: var(--table-row-highlight); }
.data-table .highlight-row td { color: var(--accent-green); font-weight: 600; }
.data-table-breakdown { min-width: max-content; }

/* ===== Account Details Card ===== */
.account-details-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); padding: 24px;
    backdrop-filter: blur(10px);
}
.account-details-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 16px; }
.account-details-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}
.account-detail-item {
    background: var(--bg-glass); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); padding: 18px;
}
.account-detail-item h4 {
    font-size: 0.9rem; font-weight: 600; margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px;
}
.detail-badge {
    width: 24px; height: 24px; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 800; color: #0a0e1a;
}
.account-detail-row {
    display: flex; justify-content: space-between; padding: 6px 0;
    font-size: 0.82rem;
}
.account-detail-row span:first-child { color: var(--text-muted); }
.account-detail-row span:last-child { color: var(--text-primary); font-weight: 600; }

/* ===== Toast ===== */
.toast-container {
    position: fixed; bottom: 24px; right: 24px; z-index: 9999;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); padding: 14px 20px;
    color: var(--text-primary); font-size: 0.85rem;
    box-shadow: var(--shadow-lg); animation: toastIn 0.4s ease-out;
    display: flex; align-items: center; gap: 10px; min-width: 280px;
}
.toast.error { border-color: rgba(239,68,68,0.4); }
.toast.success { border-color: rgba(110,231,183,0.4); }
.toast-icon { font-size: 1.2rem; }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ===== Footer ===== */
.footer {
    text-align: center; padding: 30px; color: var(--text-muted);
    font-size: 0.8rem; border-top: 1px solid var(--border-color);
    position: relative; z-index: 1;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header { padding: 12px 16px; }
    .rate-status-bar { padding: 0 16px; margin-top: 8px; }
    .rate-status { font-size: 0.68rem; max-width: calc(100% - 36px); }
    .main-content { padding: 20px 16px 40px; }
    .accounts-grid { grid-template-columns: 1fr; }
    .target-card { flex-direction: column; align-items: stretch; }
    .btn-calculate { width: 100%; justify-content: center; }
    .summary-cards { grid-template-columns: repeat(2, 1fr); }
    .summary-card-value { font-size: 1.2rem; }
    .chart-container { height: 240px; }
    .section-header { flex-direction: column; }
}
@media (max-width: 480px) {
    .summary-cards { grid-template-columns: 1fr; }
    .rate-row { flex-direction: column; align-items: stretch; }
    .rate-toggle { width: 100%; }
    .rate-toggle button { flex: 1; }
}