:root {
  --teal: #0C3B3E;
  --teal-2: #103F42;
  --teal-3: #144548;
  --gold: #C9A24A;
  --terracotta: #CA6E3A;
  --cream: #F4EFE6;
  --ink: #10201F;
  --muted: #6B7B79;
  --line: rgba(12, 59, 62, 0.12);
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 40px;
  background: var(--teal);
  color: var(--cream);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { font-size: 26px; color: var(--gold); }
.brand-name { font-family: var(--serif); font-size: 24px; font-weight: 600; letter-spacing: .3px; }
.brand-name em { color: var(--gold); font-style: italic; }
.nav a { color: rgba(244,239,230,.75); text-decoration: none; margin-left: 26px; font-weight: 500; font-size: 15px; }
.nav a.active { color: var(--cream); border-bottom: 2px solid var(--gold); padding-bottom: 4px; }
.logout-form { display: inline; margin-left: 26px; }
.logout-form button { background: none; border: 1px solid rgba(244,239,230,.3); color: rgba(244,239,230,.75); border-radius: 8px; padding: 5px 12px; font-family: var(--sans); font-size: 13px; font-weight: 500; cursor: pointer; }
.logout-form button:hover { border-color: var(--gold); color: var(--cream); }
.nav .soon { color: rgba(244,239,230,.4); margin-left: 26px; font-weight: 500; font-size: 15px; cursor: default; }
.nav .soon::after { content: " ·bald"; font-size: 10px; letter-spacing: .5px; vertical-align: super; color: var(--gold); opacity: .6; }

/* Content */
.content { max-width: 1080px; margin: 0 auto; padding: 40px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.page-head h1 { font-family: var(--serif); font-size: 40px; margin: 0 0 4px; color: var(--teal); font-weight: 600; }

/* Umschalter (Währung + Zeitraum) */
.switch-col { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.period-switch { margin-top: 0; }
.cur-switch { display: flex; gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 4px; margin-top: 8px; }
.cur-switch a { text-decoration: none; padding: 6px 12px; border-radius: 7px; font-size: 14px; font-weight: 600; color: var(--muted); }
.cur-switch a.active { background: var(--teal); color: var(--cream); }
.subtitle { color: var(--muted); margin: 0 0 28px; font-size: 15px; }
.subtitle code { background: rgba(12,59,62,.08); padding: 1px 6px; border-radius: 4px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 32px; }
.kpi {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 22px 24px; display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 1px 3px rgba(12,59,62,.05);
}
.kpi-label { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 600; }
.kpi-value { font-family: var(--serif); font-size: 34px; font-weight: 600; color: var(--teal); }
a.kpi { text-decoration: none; transition: box-shadow .15s, transform .1s; }
a.kpi:hover { box-shadow: 0 4px 14px rgba(12,59,62,.12); transform: translateY(-1px); }
.kpi-go { font-size: 11px; font-weight: 600; color: var(--gold); opacity: 0; transition: opacity .15s; text-transform: none; letter-spacing: 0; }
a.kpi:hover .kpi-go { opacity: 1; }
.kpi-income { border-left: 4px solid var(--teal); }
.kpi-expense { border-left: 4px solid var(--gold); }
.kpi-profit.positive { border-left: 4px solid #2E7D5B; }
.kpi-profit.positive .kpi-value { color: #2E7D5B; }
.kpi-profit.negative { border-left: 4px solid var(--terracotta); }
.kpi-profit.negative .kpi-value { color: var(--terracotta); }

/* Grid cards */
.grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.card h2 { font-family: var(--serif); font-size: 22px; margin: 0 0 16px; color: var(--teal); font-weight: 600; }
.empty { color: var(--muted); font-size: 15px; line-height: 1.5; }

.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list li { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.cat-list li:last-child { border-bottom: none; }
.cat-name { color: var(--ink); }
.cat-amount { font-weight: 600; color: var(--teal); }

/* Chat */
.chat { margin-top: 20px; }
.chat-hint { font-family: var(--sans); font-size: 14px; font-weight: 400; color: var(--muted); }
.chat-log { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; max-height: 240px; overflow-y: auto; }
.chat-log:empty { display: none; }
.chat-msg { padding: 9px 13px; border-radius: 12px; font-size: 14px; max-width: 80%; white-space: pre-line; line-height: 1.4; }
.chat-msg.me { align-self: flex-end; background: var(--teal); color: var(--cream); }
.chat-msg.bot { align-self: flex-start; background: #F0EBE0; color: var(--ink); }
.chat-msg.bot.ok { background: #E4EFE8; border-left: 3px solid #2E7D5B; }
.chat-msg.bot.err { background: #F6E4DA; border-left: 3px solid var(--terracotta); }
.chat-msg.pending { opacity: .5; }
.chat-form { display: flex; gap: 10px; }
.chat-form input { flex: 1; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; font-family: var(--sans); font-size: 15px; }
.chat-form input:focus { outline: none; border-color: var(--teal); }
.chat-form button, .btn-primary { background: var(--teal); color: var(--cream); border: none; border-radius: 10px; padding: 12px 22px; font-weight: 600; font-size: 15px; cursor: pointer; font-family: var(--sans); }
.chat-form button:hover, .btn-primary:hover { background: var(--teal-3); }

/* Upload */
.alert { background: #F6E4DA; border-left: 3px solid var(--terracotta); color: #7A2E12; padding: 14px 18px; border-radius: 10px; margin-bottom: 20px; }
.notice { background: #E4EFE8; border-left: 3px solid #2E7D5B; color: #1C5B3C; padding: 14px 18px; border-radius: 10px; margin-bottom: 20px; }
.key-form { display: flex; gap: 10px; margin: 14px 0 4px; }
.key-form input { flex: 1; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; font-family: var(--sans); font-size: 15px; }
.key-form input:focus { outline: none; border-color: var(--teal); }
.upload-form { display: flex; flex-direction: column; gap: 18px; align-items: flex-start; }
.dropzone { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 44px; border: 2px dashed var(--line); border-radius: 14px; cursor: pointer; text-align: center; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--gold); background: rgba(201,162,74,.06); }
.dz-icon { font-size: 34px; color: var(--gold); }
.dz-text { font-family: var(--serif); font-size: 20px; color: var(--teal); font-weight: 600; }
.dz-sub { font-size: 13px; color: var(--muted); }
.dz-file { font-size: 14px; color: var(--teal); font-weight: 600; margin-top: 4px; }
.hint-note { color: var(--muted); font-size: 14px; line-height: 1.5; margin-top: 18px; }

/* Vorschau-Tabelle */
.table-scroll { overflow-x: auto; }
.preview-table { width: 100%; border-collapse: collapse; }
.preview-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.preview-table td { padding: 6px 10px; }
.preview-table input, .preview-table select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-family: var(--sans); font-size: 14px; }
.preview-table input.num { text-align: right; }
.preview-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 20px; }
.btn-ghost { color: var(--muted); text-decoration: none; padding: 12px 20px; font-weight: 600; font-size: 15px; }

/* Letzte Buchungen (Dashboard) */
.card-head { display: flex; align-items: baseline; justify-content: space-between; }
.see-all { font-size: 14px; color: var(--gold); text-decoration: none; font-weight: 600; }
.txn-list { list-style: none; margin: 0; padding: 0; }
.txn-list li { display: grid; grid-template-columns: 92px 1fr auto auto; gap: 14px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.txn-list li:last-child { border-bottom: none; }
.txn-date { color: var(--muted); font-variant-numeric: tabular-nums; }
.txn-desc { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txn-party { color: var(--muted); }
.txn-cat { font-size: 12px; color: var(--muted); background: rgba(12,59,62,.06); padding: 3px 9px; border-radius: 20px; }
.txn-amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.txn-amount.in { color: #2E7D5B; }
.txn-amount.out { color: var(--terracotta); }

/* Filter-Tabs + Buchungstabelle */
.filter-tabs { display: flex; gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 4px; margin-bottom: 20px; width: fit-content; }
.filter-tabs a { text-decoration: none; padding: 8px 16px; border-radius: 7px; font-size: 14px; font-weight: 600; color: var(--muted); }
.filter-tabs a.active { background: var(--teal); color: var(--cream); }
.txn-table { width: 100%; border-collapse: collapse; }
.txn-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.txn-table th.r, .txn-table td.r { text-align: right; }
.txn-table td { padding: 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.txn-table tr:last-child td { border-bottom: none; }
.txn-table td.nowrap { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.txn-table td.muted-cell { color: var(--muted); }
.tag { font-size: 12px; color: var(--teal); background: rgba(12,59,62,.06); padding: 3px 10px; border-radius: 20px; }
tr.inactive { opacity: .45; }

/* Budgets */
.budget-list { list-style: none; margin: 0; padding: 0; }
.budget-list li { padding: 16px 0; border-bottom: 1px solid var(--line); }
.budget-list li:last-child { border-bottom: none; }
.budget-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.budget-cat { font-size: 15px; font-weight: 600; color: var(--ink); }
.budget-nums { font-size: 15px; }
.goal-badge { font-size: 11px; background: rgba(46,125,91,.12); color: #2E7D5B; padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.bar { height: 10px; background: rgba(12,59,62,.08); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--teal); border-radius: 6px; transition: width .3s; }
.bar-fill.over { background: var(--terracotta); }
.bar-fill.reached { background: #2E7D5B; }
.budget-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 7px; font-size: 13px; color: var(--muted); }
.budget-foot .over { color: var(--terracotta); font-weight: 600; }

/* Admin / Verwaltung */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.stat-num { font-family: var(--serif); font-size: 26px; color: var(--teal); font-weight: 600; display: flex; align-items: center; }
.stat-lbl { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.dot.on { background: #2E7D5B; } .dot.off { background: var(--terracotta); }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.admin-table th.r, .admin-table td.r { text-align: right; }
.admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.you { color: var(--gold); font-size: 12px; font-weight: 600; }
.inline { display: inline-flex; gap: 6px; margin: 0; align-items: center; }
.inline select, .inline input { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-family: var(--sans); font-size: 13px; }
.reset input { width: 170px; }
.btn-sm { background: var(--teal); color: var(--cream); border: none; border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: var(--sans); }
.btn-sm:hover { background: var(--teal-3); }
.btn-sm.danger { background: none; color: var(--terracotta); border: 1px solid var(--terracotta); }
.btn-sm.danger:hover { background: var(--terracotta); color: #fff; }
.create-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.create-form input, .create-form select { padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; font-family: var(--sans); font-size: 14px; }
.create-form input[type=email] { flex: 1; min-width: 200px; }

/* Verträge */
.type-picker { display: flex; gap: 14px; flex-wrap: wrap; }
.type-card { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 6px; padding: 22px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.type-card:hover { border-color: var(--gold); box-shadow: 0 4px 14px rgba(12,59,62,.1); }
.type-code { font-family: var(--serif); font-size: 26px; font-weight: 600; color: var(--teal); }
.type-name { font-size: 14px; color: var(--muted); }
.contract-form textarea { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; font-family: var(--sans); font-size: 14px; }
.field-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.field-grid label, .sub-fields label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field-grid input, .field-grid select, .sub-fields input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font-family: var(--sans); font-size: 14px; }
.scope-block { padding: 12px 0; border-bottom: 1px solid var(--line); }
.chk { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); font-size: 15px; }
.chk-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.sub-fields { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-top: 10px; padding-left: 26px; }
.sub-fields input[type=number] { max-width: 90px; }
.disclaimer { background: #F6E4DA; border-left: 3px solid var(--terracotta); color: #7A2E12; padding: 12px 16px; border-radius: 10px; font-size: 14px; margin-bottom: 20px; }
.catalog-group { padding: 12px 0; border-bottom: 1px solid var(--line); }
.catalog-group:last-child { border-bottom: none; }
.catalog-h { font-family: var(--serif); font-size: 16px; color: var(--teal); margin: 0 0 10px; font-weight: 600; }
.catalog-items { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; }
.cat-item { align-items: center; }
.cat-item .qty { max-width: 70px; margin-left: 6px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; }
.mini-label { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
@media (max-width: 760px) { .catalog-items, .field-grid { grid-template-columns: 1fr; } }

/* Vertrags-Dokument (druckbar) */
.contract-doc { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 48px; max-width: 820px; margin: 0 auto; }
.contract-title { font-family: var(--serif); font-size: 28px; color: var(--teal); text-align: center; margin: 0 0 6px; font-weight: 600; }
.contract-title span { font-size: 17px; color: var(--gold); }
.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin: 30px 0 16px; font-size: 14px; line-height: 1.6; }
.party-label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.contract-meta { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 10px 0; margin-bottom: 24px; }
.contract-section { margin-bottom: 18px; }
.contract-section h3 { font-family: var(--serif); font-size: 18px; color: var(--teal); margin: 0 0 6px; font-weight: 600; }
.contract-section p { font-size: 14px; line-height: 1.6; margin: 0 0 8px; }
.contract-section ul { margin: 6px 0 8px; padding-left: 20px; }
.contract-section li { font-size: 14px; line-height: 1.55; margin-bottom: 4px; }
.signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 48px; font-size: 13px; color: var(--muted); }
.sig-line { border-top: 1px solid var(--ink); margin-bottom: 6px; height: 40px; }

@media print {
  .topbar, .footer, .no-print { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .contract-doc { border: none; border-radius: 0; padding: 0; max-width: none; }
}

/* Login */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 40px; width: 100%; max-width: 420px; box-shadow: 0 8px 30px rgba(12,59,62,.10); }
.login-brand { font-family: var(--serif); font-size: 22px; color: var(--teal); font-weight: 600; margin-bottom: 24px; }
.login-brand em { color: var(--gold); font-style: italic; }
.login-brand .brand-mark { color: var(--gold); }
.login-card h1 { font-family: var(--serif); font-size: 30px; color: var(--teal); margin: 0 0 6px; font-weight: 600; }
.login-sub { color: var(--muted); font-size: 15px; margin: 0 0 22px; line-height: 1.5; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.login-form input { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; font-family: var(--sans); font-size: 15px; color: var(--ink); }
.login-form input:focus { outline: none; border-color: var(--teal); }
.login-form .btn-primary { margin-top: 6px; }

.footer { text-align: center; padding: 30px; color: var(--muted); font-size: 13px; }

@media (max-width: 760px) {
  .kpis, .grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; gap: 14px; padding: 16px 20px; }
  .content { padding: 24px; }
}
