/* Skandinavisch-ruhiges Design — viel Whitespace, dünne Linien, neutrale Palette */

@import url('https://fonts.googleapis.com/css2?family=Inter+Tight:wght@300;400;500;600;700&family=Newsreader:ital,wght@0,400;0,500;1,400&display=swap');

:root {
  /* Light theme — paper-warm neutrals */
  --bg: #fafaf7;
  --bg-elev: #ffffff;
  --bg-sunken: #f4f3ee;
  --bg-hover: #f0efe9;

  --ink: #1a1a17;
  --ink-2: #3a3a36;
  --ink-3: #6b6a64;
  --ink-4: #9a9890;
  --ink-5: #c8c5bc;

  --line: #e6e3da;
  --line-2: #efede5;
  --line-strong: #d9d6cb;

  --accent: #2d4a3e;        /* deep moss green — Scandinavian forest */
  --accent-soft: #e9efe9;
  --accent-ink: #ffffff;

  --pos: #2d6a4f;
  --neg: #8b3a2f;
  --warn: #a87930;

  --radius: 4px;
  --radius-lg: 8px;

  --font-sans: 'Inter Tight', system-ui, -apple-system, sans-serif;
  --font-serif: 'Newsreader', Georgia, serif;

  --shadow-sm: 0 1px 0 rgba(0, 0, 0, 0.02);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.04);

  --sidebar-w: 232px;
}

[data-theme="dark"] {
  --bg: #15161a;
  --bg-elev: #1c1d22;
  --bg-sunken: #101115;
  --bg-hover: #24262b;

  --ink: #ecebe6;
  --ink-2: #c9c8c2;
  --ink-3: #8a8983;
  --ink-4: #5e5d58;
  --ink-5: #3e3d39;

  --line: #2a2b31;
  --line-2: #232429;
  --line-strong: #36373d;

  --accent: #b8d4c2;
  --accent-soft: #232a26;
  --accent-ink: #15161a;

  --pos: #74b896;
  --neg: #d68876;
  --warn: #d9b073;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ───── App shell ───── */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ───── Sidebar ───── */

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--bg);
  padding: 28px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
}
.brand-mark {
  width: 22px;
  height: 22px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  position: relative;
  flex-shrink: 0;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 4px 4px auto 4px;
  height: 1px;
  background: var(--ink);
}
.brand-mark::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 4px;
  bottom: 4px;
  width: 1px;
  background: var(--ink);
}
.brand-name {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.nav-section { display: flex; flex-direction: column; gap: 1px; }
.nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-4);
  padding: 0 8px;
  margin-bottom: 8px;
  font-weight: 500;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius);
  color: var(--ink-2);
  font-size: 13.5px;
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  transition: background 120ms;
}
.nav-item:hover { background: var(--bg-hover); color: var(--ink); }
.nav-item.active {
  background: var(--bg-hover);
  color: var(--ink);
  font-weight: 500;
}
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active svg { opacity: 1; }
.nav-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}

.sidebar-footer { margin-top: auto; padding: 0 8px; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
}
.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
}
.user-name { font-size: 13px; color: var(--ink-2); }

/* ───── Main pane ───── */

.main {
  min-width: 0;
  padding: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 40px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(12px);
}
.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-3);
  flex: 1;
  min-width: 0;
}
.crumbs button {
  background: none;
  border: none;
  color: var(--ink-3);
  padding: 4px 0;
  font-size: 13px;
  cursor: pointer;
}
.crumbs button:hover { color: var(--ink); }
.crumbs .current { color: var(--ink); font-weight: 500; }
.crumbs-sep { color: var(--ink-5); }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  width: 280px;
  color: var(--ink-3);
}
.search input {
  border: none;
  background: none;
  outline: none;
  width: 100%;
  color: var(--ink);
}
.search svg { width: 13px; height: 13px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--bg-elev);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  transition: background 120ms, border 120ms;
  font-weight: 500;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ink-2);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--ink); }
.btn-sm { padding: 4px 8px; font-size: 12px; }
.btn svg { width: 13px; height: 13px; }

/* ───── Page content ───── */

.page {
  padding: 48px 40px 80px;
  max-width: 1280px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 40px;
}
.page-title {
  font-family: var(--font-serif);
  font-size: 38px;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0;
}
.page-subtitle {
  color: var(--ink-3);
  font-size: 14px;
  margin-top: 6px;
}
.page-actions { display: flex; gap: 8px; align-items: center; }

/* ───── KPI cards ───── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 48px;
}
.kpi {
  padding: 24px 24px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kpi:last-child { border-right: none; }
.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  font-weight: 500;
}
.kpi-value {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 400;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.kpi-meta {
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.kpi-meta.pos { color: var(--pos); }
.kpi-meta.neg { color: var(--neg); }

/* ───── Section ───── */

.section { margin-bottom: 56px; }
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
.section-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin: 0;
}
.section-link {
  font-size: 12px;
  color: var(--ink-3);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.section-link:hover { color: var(--ink); }

/* ───── Property grid ───── */

.prop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
}
.prop-card {
  padding: 24px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 120ms;
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
  background: transparent;
  font-family: inherit;
  color: inherit;
}
.prop-card:hover { background: var(--bg-hover); }
.prop-card-header { display: flex; flex-direction: column; gap: 4px; }
.prop-card-name {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.prop-card-addr { font-size: 12.5px; color: var(--ink-3); }
.prop-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}
.prop-card-stat .v { font-size: 16px; color: var(--ink); }
.prop-card-stat .l { font-size: 10.5px; color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }

/* Occupancy bar */
.occ-bar {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  display: flex;
  margin-top: 4px;
}
.occ-bar-fill { background: var(--accent); height: 100%; }
.occ-bar-vacant { background: var(--ink-5); height: 100%; }

/* ───── Tables ───── */

.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-elev);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-sunken);
}
.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr { cursor: pointer; transition: background 120ms; }
.table tbody tr:hover { background: var(--bg-hover); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .strong { color: var(--ink); font-weight: 500; }
.table .muted { color: var(--ink-3); }

/* ───── Pills ───── */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--line-strong);
  color: var(--ink-2);
  background: var(--bg-elev);
}
.pill-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-3); }
.pill.pos { color: var(--pos); border-color: color-mix(in oklab, var(--pos) 25%, var(--line)); }
.pill.pos .pill-dot { background: var(--pos); }
.pill.neg { color: var(--neg); border-color: color-mix(in oklab, var(--neg) 25%, var(--line)); }
.pill.neg .pill-dot { background: var(--neg); }
.pill.warn { color: var(--warn); border-color: color-mix(in oklab, var(--warn) 25%, var(--line)); }
.pill.warn .pill-dot { background: var(--warn); }

/* ───── Tabs ───── */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 32px;
}
.tab {
  padding: 12px 18px;
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  margin-bottom: -1px;
  color: var(--ink-3);
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  transition: color 120ms, border-color 120ms;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }
.tab-count {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}

/* ───── Property detail header ───── */

.detail-hero {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 48px;
  margin-bottom: 48px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--line);
}
.detail-hero h1 {
  font-family: var(--font-serif);
  font-size: 42px;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  line-height: 1.05;
}
.detail-hero .addr { color: var(--ink-3); font-size: 14px; margin-bottom: 24px; }
.detail-hero-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 32px;
  margin-top: 24px;
}
.detail-meta-item .l {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-4);
  margin-bottom: 4px;
}
.detail-meta-item .v {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.detail-hero-side {
  background: var(--bg-sunken);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.mini-stat .l {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  margin-bottom: 4px;
}
.mini-stat .v {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

/* ───── Unit list ───── */

.units-list {
  display: flex;
  flex-direction: column;
}
.unit-row {
  display: grid;
  grid-template-columns: 32px 1.5fr 1fr 0.8fr 0.8fr 1fr 24px;
  align-items: center;
  gap: 16px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 120ms;
  background: transparent;
  border-top: none;
  border-left: none;
  border-right: none;
  text-align: left;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  width: 100%;
}
.unit-row:first-child { border-top: 1px solid var(--line); }
.unit-row:hover { background: var(--bg-hover); }
.unit-num {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.unit-label { font-weight: 500; color: var(--ink); }
.unit-floor { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.unit-num-val { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.unit-num-label { font-size: 10.5px; color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }
.unit-chevron { color: var(--ink-4); }

/* ───── Document list ───── */

.doc-row {
  display: grid;
  grid-template-columns: 32px 1fr 140px 100px 100px 32px;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.doc-row:first-child { border-top: 1px solid var(--line); }
.doc-row:hover { background: var(--bg-hover); }
.doc-icon {
  width: 28px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  position: relative;
  background: var(--bg-elev);
}
.doc-icon::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
}

/* ───── Cashflow chart ───── */

.chart-frame {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px 28px 20px;
  background: var(--bg-elev);
}
.chart-grid line { stroke: var(--line); stroke-width: 1; }
.chart-axis text { fill: var(--ink-4); font-size: 10px; font-family: var(--font-sans); }
.chart-bar.income { fill: var(--accent); }
.chart-bar.expense { fill: var(--ink-5); }
[data-theme="dark"] .chart-bar.income { fill: var(--accent); }
[data-theme="dark"] .chart-bar.expense { fill: var(--ink-4); }
.chart-line { stroke: var(--ink); stroke-width: 1.5; fill: none; }
.chart-legend { display: flex; gap: 20px; font-size: 11.5px; color: var(--ink-3); margin-top: 16px; }
.chart-legend-item { display: flex; align-items: center; gap: 6px; }
.chart-legend-swatch { width: 10px; height: 10px; border-radius: 2px; }

/* ───── Calendar ───── */

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-elev);
}
.cal-head {
  padding: 10px 12px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  font-weight: 500;
}
.cal-head:last-child { border-right: none; }
.cal-cell {
  min-height: 96px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.muted { color: var(--ink-4); background: var(--bg-sunken); }
.cal-cell.today .cal-num {
  background: var(--ink);
  color: var(--bg);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
}
.cal-num { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.cal-event {
  font-size: 10.5px;
  padding: 2px 6px;
  border-left: 2px solid var(--accent);
  color: var(--ink-2);
  background: var(--accent-soft);
  border-radius: 2px;
  line-height: 1.3;
  cursor: pointer;
}
.cal-event.warn { border-left-color: var(--warn); background: color-mix(in oklab, var(--warn) 12%, var(--bg-elev)); }
.cal-event.neg { border-left-color: var(--neg); background: color-mix(in oklab, var(--neg) 12%, var(--bg-elev)); }

/* ───── Empty state ───── */

.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--ink-3);
}
.empty-title {
  font-family: var(--font-serif);
  font-size: 20px;
  color: var(--ink-2);
  margin: 0 0 6px;
}

/* ───── Two-col layouts ───── */

.two-col {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 48px;
  align-items: start;
}

/* ───── Side panel (tenant card etc) ───── */
.side-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.side-card h3 {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  margin: 0;
}
.kv-list { display: flex; flex-direction: column; gap: 10px; }
.kv {
  display: grid;
  grid-template-columns: 100px 1fr;
  font-size: 13px;
  align-items: baseline;
}
.kv .k { color: var(--ink-3); font-size: 12px; }
.kv .v { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ───── Reports / progress bars ───── */

.bar-row {
  display: grid;
  grid-template-columns: 180px 1fr 80px;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.bar-row:last-child { border-bottom: none; }
.bar-track { height: 6px; background: var(--bg-sunken); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.bar-row .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ───── Contacts ───── */

.contacts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.contact-card {
  padding: 24px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 120ms;
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
  background: transparent;
  font-family: inherit;
  color: inherit;
  position: relative;
}
.contact-card:hover { background: var(--bg-hover); }
.contact-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 15px;
  color: var(--ink);
  font-weight: 500;
}
.fav-star {
  font-size: 14px;
  color: var(--warn);
}
.contact-card-body { display: flex; flex-direction: column; gap: 2px; }
.contact-trade {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-4);
  margin-bottom: 2px;
}
.contact-company {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.2;
}
.contact-person {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 2px;
}
.contact-card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.contact-stat-l {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-4);
  margin-bottom: 2px;
}
.contact-stat-v {
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: var(--ink);
}
.contact-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.contact-action {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  text-decoration: none;
  transition: background 120ms, border 120ms, color 120ms;
}
.contact-action:hover {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  text-align: left;
  transition: background 120ms;
}
.link-row:hover { background: var(--bg-hover); }
.link-row svg { color: var(--ink-4); }

/* ───── AI Assistant ───── */

.insight-card {
  display: flex;
  gap: 20px;
  padding: 24px;
  border: 1px solid var(--line);
  border-bottom: none;
  background: var(--bg-elev);
  align-items: flex-start;
}
.insight-card:first-child { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.insight-card:last-child { border-bottom: 1px solid var(--line); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.insight-card:only-child { border-radius: var(--radius-lg); }
.insight-rail {
  width: 3px;
  align-self: stretch;
  background: var(--ink-5);
  border-radius: 2px;
  flex-shrink: 0;
}
.insight-rail[data-cat="Sparpotenzial"] { background: var(--pos); }
.insight-rail[data-cat="Steuer"] { background: var(--accent); }
.insight-rail[data-cat="Recht"] { background: var(--ink); }
.insight-rail[data-cat="Beleg"] { background: var(--neg); }
.insight-rail[data-cat="Frist"] { background: var(--warn); }
.insight-rail[data-cat="Anomalie"] { background: var(--warn); }

.insight-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  color: var(--ink-3);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}
.insight-cat { color: var(--ink-2); }
.insight-dot { color: var(--ink-5); }
.insight-conf { color: var(--ink-4); font-variant-numeric: tabular-nums; }
.insight-title {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
  line-height: 1.3;
}
.insight-summary {
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.6;
  margin-bottom: 14px;
  max-width: 720px;
}
.insight-refs { display: flex; gap: 6px; flex-wrap: wrap; }
.ref-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  font-size: 11.5px;
  color: var(--ink-2);
  cursor: pointer;
  font-family: inherit;
}
.ref-chip:hover { background: var(--bg-hover); color: var(--ink); }
.ref-chip svg { width: 11px; height: 11px; opacity: 0.6; }

.insight-aside {
  width: 200px;
  flex-shrink: 0;
  text-align: right;
  display: flex;
  flex-direction: column;
}
.insight-saving { display: flex; flex-direction: column; align-items: flex-end; }
.insight-saving .l {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-4);
}
.insight-saving .v {
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--pos);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

/* Chat */
.chat-shell {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  height: calc(100vh - 280px);
  min-height: 480px;
}
.chat-stream {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.chat-msg { display: flex; gap: 12px; align-items: flex-start; }
.chat-msg.user { justify-content: flex-end; }
.chat-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
  flex-shrink: 0;
}
.chat-bubble {
  max-width: 720px;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg-sunken);
  color: var(--ink);
}
.chat-bubble p { margin: 0 0 8px; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble strong { font-weight: 600; }
.chat-msg.user .chat-bubble {
  background: var(--ink);
  color: var(--bg);
}
.suggestions {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 0 32px 16px;
}
.suggestion {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  font-family: inherit;
}
.suggestion:hover { background: var(--bg-hover); border-color: var(--line-strong); }

.chat-input-wrap { border-top: 1px solid var(--line); padding: 16px 24px; }
.chat-input {
  display: flex; gap: 8px; align-items: center;
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
}
.chat-input input {
  flex: 1; border: none; background: none; outline: none;
  font-size: 14px; color: var(--ink);
}
.chat-foot { margin-top: 8px; text-align: center; }

.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-4);
  animation: typing 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* Audit */
.audit-row {
  display: flex; gap: 16px; align-items: flex-start;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}
.audit-row:last-child { border-bottom: none; }
.audit-status {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px;
  flex-shrink: 0;
}
.audit-status.ok { background: color-mix(in oklab, var(--pos) 15%, var(--bg-elev)); color: var(--pos); }
.audit-status.warn { background: color-mix(in oklab, var(--warn) 15%, var(--bg-elev)); color: var(--warn); }
.audit-status.missing { background: color-mix(in oklab, var(--neg) 15%, var(--bg-elev)); color: var(--neg); }
.audit-findings {
  margin: 8px 0 0; padding-left: 18px;
  font-size: 12.5px; color: var(--ink-2);
}
.audit-findings li { margin-bottom: 2px; }

/* Provider grid */
.provider-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.provider-card {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 18px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: inherit;
  position: relative;
  transition: background 120ms;
}
.provider-card:hover { background: var(--bg-hover); }
.provider-card.selected { background: var(--bg-sunken); }
.provider-card.selected::after {
  content: ""; position: absolute; inset: 0;
  border: 2px solid var(--ink); border-radius: 0;
  pointer-events: none;
}
.provider-mark {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white;
  flex-shrink: 0;
}
.provider-check {
  position: absolute; top: 12px; right: 12px;
  width: 20px; height: 20px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

.settings-form { display: flex; flex-direction: column; gap: 20px; max-width: 540px; }
.settings-label {
  display: block; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--ink-3); margin-bottom: 6px; font-weight: 500;
}
.settings-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--ink);
  outline: none;
  font-size: 13px;
}
.settings-input:focus { border-color: var(--ink); }
.settings-hint { font-size: 11.5px; color: var(--ink-3); margin-top: 6px; line-height: 1.5; }

.toggle {
  width: 32px; height: 18px;
  border-radius: 999px;
  background: var(--ink-5);
  border: none;
  position: relative;
  cursor: pointer;
  transition: background 150ms;
}
.toggle.on { background: var(--ink); }
.toggle-knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: white;
  transition: transform 150ms;
}
.toggle.on .toggle-knob { transform: translateX(14px); }

/* utility */
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-muted { color: var(--ink-3); }
.text-mono { font-variant-numeric: tabular-nums; }
.serif { font-family: var(--font-serif); }

/* ───── Analytics ───── */

.kpi-big-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  margin-bottom: 36px;
}
.kpi-big {
  padding: 20px 22px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 110px;
}
.kpi-big .kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}
.kpi-big .kpi-value {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 400;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  margin-top: auto;
}
.kpi-big .kpi-meta {
  font-size: 11.5px;
  color: var(--ink-4);
}

.proj-bar-wrap { margin-top: 8px; }
.proj-bar-track {
  height: 6px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.proj-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}
.proj-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  margin-top: 8px;
}

.prediction-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.prediction-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.prediction-impact {
  font-family: var(--font-serif);
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.prediction-impact.pos { color: var(--pos); }
.prediction-impact.neg { color: var(--neg); }
.prediction-impact.warn { color: var(--warn); }
.prediction-prob {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.prediction-prob .l {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-4);
}
.prediction-prob .v {
  font-family: var(--font-serif);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
.prediction-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.35;
}
.prediction-body {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.5;
}
.prediction-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* ───── Audit / Belegprüfung ───── */

.audit-subnav {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.audit-subnav-btn {
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-3);
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.audit-subnav-btn:hover { color: var(--ink); }
.audit-subnav-btn.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 500;
}

.audit-stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr) 1.4fr;
  gap: 12px;
  margin-bottom: 24px;
}
.audit-stat-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  background: var(--bg-elev);
}
.audit-stat-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}
.audit-stat-value {
  font-family: var(--font-serif);
  font-size: 28px;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
  color: var(--ink);
}
.audit-stat-value.warn { color: var(--warn); }
.audit-stat-value.neg { color: var(--neg); }
.audit-stat-sub {
  font-size: 11px;
  color: var(--ink-4);
  margin-top: 4px;
}
.audit-stat-sub.pos { color: var(--pos); }

.audit-upload-btn {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  background: var(--bg-sunken);
  color: var(--ink-2);
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  transition: all 120ms;
}
.audit-upload-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.audit-filter-bar {
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 0 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0;
}
.audit-filter-group { display: flex; align-items: center; gap: 10px; }
.audit-filter-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}
.audit-filter-pills { display: flex; gap: 4px; }
.audit-filter-pill {
  background: transparent;
  border: 1px solid var(--line);
  padding: 4px 10px;
  font-size: 11.5px;
  color: var(--ink-2);
  font-family: inherit;
  cursor: pointer;
  border-radius: 999px;
}
.audit-filter-pill:hover { border-color: var(--ink-3); }
.audit-filter-pill.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.audit-table-frame {
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  overflow: hidden;
}
.audit-row-title { font-weight: 500; font-size: 14px; }
.audit-row-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 4px;
}
.audit-cat-chip {
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 10.5px;
}
.audit-scope-chip {
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 10.5px;
  font-weight: 500;
}
.audit-scope-chip.allgemein {
  background: color-mix(in oklab, var(--accent) 12%, var(--bg-elev));
  color: var(--accent);
}
.audit-scope-chip.einheit {
  background: color-mix(in oklab, var(--warn) 12%, var(--bg-elev));
  color: var(--warn);
}
.audit-prop-ref { color: var(--ink-4); font-size: 11.5px; }

.audit-tip-block {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--accent-soft);
  border-radius: 4px;
  border-left: 2px solid var(--accent);
}
.audit-tip-icon { font-size: 14px; flex-shrink: 0; line-height: 1.4; }
.audit-tip-line {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.5;
  margin-bottom: 2px;
}
.audit-tip-line:last-child { margin-bottom: 0; }

/* Workbook view */
.workbook-intro {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  gap: 24px;
  flex-wrap: wrap;
}
.month-picker {
  display: flex;
  gap: 4px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.month-pill {
  background: transparent;
  border: none;
  padding: 6px 14px;
  font-size: 12px;
  font-family: inherit;
  color: var(--ink-3);
  cursor: pointer;
  border-radius: 999px;
}
.month-pill.active {
  background: var(--bg-elev);
  color: var(--ink);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.workbook-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
.workbook-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.workbook-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.workbook-card-month {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}
.workbook-card-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 400;
  margin-top: 4px;
  color: var(--ink);
}
.workbook-card-addr {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
}
.workbook-card-status {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 3px;
  white-space: nowrap;
}
.workbook-card-status.ready {
  color: var(--pos);
  background: color-mix(in oklab, var(--pos) 12%, var(--bg-elev));
}
.workbook-card-status.pending {
  color: var(--warn);
  background: color-mix(in oklab, var(--warn) 12%, var(--bg-elev));
}

.workbook-content-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.workbook-content-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.workbook-split-bar {
  height: 4px;
  background: color-mix(in oklab, var(--warn) 30%, var(--bg-sunken));
  border-radius: 2px;
  overflow: hidden;
}
.workbook-split-allg {
  height: 100%;
  background: var(--accent);
}
.workbook-split-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--ink-3);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}
.workbook-split-labels .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
}
.workbook-split-labels .dot.allg { background: var(--accent); }
.workbook-split-labels .dot.einh { background: var(--warn); }

.workbook-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.workbook-yearly {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 20px 24px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
}

/* Tips view */
.tips-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}
.tips-card {
  display: flex;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
}
.tips-card.pos { border-left: 3px solid var(--pos); }
.tips-card.warn { border-left: 3px solid var(--warn); }
.tips-card.info { border-left: 3px solid var(--accent); }
.tips-card.neg { border-left: 3px solid var(--neg); }
.tips-card-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 600;
  font-size: 13px;
}
.tips-card.pos .tips-card-icon { background: color-mix(in oklab, var(--pos) 15%, var(--bg-elev)); color: var(--pos); }
.tips-card.warn .tips-card-icon { background: color-mix(in oklab, var(--warn) 15%, var(--bg-elev)); color: var(--warn); }
.tips-card.info .tips-card-icon { background: var(--accent-soft); color: var(--accent); }
.tips-card.neg .tips-card-icon { background: color-mix(in oklab, var(--neg) 15%, var(--bg-elev)); color: var(--neg); }
.tips-card-title { font-weight: 500; font-size: 14px; margin-bottom: 4px; }
.tips-card-body { font-size: 12.5px; color: var(--ink-2); line-height: 1.5; }

.cheatsheet-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.cheat-card {
  padding: 18px 20px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.cheat-card-title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--ink);
}
.cheat-card-body {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.55;
}


/* ───── Notification bell ───── */
.bell-wrap { position: relative; }
.bell-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--ink-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background 120ms;
}
.bell-btn:hover { background: var(--bg-hover); }
.bell-dot {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  background: var(--neg);
  color: white;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  font-variant-numeric: tabular-nums;
  border: 2px solid var(--bg);
  box-sizing: content-box;
}
.bell-pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 380px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(0,0,0,0.08);
  z-index: 100;
  overflow: hidden;
}
.bell-pop-head {
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.bell-pop-title { font-family: var(--font-serif); font-size: 16px; color: var(--ink); }
.bell-pop-sub { font-size: 11.5px; color: var(--ink-4); margin-top: 2px; }
.bell-pop-list { max-height: 360px; overflow: auto; }
.bell-pop-item {
  display: flex; gap: 12px;
  width: 100%;
  padding: 12px 18px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line-2);
  text-align: left;
  cursor: pointer;
  align-items: flex-start;
  font-family: inherit;
  color: inherit;
  transition: background 120ms;
}
.bell-pop-item:hover { background: var(--bg-hover); }
.bell-pop-item:last-child { border-bottom: none; }
.bell-pop-icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  margin-top: 1px;
}
.bell-pop-item-title { font-size: 13px; color: var(--ink-2); line-height: 1.35; }
.bell-pop-item-title.urgent { color: var(--ink); font-weight: 500; }
.bell-pop-item-meta { font-size: 11px; color: var(--ink-4); margin-top: 3px; }
.bell-pop-foot {
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  background: var(--bg-sunken);
}
.btn-link {
  background: none; border: none;
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  padding: 0;
}
[data-theme="dark"] .btn-link { color: var(--accent); }
.btn-link.muted { color: var(--ink-4); }
.btn-link:hover { text-decoration: underline; }

/* ───── Messages layout ───── */
.msg-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: calc(100vh - 180px);
  min-height: 600px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-elev);
}

.msg-list-pane {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-height: 0;
}
.msg-filter {
  display: flex;
  gap: 4px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}
.msg-filter-btn {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  font-family: inherit;
  font-size: 11.5px;
  color: var(--ink-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.msg-filter-btn.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.msg-filter-count {
  font-size: 10px;
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
}
.msg-list-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.msg-list-item {
  display: flex;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line-2);
  border-left: 3px solid transparent;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  align-items: flex-start;
  transition: background 120ms;
}
.msg-list-item:hover { background: var(--bg-hover); }
.msg-list-item.active {
  background: var(--bg-elev);
  border-left-color: var(--accent);
}
.msg-list-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px;
  font-weight: 500;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}
.msg-list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.msg-list-name { font-size: 13.5px; color: var(--ink); font-weight: 500; }
.msg-list-when {
  font-size: 11px;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.msg-list-meta {
  font-size: 11px;
  color: var(--ink-4);
  display: flex;
  align-items: center;
  gap: 5px;
}
.msg-channel-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.msg-channel-dot.email { background: var(--accent); }
.msg-channel-dot.chat { background: #b88a3a; }
.msg-unread-pill {
  background: var(--neg);
  color: white;
  font-size: 10px;
  font-weight: 600;
  border-radius: 999px;
  padding: 1px 6px;
  font-variant-numeric: tabular-nums;
}
.msg-list-preview {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 4px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}

/* Thread pane */
.msg-thread-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.msg-thread-head {
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elev);
}
.msg-thread-title { font-family: var(--font-serif); font-size: 18px; color: var(--ink); }
.msg-thread-sub { font-size: 11.5px; color: var(--ink-4); margin-top: 3px; }

.msg-thread-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg-sunken);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.msg-bubble-row {
  display: flex;
}
.msg-bubble-row.tenant { justify-content: flex-start; }
.msg-bubble-row.owner { justify-content: flex-end; }
.msg-bubble {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
}
.msg-bubble.tenant {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--ink);
  border-top-left-radius: 4px;
}
.msg-bubble.owner {
  background: var(--accent);
  color: var(--accent-ink);
  border-top-right-radius: 4px;
}
.msg-bubble-body { white-space: pre-wrap; }
.msg-bubble-att {
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  background: rgba(0,0,0,0.06);
}
.msg-bubble.owner .msg-bubble-att { background: rgba(255,255,255,0.18); }
.msg-bubble-time {
  font-size: 10.5px;
  margin-top: 6px;
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
}

.msg-composer {
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
  padding: 14px 18px 16px;
}
.msg-composer-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.msg-tmpl-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-size: 11.5px;
  color: var(--ink-3);
  cursor: pointer;
  font-family: inherit;
}
.msg-tmpl-btn:hover { background: var(--bg-hover); }
.msg-composer-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  background: var(--bg);
  color: var(--ink);
  resize: vertical;
  min-height: 70px;
  outline: none;
  box-sizing: border-box;
}
.msg-composer-input:focus { border-color: var(--accent); }
.msg-composer-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  gap: 8px;
}
.btn.btn-sm { padding: 5px 10px; font-size: 11.5px; }


/* ───── Modal ───── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 20, 18, 0.45);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  max-height: 80vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.18);
}
.modal-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px;
}
.modal-title { font-family: var(--font-serif); font-size: 18px; color: var(--ink); }
.modal-sub { font-size: 12px; color: var(--ink-4); margin-top: 4px; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 24px; color: var(--ink-3); line-height: 1;
  padding: 0; width: 28px; height: 28px;
}
.modal-close:hover { color: var(--ink); }

/* Template list */
.tmpl-list { overflow-y: auto; padding: 8px 0; }
.tmpl-cat { padding: 4px 0; }
.tmpl-cat-label {
  padding: 8px 24px 4px;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-4);
}
.tmpl-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 10px 24px;
  background: transparent; border: none;
  text-align: left; cursor: pointer; font-family: inherit;
  color: var(--ink); font-size: 13.5px;
  transition: background 120ms;
}
.tmpl-row:hover { background: var(--bg-hover); }
.tmpl-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
}
.tmpl-name { flex: 1; }
.tmpl-arrow { color: var(--ink-4); font-size: 14px; }

/* Template field editor */
.tmpl-fields {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.tmpl-fields-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
  font-size: 12.5px;
}
.tmpl-fields-icon {
  width: 22px; height: 22px;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
}
.tmpl-fields-name { font-weight: 500; color: var(--ink); }
.tmpl-fields-sub { color: var(--ink-3); font-size: 11px; margin-left: auto; }
.tmpl-fields-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}
.tmpl-field { display: flex; flex-direction: column; gap: 3px; }
.tmpl-field-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-4);
}
.tmpl-field-input {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 5px 8px;
  font-family: inherit;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  outline: none;
}
.tmpl-field-input:focus { border-color: var(--accent); }

/* Owner avatar */
.owner-av {
  border-radius: 50%;
  color: white;
  display: inline-flex;
  align-items: center; justify-content: center;
  font-weight: 600;
  font-size: 9.5px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.owner-av.none {
  background: var(--bg-sunken);
  color: var(--ink-4);
  border: 1px dashed var(--line-strong);
  font-weight: 400;
}

/* Assign control */
.assign-wrap { position: relative; }
.assign-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  cursor: pointer; font-family: inherit;
  color: var(--ink-2);
}
.assign-btn:hover { background: var(--bg-hover); }
.assign-pop {
  position: absolute;
  top: calc(100% + 6px); right: 0;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0,0,0,0.1);
  z-index: 50;
  width: 220px;
  padding: 6px;
}
.assign-pop-label {
  padding: 8px 10px 4px;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-4);
}
.assign-pop-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent; border: none;
  border-radius: var(--radius);
  text-align: left; cursor: pointer; font-family: inherit;
  color: var(--ink-2);
}
.assign-pop-item:hover { background: var(--bg-hover); }
.assign-pop-item.active { background: var(--accent-soft); }
.assign-pop-divider { height: 1px; background: var(--line); margin: 4px 0; }

/* Scope tabs in header */
.scope-tabs {
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}
.scope-tab {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 12px;
  background: transparent; border: none;
  border-right: 1px solid var(--line);
  font-family: inherit;
  font-size: 12px;
  color: var(--ink-3);
  cursor: pointer;
}
.scope-tab:last-child { border-right: none; }
.scope-tab.active { background: var(--ink); color: var(--bg); }
.scope-tab-c {
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}

/* Read receipts */
.read-receipt {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px;
  opacity: 0.65;
  font-variant-numeric: tabular-nums;
}
.read-receipt.read { opacity: 1; color: #5fb0e0; }
.msg-bubble.owner .read-receipt.read { color: #a0d4f0; }
.read-receipt-label { font-size: 10px; }

.msg-bubble-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-top: 6px;
}
.msg-bubble-time {
  font-size: 10.5px;
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
}
.msg-bubble-sender {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; opacity: 0.7;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
.msg-bubble.tenant .msg-bubble-sender { border-bottom-color: var(--line); }

/* New message dropdown menu */
.new-msg-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 14px 40px rgba(0,0,0,0.18);
  width: 320px;
  z-index: 100;
  padding: 6px;
}
.new-msg-menu-item {
  display: flex; align-items: flex-start; gap: 12px;
  width: 100%;
  background: none;
  border: none;
  padding: 10px 12px;
  text-align: left;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink);
}
.new-msg-menu-item:hover { background: var(--bg-hover); }
.new-msg-menu-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-sunken);
  border-radius: 6px;
}
.new-msg-menu-name { font-size: 13px; font-weight: 500; color: var(--ink); }
.new-msg-menu-sub { font-size: 11.5px; color: var(--ink-4); margin-top: 2px; line-height: 1.4; }

/* Broadcast modal */
.modal-foot {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--line);
}
.bc-select {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  padding: 6px 10px;
  font-family: inherit;
  font-size: 12.5px;
  border-radius: var(--radius);
  outline: none;
}
.bc-recipient-list {
  padding: 12px 22px;
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bc-recipient {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.bc-recipient:hover { background: var(--bg-hover); }
.bc-recipient.selected { background: var(--bg-sunken); border-color: var(--line); }
.bc-recipient input[type="checkbox"] {
  width: 16px; height: 16px;
  flex-shrink: 0;
  accent-color: var(--accent);
}
.bc-recipient-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-sunken);
  color: var(--ink-3);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.bc-recipient-name { font-size: 13px; color: var(--ink); font-weight: 500; }
.bc-recipient-meta { font-size: 11.5px; color: var(--ink-4); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.bc-step3 {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  border-top: 1px solid var(--line);
}
.bc-fields {
  padding: 16px 18px;
  border-right: 1px solid var(--line);
  background: var(--bg-sunken);
}
.bc-summary {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  display: flex; flex-direction: column; gap: 6px;
}
.bc-summary-row {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 11.5px;
  color: var(--ink-4);
}
.bc-summary-row strong { color: var(--ink); font-weight: 600; }
.bc-preview {
  display: flex; flex-direction: column;
  max-height: 460px;
}
.bc-preview-head {
  padding: 10px 18px;
  font-size: 11.5px;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 6px;
}
.bc-preview-body {
  padding: 16px 22px;
  white-space: pre-wrap;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-2);
  overflow-y: auto;
  flex: 1;
}

/* ───── Drop zone + Upload modal ───── */

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 32px 24px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-sunken);
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
  text-align: center;
}
.drop-zone:hover,
.drop-zone.hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.drop-zone.compact {
  padding: 16px 20px;
  flex-direction: row;
  text-align: left;
  gap: 14px;
}
.drop-zone-icon {
  font-size: 22px;
  color: var(--accent);
  line-height: 1;
}
.drop-zone.compact .drop-zone-icon {
  font-size: 18px;
}
.drop-zone-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.drop-zone-sub {
  font-size: 11.5px;
  color: var(--ink-3);
}
.drop-zone.compact .drop-zone-sub {
  margin-top: 2px;
}

.upload-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 18, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  backdrop-filter: blur(4px);
}
.upload-modal {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.upload-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line-2);
}
.upload-modal-head h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  color: var(--ink);
}
.upload-modal-close {
  background: none;
  border: 0;
  color: var(--ink-3);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: var(--radius);
}
.upload-modal-close:hover {
  background: var(--bg-hover);
  color: var(--ink);
}
.upload-modal-files {
  padding: 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
  border-bottom: 1px solid var(--line-2);
}
.upload-modal-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--bg-sunken);
  border-radius: var(--radius);
  font-size: 12.5px;
}
.upload-modal-file-icon {
  font-size: 14px;
}
.upload-modal-file-name {
  flex: 1;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-modal-file-size {
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}
.upload-modal-context {
  padding: 10px 24px;
  font-size: 12px;
  color: var(--ink-3);
  background: var(--accent-soft);
  border-bottom: 1px solid var(--line-2);
}
.upload-modal-field {
  padding: 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-bottom: 1px solid var(--line-2);
}
.upload-modal-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.upload-modal-field select,
.upload-modal-field input[type="text"] {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13.5px;
  background: var(--bg-elev);
  color: var(--ink);
  font-family: inherit;
}
.upload-modal-field select:focus,
.upload-modal-field input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}
.upload-modal-radios {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.upload-modal-radios label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  background: var(--bg-elev);
  transition: border-color 120ms, background 120ms;
}
.upload-modal-radios label.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.upload-modal-radios label input {
  margin-top: 2px;
}
.upload-modal-radio-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.upload-modal-radio-sub {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 2px;
  line-height: 1.4;
}
.upload-modal-actions {
  padding: 16px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.upload-modal-progress {
  flex: 1;
  font-size: 13px;
  color: var(--ink-2);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ───── Form input warn state (Leerstand contract) ───── */
.form-input-warn {
  border-color: var(--warn) !important;
  background: rgba(168, 121, 48, 0.04);
}
.form-input-warn:focus {
  border-color: var(--warn) !important;
  outline: 2px solid rgba(168, 121, 48, 0.2);
}

/* ───── Upload modal — KI / OCR section ───── */
.upload-modal-ocr {
  padding: 14px 24px;
  border-bottom: 1px solid var(--line-2);
}
.upload-modal-ocr-btn {
  width: 100%;
  padding: 10px 12px;
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms;
  font-family: inherit;
}
.upload-modal-ocr-btn:hover:not(:disabled) {
  background: rgba(45, 74, 62, 0.08);
}
.upload-modal-ocr-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.upload-modal-ocr-result {
  position: relative;
  padding: 12px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.upload-modal-ocr-head {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.upload-modal-ocr-conf {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-3);
  margin-left: 6px;
}
.upload-modal-ocr-body {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.45;
}
.upload-modal-ocr-redo {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: 0;
  color: var(--ink-3);
  font-size: 11px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius);
}
.upload-modal-ocr-redo:hover {
  background: rgba(0,0,0,0.05);
  color: var(--ink);
}
.upload-modal-ocr-error {
  padding: 10px 12px;
  border: 1px solid var(--neg);
  border-radius: var(--radius);
  background: rgba(139,58,47,0.06);
  color: var(--neg);
  font-size: 12.5px;
}

/* ───── Doc row download button (cloud documents) ───── */
.doc-download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius);
  background: var(--bg-sunken);
  color: var(--ink-3);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 120ms, color 120ms;
}
.doc-download-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ─────────────────────────────────────────────────────────────────────
   MOBILE / TABLET RESPONSIVE
   The desktop layout above is preserved as-is. These media queries
   override specific properties for narrow viewports.
   ───────────────────────────────────────────────────────────────────── */

/* Hamburger button — hidden on desktop, shown on mobile */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  border-radius: var(--radius);
  margin-right: 4px;
  flex-shrink: 0;
}
.hamburger-btn:hover { background: var(--bg-hover); }

/* Backdrop overlay shown when mobile sidebar is open */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 99;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

@media (max-width: 768px) {
  /* App: single column, sidebar floats over content */
  .app {
    grid-template-columns: 1fr;
  }

  /* Sidebar becomes a slide-in panel */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 84vw;
    max-width: 320px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 220ms cubic-bezier(.3,.7,.4,1);
    overflow-y: auto;
    box-shadow: 0 0 0 transparent;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.18);
  }
  .sidebar-backdrop { display: block; }

  /* Hamburger appears */
  .hamburger-btn { display: inline-flex; }

  /* Topbar: tighter, hide search bar (would crowd things) */
  .topbar {
    padding: 12px 16px;
    gap: 8px;
  }
  .topbar .search {
    display: none;
  }
  .crumbs {
    font-size: 13px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
  }

  /* Page padding */
  .page {
    padding: 16px;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .page-header .page-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .page-actions .btn {
    flex: 1 1 auto;
    min-width: 120px;
    white-space: nowrap;
  }
  .page-title {
    font-size: 24px;
  }

  /* KPI grid: 2 columns instead of 4 */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .kpi-value {
    font-size: 22px;
  }

  /* Two-col layouts collapse to one */
  .two-col,
  .wizard-grid,
  .detail-hero {
    grid-template-columns: 1fr !important;
  }
  .detail-hero-side {
    margin-top: 16px;
  }

  /* Property card grid: single column */
  .prop-grid {
    grid-template-columns: 1fr;
  }

  /* Contacts grid: single column */
  .contacts-grid {
    grid-template-columns: 1fr;
  }

  /* Tables: enable horizontal scroll */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px; /* let table extend past page padding for more space */
  }
  .table-wrap .table {
    min-width: 560px;
  }

  /* Section padding */
  .section {
    margin-bottom: 24px;
  }

  /* Modals: full-screen on mobile */
  .upload-modal-backdrop {
    padding: 0;
    align-items: stretch;
  }
  .upload-modal {
    max-width: 100% !important;
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
  .upload-modal-radios {
    grid-template-columns: 1fr;
  }

  /* Form rows: stack label above input */
  .form-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .form-label {
    width: auto;
  }

  /* Detail hero meta: 2 cols instead of 4 */
  .detail-hero-meta {
    grid-template-columns: 1fr 1fr;
  }

  /* Calendar: smaller cells */
  .cal-grid {
    font-size: 11px;
  }
  .cal-cell {
    min-height: 56px;
    padding: 4px;
  }

  /* Unit row: stack on mobile */
  .unit-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Touch targets: ensure buttons are tappable */
  .btn,
  .nav-item,
  .tab {
    min-height: 40px;
  }

  /* Drop zones: less padding */
  .drop-zone {
    padding: 20px 16px;
  }
  .drop-zone.compact {
    padding: 14px 16px;
  }
}

/* Extra small phones (<400px) */
@media (max-width: 400px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .page-title {
    font-size: 20px;
  }
  .page {
    padding: 12px;
  }
  .topbar {
    padding: 10px 12px;
  }
}

/* ─────────────────────────────────────────────────────────────────────
   ANTI-HORIZONTAL-SCROLL (defensiv)
   Verhindert dass irgendein einzelnes überbreites Element
   die GESAMTE Seite horizontal scrollen lässt.
   Innere Scroll-Container (.table-wrap) funktionieren weiter.
   ───────────────────────────────────────────────────────────────────── */

html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

.app,
.main,
.page {
  max-width: 100%;
  overflow-x: hidden;
}

/* Lange Strings (E-Mail, IBAN, Verwendungszweck, Dateinamen) brechen um statt zu überlaufen */
.kv .v,
.contact-stat-v,
.detail-meta-item .v,
.doc-row,
.tx-description,
td,
.muted,
.contact-person,
.contact-company {
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}

/* Flex/Grid-Kinder können schrumpfen statt zu erzwingen */
.unit-row > *,
.contact-card > *,
.kpi > * {
  min-width: 0;
}

/* Tabellen-Wrap: kein Negativ-Margin mehr (war Auslöser auf einigen Pages),
   stattdessen volle Breite mit innerem Scroll */
@media (max-width: 768px) {
  .table-wrap {
    margin: 0;
  }

  /* Vertrags-Vorschau (A4-Format) auf Mobile in Scroll-Container packen */
  .preview-paper,
  .cp-doc {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  .cp-doc {
    transform-origin: top left;
  }

  /* Topbar darf nichts horizontal überlaufen */
  .topbar {
    overflow: hidden;
  }
  .crumbs {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Lange Doc-Row-Einträge umbrechen */
  .doc-row {
    flex-wrap: wrap;
  }
}
