/* ============================================================
   WG Accounts — stylesheet
   ============================================================ */
:root {
  --bg: #0f1420;
  --bg-soft: #151b2b;
  --bg-card: #1a2233;
  --bg-hover: #202a40;
  --border: #2a3550;
  --border-soft: #232d45;
  --text: #e6eaf2;
  --text-dim: #9aa5bd;
  --text-faint: #6b7690;
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --green: #38c98b;
  --green-bg: rgba(56, 201, 139, 0.14);
  --red: #ff6b6b;
  --red-bg: rgba(255, 107, 107, 0.14);
  --amber: #f5b84b;
  --amber-bg: rgba(245, 184, 75, 0.14);
  --purple: #b28cff;
  --purple-bg: rgba(178, 140, 255, 0.14);
  --cyan: #4cd4d4;
  --cyan-bg: rgba(76, 212, 212, 0.14);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

html[data-theme="light"] {
  --bg: #eef1f7;
  --bg-soft: #e4e8f1;
  --bg-card: #ffffff;
  --bg-hover: #f0f3fa;
  --border: #d5dbe8;
  --border-soft: #e3e8f1;
  --text: #1c2333;
  --text-dim: #4a556e;
  --text-faint: #7b86a0;
  --accent: #2f6bff;
  --accent-soft: rgba(47, 107, 255, 0.1);
  --green: #0ea56b;
  --green-bg: rgba(14, 165, 107, 0.12);
  --red: #e04848;
  --red-bg: rgba(224, 72, 72, 0.1);
  --amber: #c98a16;
  --amber-bg: rgba(201, 138, 22, 0.12);
  --purple: #7a46e0;
  --purple-bg: rgba(122, 70, 224, 0.1);
  --cyan: #0e9a9a;
  --cyan-bg: rgba(14, 154, 154, 0.1);
  --shadow: 0 8px 24px rgba(30, 40, 70, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 15px;
  transition: background 0.25s, color 0.25s;
}

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: 264px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 10px 18px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 14px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
}

.brand h1 { font-size: 16px; margin: 0; line-height: 1.2; }
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--text-dim); }

.nav-label {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 12px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  color: var(--text-dim);
  font-weight: 500;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}

.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.nav-item .ico { width: 18px; text-align: center; font-size: 15px; }

.sidebar-foot {
  margin-top: auto;
  padding: 14px 10px 4px;
  font-size: 12px;
  color: var(--text-faint);
  border-top: 1px solid var(--border-soft);
  line-height: 1.5;
}

.main {
  padding: 26px 32px 60px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.topbar h2 { margin: 0; font-size: 22px; }

.topbar-controls { display: flex; align-items: center; gap: 10px; }

.search-wrap { position: relative; }
.search-wrap input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 12px 8px 32px;
  width: 210px;
  font-size: 13.5px;
  outline: none;
  transition: border 0.15s, width 0.2s;
}
.search-wrap input:focus { border-color: var(--accent); width: 250px; }
.search-wrap .mag { position: absolute; left: 10px; top: 8px; opacity: 0.5; font-size: 13px; }

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 9px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.15s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Cards & grids ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 18px; }

.card h3 {
  margin: 0 0 4px;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card h3 .sub { font-size: 12px; color: var(--text-faint); font-weight: 500; }

.card-desc { color: var(--text-dim); font-size: 13px; margin: 0 0 14px; }

.grid-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}

.kpi::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
}
.kpi.green::before { background: var(--green); }
.kpi.red::before { background: var(--red); }
.kpi.amber::before { background: var(--amber); }
.kpi.purple::before { background: var(--purple); }
.kpi.cyan::before { background: var(--cyan); }

.kpi .k-label { font-size: 11.5px; color: var(--text-dim); letter-spacing: 0.04em; text-transform: uppercase; }
.kpi .k-value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .k-value small { font-size: 14px; font-weight: 500; color: var(--text-dim); }
.kpi .k-sub { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; }
.grid-2 .card { margin: 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

table.data th, table.data td {
  padding: 7px 9px;
  border-bottom: 1px solid var(--border-soft);
  text-align: right;
  white-space: nowrap;
}

table.data th {
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-soft);
  position: sticky;
  top: 0;
  font-weight: 600;
}

table.data th.left, table.data td.left { text-align: left; }
table.data td.left { white-space: normal; }

table.data tr:hover td { background: var(--bg-hover); }

table.data .num-pos { color: var(--green); }
table.data .num-neg { color: var(--red); }

table.data tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
}

tr.row-total td { font-weight: 700; background: var(--bg-soft); }

/* ---------- Person tables (Mieten / Kaution) ---------- */
.people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 18px;
}

.person-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.person-head {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.person-room {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 8px;
  padding: 3px 9px;
  font-weight: 700;
  font-size: 13px;
}

.person-name { font-weight: 700; font-size: 15px; }

.badge {
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge.pays-early { background: var(--cyan-bg); color: var(--cyan); }
.badge.pays-late { background: var(--amber-bg); color: var(--amber); }
.badge.sublet { background: var(--purple-bg); color: var(--purple); }
.badge.open { background: var(--amber-bg); color: var(--amber); }

.person-body { padding: 6px 0 10px; }

.person-body table.data th, .person-body table.data td { padding: 5px 7px; font-size: 12.5px; }

.person-foot {
  padding: 8px 16px 12px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ---------- Diff colors in person tables ---------- */
td.diff-pos { color: var(--green); }
td.diff-neg { color: var(--red); }
td.diff-zero { color: var(--text-faint); }

/* ---------- Annotations / notes ---------- */
.note-dot {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--amber-bg);
  color: var(--amber);
  font-size: 10px;
  font-weight: 800;
  cursor: help;
  vertical-align: middle;
  margin-left: 4px;
}

.note-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.note-pill {
  background: var(--accent-soft);
  color: var(--text-dim);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 3px 9px;
  font-size: 11.5px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.note-pill .np-dot { color: var(--amber); font-weight: 800; }

.callout {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 12px 15px;
  font-size: 13px;
  color: var(--text-dim);
  margin: 10px 0;
}
.callout.warn { border-left-color: var(--amber); }
.callout.good { border-left-color: var(--green); }

/* ---------- Tooltip ---------- */
.tip-wrap { position: relative; display: inline-flex; }

.tip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #0b0f18;
  color: #eef1f7;
  border: 1px solid #2a3550;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12.5px;
  width: max-content;
  max-width: 320px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  line-height: 1.45;
}
html[data-theme="light"] .tip { background: #1c2333; color: #eef1f7; border-color: #2a3550; }
.tip-wrap:hover .tip { opacity: 1; }
.tip .tip-meta { display: block; margin-top: 4px; font-size: 11px; color: #8f9bb3; }

/* ---------- Legend ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 4px; font-size: 12px; color: var(--text-dim); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* ---------- Charts ---------- */
.chart-box { width: 100%; }
.chart-box svg { width: 100%; height: auto; display: block; }
.chart-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; }

/* ---------- Room overview ---------- */
.room-overview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.room-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.room-tile .rt-room { font-size: 11px; color: var(--text-faint); }
.room-tile .rt-name { font-weight: 700; font-size: 13px; }
.room-tile .rt-meta { font-size: 11.5px; color: var(--text-dim); margin-top: 3px; }

/* ---------- Sonstiges ledger ---------- */
.ledger { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.ledger-month { background: var(--bg-soft); border: 1px solid var(--border-soft); border-radius: 10px; padding: 12px 14px; }
.ledger-month h4 { margin: 0 0 8px; font-size: 13px; display: flex; justify-content: space-between; }
.ledger-month ul { margin: 0; padding: 0; list-style: none; font-size: 12.5px; }
.ledger-month li { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; border-bottom: 1px dashed var(--border-soft); }
.ledger-month li span:first-child { color: var(--text-dim); }
.ledger-month li:last-child { border-bottom: none; }

/* ---------- About / meta ---------- */
.meta-list { display: grid; gap: 6px; font-size: 13.5px; }
.meta-list div { display: flex; gap: 10px; }
.meta-list dt { color: var(--text-faint); width: 180px; flex-shrink: 0; }

.mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- View visibility ---------- */
.view { display: none; }
.view.active { display: block; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    gap: 4px;
  }
  .brand { border-bottom: none; padding: 0 10px 0 4px; margin: 0; }
  .brand p { display: none; }
  .nav-label { display: none; }
  .nav-item { padding: 7px 9px; font-size: 13px; }
  .sidebar-foot { display: none; }
  .main { padding: 18px 14px 40px; }
  .search-wrap input { width: 130px; }
  .search-wrap input:focus { width: 170px; }
}

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar-controls, .icon-btn, .search-wrap { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .main { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; color: #000; }
}
