/* teamgnesda Immobilien-Plattform · Shared UI */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--tg-text);
  background: var(--tg-cream);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--tg-coral); text-decoration: none; }
a:hover { color: var(--tg-coral-hover); }
h1,h2,h3,h4 { margin: 0 0 .4em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
img { max-width: 100%; display: block; }

/* ---------- Topbar ---------- */
.topbar {
  height: var(--header-h); background: var(--tg-dark); color: #fff;
  display: flex; align-items: center; gap: 20px; padding: 0 20px; position: sticky; top: 0; z-index: 100;
}
.brand { font-weight: 800; font-size: 1.1rem; letter-spacing: -.02em; color: #fff; display: flex; align-items: center; gap: 8px; }
.brand .dot { color: var(--tg-coral); }
.topbar .spacer { flex: 1; }
.topbar nav { display: flex; gap: 6px; }
.topbar nav a { color: #cfcfcf; padding: 8px 12px; border-radius: var(--radius-sm); font-size: .9rem; }
.topbar nav a:hover, .topbar nav a.active { color: #fff; background: rgba(255,255,255,.1); }
.topbar .user { color: #cfcfcf; font-size: .85rem; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: calc(100vh - var(--header-h)); }
.sidebar {
  width: var(--sidebar-w); background: var(--tg-white); border-right: 1px solid var(--tg-border);
  padding: 16px 12px; flex-shrink: 0;
}
.sidebar a {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius-sm);
  color: var(--tg-text); font-weight: 500; font-size: .92rem; margin-bottom: 2px;
}
.sidebar a:hover { background: var(--tg-light); }
.sidebar a.active { background: var(--tg-coral-light); color: var(--tg-coral-hover); font-weight: 600; }
.sidebar .sb-group { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--tg-muted); margin: 18px 14px 6px; }
.content { flex: 1; padding: 28px; max-width: 100%; overflow-x: hidden; }
.page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .spacer { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-family: var(--font); font-size: .92rem; font-weight: 600; cursor: pointer;
  background: var(--tg-coral); color: #fff; transition: background .15s, transform .05s; text-decoration: none;
}
.btn:hover { background: var(--tg-coral-hover); color:#fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--tg-white); color: var(--tg-text); border-color: var(--tg-border); }
.btn.secondary:hover { background: var(--tg-light); color: var(--tg-text); }
.btn.ghost { background: transparent; color: var(--tg-text); }
.btn.ghost:hover { background: rgba(0,0,0,.05); color: var(--tg-text); }
.btn.danger { background: var(--tg-danger); }
.btn.danger:hover { background: #c62828; }
.btn.sm { padding: 6px 12px; font-size: .82rem; }
.btn.block { width: 100%; }

/* ---------- Cards ---------- */
.card { background: var(--tg-white); border: 1px solid var(--tg-border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card.pad { padding: 20px; }
.grid { display: grid; gap: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat { background: var(--tg-white); border: 1px solid var(--tg-border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.stat .num { font-size: 2rem; font-weight: 800; color: var(--tg-coral); line-height: 1; }
.stat .lbl { color: var(--tg-muted); font-size: .82rem; margin-top: 6px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 6px; }
.field .hint { color: var(--tg-muted); font-size: .78rem; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=datetime-local], input[type=search], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--tg-border); border-radius: var(--radius-sm);
  font-family: var(--font); font-size: .92rem; background: #fff; color: var(--tg-text);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--tg-coral); box-shadow: 0 0 0 3px var(--tg-coral-light); }
textarea { resize: vertical; min-height: 80px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 720px){ .form-grid { grid-template-columns: 1fr; } }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--tg-border); background:#fff; }
table.tg { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.tg th, table.tg td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--tg-border); white-space: nowrap; }
table.tg th { background: var(--tg-light); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--tg-muted); cursor: pointer; user-select: none; }
table.tg th.no-sort { cursor: default; }
table.tg tbody tr:hover { background: var(--tg-coral-light); }
table.tg .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 600; white-space: nowrap; }
.badge.neubau { background: #E6F4EA; color: #1B7A37; }
.badge.sanierung { background: #FFF1E0; color: #B25E00; }
.badge.bestand { background: #ECECEC; color: #555; }
.badge.konzept { background: #EDE7F6; color: #5E35B1; }
.badge.active { background: #E6F4EA; color: #1B7A37; }
.badge.inactive { background: #FCE4E4; color: #B71C1C; }
.district-pill { display:inline-flex; align-items:center; gap:6px; }
.district-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--tg-border); margin-bottom: 20px; flex-wrap: wrap; }
.tabs button { background: none; border: none; padding: 12px 18px; font-family: var(--font); font-size: .95rem; font-weight: 600; color: var(--tg-muted); cursor: pointer; border-bottom: 3px solid transparent; }
.tabs button:hover { color: var(--tg-text); }
.tabs button.active { color: var(--tg-coral); border-bottom-color: var(--tg-coral); }

/* ---------- Star / fav ---------- */
.star { cursor: pointer; font-size: 1.25rem; line-height: 1; color: #ccc; background: none; border: none; padding: 2px; transition: transform .1s; }
.star:hover { transform: scale(1.15); }
.star.on { color: #F5B301; }

/* ---------- Chips / filters ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--tg-border); background: #fff; cursor: pointer; font-size: .85rem; font-weight: 500; }
.chip.active { background: var(--tg-dark); color: #fff; border-color: var(--tg-dark); }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal-back.show { display: flex; }
.modal { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; }
.modal .m-head { padding: 18px 22px; border-bottom: 1px solid var(--tg-border); display: flex; align-items: center; }
.modal .m-head h3 { margin: 0; }
.modal .m-body { padding: 22px; }
.modal .m-foot { padding: 16px 22px; border-top: 1px solid var(--tg-border); display: flex; gap: 10px; justify-content: flex-end; }
.x-close { margin-left: auto; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--tg-muted); line-height:1; }

/* ---------- Toast ---------- */
#toasts { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--tg-dark); color: #fff; padding: 12px 18px; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: .88rem; animation: slidein .2s ease; max-width: 320px; }
.toast.success { background: #2e7d32; } .toast.error { background: #c62828; }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--tg-cream); }
.auth-card { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow); width: 100%; max-width: 400px; padding: 36px 32px; }
.auth-card .brand { color: var(--tg-dark); justify-content: center; font-size: 1.5rem; margin-bottom: 4px; }
.auth-card .sub { text-align: center; color: var(--tg-muted); font-size: .88rem; margin-bottom: 24px; }
.auth-error { background: var(--tg-coral-light); color: var(--tg-coral-hover); padding: 10px 14px; border-radius: var(--radius-sm); font-size: .85rem; margin-bottom: 16px; }

/* ---------- Misc ---------- */
.muted { color: var(--tg-muted); }
.empty { text-align: center; padding: 48px 20px; color: var(--tg-muted); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--tg-border); border-top-color: var(--tg-coral); border-radius: 50%; animation: spin .7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg,#eee 25%,#f5f5f5 37%,#eee 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: 6px; }
@keyframes shimmer { 0%{background-position:100% 0} 100%{background-position:-100% 0} }
.row { display: flex; gap: 10px; align-items: center; }
.wrap { flex-wrap: wrap; }
.gap-sm { gap: 6px; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }
.text-right { text-align: right; }
.hidden { display: none !important; }
.code-box { font-family: ui-monospace, monospace; background: var(--tg-light); border: 1px dashed var(--tg-border); padding: 10px 14px; border-radius: var(--radius-sm); word-break: break-all; }
