:root {
  --text: #1d1d1f; --muted: #6e6e73; --line: #e5e5ea; --bg: #fff; --accent: #1f4e79;
  --green: #2e7d32; --yellow: #b7950b; --red: #c62828; --grey: #9e9e9e;
  --bg-soft: #f6f6f8;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; color: var(--text); background: var(--bg); line-height: 1.5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--bg); padding: 4px 8px; z-index: 10; }

.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; color: var(--text); text-decoration: none; letter-spacing: .01em; }
.brand.big { font-size: 1.4rem; margin-bottom: 8px; }
.mainnav { display: flex; flex-wrap: wrap; gap: 4px 16px; flex: 1; }
.mainnav a { color: var(--muted); text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
.mainnav a:hover { color: var(--text); }
.mainnav a.aktiv { color: var(--text); border-bottom-color: var(--accent); }
.user { display: flex; align-items: center; gap: 12px; }
.user form { margin: 0; }
.user a { text-decoration: none; }

.content { max-width: 1200px; margin: 0 auto; padding: 24px 16px 48px; }
.stack > * + * { margin-top: 12px; }
.narrow { max-width: 420px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 12px; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }

.btn { display: inline-block; font: inherit; padding: 6px 14px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--text); text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--bg-soft); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #17405f; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #a81f1f; }
.btn-link { border: 0; background: none; color: var(--accent); padding: 4px 0; }
.btn-link:hover { background: none; text-decoration: underline; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 500; font-size: .9rem; white-space: nowrap; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; background: var(--bg-soft); border: 1px solid var(--line); font-size: .85rem; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; background: var(--grey); }
.dot-green { background: var(--green); }
.dot-yellow { background: var(--yellow); }
.dot-red { background: var(--red); }
.dot-grey { background: var(--grey); }

.tabs { display: flex; flex-wrap: wrap; gap: 4px 16px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 6px 0; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; }
.tabs a.aktiv { color: var(--text); border-bottom-color: var(--accent); }

.alert { padding: 8px 12px; border-radius: 6px; border: 1px solid var(--line); }
.alert-info { background: #eef4fa; border-color: #c9dcee; }
.alert-warn { background: #fbf6e4; border-color: #ecdca0; }
.alert-error { background: #fbeaea; border-color: #efc0c0; color: #8e1c1c; }

.form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.form-row label { font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search],
select, textarea { font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); max-width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

body.auth { background: var(--bg-soft); display: flex; justify-content: center; padding: 48px 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 24px; align-self: flex-start; }

@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { padding: 8px 12px; }
  .content { padding: 16px 12px 32px; }
}
@media print {
  .topbar, .skip, .toolbar, .tabs, .btn { display: none !important; }
  body { color: #000; }
  .content { max-width: none; padding: 0; }
  .table-wrap { overflow: visible; }
}

.company-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }
.company-head h1 { margin-bottom: 0; }
.company-head p { margin: 0 0 12px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 24px; max-width: 700px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.narrow-form { max-width: 520px; }
.narrow-form input[type=text], .narrow-form input[type=email], .narrow-form input[type=number], .narrow-form input[type=date],
.narrow-form select, .narrow-form textarea { width: 100%; }
.signature { max-height: 80px; border: 1px solid var(--line); background: #fff; }
.actions form { display: inline; margin-left: 8px; }
.check-list { display: flex; flex-direction: column; gap: 4px; }
.check-list label { font-weight: normal; }

/* Fristen und Ziele */
.table tr.overdue td { background: #fdecea; }
.badge-red, .badge-missed { background: var(--red); border-color: var(--red); color: #fff; }
.badge-at_risk { background: var(--yellow); border-color: var(--yellow); color: #fff; }
.badge-on_track, .badge-achieved { background: var(--green); border-color: var(--green); color: #fff; }
.badge-planned { color: var(--muted); }
.mailbody { overflow-wrap: anywhere; padding: 12px; border: 1px solid var(--line); background: var(--bg-soft); margin-bottom: 16px; }
.pre { white-space: pre-wrap; }
form.inline { display: inline; margin-left: 8px; }
.agenda-item { border-top: 1px solid var(--line); padding: 8px 0 12px; }
.agenda-item textarea.notes { width: 100%; }
.agenda-item details { margin: 6px 0; }
.agenda-item h3, .agenda-item h4 { margin: 8px 0 4px; }
pre.mailbody { white-space: pre-wrap; }

/* Unterzeichnung */
.auth-card.wide { max-width: 960px; }
.pdf-frame { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 6px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; }
.hash { font-family: ui-monospace, Menlo, monospace; font-size: .85rem; word-break: break-all; }

/* Firmenkopf und Startseite */
.company-summary { display: flex; flex-wrap: wrap; gap: 4px 24px; margin: 0 0 12px; font-size: .95rem; }
.company-summary .stale { color: var(--muted); font-style: italic; }
.overdue-text { color: var(--red); }
.kpi-matrix td:first-child { white-space: nowrap; }
