/* Jomo-Verwaltung – ruhiges Kontobuch: Papierton, dunkelgrüne Tinte, tabellarische Ziffern. */
:root {
  --paper: #f6f3ec;
  --card: #fffdf8;
  --ink: #16201d;
  --ink-2: #4c5652;
  --ink-3: #7c8580;
  --line: #e3ddd0;
  --line-2: #cfc7b6;
  --brand: #14322b;
  --brand-2: #1f4d41;
  --accent: #c9a96a;
  --credit: #0f6b46;
  --debit: #a8402c;
  --income: #2a78d6;   /* Serie 1 */
  --expense: #eb6834;  /* Serie 2 */
  --warn-bg: #fff4dc;
  --radius: 10px;
  --shadow: 0 1px 0 rgba(20, 30, 25, .04), 0 6px 20px -12px rgba(20, 30, 25, .25);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; font-size: 15px; line-height: 1.45; }
.num, td.num, .amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
a { color: var(--brand-2); }
h1, h2, h3 { font-family: ui-serif, Georgia, "Times New Roman", serif; font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
small, .muted { color: var(--ink-3); }
[hidden] { display: none !important; }

/* Kopfzeile */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px; padding: 10px 28px;
  background: var(--brand); color: #f4efe4; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand small { display: block; color: #b9c7bf; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: #f4efe4; color: var(--brand);
  font: 700 20px ui-serif, Georgia, serif; }
nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
nav a { color: #d9e2dc; text-decoration: none; padding: 7px 12px; border-radius: 8px; white-space: nowrap; font-size: 14px; }
nav a:hover { background: rgba(255,255,255,.08); }
nav a.active { background: #f4efe4; color: var(--brand); font-weight: 600; }
.me { display: flex; align-items: center; gap: 10px; font-size: 14px; white-space: nowrap; }
.me .link { color: #d9e2dc; }

main { max-width: 1180px; margin: 0 auto; padding: 28px 28px 80px; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
.page-head select, .actions select { width: auto; min-width: 110px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Karten */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpi .label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.kpi .value { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.section { margin-top: 26px; }
.section > h2 { margin-bottom: 12px; }

/* Saldo-Hero */
.hero { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: 0; padding: 0; overflow: hidden; }
.hero .side { padding: 20px 22px; }
.hero .side.right { text-align: right; }
.hero .side .who { font: 600 18px ui-serif, Georgia, serif; }
.hero .side dl { margin: 10px 0 0; display: grid; grid-template-columns: auto auto; gap: 3px 14px; font-size: 13px; color: var(--ink-2); }
.hero .side.right dl { justify-content: end; }
.hero .side dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.hero .center { background: var(--brand); color: #f4efe4; padding: 22px 26px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; min-width: 280px; }
.hero .center .big { font: 600 34px ui-serif, Georgia, serif; font-variant-numeric: tabular-nums; margin: 6px 0; }
.hero .center .arrow { font-size: 13px; color: #c9d6cf; }
.hero .center .label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: #b9c7bf; }
.balanced { color: #cfe8d9; }

/* Buttons und Formulare */
button, .btn { font: inherit; border-radius: 8px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink); padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: var(--ink-3); }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: #f4efe4; }
button.primary:hover { background: var(--brand-2); }
button.danger { color: var(--debit); border-color: #e6c3b9; }
button.link { background: none; border: none; padding: 0; text-decoration: underline; cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 4px; font-weight: 500; }
input, select, textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; color: var(--ink); }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: 12px; }
.row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.row.three { grid-template-columns: 1fr 1fr 1fr; }
.seg { display: flex; flex-wrap: wrap; border: 1px solid var(--line-2); border-radius: 9px; overflow: hidden; background: #fff; }
.seg button { border: none; border-radius: 0; flex: 1; padding: 8px 10px; border-right: 1px solid var(--line); font-size: 14px; white-space: nowrap; }
.seg button:last-child { border-right: none; }
.seg button[aria-pressed="true"] { background: var(--brand); color: #f4efe4; }
.preview { background: var(--paper); border: 1px dashed var(--line-2); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.preview strong { font-variant-numeric: tabular-nums; }
.error { color: var(--debit); font-size: 14px; min-height: 1em; }
.notice { background: var(--warn-bg); border: 1px solid #efd9a8; border-radius: 8px; padding: 10px 12px; font-size: 14px; }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); padding: 8px 10px; border-bottom: 2px solid var(--line-2); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th.num, td.num { text-align: right; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #faf6ec; }
tfoot td { font-weight: 600; border-top: 2px solid var(--line-2); border-bottom: none; }
.t-account th.left, .t-account td.left { border-left: 2px solid var(--line-2); }
.t-account th.right, .t-account td.right { border-right: 2px solid var(--line-2); }
.credit { color: var(--credit); }
.debit { color: var(--debit); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--ink-2); background: #fff; white-space: nowrap; }
.tag.k-expense { border-color: #ecc3b4; }
.tag.k-income { border-color: #b9d2f0; }
.tag.k-transfer { border-color: #b8d9c9; }
.tag.k-opening { border-color: #ddd0ab; }
.tag.open { background: var(--warn-bg); border-color: #efd9a8; }
.sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.filters input, .filters select { width: auto; min-width: 140px; }
.empty { text-align: center; padding: 30px 10px; color: var(--ink-3); }

/* Diagramm */
.chart { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 170px; padding: 6px 0 0; border-bottom: 1px solid var(--line-2); position: relative; }
.chart .month { display: flex; gap: 2px; align-items: flex-end; height: 100%; justify-content: center; position: relative; }
.chart .bar { width: 42%; max-width: 18px; border-radius: 4px 4px 0 0; min-height: 0; }
.chart .bar.inc { background: var(--income); }
.chart .bar.exp { background: var(--expense); }
.chart .month:hover { background: rgba(20, 50, 43, .05); border-radius: 6px 6px 0 0; }
.chart-x { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; font-size: 11px; color: var(--ink-3); text-align: center; margin-top: 4px; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tip { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 12px; padding: 6px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none; z-index: 2; display: none; }
.chart .month:hover .tip, .chart .month:focus .tip { display: block; }

/* Dialog */
dialog { border: none; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 30px 80px -20px rgba(0,0,0,.45); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(15, 25, 22, .45); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 1; }
.modal-body { padding: 16px 20px; }
.modal-foot { display: flex; justify-content: space-between; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--card); }
.close { border: none; background: none; font-size: 22px; line-height: 1; padding: 4px 8px; }

/* Anmeldung */
.auth { max-width: 460px; margin: 8vh auto 0; }
.auth .brand-big { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth .brand-big .mark { background: var(--brand); color: #f4efe4; width: 44px; height: 44px; font-size: 26px; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50; }
#toast.show { opacity: 1; }
.att-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.att-list .att { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; background: var(--paper); border-radius: 6px; padding: 6px 10px; }
.mobile-only { display: none; }

@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  nav { order: 3; flex-basis: 100%; }
  main { padding: 18px 14px 80px; }
  .grid.two, .row, .row.three { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; }
  .hero .side.right { text-align: left; }
  .hero .side.right dl { justify-content: start; }
  .hide-sm { display: none; }
  .mobile-only { display: block; }
}

/* ---------- Holding ---------- */
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin: 0; font-size: 14px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { margin-left: 18px; padding-left: 14px; border-left: 2px solid var(--line-2); }
.tree li { margin: 8px 0; }
.tree-node { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; color: var(--ink); text-decoration: none; }
.tree-node:hover { border-color: var(--brand-2); }
.tree-holders { font-size: 12px; color: var(--ink-3); margin-bottom: 4px; }
.tree-share { font-size: 12px; color: var(--brand-2); font-weight: 600; }
.company-cards { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.company-card { color: var(--ink); text-decoration: none; display: block; }
.company-card:hover { border-color: var(--brand-2); }
.cc-head { display: flex; justify-content: space-between; align-items: center; font-size: 18px; }
.cc-name { color: var(--ink-2); font-size: 13px; margin: 2px 0 10px; }
.deadlines { list-style: none; margin: 0; padding: 0; }
.deadlines li { display: grid; grid-template-columns: 96px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.deadlines li:last-child { border-bottom: none; }
.dl-date { font-weight: 600; color: var(--brand-2); }
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.sheet-col h3 { margin: 6px 0 6px; }
table.sheet td { padding: 6px 4px; }
table.sheet tfoot td { font-weight: 700; }
.tag.ok { background: #e3f3ea; border-color: #b7dcc6; color: var(--credit); }
.back { font-size: 13px; text-decoration: none; display: inline-block; margin-bottom: 4px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 14px; }
label.inline input { width: auto; }
.holder-row { margin-bottom: 10px; padding: 12px 14px; box-shadow: none; }
ul.plain { margin: 0; padding-left: 18px; }
.muted { color: var(--ink-2); font-size: 14px; }

/* ---------- Handy ---------- */
.tabbar { display: none; }
.fab { display: none; }
@media (max-width: 820px) {
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .topbar { padding: calc(8px + env(safe-area-inset-top)) 14px 8px; }
  .topbar nav, .topbar .me { display: none; }
  .brand small { max-width: 220px; }
  .tabbar:not([hidden]) { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--card); border-top: 1px solid var(--line-2); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 9px; font-size: 11px; color: var(--ink-2); text-decoration: none; min-height: 56px; justify-content: center; }
  .tabbar a span { font-size: 19px; line-height: 1; }
  .tabbar a.active { color: var(--brand); font-weight: 700; }
  .fab:not([hidden]) { display: grid; place-items: center; position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 21; width: 56px; height: 56px;
    border-radius: 50%; border: none; background: var(--brand); color: #f4efe4; font-size: 30px; box-shadow: 0 8px 22px -6px rgba(0,0,0,.45); padding: 0; }
  h1 { font-size: 24px; }
  input, select, textarea { font-size: 16px; }
  button, .btn { min-height: 44px; }
  .seg button { min-height: 44px; }
  .actions { width: 100%; }
  .actions select, .actions .btn, .actions button { flex: 1 1 auto; }
  .filters input, .filters select { flex: 1 1 140px; }
  .grid.kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi .value { font-size: 18px; }
  .sheet-grid { grid-template-columns: 1fr; }
  .card.table-wrap { padding: 10px; }
  /* Tabellen als Karten */
  table.cards-sm thead { display: none; }
  table.cards-sm, table.cards-sm tbody, table.cards-sm tfoot { display: block; }
  table.cards-sm tr { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; padding: 12px 6px; border-bottom: 1px solid var(--line); }
  table.cards-sm td { display: block; border: none; padding: 2px 0; }
  table.cards-sm td.main-cell { grid-column: 1 / -1; order: -1; font-size: 15px; }
  table.cards-sm td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; }
  table.cards-sm td.num { text-align: left; }
  table.cards-sm td.empty-sm, table.cards-sm td.hide-sm { display: none; }
  table.cards-sm td.left, table.cards-sm td.right { border: none; }
  table.cards-sm tfoot tr { background: var(--paper); border-radius: 8px; }
  .status-cell .tag { margin-right: 4px; }
  /* Dialog als Vollbild */
  dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .modal-head { padding-top: calc(12px + env(safe-area-inset-top)); }
  .modal-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .modal-foot .actions { width: auto; flex: 1; justify-content: flex-end; }
  .hero .center { min-width: 0; }
  .deadlines li { grid-template-columns: 1fr; gap: 2px; }
  .hero .center { order: -1; }
  .hero .side dl, .hero .side.right dl { grid-template-columns: 1fr auto; justify-content: stretch; }
  .hero .side.right { text-align: left; }
}

/* ---------- Übersicht: Kopf und Timeline ---------- */
.ov-title { align-items: center; }
.ov-head { display: grid; grid-template-columns: 1fr auto 1fr; padding: 0; overflow: hidden; }
.ov-side { padding: 18px 20px; }
.ov-side.right { text-align: right; }
.ov-side .who { font: 600 18px ui-serif, Georgia, serif; }
.ov-side .label, .ov-mid .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin-top: 6px; }
.ov-side .sum { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ov-mid { background: var(--brand); color: #f4efe4; padding: 18px 28px; text-align: center; display: flex; flex-direction: column; justify-content: center; min-width: 240px; }
.ov-mid .label { color: #b9c7bf; margin: 0; }
.ov-mid .big { font: 600 32px ui-serif, Georgia, serif; font-variant-numeric: tabular-nums; white-space: nowrap; margin-top: 4px; }
.ov-mid .dir { font-size: 14px; color: #dfe7e2; }

.timeline { list-style: none; margin: 20px 0 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: var(--line-2); }
.tl-row { display: grid; grid-template-columns: 1fr 28px 1fr; align-items: center; position: relative; padding: 6px 0; }
.tl-heads { position: sticky; top: 54px; z-index: 2; padding: 0 0 8px; font: 600 15px ui-serif, Georgia, serif; }
.tl-heads .tl-cell { background: var(--paper); padding: 4px 0; }
.tl-cell.left { display: flex; justify-content: flex-end; }
.tl-cell.right { display: flex; justify-content: flex-start; }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--card); border: 2px solid var(--line-2); justify-self: center; position: relative; z-index: 1; }
.tl-box { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 1px; width: min(100%, 320px); min-height: 0; padding: 10px 12px; text-align: left; font: inherit; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); cursor: pointer; }
.tl-cell.left .tl-box { border-right: 4px solid var(--income); align-items: flex-end; text-align: right; }
.tl-cell.right .tl-box { border-left: 4px solid var(--income); }
.tl-cell .tl-box.k-expense { border-color: var(--line); }
.tl-cell.left .tl-box.k-expense { border-right: 4px solid var(--expense); }
.tl-cell.right .tl-box.k-expense { border-left: 4px solid var(--expense); }
.tl-cell.left .tl-box.k-opening { border-right: 4px solid var(--accent); }
.tl-cell.right .tl-box.k-opening { border-left: 4px solid var(--accent); }
.tl-box:hover { border-color: var(--line-2); }
.tl-name { font-weight: 600; font-size: 15px; line-height: 1.25; overflow-wrap: break-word; -webkit-hyphens: auto; hyphens: auto; max-width: 100%; }
.tl-sum { font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl-box.k-expense .tl-sum { color: var(--debit); }
.tl-note { font-size: 13px; color: var(--ink-2); overflow-wrap: break-word; max-width: 100%; }
.tl-date { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tl-pill { grid-column: 1 / -1; justify-self: center; max-width: 92%; position: relative; z-index: 1; display: inline-flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 4px 6px; min-height: 0; padding: 7px 14px;
  border-radius: 999px; border: 1px solid #b8d9c9; background: #e8f3ed; color: var(--ink); font: inherit; font-size: 14px; font-variant-numeric: tabular-nums; cursor: pointer; }
.tl-pill .tl-date { width: 100%; text-align: center; }
@media (max-width: 820px) {
  .ov-head { grid-template-columns: 1fr 1fr; }
  .ov-mid { grid-column: 1 / -1; order: -1; min-width: 0; padding: 14px; }
  .ov-mid .big { font-size: 28px; }
  .ov-side { padding: 12px 14px; }
  .ov-side .sum { font-size: 18px; }
  .tl-row { grid-template-columns: 1fr 20px 1fr; padding: 5px 0; }
  .tl-heads { top: calc(50px + env(safe-area-inset-top)); }
  .tl-box { padding: 8px 9px; }
  .tl-name { font-size: 14px; }
  .tl-sum { font-size: 15px; }
  .tl-pill { min-height: 0; font-size: 13px; padding: 6px 12px; }
  .tl-box { min-height: 0; }
}
