:root
{
    --color-bg: #f7f8fa;
    --color-surface: #ffffff;
    --color-surface-hover: #eaf5f3;
    --color-border: #e2e5e9;
    --color-text: #1c1f24;
    --color-text-muted: #6b7280;
    --color-primary: #146c64;
    --color-good: #16a34a;
    --color-warn: #d97706;
    --color-bad: #dc2626;
    --color-warn-bg: #fff7ed;
    --color-warn-border: #fdba74;
    --color-warn-text: #9a3412;
    --color-error-bg: #fef2f2;
    --color-error-border: #fca5a5;
    --color-error-text: #991b1b;
    --color-input-bg: #ffffff;
    --radius: 10px;
}

:root[data-theme="dark"]
{
    --color-bg: #14171c;
    --color-surface: #1c2027;
    --color-surface-hover: #262b33;
    --color-border: #2c313a;
    --color-text: #e6e8eb;
    --color-text-muted: #9aa1ab;
    --color-primary: #4fc3b0;
    --color-good: #22c55e;
    --color-warn: #f59e0b;
    --color-bad: #f87171;
    --color-warn-bg: #3a2c12;
    --color-warn-border: #7c4a12;
    --color-warn-text: #fbbf24;
    --color-error-bg: #3f1d1d;
    --color-error-border: #7f1d1d;
    --color-error-text: #fca5a5;
    --color-input-bg: #20242c;
}

*
{
    box-sizing: border-box;
}

body
{
    margin: 0;
    font-family: "Roboto", system-ui, -apple-system, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    transition: background-color 0.15s ease, color 0.15s ease;
}

/* Ohne diese Regel fallen einfache <a>-Tags (z.B. in Hinweistexten) auf die
   Browser-Standardfarbe zurück — deren "besucht"-Violett hat auf dem dunklen Theme
   sehr schlechten Kontrast. Explizit auf die Theme-Akzentfarbe setzen, unabhängig
   vom Besucht-Status. */
a
{
    color: var(--color-primary);
}

a:visited
{
    color: var(--color-primary);
}

.page
{
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar
{
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 1.5rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

    .top-bar .brand
    {
        font-weight: 600;
        text-decoration: none;
        color: var(--color-text);
        font-size: 1.05rem;
    }

    .top-bar nav
    {
        display: flex;
        gap: 1rem;
        align-items: center;
    }

        .top-bar nav a
        {
            color: var(--color-text-muted);
            text-decoration: none;
            font-size: 0.9rem;
        }

            .top-bar nav a:hover
            {
                color: var(--color-primary);
            }

.link-button
{
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
}

main
{
    flex: 1;
    max-width: 1920px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 2rem 2.5rem;
}

.workspace
{
    display: grid;
    grid-template-columns: minmax(620px, 840px) 1fr;
    gap: 1.75rem;
    align-items: start;
    margin-top: 1rem;
}

.workspace-col
{
    display: flex;
    flex-direction: column;
    min-width: 0; /* verhindert Grid-Spalten-Überlauf durch breite Tabellen */
}

@media (max-width: 960px)
{
    .workspace
    {
        grid-template-columns: 1fr;
    }
}

h1
{
    font-size: 1.4rem;
    margin: 0 0 0.25rem;
}

.hint
{
    color: var(--color-text-muted);
    margin-top: 0;
    margin-bottom: 1rem;
}

.import-box
{
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
}

textarea
{
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 0.6rem;
    font-family: inherit;
    resize: vertical;
}

button.primary, a.primary
{
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1.1rem;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    width: fit-content;
}

button.secondary
{
    background: var(--color-surface);
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
    border-radius: 8px;
    padding: 0.55rem 1rem;
    font-size: 0.88rem;
    cursor: pointer;
    width: fit-content;
    margin: 0.75rem 0 0.5rem;
}

    button.secondary:hover
    {
        background: var(--color-surface-hover);
    }

.breakdown-box
{
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    font-size: 0.88rem;
}

    .breakdown-box h4
    {
        font-size: 0.8rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: var(--color-text-muted);
        margin: 1rem 0 0.5rem;
    }

        .breakdown-box h4:first-child
        {
            margin-top: 0;
        }

.breakdown-line
{
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.3rem 0;
    border-bottom: 1px dashed var(--color-border);
}

    .breakdown-line span:first-child
    {
        color: var(--color-text);
    }

    .breakdown-line span:last-child
    {
        font-family: "Consolas", "SF Mono", monospace;
        white-space: nowrap;
    }

    .breakdown-line.muted span
    {
        color: var(--color-text-muted);
    }

    .breakdown-line.total
    {
        font-weight: 600;
        border-bottom: 1px solid var(--color-text);
    }

    .breakdown-line.highlight
    {
        font-weight: 700;
        color: var(--color-primary);
        border-bottom: none;
        padding-top: 0.5rem;
    }

button.primary:disabled
{
    opacity: 0.6;
    cursor: not-allowed;
}

.extracted, .result
{
    margin-top: 1.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.warning-box
{
    background: var(--color-warn-bg);
    border: 1px solid var(--color-warn-border);
    color: var(--color-warn-text);
    border-radius: 8px;
    padding: 0.7rem 0.9rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.warning-box.error-box
{
    background: var(--color-error-bg);
    border-color: var(--color-error-border);
    color: var(--color-error-text);
}

.field-grid
{
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.1rem;
}

.group-heading
{
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
    margin: 1.3rem 0 0.6rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--color-border);
}

    .group-heading:first-of-type
    {
        margin-top: 0.4rem;
        padding-top: 0;
        border-top: none;
    }

.field-grid label
{
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.field-grid input, .field-grid select
{
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 0.45rem 0.5rem;
    font-size: 0.95rem;
    color: var(--color-text);
    font-family: inherit;
    background: var(--color-input-bg);
}

.source-url-row
{
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

    .source-url-row input
    {
        flex: 1;
        min-width: 0;
    }

    .source-url-row a
    {
        color: var(--color-primary);
        text-decoration: none;
        font-size: 1.1rem;
        flex-shrink: 0;
    }

/* Eigene Tooltip-Umsetzung statt des nativen "title"-Attributs: Browser verzögern den
   title-Tooltip um ~0.5-1s, was sich beim schnellen Durchklicken mehrerer Eingabefelder
   störend anfühlt. Über CSS :hover erscheint der Tooltip stattdessen sofort. */
.hover-tooltip
{
    position: relative;
    display: block;
}

    .hover-tooltip[data-tooltip]:hover::after
    {
        content: attr(data-tooltip);
        position: absolute;
        bottom: calc(100% + 8px);
        left: 0;
        background: var(--color-text);
        color: var(--color-surface);
        padding: 0.35rem 0.6rem;
        border-radius: 6px;
        font-size: 0.78rem;
        font-family: "Consolas", "SF Mono", monospace;
        white-space: nowrap;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        z-index: 20;
        pointer-events: none;
    }

/* Variante für erklärende Begriffs-Tooltips (ganze Sätze statt kurzer Zahlenwerte) —
   Fließtext statt Monospace, mit Zeilenumbruch und begrenzter Breite. */
.hover-tooltip.has-info
{
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    cursor: help;
}

    .hover-tooltip.has-info[data-tooltip]:hover::after
    {
        font-family: inherit;
        white-space: normal;
        line-height: 1.4;
        width: max-content;
        max-width: 260px;
    }

.info-icon
{
    color: var(--color-text-muted);
    font-size: 0.9em;
}

.metric-grid
{
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.9rem;
    margin: 1rem 0 1.5rem;
}

.metric
{
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem;
    background: var(--color-bg);
    border-radius: 8px;
}

    .metric span
    {
        font-size: 0.78rem;
        color: var(--color-text-muted);
    }

    .metric strong
    {
        font-size: 1.2rem;
    }

.result.rating-sehr-gut
{
    border-left: 5px solid var(--color-good);
}

.result.rating-gut
{
    border-left: 5px solid var(--color-good);
}

.result.rating-durchschnittlich
{
    border-left: 5px solid var(--color-warn);
}

.result.rating-schlecht
{
    border-left: 5px solid var(--color-bad);
}

.result.rating-unbekannt
{
    border-left: 5px solid var(--color-border);
}

.login-buttons
{
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.save-row
{
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin-top: 1.5rem;
}

.saved-hint
{
    color: var(--color-good);
    font-size: 0.9rem;
}

.investments-table
{
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}

    .investments-table th, .investments-table td
    {
        text-align: left;
        padding: 0.7rem 0.9rem;
        border-bottom: 1px solid var(--color-border);
        font-size: 0.92rem;
    }

    .investments-table th
    {
        color: var(--color-text-muted);
        font-weight: 600;
        font-size: 0.8rem;
        text-transform: uppercase;
    }

    .investments-table tbody tr:last-child td
    {
        border-bottom: none;
    }

    .investments-table tbody tr.clickable-row
    {
        cursor: pointer;
    }

    .investments-table tbody tr.clickable-row:hover
    {
        background: var(--color-surface-hover);
    }

.badge
{
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
}

    .badge.rating-sehr-gut, .badge.rating-gut
    {
        background: var(--color-good);
    }

    .badge.rating-durchschnittlich
    {
        background: var(--color-warn);
    }

    .badge.rating-schlecht
    {
        background: var(--color-bad);
    }

    .badge.rating-unbekannt
    {
        background: var(--color-text-muted);
    }

.map-embed-wrapper
{
    width: 100%;
    height: 320px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.25rem;
}

    .map-embed-wrapper iframe
    {
        width: 100%;
        height: 100%;
        border: 0;
    }

.raw-expose
{
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 0.9rem;
    max-height: 420px;
    overflow-y: auto;
    font-size: 0.8rem;
    font-family: "Consolas", "SF Mono", monospace;
}

.amortization-table-wrapper
{
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    max-height: 420px;
    overflow-y: auto;
}

.amortization-table
{
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    white-space: nowrap;
}

    .amortization-table th, .amortization-table td
    {
        text-align: right;
        padding: 0.5rem 0.75rem;
        border-bottom: 1px solid var(--color-border);
    }

        .amortization-table th:first-child, .amortization-table td:first-child
        {
            text-align: left;
        }

    .amortization-table thead th
    {
        position: sticky;
        top: 0;
        background: var(--color-surface);
        color: var(--color-text-muted);
        font-weight: 600;
        font-size: 0.75rem;
        text-transform: uppercase;
        z-index: 1;
    }

    .amortization-table tbody tr:last-child td
    {
        border-bottom: none;
    }

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

ul
{
    padding-left: 1.2rem;
}

li
{
    margin-bottom: 0.35rem;
}

.factors-grid
{
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0 1.5rem;
    margin-top: 1rem;
}

    .factors-grid h3
    {
        margin-top: 0;
    }

    .factors-grid ul
    {
        margin-top: 0;
    }

.print-page
{
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

    .print-page section
    {
        margin-bottom: 1.5rem;
    }

.print-actions
{
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.print-header
{
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--color-border);
}

    .print-header h1
    {
        font-size: 1.3rem;
        margin: 0 0 0.25rem;
    }

    .print-header .hint
    {
        margin: 0;
    }

@media print
{
    .no-print
    {
        display: none !important;
    }

    body
    {
        background: white;
        color: black;
    }

    .print-page
    {
        max-width: none;
        padding: 0;
    }

    .amortization-table-wrapper
    {
        max-height: none;
        overflow: visible;
        border: none;
    }

    .breakdown-box, .metric-grid, .amortization-table-wrapper, .print-header
    {
        break-inside: avoid;
    }
}
