/* ═══════════════════════════════════════════
   Immo Mgmt — IS24-inspired Design System
   Body/UI: Inter | Primary: #00A69C (Teal)
   ═══════════════════════════════════════════ */

/* ── Tokens ── */
:root {
  --bg-page:       #F2F4F5;
  --bg-surface:    #FFFFFF;
  --bg-surface-2:  #F9FAFB;

  --border-subtle:  #F3F4F6;
  --border-default: #E5E7EB;
  --border-strong:  #D1D5DB;
  --border-faint:   #F9FAFB;
  --border-hover:   #9CA3AF;

  --color-primary:            #00A69C;
  --color-primary-dim:        rgba(0,166,156,.10);
  --color-primary-border:     rgba(0,166,156,.30);
  --color-primary-hover:      #008F86;
  --color-primary-dark:       #006B65;
  --color-primary-btn-border: #00B5AB;

  /* Gold-Aliases → Türkis (hält Badge-CSS kompatibel ohne Massenänderung) */
  --color-gold:               #00A69C;
  --color-gold-dim:           rgba(0,166,156,.10);
  --color-gold-border:        rgba(0,166,156,.30);
  --color-gold-nav-bg:        rgba(0,166,156,.10);
  --color-gold-nav-border:    rgba(0,166,156,.25);
  --color-gold-hover:         #008F86;
  --color-gold-btn-border:    #00B5AB;

  --color-green:         #22C55E;
  --color-green-dim:     rgba(34,197,94,.12);
  --color-red:           #DC2626;
  --color-red-light:     #EF4444;
  --color-red-dim:       rgba(220,38,38,.12);
  --color-red-hover:     #B91C1C;
  --color-red-btn-border: #EF4444;
  --focus-ring-red:      rgba(220,38,38,.12);
  --color-purple-light:  #A855F7;
  --color-purple-dim:    rgba(88,28,135,.20);

  --text-primary:   #111827;
  --text-secondary: #374151;
  --text-muted:     #6B7280;
  --text-faint:     #9CA3AF;

  --shadow-glow: 0 0 12px rgba(0,166,156,.20);
  --shadow-lg:   0 4px 16px rgba(0,0,0,.08);

  --radius-sm:   3px;
  --radius-md:   6px;
  --radius-full: 9999px;

  --transition: .15s ease;
}

/* ── Reset ── */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Base ── */
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 13px;
  line-height: 1.5;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--color-primary-hover); }
h1,.page-title {
  font-size: 22px; font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.4px; line-height: 1.2;
}
h2 {
  font-size: 16px; font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}
h3 {
  font-size: 14px; font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.subtitle,.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ── Top Navigation ── */
.topnav {
  height: 56px; background: #fff;
  border-bottom: 1px solid var(--border-default);
  display: flex; align-items: center;
  padding: 0 24px; position: sticky;
  top: 0; z-index: 40; flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.topnav-logo {
  display: flex; align-items: center; gap: 8px;
  margin-right: 32px; text-decoration: none; flex-shrink: 0;
}
.topnav-logo:hover { text-decoration: none; opacity: .9; }
.topnav-logo-mark {
  width: 34px; height: 34px;
  background: var(--color-primary);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.topnav-logo-text { font-size: 15px; font-weight: 700; color: var(--text-primary); letter-spacing: -.3px; }
.topnav-logo-text span { color: var(--color-primary); }
.topnav-nav { display: flex; align-items: stretch; height: 100%; flex: 1; gap: 0; }
.nav-link {
  display: flex; align-items: center; gap: 6px;
  padding: 0 14px; font-size: 13px; font-weight: 500;
  color: var(--text-muted); border-bottom: 3px solid transparent;
  white-space: nowrap; cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  text-decoration: none;
}
.nav-link:hover { color: var(--text-primary); border-bottom-color: var(--border-strong); text-decoration: none; }
.nav-link.active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }
.nav-ico { font-size: 14px; flex-shrink: 0; }
.nav-label { font-size: 13px; }
.topnav-right { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-shrink: 0; }
.topnav-user { width: 34px; height: 34px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.topnav-user:hover { opacity: .85; }
.user-avatar {
  width: 34px; height: 34px; border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-avatar-img { width: 34px; height: 34px; border-radius: var(--radius-full); object-fit: cover; flex-shrink: 0; }

/* User-Menu Dropdown */
.user-menu { position: relative; }
.user-menu-dropdown {
  display: none;
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 220px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 6px; z-index: 100;
  box-shadow: var(--shadow-lg);
}
.user-menu-dropdown.open { display: block; }
.user-menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-md);
  font-size: 13px; color: var(--text-secondary); text-decoration: none;
}
.user-menu-item:hover { background: var(--bg-surface-2); color: var(--text-primary); text-decoration: none; }

/* Bell */
.bell-container { position: relative; }
#bell-btn {
  width: 34px; height: 34px; border-radius: var(--radius-full);
  background: var(--bg-surface-2); border: 1px solid var(--border-default);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted); font-size: 14px;
  position: relative; padding: 0;
}
#bell-btn:hover { border-color: var(--border-hover); color: var(--text-secondary); }
#notif-panel {
  display: none; position: absolute; right: 0; top: 110%; width: 300px;
  background: var(--bg-surface); border: 1px solid var(--border-default);
  border-radius: var(--radius-md); z-index: 100; box-shadow: var(--shadow-lg);
}
.notif-badge {
  position: absolute; top: -3px; right: -3px;
  background: var(--color-red); color: #fff;
  font-size: 8px; border-radius: var(--radius-full);
  padding: 1px 3px; font-weight: 700; line-height: 1;
}

/* ── Main content ── */
.main { flex: 1; padding: 24px 28px; min-height: calc(100vh - 56px); }

/* ── Page header ── */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.header-actions { display: flex; gap: 8px; align-items: center; }

/* ── Breadcrumb ── */
.breadcrumb { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text-secondary); text-decoration: none; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 20px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent;
  text-decoration: none; white-space: nowrap;
  letter-spacing: .2px; line-height: 1;
  transition: background var(--transition), opacity var(--transition);
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary-btn-border); }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary { background: #fff; color: var(--color-primary); border-color: var(--color-primary); }
.btn-secondary:hover { background: var(--color-primary-dim); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border-default); }
.btn-ghost:hover { background: var(--bg-surface-2); }
.btn-danger { background: var(--color-red); color: #fff; border-color: var(--color-red-btn-border); }
.btn-danger:hover { background: var(--color-red-hover); }
.btn-sm { font-size: 12px; padding: 5px 13px; }
.btn:disabled,.btn[disabled] { opacity: .35; cursor: not-allowed; pointer-events: none; }

/* ── Detail-page action buttons (Bearbeiten, Start/Ende setzen, Abbrechen) ── */
.page-header .btn,
.page-header a.btn {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary-btn-border);
  box-shadow: none;
}
.page-header .btn:hover,
.page-header a.btn:hover {
  background: var(--color-primary-hover);
  text-decoration: none;
}

/* ── Cards ── */
.card {
  background: var(--bg-surface); border: 1px solid var(--border-default);
  border-radius: var(--radius-md); padding: 16px 18px;
  transition: box-shadow .3s ease, border-color .3s ease;
}
.card:hover { border-color: var(--color-primary-border); box-shadow: var(--shadow-glow); }
.card-accent { border-top: 2px solid var(--color-primary); }

/* Disable hover glow on detail page info cards */
.page-header ~ .grid-3 .card:hover,
.page-header + .grid-3 .card:hover {
  box-shadow: none;
}

/* ── Stat cards ── */
.stat-card {
  background: var(--bg-surface); border: 1px solid var(--border-default);
  border-radius: var(--radius-md); padding: 13px 15px; border-top-width: 2px;
}
.stat-label {
  font-size: 10px; font-weight: 600;
  color: var(--text-muted); letter-spacing: .8px; text-transform: uppercase; margin-bottom: 6px;
}
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; color: var(--text-primary); }
.stat-delta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-card.accent,
.stat-card.warn   { border-top-color: var(--color-primary); }
.stat-card.accent .stat-value,
.stat-card.warn   .stat-value { color: var(--color-primary); }
.stat-card.danger { border-top-color: var(--color-red); }
.stat-card.danger .stat-value { color: var(--color-red); }

/* ── Table wrapper ── */
.table-card {
  background: var(--bg-surface); border: 1px solid var(--border-default);
  border-radius: var(--radius-md); overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
table { width: 100%; border-collapse: collapse; }
th {
  padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted);
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-surface-2);
}
td {
  padding: 10px 14px; font-size: 13px; color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}
td:first-child { color: var(--text-primary); font-weight: 600; }
tbody tr:hover { background: rgba(0,166,156,.04); }
tbody tr:last-child td { border-bottom: none; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 600;
  letter-spacing: .4px; text-transform: uppercase;
}
.badge-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-ok,
.badge-done    { background: var(--color-green-dim); color: var(--color-green); }
.badge-warn,
.badge-accent,
.badge-scheduled,
.badge-due_soon,
.badge-active  { background: var(--color-gold-dim);  color: var(--color-gold); }
.badge-danger,
.badge-overdue { background: var(--color-red-dim);   color: var(--color-red-light); }
.badge-muted,
.badge-skipped,
.badge-open_ended,
.badge-cancelled,
.badge-not_started,
.badge-pending    { background: rgba(0,0,0,.06); border: 1px solid var(--border-default); color: var(--text-muted); }
.badge-obsolete { background: rgba(0,0,0,.06); border: 1px solid var(--border-default); color: var(--text-muted); }
.badge-info    { background: var(--color-purple-dim); color: var(--color-purple-light); }

/* ── Badge aliases — dynamic status values from model properties ── */

/* contracts: Contract.status property */
.badge-active      { background: var(--color-green-dim); color: var(--color-green); }
.badge-expired     { background: var(--color-red-dim);   color: var(--color-red-light); }
.badge-expiring    { background: var(--color-gold-dim);  color: var(--color-gold); }
.badge-renewing_soon { background: var(--color-gold-dim); color: var(--color-gold); }
.badge-open_ended  { background: rgba(0,0,0,.06); border: 1px solid var(--border-default); color: var(--text-muted); }

/* Contract detail badge — larger & readable */
.page-header .badge {
  padding: 5px 14px;
  font-size: 13px;
  letter-spacing: .5px;
  white-space: nowrap;
}

/* renovation: Measure.status & MaintenanceTask.status */
.badge-in_progress { background: var(--color-gold-dim);  color: var(--color-gold); }
.badge-planning    { background: var(--color-purple-dim); color: var(--color-purple-light); }

/* renovation: PhaseInstance.status choices */
.badge-completed   { background: var(--color-green-dim); color: var(--color-green); }

/* renovation: Milestone.status & WarrantyTickler.status */
.badge-due         { background: var(--color-red-dim);   color: var(--color-red-light); }

/* maintenance: MaintenanceInstance.status & MaintenanceTask.status */
.badge-planned     { background: var(--color-gold-dim);  color: var(--color-gold); }
.badge-open        { background: var(--color-purple-dim); color: var(--color-purple-light); }

/* ── Messages ── */
.messages { margin-bottom: 16px; }
.message { border-radius: var(--radius-md); padding: 10px 14px; margin-bottom: 8px; font-size: 13px; }
.message.success { background: var(--color-green-dim);  border: 1px solid rgba(34,197,94,.25);  color: var(--color-green); }
.message.error   { background: var(--color-red-dim);    border: 1px solid rgba(153,27,27,.35);  color: var(--color-red-light); }
.message.warning { background: var(--color-gold-dim);   border: 1px solid var(--color-gold-border);  color: var(--color-gold); }
.message.info    { background: var(--color-purple-dim); border: 1px solid rgba(88,28,135,.35);  color: var(--color-purple-light); }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 5px;
}
input,textarea {
  width: 100%; padding: 8px 11px; height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface); color: var(--text-primary);
  font-size: 13px;
}
textarea { height: auto; padding-top: 9px; resize: vertical; }
select {
  width: 100%; height: 38px; padding: 8px 32px 8px 11px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-surface); color: var(--text-primary);
  font-size: 13px;
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
input:hover,select:hover,textarea:hover { border-color: var(--border-hover); }
input:focus,select:focus,textarea:focus {
  border-color: var(--color-primary); outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-dim);
}
input.error,select.error,textarea.error {
  border-color: var(--color-red);
  box-shadow: 0 0 0 3px var(--focus-ring-red);
}
input[type=checkbox] { width: auto; height: auto; }
input::placeholder,textarea::placeholder { color: var(--text-faint); }

/* ── Checkbox pills ── */
.checkbox-pills ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.checkbox-pills li { margin: 0; }
.checkbox-pills label {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: var(--radius-sm);
  background: var(--bg-surface); border: 1px solid var(--border-strong);
  font-size: 12px; color: var(--text-muted);
  text-transform: none; letter-spacing: 0; font-weight: 500;
  margin: 0; cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.checkbox-pills label:hover { background: var(--bg-surface-2); }
.checkbox-pills label:has(input:checked) {
  background: var(--color-primary); color: #fff; border-color: var(--color-primary);
}
.checkbox-pills input[type=checkbox] { width: auto; margin: 0; }

/* ── Tabs ── */
.tabs { display: flex; border-bottom: 1px solid var(--border-default); margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  padding: 9px 16px;
  font-size: 13px; font-weight: 500; letter-spacing: .2px;
  color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  text-decoration: none; display: inline-block;
  transition: color var(--transition), border-color var(--transition);
}
.tab:hover { color: var(--text-secondary); text-decoration: none; }
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }

/* ── Inline form ── */
.inline-form {
  background: var(--color-primary-dim); border: 1px solid var(--color-primary-border);
  border-radius: var(--radius-md); padding: 14px; margin-top: 10px;
}

/* ── Empty state ── */
.empty-state { text-align: center; padding: 60px 40px; color: var(--text-muted); font-size: 14px; }

/* ── Grids ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── HTMX ── */
.htmx-indicator { opacity: 0; transition: opacity 200ms ease-in; }
.htmx-request .htmx-indicator { opacity: 1; }

/* ── Login ── */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; width: 100%; padding: 24px;
}
.login-card { width: 100%; max-width: 400px; }
.login-card h1 {
  font-size: 20px; font-weight: 700; margin-bottom: 24px;
  color: var(--color-primary); letter-spacing: -.3px;
}

/* ── Profile ── */
.profile-avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
.profile-avatar-placeholder {
  width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; color: #fff;
}

/* ── Bottom Nav — hidden on desktop ── */
.bottom-nav { display: none; }

/* ═══════════════════════════════════════════════
   Mobile — max-width: 767px
   All rules here override desktop ONLY on mobile.
   Desktop (≥ 768px) is completely unaffected.
   ═══════════════════════════════════════════════ */
@media (max-width: 767px) {

  /* ── Base ── */
  body { font-size: 15px; padding-bottom: 64px; }
  .main { padding: 16px 16px; }

  /* ── Topnav — slim ── */
  .topnav { padding: 0 16px; }
  .topnav-nav { display: none; }
  .topnav-logo { margin-right: 0; }

  /* ── Bottom Navigation ── */
  .bottom-nav {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid var(--border-default);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 40;
  }
  .bn-tab {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px; padding: 8px 4px;
    font-size: 10px; color: var(--text-faint);
    text-decoration: none; line-height: 1;
  }
  .bn-tab:hover { color: var(--text-muted); text-decoration: none; }
  .bn-tab.bn-active { color: var(--color-primary); font-weight: 600; }
  .bn-ico { font-size: 18px; line-height: 1; }

  /* ── Touch targets ── */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  input:not([type=hidden]):not([type=checkbox]),
  select,
  textarea { min-height: 44px; }

  /* ── Page header ── */
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .header-actions { width: 100%; flex-direction: column; }
  .header-actions .btn,
  .page-header > .btn,
  .page-header > a.btn { width: 100%; justify-content: center; }

  /* ── Filter forms — wrap on narrow screens ── */
  form[method="get"] { flex-wrap: wrap !important; }
  form[method="get"] select { min-width: 140px; flex: 1 1 140px; }

  /* ── Grids → single column ── */
  .grid-2, .grid-3 { grid-template-columns: 1fr; }

  /* ── Tables → Cards ── */
  .table-card {
    border: none; background: transparent;
    box-shadow: none; overflow: visible;
  }
  .table-card table,
  .table-card thead,
  .table-card tbody,
  .table-card tr,
  .table-card td { display: block; width: 100%; }
  .table-card thead { display: none; }
  .table-card tbody tr {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
  }
  .table-card tbody tr:hover {
    background: var(--bg-surface);
    box-shadow: var(--shadow-glow);
  }
  .table-card tbody tr:last-child td { border-bottom: none; }
  .table-card td {
    padding: 5px 0; border-bottom: none;
    display: flex; align-items: flex-start; gap: 8px;
  }
  .table-card td::before {
    content: attr(data-label);
    font-size: 11px; font-weight: 600;
    color: var(--text-faint);
    text-transform: uppercase; letter-spacing: .05em;
    min-width: 90px; flex-shrink: 0; padding-top: 1px;
  }
  .table-card td:first-child { font-size: 14px; font-weight: 600; }
  .table-card td:first-child::before { display: none; }

  /* ── Detail tables inside panels — horizontal scroll ── */
  .card > .table-card,
  .card > table { overflow-x: auto; }
}

/* Modal overlay for HTMX dialogs */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-content {
  background: var(--color-bg, #fff);
  border-radius: var(--radius-lg, 12px);
  padding: 24px;
  max-width: 580px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.form-col .form-group {
  margin-bottom: 0;
}
