/* ===========================================
   MODERN TAX APP - LIGHT/DARK THEME
   Inspired by Palantir & Tepedu
   =========================================== */

:root {
    /* Light Mode (Default) */
    --bg-primary: #ffffff;
    --bg-secondary: #ffffff;
    --bg-tertiary: #ffffff;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
    --border-subtle: #f3f4f6;

    /* Lighter, calmer greys (less "ink heavy") */
    --text-primary: #2b313b;
    --text-secondary: #6b7280;
    --text-muted: #a0a7b4;

    /* Keep a chart accent, but avoid "blue frames" in UI */
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --ui-accent: #111827;
    --ui-accent-soft: rgba(17, 24, 39, 0.08);
    --focus-ring: rgba(15, 23, 42, 0.10);
    --chart-net: #4f8df7;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    /* Discrete white-on-white shadows - uniform on all sides */
    --shadow-sm: 0 0 4px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 0 10px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 0 20px 6px rgba(0, 0, 0, 0.15);

    /* Square containers (no rounded corners) */
    --radius: 0px;
    --header-height: 64px;

    /* IBM Plex Mono font */
    --font-main: 'IBM Plex Mono', 'SF Mono', Monaco, monospace;
    --font-mono: 'IBM Plex Mono', 'SF Mono', Monaco, monospace;

    /* Animations */
    --transition-speed: 0.2s;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-primary: #1a1f28;
    --bg-secondary: #1a1f28;
    --bg-tertiary: #232831;
    --card-bg: #1a1f28;
    --border-color: #2d3339;
    --border-subtle: #252a31;

    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;

    --accent: #60a5fa;
    --accent-hover: #3b82f6;
    --ui-accent: #e5e7eb;
    --ui-accent-soft: rgba(229, 231, 235, 0.10);
    --focus-ring: rgba(226, 232, 240, 0.14);
    --chart-net: #60a5fa;
    --success: #34d399;
    --danger: #f87171;
    --warning: #fbbf24;

    /* Light shadows for dark mode - visible on dark backgrounds */
    --shadow-sm: 0 0 4px 2px rgba(255, 255, 255, 0.08);
    --shadow-md: 0 0 10px 3px rgba(255, 255, 255, 0.12);
    --shadow-lg: 0 0 20px 6px rgba(255, 255, 255, 0.18);
}

/* ===========================================
   RESET & BASE
   =========================================== */

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

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    transition: background-color var(--transition-speed), color var(--transition-speed);
    font-weight: 300;
}

* {
    font-weight: inherit;
}

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

header {
    min-height: var(--header-height);
    height: auto;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-speed);
}

header:hover {
    box-shadow: var(--shadow-lg);
}

[data-theme="dark"] header {
    background: rgba(26, 31, 40, 0.85);
    border-bottom-color: var(--border-color);
}

header h1 {
    font-size: 1.25rem;
    font-weight: 300;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

header svg {
    stroke: var(--text-secondary);
}

.brand-logo {
    width: 140px;
    height: auto;
    display: block;
    border: none;
    outline: none;
    max-height: 56px;
    object-fit: contain;
}

header h1 {
    /* Subtle “Palantir-ish” sheen without shouting */
    background: linear-gradient(90deg, var(--text-primary) 0%, rgba(107, 114, 128, 0.95) 55%, var(--text-primary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 400;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Theme Toggle */
.theme-toggle {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed);
}

.theme-toggle:hover {
    color: var(--text-primary);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
}

.theme-toggle:hover svg {
    animation: iconSlide 0.4s ease-in-out;
}

/* Export Buttons */
.btn-export {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 300;
    cursor: pointer;
    border-radius: var(--radius);
    font-family: var(--font-main);
    transition: all var(--transition-speed);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-export:hover {
    color: var(--text-primary);
}

.btn-export:hover svg {
    animation: iconSlide 0.4s ease-in-out;
}

@keyframes iconSlide {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-2px);
    }
}

/* Header Text Buttons */
.btn-header-text {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 300;
    cursor: pointer;
    font-family: var(--font-main);
    transition: color var(--transition-speed);
    display: inline-flex;
    align-items: center;
}

.btn-header-text:hover {
    color: var(--text-primary);
}

.btn-header-text:hover svg {
    animation: iconSlide 0.4s ease-in-out;
}

.btn-header-text.active {
    color: var(--text-primary);
}

.header-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 0.5rem;
}

/* Reset Budget Button */
.btn-reset-budget {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-speed);
}

.btn-reset-budget:hover {
    color: var(--text-secondary);
}

.btn-reset-budget:hover .reset-icon {
    animation: resetIconSpin 0.6s ease-in-out;
}

.btn-reset-budget:active .reset-icon {
    animation: resetIconSpin 0.4s ease-out;
}

@keyframes resetIconSpin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* ===========================================
   LAYOUT
   =========================================== */

.container {
    flex: 1;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 0;
    overflow: visible;
}

.main-column {
    flex: 0 0 30%;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 1.5rem;
    overflow: visible;
}

/* Side-by-side layout for Person 1 & Person 2 */
.people-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

.dual-view {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.dual-view>.card {
    margin: 0;
    width: 100%;
}

.sidebar {
    flex: 0 0 70%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.5rem;
    overflow: hidden;
}

/* Couple page specific: Full width when detailed calculation is under inputs */
body.couple-page .main-column {
    flex: 1;
    max-width: 100%;
}

body.couple-page .sidebar {
    display: none;
}

/* Detailed calculation under inputs should span full width */
body.couple-page .main-column>.card:has(.detailed-calculation-combined) {
    width: 100%;
    max-width: 100%;
}

/* Make sure people-grid allows full width for cards after it */
body.couple-page .people-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

body.couple-page .main-column {
    display: flex;
    flex-direction: column;
}

.card+.card,
.main-column>*+* {
    margin-top: 0;
}

.btn-group {
    margin-bottom: 0;
}

/* ===========================================
   CARDS
   =========================================== */

.card {
    background: var(--card-bg);
    border: none;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: none;
    transition: all var(--transition-speed);
    overflow: visible;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
}

.card-title {
    font-size: 0.75rem;
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

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

.form-cols {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
}

.form-cols .form-group {
    margin-bottom: 1rem;
    width: 100%;
    box-sizing: border-box;
}

.form-group {
    width: 100%;
    box-sizing: border-box;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 300;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input {
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    font-family: var(--font-main);
    border-radius: var(--radius);
    text-align: right;
    transition: all var(--transition-speed);
    box-shadow: var(--shadow-sm);
}

/* Input groups with units */
.input-group {
    display: flex;
    align-items: stretch;
    width: 100%;
}

.input-group input {
    flex: 1;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-unit {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-left: none;
    color: var(--text-muted);
    font-size: 0.8125rem;
    min-width: 50px;
    white-space: nowrap;
    user-select: none;
}

/* Sync focus state */
.input-group:focus-within input {
    border-color: var(--text-muted);
    z-index: 1;
}

.input-group:focus-within .input-unit {
    border-color: var(--text-muted);
}

select {
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    font-family: var(--font-main);
    border-radius: var(--radius);
    transition: all var(--transition-speed);
    box-shadow: var(--shadow-sm);
}

/* Input field width classes - all inputs are 100% of their container */
.form-group.input-wide,
.form-group.input-narrow {
    width: 100%;
}

.form-group.input-wide input,
.form-group.input-wide select,
.form-group.input-narrow input,
.form-group.input-narrow select {
    width: 100%;
    box-sizing: border-box;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--text-muted);
    background: var(--bg-tertiary);
    box-shadow: 0 0 0 1px var(--text-muted), var(--shadow-md);
}

input:hover:not(:focus),
select:hover:not(:focus) {
    border-color: var(--text-muted);
}

/* Input validation styles */
input.input-invalid,
select.input-invalid {
    border-color: var(--danger);
    background-color: rgba(239, 68, 68, 0.05);
    box-shadow: 0 0 0 1px var(--danger), var(--shadow-sm);
}

[data-theme="dark"] input.input-invalid,
[data-theme="dark"] select.input-invalid {
    background-color: rgba(239, 68, 68, 0.1);
}

input.input-warning,
select.input-warning {
    border-color: var(--warning);
    background-color: rgba(245, 158, 11, 0.05);
    box-shadow: 0 0 0 1px var(--warning), var(--shadow-sm);
}

[data-theme="dark"] input.input-warning,
[data-theme="dark"] select.input-warning {
    background-color: rgba(245, 158, 11, 0.1);
}

/* Validation message */
.validation-message {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 0.25rem;
    display: none;
}

.validation-message.show {
    display: block;
}

.validation-message.warning {
    color: var(--warning);
}

button:focus,
button:focus-visible {
    outline: none;
}

button:focus-visible {
    box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Remove blue outline from images */
img {
    border: none;
    outline: none;
}

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

.btn-group {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: 300;
    cursor: pointer;
    border-radius: var(--radius);
    font-family: var(--font-main);
    transition: all var(--transition-speed);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--text-muted);
    box-shadow: var(--shadow-md);
}

.btn:hover .btn-ico {
    animation: iconFloat 0.6s ease-in-out infinite;
}

.btn.active {
    background: var(--ui-accent-soft);
    border-color: var(--text-muted);
    color: var(--ui-accent);
}

.btn-quiet {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-xs {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    cursor: pointer;
    border-radius: var(--radius);
    transition: all var(--transition-speed);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: var(--shadow-sm);
}

.btn-xs:hover {
    border-color: var(--text-muted);
    color: var(--text-secondary);
    box-shadow: var(--shadow-md);
}

.btn-xs:hover .btn-ico {
    animation: iconBounce 0.5s ease-in-out;
}

@keyframes iconBounce {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-2px) scale(1.1);
    }
}

/* Loan section – GSAP-animated buttons, square, same style as site */
.loan-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-loan-fetch {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: var(--font-main);
    font-size: 0.875rem;
    font-weight: 300;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    position: relative;
    transform-origin: center;
}

.btn-loan-fetch .btn-loan-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-loan-fetch .btn-loan-icon svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

.btn-loan-fetch:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-loan-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: var(--font-main);
    font-size: 0.875rem;
    font-weight: 300;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    position: relative;
}

.btn-loan-link .btn-loan-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-loan-link .btn-loan-icon svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

.btn-loan-link:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-ico {
    flex: 0 0 auto;
    opacity: 0.9;
    transform: translateY(0);
    transition: transform 180ms ease, opacity 180ms ease;
}

.btn:hover .btn-ico,
.btn-xs:hover .btn-ico {
    opacity: 1;
}

.btn-xs:hover .btn-ico {
    transform: translateY(-1px);
}

.btn.active .btn-ico {
    animation: icoPulse 800ms ease-in-out infinite;
}

@keyframes icoPulse {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-2px);
    }
}

@keyframes iconFloat {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-2px) rotate(2deg);
    }
}

.micro-actions {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

/* ===========================================
   SECTIONS
   =========================================== */

.section-box {
    background: var(--bg-secondary);
    padding: 0;
    border-radius: var(--radius);
    margin-top: 0.75rem;
    border: none;
    box-shadow: none;
    width: 100%;
    box-sizing: border-box;
}

.section-box .form-group {
    width: 100%;
    box-sizing: border-box;
}

/* Soft panels (housing breakdown, etc.) */
.panel-soft {
    background: var(--bg-secondary);
    border: none;
    padding: 1rem;
    border-radius: var(--radius);
    margin-top: 1rem;
    box-shadow: none;
}

/* ===========================================
   RESULTS
   =========================================== */

.result-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.9375rem;
}

.result-row span:first-child {
    color: var(--text-secondary);
}

.result-row:last-child {
    border-bottom: none;
}

.result-value {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 0.875rem;
}

.result-total {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 2px solid var(--border-color);
    font-size: 0.9375rem;
    font-weight: 300;
}

/* Color Helpers - Enhanced Specificity and !important */
.val-income,
.val-income *,
.result-row span.val-income,
.summary-box span.val-income {
    color: var(--success) !important;
}

.val-tax,
.val-tax *,
.result-row span.val-tax,
.summary-box span.val-tax {
    color: var(--danger) !important;
}

.val-neutral,
.val-neutral *,
.result-row span.val-neutral,
.summary-box span.val-neutral {
    color: var(--text-primary) !important;
}

.val-deduction,
.val-deduction * {
    color: var(--success) !important;
}

.val-green,
.val-green * {
    color: var(--success) !important;
}

.val-red,
.val-red * {
    color: var(--danger) !important;
}

/* ===========================================
   DETAILED CALCULATION
   =========================================== */

.detailed-calculation {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.detailed-calculation-combined {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0.5rem 0;
}

.calc-header-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 2px solid var(--border-color);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.calc-header-row div:not(:first-child) {
    text-align: right;
}

.calc-section-combined {
    margin-bottom: 1rem;
}

.calc-row-combined {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 1rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border-subtle);
    align-items: center;
    font-size: 0.875rem;
}

.calc-row-combined:last-child {
    border-bottom: none;
}

.calc-row-combined.calc-row-total {
    font-weight: 600;
    border-top: 1px solid var(--border-color);
    margin-top: 0.25rem;
    padding-top: 0.6rem;
    color: var(--text-primary);
}

.calc-label-col {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.calc-person-col,
.calc-total-col {
    font-family: var(--font-mono);
    text-align: right;
    white-space: nowrap;
}

.calc-total-col {
    font-weight: 600;
}

.calc-section {
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 1.5rem;
}

.calc-section:last-child {
    border-bottom: none;
}

.calc-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.calc-step {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.calc-substep {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-left: 1rem;
    margin-top: 0.25rem;
    border-left: 2px solid var(--border-subtle);
}

.calc-formula {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.5rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    gap: 1rem;
}

.calc-formula.calc-total {
    font-weight: 500;
    color: var(--text-primary);
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-subtle);
}

.calc-formula.calc-formula-info {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.calc-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.calc-value {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: nowrap;
    text-align: right;
}

.calc-explanation {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.25rem;
    padding-left: 1rem;
}

/* ===========================================
   CHARTS
   =========================================== */

.chart-box {
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--radius);
    height: 200px;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    padding: 1rem;
    margin-top: 1rem;
    box-shadow: none;
}

.sankey-container {
    margin-top: 1rem;
    min-height: 280px;
    background: var(--bg-secondary);
    position: relative;
    width: 100%;
    overflow: hidden;
}

.sankey-container #sankey-chart,
.sankey-container [id^="sankey-chart"] {
    min-height: 280px;
}

/* Double-buffer: kun én buffer synlig ad gangen – undgår synlig genberegning */
.sankey-buffer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    min-height: 280px;
    opacity: 0;
    pointer-events: none;
}

.sankey-buffer.sankey-visible {
    position: relative;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.15s ease-out;
}

/* Google Charts Sankey tooltip – samme tema som figur, lækker animation */
.google-visualization-tooltip {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    font-family: var(--font-main) !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
    padding: 0.875rem 1.125rem !important;
    box-shadow: var(--shadow-lg) !important;
    border-radius: 4px !important;
    animation: sankeyTooltipFadeIn 0.2s ease-out !important;
}

@keyframes sankeyTooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.google-visualization-tooltip *,
.google-visualization-tooltip-item {
    color: var(--text-primary) !important;
    font-family: var(--font-main) !important;
}

.google-visualization-tooltip strong {
    color: var(--text-primary) !important;
}

.bar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
    width: 25%;
}

.bar-fill {
    width: 100%;
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 2px;
    border-radius: var(--radius);
    opacity: 0.9;
}

.bar-fill:hover {
    opacity: 1;
}

.bar-label {
    margin-top: 0.5rem;
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bar-val {
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

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

.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===========================================
   SCROLLBAR
   =========================================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #ffffff;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ===========================================
   PRINT STYLES
   =========================================== */

@media print {
    body {
        background: white;
        color: black;
    }

    header {
        position: static;
        box-shadow: none;
    }

    .theme-toggle,
    .btn-export,
    .btn-reset-budget,
    .btn-group,
    .btn-xs {
        display: none !important;
    }

    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #e5e7eb;
    }

    .container {
        display: block;
    }

    .sidebar {
        margin-top: 2rem;
    }
}

/* ===========================================
   AMBIENT COPY / TYPEWRITER
   =========================================== */

.ambient-copy {
    padding: 4rem 2rem;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    width: 100%;
    position: relative;
    margin: 0;
    text-align: center;
}

.ambient-kicker {
    font-size: 3rem;
    font-weight: 200;
    letter-spacing: 0.02em;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    font-family: var(--font-main);
    min-height: 1.2em;
}

.typewriter-line {
    font-size: 3rem;
    line-height: 1.2;
    position: relative;
    font-weight: 400;
    font-family: 'Anton', sans-serif;
    min-height: 1.5em;
    /* Prevent layout shift */
    margin-bottom: 0.5rem;
    letter-spacing: 0.02em;
}

.tw-part-1 {
    color: #d1d5db;
    font-weight: 400;
}

.tw-part-2 {
    color: #d1d5db;
    /* Light grey */
}

.typewriter-line::after {
    content: '|';
    display: inline-block;
    color: #d1d5db;
    animation: blink 1s step-end infinite;
    margin-left: 2px;
}

.typewriter-line.completed::after {
    display: inline-block;
    /* Keep blinking */
}

.typewriter-line.fade-out {
    animation: fadeOutText 1s ease-out forwards;
}

@keyframes blink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0;
    }
}

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

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

@media (max-width: 1024px) {
    .container {
        flex-direction: column;
    }

    .main-column {
        flex: 1;
    }

    .sidebar {
        flex: 1;
    }

    .dual-view {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    header {
        padding: 0 1rem;
    }

    header h1 {
        font-size: 1rem;
    }

    .container {
        padding: 0;
    }

    .main-column {
        padding: 1rem;
        flex: 1;
    }

    .sidebar {
        padding: 1rem;
        flex: 1;
    }

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

    .btn-group {
        flex-direction: column;
    }

    .calc-formula {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .calc-value {
        text-align: left;
    }

    .calc-substep {
        padding-left: 0.75rem;
    }
}

/* ===========================================
   LOAN HEATMAP OVERRIDES (Visibility in Dark Mode)
   =========================================== */
[data-theme="dark"] .loan-heatmap .cell.cell-udbetalingskrav {
    color: #f87171 !important;
    /* Lighter red for better contrast */
    background: rgba(127, 29, 29, 0.5) !important;
    /* Deep dark red background */
    border: 1px solid rgba(248, 113, 113, 0.2) !important;
}

[data-theme="dark"] .loan-heatmap .cell.cell-udbetalingskrav .cell-icon svg {
    filter: drop-shadow(0 0 4px rgba(248, 113, 113, 0.4));
}

[data-theme="dark"] .loan-heatmap .cell.cell-vaekstvejledning {
    color: #fca5a5 !important;
    background: rgba(185, 28, 28, 0.3) !important;
}

[data-theme="dark"] .loan-heatmap .cell.cell-god_skik {
    color: #fde047 !important;
    /* Lighter yellow */
    background: rgba(161, 98, 7, 0.25) !important;
}

[data-theme="dark"] .loan-heatmap .cell.cell-frit_valg {
    color: #4ade80 !important;
    /* Lighter green */
    background: rgba(21, 128, 61, 0.2) !important;
}

/* ===========================================
   ABOUT DROPDOWN & INFO BUTTON
   =========================================== */

.about-container {
    position: relative;
    display: inline-block;
}

.about-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: visible;
    /* Changed to visible for pulse */
}

.about-btn::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1px solid var(--accent);
    opacity: 0;
    transition: all 0.5s ease;
}

.about-btn:hover::before {
    animation: aboutPulse 1.5s infinite;
}

@keyframes aboutPulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

.about-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent);
    background: var(--bg-tertiary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.about-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.about-btn:hover svg {
    transform: scale(1.1);
}

.about-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 320px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xl);
    padding: 1.25rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    transform-origin: top right;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    margin-top: 12px;
}

/* Pseudo-element to bridge the gap for hover */
.about-dropdown::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 0;
    right: 0;
    height: 20px;
}

.about-container:hover .about-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Dropdown visibility handled by hover now */

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.about-dropdown h3 {
    font-size: 0.875rem;
    font-weight: 500;
    margin: 0;
    color: var(--text-primary);
}

.about-person {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
}

.about-person img {
    width: 50px;
    height: 50px;
    border-radius: 0;
    object-fit: cover;
    filter: grayscale(40%);
    transition: all 0.4s ease;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.about-person small {
    display: block;
    line-height: 1.5;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.about-disclaimer {
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.about-disclaimer small {
    display: block;
    line-height: 1.4;
    color: var(--text-muted);
}


.about-person:hover img {
    filter: grayscale(0%);
}

/* ===========================================
   INFO ICONS & TOOLTIPS
   =========================================== */

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    font-size: 0.7rem;
    font-weight: 500;
    cursor: help;
    margin-left: 0.4rem;
    vertical-align: middle;
    line-height: 1;
    transition: all 0.2s ease;
}

.info-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.info-icon.val-tax {
    color: var(--danger);
    border-color: var(--danger);
}

.info-icon.val-income,
.info-icon.val-deduction {
    color: var(--success);
    border-color: var(--success);
}

/* Tooltip base styles are usually in the HTML files specifically, 
   but we can share some properties here if needed. */