/* ==========================================================================
   WF Immobilien-Radar – Designsystem (internes Dashboard)
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-sans);
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; font-weight: 700; color: var(--primary); }
h1 { font-size: 1.6rem; letter-spacing: -0.02em; }
h2 { font-size: 1.2rem; margin-bottom: .6rem; }
h3 { font-size: 1rem; }
small { font-size: .82rem; }
code, .mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.main { min-height: calc(100vh - 124px); padding-bottom: 48px; }
.section { padding: 24px 0; }

/* ---- Topbar -------------------------------------------------------------- */
.topbar {
    background: var(--primary);
    color: #fff;
    position: sticky; top: 0; z-index: 50;
    box-shadow: 0 1px 0 rgba(0,0,0,.15);
}
.topbar__inner {
    max-width: var(--maxw); margin: 0 auto; padding: 0 24px;
    height: 58px; display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand__mark { font-size: 1.35rem; }
.brand__name { font-weight: 800; font-size: 1.02rem; display: block; letter-spacing: -.01em; }
.brand__sub { font-size: .72rem; opacity: .65; display: block; margin-top: -2px; }
.mainnav { display: flex; gap: 4px; margin-left: 8px; flex: 1; }
.mainnav__link {
    color: rgba(255,255,255,.78); padding: 7px 13px; border-radius: 7px;
    font-weight: 500; font-size: .92rem;
}
.mainnav__link:hover { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }
.mainnav__link.is-active { color: #fff; background: rgba(255,255,255,.16); font-weight: 600; }
.topbar__logout { color: rgba(255,255,255,.7); font-size: .85rem; }
.topbar__logout:hover { color: #fff; }

/* ---- Crumbs -------------------------------------------------------------- */
.crumbs { padding: 12px 0 0; font-size: .85rem; }
.crumbs__sep { color: var(--muted); margin: 0 8px; }
.crumbs__cur { color: var(--muted); }

/* ---- Cards --------------------------------------------------------------- */
.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 18px 20px;
}
.card--pad-lg { padding: 24px 26px; }
.card__title { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; margin-bottom: 10px; }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
@media (max-width: 980px) { .grid--3, .grid--4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid--2, .grid--3, .grid--4 { grid-template-columns: 1fr; } }

/* ---- KPI-Kacheln --------------------------------------------------------- */
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.kpi__label { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi__value { font-size: 1.7rem; font-weight: 800; color: var(--primary); letter-spacing: -.02em; margin-top: 4px; }
.kpi__sub { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.kpi__value.good { color: var(--good); } .kpi__value.warn { color: var(--warn); } .kpi__value.bad { color: var(--bad); }

/* ---- Badges -------------------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px; font-size: .76rem; font-weight: 600;
    padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
    border: 1px solid var(--line); white-space: nowrap;
}
.badge--good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge--warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge--bad  { background: var(--bad-soft);  color: var(--bad);  border-color: transparent; }
.badge--kauf { background: #e0edff; color: #1d4ed8; border-color: transparent; }
.badge--miete{ background: #ede9fe; color: #6d28d9; border-color: transparent; }
.badge--gone { background: #f1f5f9; color: #94a3b8; border-color: transparent; }

.tone-good { color: var(--good); } .tone-warn { color: var(--warn); } .tone-bad { color: var(--bad); }

/* ---- Tabellen ------------------------------------------------------------ */
.table-wrap { overflow-x: auto; max-width: 100%; min-width: 0; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
/* Kompakte Tabelle: kleinere Schrift/Padding; Spalten mit .wrap dürfen umbrechen. */
.data--compact { font-size: .84rem; }
.data--compact th, .data--compact td { padding: 8px 10px; }
.data--compact td.wrap, .data--compact th.wrap { white-space: normal; min-width: 150px; max-width: 240px; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { padding: 10px 13px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: var(--surface-2); cursor: pointer; user-select: none; }
table.data th:hover { color: var(--ink); }
table.data th[data-sort-dir] { color: var(--accent); }
.sort-arr { font-size: .85em; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: none; }

/* ---- Buttons ------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
    font: inherit; font-weight: 600; font-size: .9rem;
    padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
    background: var(--surface); color: var(--ink); transition: .12s;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn--ghost { background: transparent; }
.btn--sm { padding: 6px 11px; font-size: .84rem; }
.btn--danger { color: var(--bad); border-color: var(--bad-soft); }
.btn--danger:hover { background: var(--bad-soft); }

/* ---- Formulare ----------------------------------------------------------- */
label.field { display: block; margin-bottom: 14px; }
.field__label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink); margin-bottom: 5px; }
.field__hint { font-size: .76rem; color: var(--muted); margin-top: 3px; }
input[type=text], input[type=number], input[type=search], input[type=password], select, textarea {
    width: 100%; font: inherit; font-size: .92rem; padding: 9px 11px;
    border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.checkrow { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: .9rem; }
.checkrow input { width: auto; }

/* ---- Filterleiste -------------------------------------------------------- */
.filterbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 18px; }
.filterbar .field-inline { display: flex; flex-direction: column; gap: 4px; }
.filterbar .field-inline label { font-size: .74rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.filterbar input, .filterbar select { min-width: 130px; }

/* ---- Page-Head ----------------------------------------------------------- */
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 18px 0 18px; flex-wrap: wrap; }
.pagehead__sub { color: var(--muted); font-size: .92rem; margin-top: 2px; }

/* ---- Login --------------------------------------------------------------- */
.login-screen { min-height: calc(100vh - 124px); display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 32px; box-shadow: 0 10px 40px rgba(15,41,66,.10); }
.login-card h1 { font-size: 1.3rem; margin-bottom: 4px; }
.login-card .login-sub { color: var(--muted); font-size: .9rem; margin-bottom: 22px; }
.login-error { background: var(--bad-soft); color: var(--bad); padding: 10px 13px; border-radius: 8px; font-size: .88rem; margin-bottom: 16px; }

/* ---- Notices / Alerts ---------------------------------------------------- */
.notice { padding: 13px 16px; border-radius: var(--radius); font-size: .9rem; margin-bottom: 16px; border: 1px solid var(--line); background: var(--surface); }
.notice--good { background: var(--good-soft); border-color: transparent; color: #14532d; }
.notice--warn { background: var(--warn-soft); border-color: transparent; color: #78350f; }
.notice--bad  { background: var(--bad-soft);  border-color: transparent; color: #7f1d1d; }
.notice--info { background: #e0f2fe; border-color: transparent; color: #075985; }

/* ---- Mini-Sparkline / Balken --------------------------------------------- */
.bar-track { background: var(--surface-2); border-radius: 999px; height: 7px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.bar-fill.good { background: var(--good); } .bar-fill.warn { background: var(--warn); } .bar-fill.bad { background: var(--bad); }

/* ---- Pagination ---------------------------------------------------------- */
.pager { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 22px; }
.pager a, .pager span { padding: 7px 12px; border: 1px solid var(--line); border-radius: 7px; font-size: .88rem; background: var(--surface); }
.pager .is-cur { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- Footer -------------------------------------------------------------- */
.sitefoot { border-top: 1px solid var(--line); background: var(--surface); padding: 18px 0; }
.sitefoot__inner { display: flex; justify-content: space-between; gap: 12px; font-size: .82rem; color: var(--muted); flex-wrap: wrap; }

/* ---- Tooltips (Fachbegriff-Erklärungen) ---------------------------------- */
.tip { position: relative; display: inline-flex; vertical-align: middle; margin-left: 5px; cursor: help; outline: none; }
.tip__q {
    display: inline-flex; align-items: center; justify-content: center;
    width: 15px; height: 15px; border-radius: 50%;
    background: var(--line); color: var(--muted);
    font-size: 10px; font-weight: 700; line-height: 1;
}
.tip:hover .tip__q, .tip:focus .tip__q { background: var(--accent); color: #fff; }
.tip__bubble {
    position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
    width: max-content; max-width: 300px; z-index: 80;
    background: var(--primary); color: #fff;
    font-size: .82rem; font-weight: 400; line-height: 1.45; text-transform: none; letter-spacing: normal;
    text-align: left; padding: 10px 12px; border-radius: 10px;
    box-shadow: 0 10px 30px rgba(15,41,66,.28);
    opacity: 0; visibility: hidden; transition: opacity .12s, visibility .12s; pointer-events: none;
    white-space: normal;
}
.tip__bubble::after {
    content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    border: 6px solid transparent; border-top-color: var(--primary);
}
.tip:hover .tip__bubble, .tip:focus .tip__bubble { opacity: 1; visibility: visible; }
/* Nahe am rechten Rand: Blase linksbündig ausrichten, damit sie nicht abgeschnitten wird. */
.tip--right .tip__bubble { left: auto; right: 0; transform: none; }
.tip--right .tip__bubble::after { left: auto; right: 5px; transform: none; }
table.data .tip__bubble { font-variant-numeric: normal; }

/* ---- Utilities ----------------------------------------------------------- */
.row { display: flex; gap: 12px; align-items: center; }
.row--wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.mt-0{margin-top:0}.mt-1{margin-top:8px}.mt-2{margin-top:16px}.mt-3{margin-top:24px}
.mb-1{margin-bottom:8px}.mb-2{margin-bottom:16px}.mb-3{margin-bottom:24px}
.nowrap { white-space: nowrap; }
.tabnums { font-variant-numeric: tabular-nums; }

/* ---- Orte-Multiselect (Checkbox-Dropdown) -------------------------------- */
.btn--sm { padding: 6px 12px; font-size: .85rem; }
.ortfilter { position: relative; display: inline-block; }
.ortfilter__sum {
    display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
    background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
    padding: 9px 14px; font-size: .92rem; list-style: none;
}
.ortfilter__sum::-webkit-details-marker { display: none; }
.ortfilter__sum:hover { border-color: var(--muted); }
.ortfilter__chev { color: var(--muted); transition: transform .15s; }
.ortfilter[open] .ortfilter__chev { transform: rotate(180deg); }
.ortfilter__panel {
    position: absolute; z-index: 30; margin-top: 6px; min-width: 280px; max-width: 460px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 12px 14px; box-shadow: 0 12px 32px rgba(0,0,0,.18);
}
.ortfilter__grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 2px 14px; max-height: 320px; overflow-y: auto; margin: 6px 0;
}
.ortfilter__opt { display: flex; align-items: center; gap: 8px; padding: 5px 4px; font-size: .9rem; cursor: pointer; border-radius: 6px; }
.ortfilter__opt:hover { background: var(--surface-2); }
.ortfilter__opt input { width: 16px; height: 16px; flex: none; }
.ortfilter__opt--all { border-bottom: 1px solid var(--line); padding-bottom: 9px; margin-bottom: 4px; }
.ortfilter__hint { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); font-size: .8rem; }
.empty { text-align: center; color: var(--muted); padding: 48px 24px; }
