:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --ink: #1d2327;
  --ink-2: #4a545b;
  --muted: #7a848b;
  --line: #e2dfd8;
  --accent: #1f5f5b;
  --accent-ink: #ffffff;
  --accent-soft: #e3efed;
  --ok: #2c7a4b;
  --ok-soft: #e4f3ea;
  --warn: #9a6200;
  --warn-soft: #fbf0db;
  --err: #a8322d;
  --err-soft: #f8e4e2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 25, 30, .05), 0 4px 16px rgba(20, 25, 30, .04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 var(--font);
}
a { color: var(--accent); }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 1.6rem 0 1rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .8rem; }
h3 { font-size: 1rem; margin: 1.4rem 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.right { text-align: right; }
.mono { font-family: var(--mono); font-size: .82rem; word-break: break-all; }
.inline { display: inline; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* Kopfzeile */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 58px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 650; color: var(--ink); text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: var(--accent-ink); font-size: .85rem; font-weight: 700;
}
.brand-lg { font-size: 1.1rem; margin-bottom: .4rem; }
.nav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.nav a, .nav .linkbtn {
  padding: .45rem .7rem; border-radius: 7px; color: var(--ink-2); text-decoration: none; font-size: .93rem;
}
.nav a:hover, .nav .linkbtn:hover { background: var(--bg); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.foot { color: var(--muted); font-size: .8rem; padding-top: 2.5rem; padding-bottom: 2rem; }

/* Karten & Raster */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.grid-main { grid-template-columns: 1.7fr 1fr; }
@media (max-width: 760px) { .grid-2, .grid-main { grid-template-columns: 1fr; } }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 1.6rem 0 1rem; }
.pagehead h1 { margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; line-height: 1.2;
}
.btn:hover { border-color: #cfcbc2; background: #fbfaf8; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #184d4a; border-color: #184d4a; }
.btn-primary:disabled { background: #9db5b3; border-color: #9db5b3; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-sm { padding: .35rem .65rem; font-size: .86rem; }
.linkbtn { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
.linkbtn.danger { color: var(--err); }

/* Formulare */
.form { display: grid; gap: .9rem; }
.form label { display: grid; gap: .3rem; font-weight: 550; font-size: .92rem; }
.form .hint { font-weight: 400; color: var(--muted); font-size: .84rem; }
input[type=text], input[type=email], input[type=password], input[type=date], input:not([type]), select, textarea {
  width: 100%; padding: .6rem .7rem; border: 1px solid #d3cfc6; border-radius: 8px; background: #fff;
  font: inherit; color: var(--ink);
}
textarea { min-height: 220px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
input[type=file] { font: inherit; }
.check { display: flex !important; align-items: flex-start; gap: .55rem; font-weight: 400 !important; }
.check input { margin-top: .25rem; width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 0; }
legend { font-weight: 600; padding: 0 .4rem; }

/* Tabellen */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .65rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.table.compact td { padding: .45rem .4rem; }
.table a.rowlink { color: var(--ink); font-weight: 600; text-decoration: none; }
.table a.rowlink:hover { color: var(--accent); }
.table tr.inactive td { color: var(--muted); }

/* Hinweise & Status */
.flash { padding: .7rem .9rem; border-radius: 8px; margin: 1rem 0; border: 1px solid; }
.flash-ok { background: var(--ok-soft); border-color: #bfe0cb; color: #1d5a37; }
.flash-err { background: var(--err-soft); border-color: #eec3bf; color: #7d221e; }
.flash-info { background: var(--accent-soft); border-color: #c6dedb; color: #184d4a; }

.chip { display: inline-block; padding: .14rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-open { background: #eeece7; color: var(--ink-2); }
.chip-seen { background: var(--accent-soft); color: var(--accent); }
.chip-late { background: var(--err-soft); color: var(--err); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }

.progress { height: 8px; background: #ebe8e1; border-radius: 99px; overflow: hidden; min-width: 90px; }
.progress > span { display: block; height: 100%; background: var(--ok); border-radius: 99px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .85rem; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }

/* Filterleiste */
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: .8rem; }
.tabs a { padding: .35rem .7rem; border-radius: 7px; color: var(--ink-2); text-decoration: none; font-size: .9rem; }
.tabs a.active { background: var(--ink); color: #fff; }

/* Empfänger-Auswahl */
.picker { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: .4rem .7rem; background: #fcfbf9; }
.picker .check { padding: .3rem 0; }
.picker .dept { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: .7rem 0 .2rem; font-weight: 600; }

/* Anmeldung */
.auth { min-height: 78vh; display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.8rem; box-shadow: var(--shadow); }
.auth-card h1 { margin-top: .6rem; }

/* Empfängerseite */
.reader { max-width: 760px; margin: 0 auto; }
.reader-head { padding: 1.8rem 0 1rem; }
.reader-head .eyebrow { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.reader-head h1 { margin: .35rem 0 .5rem; font-size: 1.75rem; }
.doc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.doc-body { padding: 1.5rem 1.6rem; max-height: 62vh; overflow-y: auto; font-size: 1.02rem; line-height: 1.65; }
.doc-body p { margin: 0 0 1em; }
.doc-body ul { margin: 0 0 1em; padding-left: 1.3em; }
.doc-body .endmark { text-align: center; color: var(--muted); font-size: .82rem; border-top: 1px dashed var(--line); padding-top: .9rem; margin-top: 1.4rem; }
.doc-attach { border-top: 1px solid var(--line); padding: 1rem 1.6rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; background: #fcfbf9; }
.doc-attach .file { display: flex; align-items: center; gap: .6rem; font-weight: 550; }
.doc-attach .file-icon { width: 34px; height: 40px; border-radius: 4px; background: var(--err-soft); color: var(--err); display: grid; place-items: center; font-size: .66rem; font-weight: 800; }
.ack { margin-top: 1rem; }
.ack .gate { font-size: .88rem; color: var(--warn); background: var(--warn-soft); padding: .55rem .8rem; border-radius: 8px; }
.ack .gate.done { color: var(--ok); background: var(--ok-soft); }
.receipt { border-left: 4px solid var(--ok); }
.receipt dl { display: grid; grid-template-columns: 170px 1fr; gap: .45rem 1rem; margin: 0; }
.receipt dt { color: var(--muted); }
.receipt dd { margin: 0; }
@media (max-width: 560px) { .receipt dl { grid-template-columns: 1fr; gap: .1rem; } .receipt dd { margin-bottom: .5rem; } .doc-body { padding: 1.1rem; } }

.linkbox { display: flex; gap: .4rem; align-items: center; }
.linkbox input { font-family: var(--mono); font-size: .78rem; padding: .35rem .5rem; min-width: 0; }

@media print {
  .topbar, .foot, .noprint, .actions, .btn { display: none !important; }
  body { background: #fff; }
  .card, .doc { box-shadow: none; }
  .doc-body { max-height: none; overflow: visible; }
}
