/* ============================================
   LadenBuch — Warm Dark Theme
   Senior-friendly, iPad-optimized
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

:root {
    --bg:           #1a1714;
    --bg-raised:    #242019;
    --card:         #2c2720;
    --card-hover:   #342f27;
    --surface:      #3a342b;
    --border:       #4a4238;
    --border-light: #3a342b;

    --text:         #e8e0d4;
    --text-mid:     #b8ad9e;
    --text-muted:   #8a7e70;

    --primary:      #c8956c;
    --primary-hover:#daa87f;

    --einnahme:     #6ec87a;
    --einnahme-bg:  rgba(110,200,122,0.12);
    --ausgabe:      #e8756a;
    --ausgabe-bg:   rgba(232,117,106,0.12);

    --info:         #6ab0d4;
    --info-bg:      rgba(106,176,212,0.12);
    --warning:      #d4a84a;
    --warning-bg:   rgba(212,168,74,0.12);

    --radius:       12px;
    --radius-sm:    8px;
}

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

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 17px;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* ---- Navigation ---- */
nav {
    background: var(--bg-raised);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    height: 64px;
    border-bottom: 1px solid var(--border-light);
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

nav .logo {
    color: var(--primary);
    font-size: 1.25rem;
    font-weight: 700;
    text-decoration: none;
    margin-right: 1rem;
    letter-spacing: -0.02em;
}

nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    transition: color 0.2s, background 0.2s;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

nav a:hover {
    color: var(--text);
    background: var(--surface);
}

nav a.active {
    color: var(--primary);
    background: rgba(200,149,108,0.1);
}

/* ---- Layout ---- */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    color: var(--text);
    letter-spacing: -0.02em;
}

h2 {
    letter-spacing: -0.01em;
}

/* ---- Cards ---- */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    border: 1px solid var(--border-light);
}

/* ---- Flash Messages ---- */
.flash {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: 1rem;
    font-weight: 500;
}

.flash.success {
    background: var(--einnahme-bg);
    color: var(--einnahme);
    border: 1px solid rgba(110,200,122,0.2);
}

.flash.error {
    background: var(--ausgabe-bg);
    color: var(--ausgabe);
    border: 1px solid rgba(232,117,106,0.2);
}

/* ---- Month Navigation ---- */
.monat-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.monat-nav h1 {
    margin-bottom: 0;
    flex: 1;
    text-align: center;
}

.monat-nav a {
    color: var(--primary);
    text-decoration: none;
    font-size: 2rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    min-width: 48px;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.monat-nav a:hover {
    background: rgba(200,149,108,0.12);
}

/* ---- Dashboard Totals ---- */
.totals {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.total-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.25rem 1rem;
    text-align: center;
    border: 1px solid var(--border-light);
}

.total-card .label {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
    font-weight: 500;
}

.total-card .value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.total-card .value.einnahme { color: var(--einnahme); }
.total-card .value.ausgabe  { color: var(--ausgabe); }
.total-card .value.saldo-pos { color: var(--einnahme); }
.total-card .value.saldo-neg { color: var(--ausgabe); }

/* ---- Tables ---- */
table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

th {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

td {
    font-size: 1.05rem;
}

tr:hover {
    background: var(--card-hover);
}

.text-right  { text-align: right; }
.text-center { text-align: center; }

.betrag-einnahme { color: var(--einnahme); font-weight: 600; }
.betrag-ausgabe  { color: var(--ausgabe);  font-weight: 600; }

/* ---- Forms ---- */
.form-row {
    display: flex;
    gap: 0.85rem;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
}

input, select {
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1.05rem;
    font-family: inherit;
    background: var(--bg-raised);
    color: var(--text);
    min-height: 48px;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
}

input::placeholder {
    color: var(--text-muted);
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(200,149,108,0.2);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, transform 0.1s;
    min-height: 48px;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    color: var(--bg);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-sm {
    padding: 0.5rem 0.85rem;
    font-size: 0.95rem;
    min-height: 40px;
}

.btn-danger {
    background: var(--ausgabe);
    color: white;
}

.btn-danger:hover {
    background: #d4645a;
}

.btn-ghost {
    background: transparent;
    color: var(--text-mid);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--surface);
    color: var(--text);
}

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge-aktiv    { background: var(--info-bg);     color: var(--info); }
.badge-passiv   { background: var(--warning-bg);  color: var(--warning); }
.badge-einnahme { background: var(--einnahme-bg); color: var(--einnahme); }
.badge-ausgabe  { background: var(--ausgabe-bg);  color: var(--ausgabe); }

/* ---- Chart ---- */
.chart-container {
    position: relative;
    height: 280px;
    margin-top: 1rem;
}

/* ---- Konten-Aufschlüsselung ---- */
.konto-liste {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 2rem;
}

.konto-eintrag {
    display: flex;
    justify-content: space-between;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 1rem;
}

/* ---- Actions ---- */
.actions {
    display: flex;
    gap: 0.4rem;
}

/* ---- Edit Forms ---- */
.edit-form        { display: none; }
.edit-form.visible { display: table-row; }

/* ---- Dialogs ---- */
dialog {
    border: none;
    border-radius: var(--radius);
    padding: 2rem;
    background: var(--card);
    color: var(--text);
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    max-width: 520px;
    width: 90%;
}

dialog::backdrop {
    background: rgba(0,0,0,0.6);
}

dialog h2 {
    font-size: 1.2rem;
    margin-bottom: 1.25rem;
}

dialog .form-group {
    margin-bottom: 1rem;
}

dialog .dialog-actions {
    display: flex;
    gap: 0.6rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

/* ---- Beleg Details ---- */
.beleg-details {
    margin-top: 0.75rem;
    padding: 0.5rem 0;
}

.beleg-details summary {
    cursor: pointer;
    font-size: 1rem;
    color: var(--primary);
    font-weight: 600;
}

.beleg-details summary:hover {
    color: var(--primary-hover);
}

.beleg-link {
    font-size: 1.3rem;
    text-decoration: none;
}

/* ---- Abrechnung ---- */
.abrechnung-summary {
    margin-top: 1.5rem;
    border-top: 2px solid var(--border);
    padding-top: 1rem;
}

.abrechnung-line {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 1.05rem;
}

.abrechnung-line.total {
    border-top: 2px solid var(--text-mid);
    margin-top: 0.5rem;
    padding-top: 0.85rem;
    font-size: 1.2rem;
}

/* ---- Erfolgsrechnung ---- */
.er-section-title {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border-light);
    font-weight: 600;
}

.er-table { margin-bottom: 0.5rem; }
.er-table td:first-child { width: 70px; color: var(--text-muted); font-size: 0.95rem; }
.er-table td:last-child  { width: 130px; }
.er-table tfoot tr { border-top: 2px solid var(--text-mid); }

.er-ergebnis {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding: 1.25rem;
    border-radius: var(--radius);
    font-size: 1.15rem;
}

.er-gewinn  { background: var(--einnahme-bg); color: var(--einnahme); }
.er-verlust { background: var(--ausgabe-bg);  color: var(--ausgabe); }

.er-ergebnis-betrag { font-size: 1.4rem; }

/* ---- Touch / Tablet ---- */
.touch-card {
    padding: 1.25rem 1.5rem;
}

.touch-title {
    font-size: 1.05rem;
    margin-bottom: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.touch-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.touch-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.touch-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex: 1;
}

.touch-input-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
}

.touch-input, .touch-select {
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1.15rem;
    font-family: inherit;
    background: var(--bg-raised);
    color: var(--text);
    min-height: 52px;
    -webkit-appearance: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.touch-input::placeholder {
    color: var(--text-muted);
}

.touch-input:focus, .touch-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(200,149,108,0.2);
}

.btn-touch {
    padding: 0.85rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    min-height: 52px;
    min-width: 130px;
    transition: background 0.2s, transform 0.1s;
}

.btn-touch:active {
    transform: scale(0.97);
}

.btn-touch-green {
    background: var(--einnahme);
    color: var(--bg);
}
.btn-touch-green:hover { background: #5db86a; }

.btn-touch-orange {
    background: var(--primary);
    color: var(--bg);
}
.btn-touch-orange:hover { background: var(--primary-hover); }

/* ---- Login ---- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
    background: var(--bg);
}

.login-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 3rem;
    border: 1px solid var(--border-light);
    box-shadow: 0 8px 40px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
}

.login-title {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 0.25rem;
    text-align: center;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 1rem;
}

/* ---- Print ---- */
@media print {
    nav, .flash, form, .btn, .monat-nav a, .actions { display: none !important; }
    .container { max-width: 100%; padding: 0; }
    .card { box-shadow: none; border: none; padding: 0; background: white; }
    body { background: white; color: black; }
    .abrechnung-detail, .er-report { break-inside: avoid; }
    .total-card { border: 1px solid #ccc; }
    .total-card .value { color: black !important; }
    .betrag-einnahme { color: #006600 !important; }
    .betrag-ausgabe  { color: #cc0000 !important; }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    body { font-size: 16px; }
    nav { padding: 0 1rem; gap: 0.15rem; height: 56px; }
    nav a { font-size: 0.9rem; padding: 0.4rem 0.65rem; }
    .container { padding: 1rem; }
    .totals { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; }
    .form-group { width: 100%; }
    .konto-liste { grid-template-columns: 1fr; }
    .total-card .value { font-size: 1.5rem; }
    .touch-row { flex-direction: column; }
    .btn-touch { width: 100%; }
    .login-card { padding: 2rem; }
}
