/* ---------- Basis & Farben ---------- */
:root {
  --accent: #334155;
  --accent-soft: #e2e8f0;
  --bg: #eef1f6;
  --surface: #fff;
  --line: #e6e9ef;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 16px rgba(16,24,40,.06);
  --text: #1f2933;
  --muted: #6b7280;
  --ok: #15803d;
  --warn: #b45309;
  --err: #b91c1c;
  --info: #1d4ed8;
  --radius: 14px;
  --sidebar: 230px;
  --topbar: 60px;
}
body[data-area="verwaltung"]  { --accent: #1d4ed8; --accent-soft: #dbe4ff; }
body[data-area="eigentuemer"] { --accent: #15803d; --accent-soft: #dcf2e3; }
body[data-area="mieter"]      { --accent: #c2410c; --accent-soft: #fde4d6; }
body[data-area="hausmeister"] { --accent: #0f766e; --accent-soft: #d3eeeb; }
body[data-area="admin"]       { --accent: #6d28d9; --accent-soft: #e9ddff; }

* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); line-height: 1.45;
       background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 8%, var(--bg)), var(--bg) 320px) fixed; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.5rem; margin: 0; font-weight: 600; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; font-weight: 600; }
h3 { font-size: .95rem; margin: 0 0 .5rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--ok); }
.neg { color: var(--err); }
.mt { margin-top: 1rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* ---------- Rahmen: Topbar, Sidebar, Inhalt ---------- */
.topbar { position: sticky; top: 0; z-index: 10; height: var(--topbar); display: flex; align-items: center; gap: 1rem; padding: 0 1rem; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #000)); color: #fff; }
.topbar .brand { color: #fff; font-weight: 600; font-size: 1.05rem; white-space: nowrap; }
.topbar .brand span { font-weight: 400; opacity: .85; }
.topbar .brand .app { font-weight: 600; opacity: 1; margin-right: .5rem; }
.topbar .user { margin-left: auto; display: flex; gap: 1rem; align-items: center; font-size: .9rem; }
.topbar .user a { color: #fff; background: rgba(255,255,255,.14); border-radius: 999px; padding: .25rem .75rem; white-space: nowrap; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 1.4rem; padding: 0 .25rem; cursor: pointer; }

.shell { display: flex; min-height: calc(100vh - var(--topbar)); }
.sidebar { width: var(--sidebar); flex: 0 0 var(--sidebar); padding: 1rem .75rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar a { display: block; padding: .6rem 1rem; border-radius: 999px; color: var(--text); }
.sidebar a.active { background: var(--accent); color: #fff; font-weight: 600; }
.sidebar .group { margin: 1rem .75rem .35rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.content { flex: 1; min-width: 0; padding: 1.5rem; max-width: 1280px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.plain { max-width: 1000px; margin: 0 auto; padding: 3rem 1.5rem; }

/* ---------- Karten, KPI, Grid ---------- */
.card { background: var(--surface); box-shadow: var(--shadow); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.kpi { background: var(--surface); box-shadow: var(--shadow); border-radius: var(--radius); padding: .9rem 1rem; }
.kpi .label { font-size: .8rem; color: var(--muted); }
.kpi .value { font-size: 1.7rem; font-weight: 600; margin: .15rem 0; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .8rem; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.kpis > *, .grid-2 > *, .grid-3 > * { min-width: 0; }

/* ---------- Tabellen & Listen ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .55rem .6rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: .82rem; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 600; border-top: 2px solid var(--line); }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.25rem; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.list { display: flex; flex-direction: column; gap: .5rem; }
.list a.item, .list .item { display: block; background: var(--surface); box-shadow: var(--shadow); border-radius: var(--radius); padding: .8rem 1rem; color: var(--text); }
.item .title { font-weight: 600; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--accent-soft); }
.timeline li { position: relative; padding: 0 0 .9rem .75rem; }
.timeline li::before { content: ""; position: absolute; left: -1.4rem; top: .4rem; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.timeline .meta { font-size: .8rem; color: var(--muted); }
.empty { color: var(--muted); padding: 1rem; text-align: center; }

/* ---------- Badges, Buttons, Formulare ---------- */
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 6px; font-size: .78rem; font-weight: 600; white-space: nowrap; background: var(--accent-soft); color: var(--text); }
.b-ok { background: #dcf2e3; color: var(--ok); }
.b-warn { background: #fdebd0; color: var(--warn); }
.b-err { background: #fde2e2; color: var(--err); }
.b-info { background: #dbe4ff; color: var(--info); }
.b-muted { background: #e9ebef; color: var(--muted); }

.btn { display: inline-block; padding: .55rem 1.1rem; border-radius: 999px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font: inherit; font-size: .9rem; cursor: pointer; }
.btn-ghost { background: var(--surface); color: var(--accent); }
.btn-sm { padding: .3rem .6rem; font-size: .82rem; }
.btn-block { display: block; width: 100%; text-align: center; }

.form { display: grid; gap: .9rem; max-width: 640px; }
.form.two { grid-template-columns: 1fr 1fr; }
.form .full { grid-column: 1 / -1; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }
input, select, textarea { width: 100%; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #f8fafc; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
textarea { min-height: 110px; resize: vertical; }
.check { display: flex; align-items: center; gap: .5rem; }
.check input { width: auto; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: .6rem .9rem; font: inherit; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- Startseite / Rollenauswahl ---------- */
.roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.role { display: block; padding: 1.25rem; border-radius: var(--radius); color: #fff; }
.role strong { display: block; font-size: 1.1rem; margin-bottom: .25rem; }
.role span { font-size: .85rem; opacity: .9; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .nav-toggle { display: inline-block; }
  .topbar .user span, .topbar .brand .app { display: none; }
  .shell { display: block; }
  .sidebar { display: none; position: fixed; top: var(--topbar); left: 0; bottom: 0; z-index: 9; overflow-y: auto; background: var(--bg); box-shadow: var(--shadow); }
  .sidebar.open { display: block; }
  .content { padding: 1rem; }
  .kpis, .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-2, .form.two { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; gap: .15rem; }
  .dl dt { margin-top: .5rem; }
}
@media (max-width: 540px) {
  .kpis, .grid-3 { grid-template-columns: 1fr; }
  h1 { font-size: 1.25rem; }
}
