:root {
  --bg: #FAF8F3; --surface: #F1ECE2; --white: #FFFFFF; --ink: #132A33; --ink-soft: #48575D; --muted: #7C878B;
  --line: #E3DCCF; --gold: #C8960C; --gold-soft: #F4EAD0; --ok: #2F6B4F; --ok-bg: #E4EFE8; --warn: #8A5A00; --warn-bg: #F6EBD3;
  --err: #9B2C2C; --err-bg: #F6E3E1;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: Montserrat, "Helvetica Neue", Arial, sans-serif;
  font: 15px/1.55 var(--sans); color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
[hidden] { display: none !important; }
a { color: var(--ink); }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.1; margin: 0; }
h1 { font-size: 2.3rem; }
h2 { font-size: 1.5rem; margin: 28px 0 12px; }
h3 { font-size: 1.2rem; }
.sub { color: var(--ink-soft); margin: 6px 0 24px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Rahmen */
.shell { display: flex; min-height: 100vh; }
.nav { width: 232px; flex: none; background: var(--ink); color: var(--bg); padding: 26px 16px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { font-family: var(--serif); font-size: 1.7rem; letter-spacing: .14em; padding: 0 10px 26px; }
.brand small { display: block; font-family: var(--sans); font-size: .7rem; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); margin-top: 4px; }
.brand--big { color: var(--ink); text-align: center; font-size: 2.4rem; padding-bottom: 18px; }
.nav nav { display: flex; flex-direction: column; gap: 2px; }
.nav nav a { color: rgba(250,248,243,.78); text-decoration: none; padding: 10px 12px; border-radius: 8px; font-size: .95rem; }
.nav nav a:hover { color: var(--bg); background: rgba(250,248,243,.06); }
.nav nav a.active { color: var(--ink); background: var(--bg); font-weight: 600; }
.nav__foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 12px; font-size: .85rem; }
.nav__foot a, .nav__foot .link { color: rgba(250,248,243,.7); }
main { flex: 1; min-width: 0; padding: 36px 40px 80px; max-width: 1280px; }
main:focus { outline: none; }

/* Bausteine */
.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 18px; }
.bar .grow { flex: 1; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 24px; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; }
.card .k { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.card .v { font-family: var(--serif); font-size: 2.4rem; line-height: 1.1; margin-top: 6px; }
.card .s { font-size: .82rem; color: var(--ink-soft); margin-top: 2px; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 20px; margin-bottom: 18px; overflow-x: auto; }
.two { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
@media (max-width: 1050px) { .two { grid-template-columns: 1fr; } }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; white-space: nowrap; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--bg); }
.empty { padding: 34px 10px; text-align: center; color: var(--ink-soft); }

.btn { font: inherit; font-size: .78rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; border-radius: 8px; padding: 11px 18px; cursor: pointer; border: 1px solid var(--ink); background: transparent; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: var(--surface); }
.btn--primary { background: var(--ink); color: var(--white); }
.btn--primary:hover { background: #1d3b46; }
.btn--danger { border-color: var(--err); color: var(--err); }
.btn--small { padding: 6px 12px; font-size: .7rem; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .editor:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn[disabled] { opacity: .55; cursor: wait; }
.link { font: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; color: var(--ink); text-align: left; }

label { display: block; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; color: var(--ink-soft); }
input, select, textarea { display: block; width: 100%; margin-top: 6px; font: inherit; font-size: .95rem; color: var(--ink); background: var(--white); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; text-transform: none; letter-spacing: 0; font-weight: 400; }
textarea { min-height: 90px; resize: vertical; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 16px; }
.form .wide { grid-column: 1 / -1; }
.check { display: flex; gap: 10px; align-items: flex-start; text-transform: none; letter-spacing: 0; font-weight: 400; font-size: .9rem; color: var(--ink); }
.check input { width: auto; margin: 3px 0 0; }

.tag { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.tag--confirmed { background: var(--ok-bg); color: var(--ok); }
.tag--pending { background: var(--warn-bg); color: var(--warn); }
.tag--unsubscribed { background: var(--surface); color: var(--ink-soft); }
.tag--draft { background: var(--surface); color: var(--ink-soft); }
.tag--sent { background: var(--ok-bg); color: var(--ok); }
.tag--sending { background: var(--gold-soft); color: var(--warn); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border: 1px solid var(--line); border-radius: 999px; font-size: .75rem; margin: 2px 4px 2px 0; background: var(--white); }

.note { background: var(--gold-soft); border-radius: 8px; padding: 12px 14px; font-size: .9rem; margin-bottom: 16px; }
.note--plain { background: var(--surface); }

/* Diagramm */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 160px; padding-top: 12px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.chart .bars { display: flex; gap: 2px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.chart .b { width: 38%; min-height: 2px; border-radius: 3px 3px 0 0; }
.chart .b--in { background: var(--ink); }
.chart .b--out { background: var(--gold); }
.chart .l { font-size: .66rem; color: var(--muted); }
.legend { display: flex; gap: 16px; font-size: .78rem; color: var(--ink-soft); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.meter { height: 6px; background: var(--surface); border-radius: 3px; overflow: hidden; min-width: 80px; }
.meter > span { display: block; height: 100%; background: var(--gold); }

/* Editor */
.editor-wrap { border: 1px solid var(--line); border-radius: 6px; background: var(--white); margin-top: 6px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border-bottom: 1px solid var(--line); background: var(--bg); border-radius: 6px 6px 0 0; }
.toolbar button { font: inherit; font-size: .82rem; border: 1px solid transparent; background: none; border-radius: 6px; padding: 5px 9px; cursor: pointer; color: var(--ink); min-width: 32px; }
.toolbar button:hover { border-color: var(--line); background: var(--white); }
.editor { min-height: 280px; padding: 16px 18px; font-size: 15px; line-height: 1.7; color: var(--ink-soft); text-transform: none; letter-spacing: 0; font-weight: 400; }
.editor:empty::before { content: attr(data-placeholder); color: var(--muted); }
.editor h2, .editor h3 { color: var(--ink); margin: .6em 0 .3em; }
.editor-split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .editor-split { grid-template-columns: 1fr; } }
.preview { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }

/* Dialog, Meldungen, Login */
dialog { border: 0; border-radius: 10px; padding: 0; width: min(640px, 94vw); max-height: 90vh; box-shadow: 0 20px 60px rgba(19,42,51,.25); color: var(--ink); }
dialog::backdrop { background: rgba(19,42,51,.45); }
#dlg-body { padding: 26px; }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 22px; }
#toast { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
#toast div { background: var(--ink); color: var(--white); padding: 12px 16px; border-radius: 8px; max-width: 420px; font-size: .9rem; }
#toast div.err { background: var(--err); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--surface); }
.login__card { background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 34px; width: min(380px, 100%); display: grid; gap: 16px; }
.login__msg { color: var(--err); margin: 0; min-height: 1.2em; font-size: .9rem; }

@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .nav { width: 100%; height: auto; position: static; padding: 14px 12px; }
  .nav nav { flex-direction: row; flex-wrap: wrap; }
  .brand { padding-bottom: 10px; }
  .nav__foot { flex-direction: row; margin-top: 10px; }
  main { padding: 22px 16px 60px; }
  h1 { font-size: 1.9rem; }
}
