:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6ec;
  --text: #16191f;
  --muted: #6b7280;
  --accent: #1f5eff;
  --accent-soft: #eef3ff;
  --ok: #0f7b45;
  --ok-soft: #e7f5ee;
  --warn: #a5670a;
  --warn-soft: #fdf3e2;
  --err: #b3261e;
  --err-soft: #fdecea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- layout */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 24px; min-height: 60px; flex-wrap: wrap;
}
.brand { font-weight: 700; letter-spacing: -.02em; color: var(--text); font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a {
  padding: 7px 12px; border-radius: 8px; color: var(--muted);
  font-weight: 500; font-size: 14px;
}
.nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 20px 64px; }
.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
h1 { font-size: 24px; letter-spacing: -.02em; margin: 0 0 4px; }
h2 { font-size: 17px; letter-spacing: -.01em; margin: 0 0 14px; }
h3 { font-size: 14px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sub { color: var(--muted); font-size: 14px; margin: 0; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.grid { display: grid; gap: 20px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ------------------------------------------------------------- elements */
.stat { }
.stat .label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.stat .value { font-size: 26px; font-weight: 650; letter-spacing: -.03em; }
.stat .value.small { font-size: 19px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600; padding: 0 12px 10px; border-bottom: 1px solid var(--border);
}
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfd; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge.offen { background: var(--warn-soft); color: var(--warn); }
.badge.ausgezahlt { background: var(--ok-soft); color: var(--ok); }
.badge.storniert { background: var(--err-soft); color: var(--err); }
.badge.neutral { background: var(--bg); color: var(--muted); }
.badge.info { background: var(--accent-soft); color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 14px; border-radius: 9px; font-size: 14px; font-weight: 550;
  font-family: inherit; text-decoration: none; line-height: 1.2;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1a4fd8; }
.btn.danger { color: var(--err); border-color: #f3c9c5; background: var(--err-soft); }
.btn.danger:hover { background: #fbdcd9; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #374151; }
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=file], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px;
  font: inherit; background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-soft); border-color: var(--accent);
}
textarea { min-height: 84px; resize: vertical; }
.field { margin-bottom: 16px; }
.field-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.check { display: flex; align-items: center; gap: 9px; font-size: 14px; }
.check input { width: auto; }
.check label { margin: 0; font-weight: 500; }
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; font-size: 14px; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.warn { background: var(--warn-soft); color: var(--warn); }
.flash.error { background: var(--err-soft); color: var(--err); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }

/* ----------------------------------------------------------------- chart */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 150px; margin-top: 8px; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 6px; }
.chart .bar { background: var(--accent); border-radius: 5px 5px 2px 2px; min-height: 3px; width: 100%; }
.chart .bar.zero { background: var(--border); }
.chart .cap { font-size: 11px; color: var(--muted); text-align: center; }
.chart-values { display: flex; gap: 8px; }
.chart-values div { flex: 1; text-align: center; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- specifics */
.file-item {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px;
}
.file-icon {
  width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0; color: #fff; background: var(--muted);
}
.file-icon.pdf { background: #c0392b; }
.file-icon.excel { background: #1d6f42; }
.file-meta { flex: 1; min-width: 0; }
.file-meta .name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta .size { color: var(--muted); font-size: 13px; }

.msg { border-left: 3px solid var(--border); padding: 4px 0 4px 14px; margin-bottom: 16px; }
.msg.admin { border-left-color: var(--accent); }
.msg .who { font-size: 13px; color: var(--muted); margin-bottom: 3px; }
.msg .body { white-space: pre-wrap; }

.filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.filters .field { margin: 0; min-width: 150px; }

.pw-box {
  background: #101418; color: #e6edf3; padding: 16px; border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px;
  display: flex; justify-content: space-between; gap: 16px; align-items: center; flex-wrap: wrap;
}

.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .card { margin: 0; padding: 28px; }
.auth-logo { text-align: center; margin-bottom: 22px; font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.auth-logo span { color: var(--accent); }

.table-wrap { overflow-x: auto; }

@media (max-width: 760px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; }
  .topbar-inner { min-height: 0; padding: 10px 16px; }
  .wrap { padding: 20px 16px 48px; }
  th, td { padding-left: 8px; padding-right: 8px; }
}

.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }

/* --------------------------------------------------------- Abrechnungslauf */
.period-banner {
  display: flex; justify-content: space-between; align-items: center; gap: 20px;
  flex-wrap: wrap; padding: 16px 20px; border-radius: var(--radius);
  background: var(--accent-soft); border: 1px solid #d4e0ff; margin-bottom: 20px;
}
.period-banner .title { font-weight: 650; font-size: 16px; letter-spacing: -.01em; }
.period-banner .meta { color: var(--muted); font-size: 14px; }
.period-banner.due { background: var(--warn-soft); border-color: #f0dcb6; }
.period-banner.overdue { background: var(--err-soft); border-color: #f3c9c5; }

.state { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; white-space: nowrap; }
.state .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.state.yes .dot { background: var(--ok); }
.state.no  .dot { background: #d6d9e0; }
.state.no  { color: var(--muted); }
.state.draft .dot { background: var(--warn); }

.progress { display: flex; gap: 10px; align-items: baseline; }
.progress .big { font-size: 26px; font-weight: 650; letter-spacing: -.03em; }
.progress .of { color: var(--muted); font-size: 14px; }
.track { height: 6px; border-radius: 99px; background: var(--bg); overflow: hidden; margin-top: 10px; }
.track .fill { height: 100%; background: var(--accent); border-radius: 99px; }
.track .fill.ok { background: var(--ok); }
