:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --panel: #ffffff;
  --panel-soft: #f8faf9;
  --text: #17201d;
  --muted: #66716d;
  --line: #dce3df;
  --green: #287a54;
  --teal: #146f76;
  --amber: #b87516;
  --red: #b84236;
  --blue: #335c9b;
  --shadow: 0 18px 50px rgba(23, 32, 29, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font: inherit; }
button, input, select, textarea { border: 1px solid var(--line); border-radius: 8px; }
button, input, select { min-height: 40px; }
input, select, textarea { width: 100%; padding: 0 11px; background: var(--panel-soft); color: var(--text); }
textarea { padding: 10px 11px; resize: vertical; }
button { padding: 0 14px; background: var(--panel-soft); font-weight: 800; cursor: pointer; touch-action: manipulation; }
button:hover { border-color: #b8c3bd; }
a { color: var(--blue); font-weight: 800; text-decoration: none; }

.app-shell { width: min(1200px, calc(100vw - 28px)); margin: 0 auto; padding: 16px 0 24px; }
.login-view { min-height: 100vh; display: grid; place-items: center; }
.login-view[hidden], .dashboard[hidden] { display: none; }
.login-panel { width: min(410px, 100%); display: grid; gap: 12px; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.eyebrow { margin: 0 0 3px; color: var(--teal); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0; }
h1, h2, p { margin: 0; }
h1 { font-size: 34px; line-height: 1; letter-spacing: 0; }
h2 { font-size: 17px; }
label { display: grid; gap: 5px; min-width: 0; }
label span { color: var(--muted); font-size: 12px; font-weight: 700; }
.primary { border-color: var(--green); background: var(--green); color: white; }
.danger { border-color: #d8aca7; background: #fff0ef; color: #913128; }
.form-error { min-height: 18px; color: var(--red); font-weight: 700; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.stats-grid article, .toolbar, .apartment-card, .editor { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.stats-grid article { display: grid; gap: 5px; padding: 11px 12px; }
.stats-grid span { color: var(--muted); }
.stats-grid strong { font-size: 24px; line-height: 1.05; }

.toolbar { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(180px, 220px) auto; gap: 8px; align-items: end; padding: 8px; margin-bottom: 8px; }
.content-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 0.42fr); gap: 8px; align-items: start; }
.apartment-list { display: grid; gap: 8px; }
.empty-state { padding: 24px; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); text-align: center; background: rgba(255,255,255,0.64); }
.apartment-card { display: grid; gap: 10px; padding: 12px; cursor: pointer; }
.apartment-card:hover { border-color: #b8c3bd; }
.card-main { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.card-main h2 { margin-top: 6px; }
.card-main p { color: var(--muted); }
.card-main strong { white-space: nowrap; font-size: 18px; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.facts span { padding: 7px 8px; border-radius: 8px; background: var(--panel-soft); color: #26312d; font-weight: 800; text-align: center; }
.card-footer { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); }

.status-badge { display: inline-flex; width: fit-content; align-items: center; min-height: 26px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 900; }
.status-interessant { background: #eef3f2; color: #4a5b55; }
.status-angefragt { background: #e9f1ff; color: #274f94; }
.status-daten-geschickt { background: #edf7f4; color: #12634f; }
.status-wohnung-besichtigt { background: #fff4df; color: #7a4a08; }
.status-warten-auf-rueckmeldung { background: #f8ecff; color: #70408d; }
.status-zusage { background: #e8f7ed; color: #17683e; }
.status-absage { background: #fdebe9; color: #9c2f25; }
.status-archiv { background: #f0f0ef; color: #6d6b66; }

.editor { position: sticky; top: 10px; display: grid; gap: 9px; padding: 10px; }
.editor-head, .form-actions { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (max-width: 880px) {
  .content-layout { grid-template-columns: 1fr; }
  .editor { position: static; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  body { font-size: 13px; }
  .app-shell { width: min(100vw - 14px, 430px); padding: 10px 0 max(18px, env(safe-area-inset-bottom)); }
  .topbar { align-items: stretch; flex-direction: column; }
  h1 { font-size: 28px; }
  .toolbar { grid-template-columns: 1fr; }
  .stats-grid { gap: 7px; }
  .stats-grid article, .toolbar, .apartment-card, .editor, .login-panel { box-shadow: none; }
  .stats-grid strong { font-size: 20px; }
  .card-main { display: grid; }
  .card-main strong { justify-self: start; }
  .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .facts span { padding: 7px 4px; font-size: 12px; }
  .card-footer { display: grid; }
  .field-row, .field-row.three { grid-template-columns: 1fr; }
  .form-actions { display: grid; grid-template-columns: 1fr 1fr; }
}
