:root {
    --bg: #f5f7fa;
    --card: #ffffff;
    --ink: #16202e;
    --muted: #64748b;
    --line: #e2e8f0;
    --brand: #0d7d8a;
    --brand-dark: #0a5f6a;
    --ok: #16794f;
    --warn: #9a6b00;
    --err: #b3261e;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ---------------------------------------------------------------- Kopfzeile */
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 10;
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; height: 62px; gap: 16px; }
.brand { font-size: 21px; font-weight: 700; color: var(--brand-dark); text-decoration: none; letter-spacing: -0.3px; }
.brand span { color: var(--ink); font-weight: 400; }
.topbar nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.topbar nav a { color: var(--muted); text-decoration: none; font-size: 15px; }
.topbar nav a:hover { color: var(--ink); }
.topbar nav a.btn { color: #fff; }

/* --------------------------------------------------------------------- Text */
h1 { font-size: 28px; margin: 28px 0 6px; letter-spacing: -0.4px; }
h2 { font-size: 20px; margin: 28px 0 12px; }
h3 { font-size: 16px; margin: 0 0 10px; }
.lead { color: var(--muted); margin: 0 0 24px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* -------------------------------------------------------------------- Karten */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.stat { text-align: left; }
.stat .value { font-size: 30px; font-weight: 700; color: var(--brand-dark); line-height: 1.2; }
.stat .label { color: var(--muted); font-size: 14px; }

/* ------------------------------------------------------------------ Formular */
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], select, textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 7px;
    font: inherit;
    background: #fff;
    color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: 16px; }
.field .hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.field .error { color: var(--err); font-size: 13px; margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.check input { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 0 0 18px; }
legend { font-weight: 600; padding: 0 8px; }

.btn {
    display: inline-block;
    background: var(--brand);
    color: #fff;
    border: 0;
    padding: 10px 18px;
    border-radius: 7px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--brand-dark); }
.btn-sm { padding: 6px 12px; font-size: 14px; }
.btn-ghost { background: transparent; color: var(--brand-dark); border: 1px solid var(--line); }
.btn-ghost:hover { background: #eef4f5; }
.btn-danger { background: transparent; color: var(--err); border: 1px solid #f0cdcb; }
.btn-danger:hover { background: #fdeceb; }
.link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }
.link:hover { color: var(--ink); text-decoration: underline; }
.inline { display: inline; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

/* ------------------------------------------------------------------ Hinweise */
.alert { padding: 12px 16px; border-radius: 7px; margin: 18px 0; border: 1px solid; font-size: 15px; }
.alert-success { background: #e8f6ef; border-color: #b9e2cd; color: var(--ok); }
.alert-error   { background: #fdeceb; border-color: #f5c9c6; color: var(--err); }
.alert-info    { background: #e9f2fb; border-color: #c5dcf2; color: #17558a; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-ok    { background: #e8f6ef; color: var(--ok); }
.badge-warn  { background: #fdf3dc; color: var(--warn); }
.badge-muted { background: #eef1f5; color: var(--muted); }
.badge-brand { background: #e3f1f2; color: var(--brand-dark); }

/* -------------------------------------------------------------------- Tabelle */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); font-size: 15px; vertical-align: top; }
th { font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }

/* --------------------------------------------------------------------- Score */
.score { display: flex; align-items: center; gap: 10px; }
.score-value { font-weight: 700; font-size: 17px; min-width: 46px; }
.bar { flex: 1; height: 7px; background: #e8edf3; border-radius: 999px; overflow: hidden; min-width: 70px; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.score-breakdown { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.score-breakdown .bar { margin-top: 6px; }

/* ------------------------------------------------------------------- Gesperrt */
.locked { position: relative; }
.locked .blurred { filter: blur(5px); user-select: none; pointer-events: none; }
.unlock-box {
    background: #f8fafc;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}
.unlock-box .price { font-size: 24px; font-weight: 700; color: var(--brand-dark); }

.dl { display: grid; grid-template-columns: 190px 1fr; gap: 8px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: 14px; }
.dl dd { margin: 0; }

/* --------------------------------------------------------- Standort-Zeilen */
.site-row { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 6px; }
.site-row:first-child { border-top: 0; padding-top: 0; }
.site-row-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.site-row-head strong { color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; font-size: 12px; }
.site-list { margin: 0; padding-left: 18px; }
.site-list li { margin-bottom: 2px; }
.site-list li.primary { font-weight: 600; }
#site-add[disabled] { opacity: 0.5; cursor: not-allowed; }

/* -------------------------------------------------------------------- Filter */
.filters form { margin: 0; }
.filters .field { margin-bottom: 10px; }
.filters .field .btn { margin-right: 6px; }
.state-select { padding: 5px 8px; font-size: 14px; width: auto; min-width: 130px; }

/* --------------------------------------------------------------- Seitenwechsel */
.pagination { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 4px 0 24px; }
.pagination a, .pagination .current {
    display: inline-block;
    padding: 6px 11px;
    border-radius: 7px;
    border: 1px solid var(--line);
    text-decoration: none;
    color: var(--brand-dark);
    font-size: 14px;
    background: var(--card);
}
.pagination a:hover { background: #eef4f5; }
.pagination .current { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* ---------------------------------------------------------------- Nachrichten */
.thread { display: flex; flex-direction: column; gap: 14px; }
.message { max-width: 78%; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.message.own { align-self: flex-end; background: #eef6f7; border-color: #cfe4e6; }
.message-head { margin-bottom: 6px; }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; }

.footer { color: var(--muted); font-size: 14px; padding: 30px 0; margin-top: 40px; border-top: 1px solid var(--line); }
.footer .badge { margin-left: 10px; }

.empty { text-align: center; color: var(--muted); padding: 34px 20px; }

@media (max-width: 620px) {
    .dl { grid-template-columns: 1fr; gap: 2px 0; }
    .dl dd { margin-bottom: 10px; }
    .topbar .wrap { height: auto; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }
    .message { max-width: 100%; }
}
