/*
 * Budgetplaner – Designsystem „Nachtkasse“ (nur Dunkelmodus)
 * Tiefes Schieferblau als Grund, Messing als einzige Akzentfarbe für Aktionen und Auswahl,
 * Grün/Koralle ausschließlich für Geldbewegungen (Plus/Minus). Zahlen immer tabellarisch.
 */
:root {
    color-scheme: dark;

    /* Flächen */
    --background: #121925;
    --surface: #19212f;
    --surface-raised: #202a3b;
    --surface-muted: #161e2b;
    --ink: #0e141e;
    --ink-soft: #1a2333;

    /* Text */
    --text: #e8ecf4;
    --text-muted: #9aa6bc;
    --text-subtle: #6c7890;

    /* Linien */
    --border: #283246;
    --border-strong: #37435b;

    /* Akzent: Messing */
    --accent: #ddb05c;
    --accent-hover: #e9c47e;
    --accent-soft: #352f22;
    --on-accent: #1d1608;

    /* Geld */
    --positive: #74c99a;
    --negative: #f08a7e;
    --positive-soft: #1d3329;
    --negative-soft: #3a2427;
    --transfer: #8aa4d6;

    /* Zustände */
    --danger: #f08a7e;
    --danger-surface: #34212a;
    --danger-border: #6b3a40;
    --danger-text: #f6a89f;
    --warning: #e8b65a;

    --shadow: 0 1px 0 rgb(255 255 255 / 0.025) inset, 0 12px 28px rgb(2 6 14 / 0.32);
    --radius: 0.75rem;
    --radius-small: 0.5rem;
    --focus: 0 0 0 3px rgb(221 176 92 / 0.32);

    --font: "Segoe UI Variable Text", "Segoe UI", "SF Pro Text", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: "Segoe UI Variable Display", "Segoe UI", "SF Pro Display", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;

    --sidebar-width: 15.5rem;
    font-family: var(--font);
}

* {
    box-sizing: border-box;
}

html {
    background: var(--background);
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--background);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    font-feature-settings: "tnum" 1;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-family: var(--font-display);
    color: var(--text);
}

a {
    color: var(--accent);
}

strong, dd, td, .money {
    font-variant-numeric: tabular-nums;
}

button,
input,
select,
textarea {
    font: inherit;
}

:focus-visible {
    outline: none;
    box-shadow: var(--focus);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
select,
textarea {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.62rem 0.78rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-small);
    outline: none;
    background: var(--surface-muted);
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 400;
    transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"])[readonly] {
    border-style: dashed;
    background: var(--surface);
    color: var(--text-muted);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-subtle);
}

select {
    appearance: none;
    padding-right: 2.2rem;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 1.05rem) 52%, calc(100% - 0.75rem) 52%;
    background-size: 0.3rem 0.3rem, 0.3rem 0.3rem;
    background-repeat: no-repeat;
}

select option {
    background: var(--surface-raised);
    color: var(--text);
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
}

input[type="checkbox"],
input[type="radio"] {
    width: 1.05rem;
    height: 1.05rem;
    flex: 0 0 auto;
    margin: 0;
    accent-color: var(--accent);
}

input[type="file"] {
    width: 100%;
    color: var(--text-muted);
    font-size: 0.82rem;
}

input[type="file"]::file-selector-button {
    margin-right: 0.7rem;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-small);
    background: var(--surface-raised);
    color: var(--text);
    cursor: pointer;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: var(--focus);
}

button {
    min-height: 2.6rem;
    padding: 0.6rem 0.95rem;
    border: 1px solid var(--accent);
    border-radius: var(--radius-small);
    background: var(--accent);
    color: var(--on-accent);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 650;
    transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

button:hover:not(:disabled) {
    border-color: var(--accent-hover);
    background: var(--accent-hover);
}

button.secondary {
    border-color: var(--border-strong);
    background: var(--surface-raised);
    color: var(--text);
}

button.secondary:hover:not(:disabled) {
    border-color: var(--text-subtle);
    background: var(--ink-soft);
}

button.danger {
    border-color: var(--danger-border);
    background: transparent;
    color: var(--danger-text);
}

button.danger:hover:not(:disabled) {
    border-color: var(--danger-text);
    background: var(--danger-surface);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.positive {
    color: var(--positive);
}

.negative {
    color: var(--negative);
}

.validation-message,
.validation-errors {
    color: var(--danger-text);
    font-size: 0.82rem;
}

.validation-errors {
    margin: 0;
    padding: 0.75rem 0.9rem 0.75rem 1.8rem;
    border: 1px solid var(--danger-border);
    border-radius: var(--radius-small);
    background: var(--danger-surface);
}

.valid.modified:not([type=checkbox]) {
    border-color: var(--border-strong);
}

.invalid {
    border-color: var(--danger-border) !important;
}

::selection {
    background: rgb(221 176 92 / 0.3);
}

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

::-webkit-scrollbar-thumb {
    border: 3px solid var(--background);
    border-radius: 999px;
    background: var(--border-strong);
}

::-webkit-scrollbar-track {
    background: transparent;
}

.system-page {
    max-width: 640px;
    min-height: 24rem;
    display: grid;
    align-content: center;
    justify-items: start;
}

.system-page > span {
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 650;
}

.system-page h1 {
    margin: 0.6rem 0;
    font-size: clamp(2rem, 5vw, 3.2rem);
    line-height: 1.05;
    letter-spacing: -0.03em;
}

.system-page p {
    margin: 0;
    color: var(--text-muted);
}

.system-page a {
    display: inline-flex;
    align-items: center;
    min-height: 2.6rem;
    margin-top: 1.5rem;
    padding: 0 0.95rem;
    border-radius: var(--radius-small);
    background: var(--accent);
    color: var(--on-accent);
    font-size: 0.88rem;
    font-weight: 650;
    text-decoration: none;
}

.system-page .request-id {
    margin-top: 1rem;
    font-size: 0.78rem;
}

#blazor-error-ui {
    position: fixed;
    z-index: 1000;
    right: 1rem;
    bottom: 1rem;
    display: none;
    padding: 0.8rem 1rem;
    border: 1px solid var(--danger-border);
    border-radius: var(--radius-small);
    background: var(--danger-surface);
    color: var(--danger-text);
}

/* Handy */
@media (max-width: 960px) {
    /* iOS zoomt beim Antippen in Felder mit weniger als 16 px – darum mindestens 16 px.
       Gleicher Selektor wie die Grundregel oben (kein !important), größere Felder behalten ihre Größe. */
    input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
    select,
    textarea {
        font-size: 16px;
    }

    /* Textlinks und kleine Schaltflächen: genug Fläche zum Antippen */
    a.secondary-link,
    a.back-link,
    a.export-link,
    button.history-toggle,
    .transaction-receipts a {
        min-height: 2.25rem;
        display: inline-flex;
        align-items: center;
    }

    /* Keine Textvergrößerung im Querformat, kein grauer Tipp-Blitz */
    html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    a,
    button,
    label {
        -webkit-tap-highlight-color: transparent;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition: none !important;
        animation: none !important;
    }
}
