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

:root {
  --brand:    #6d28d9;
  --brand-dk: #4c1d95;
  --success:  #16a34a;
  --warn:     #d97706;
  --danger:   #dc2626;
  --bg:       #f8fafc;
  --surface:  #ffffff;
  --border:   #e2e8f0;
  --text:     #1e293b;
  --muted:    #64748b;
  --radius:   10px;
}

body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

a { color: var(--brand); text-decoration: none; }

/* ── Layout ── */
.page-center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.card        { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; width: 100%; max-width: 440px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card-wide   { max-width: 820px; }
.card-full   { max-width: 100%; }

header.top-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.top-bar .logo { font-size: 15px; font-weight: 700; color: var(--brand); display: flex; align-items: center; gap: 8px; }
.top-bar .phase-badge { font-size: 12px; background: #ede9fe; color: var(--brand); padding: 3px 10px; border-radius: 20px; font-weight: 600; }

/* ── Notification bell ── */
.notif-wrap { position: relative; margin-left: auto; margin-right: 10px; }
.notif-badge { position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.notif-panel { position: absolute; top: calc(100% + 8px); right: 0; width: 320px; max-height: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.12); overflow: hidden; z-index: 20; display: flex; flex-direction: column; }
.notif-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 700; }
.btn-link { background: none; border: none; color: var(--brand); font-size: 12px; font-weight: 600; cursor: pointer; padding: 0; }
.notif-list { overflow-y: auto; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: #f8fafc; }
.notif-item.notif-unread { background: #f5f3ff; }
.notif-title { font-size: 13px; font-weight: 700; }
.notif-body { font-size: 12px; color: var(--muted); margin-top: 2px; }
.notif-time { font-size: 11px; color: var(--muted); margin-top: 4px; }

.main-content { max-width: 900px; margin: 0 auto; padding: 32px 24px; }

/* ── Bottom nav (rep app) ── */
.bottom-nav { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); display: flex; z-index: 10; }
.bottom-nav a { flex: 1; text-align: center; padding: 10px 4px 8px; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.bottom-nav a.active { color: var(--brand); font-weight: 700; }

/* ── Typography ── */
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.subtitle { font-size: 13px; color: var(--muted); margin-top: 4px; }
.label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; display: block; }

/* ── Inputs ── */
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; font-size: 14px;
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(109,40,217,.12); }
.form-group { margin-bottom: 16px; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 20px; font-size: 14px; font-weight: 600; border-radius: 8px; border: none; cursor: pointer; transition: opacity .15s, transform .1s; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary   { background: var(--brand);   color: #fff; }
.btn-primary:hover   { background: var(--brand-dk); }
.btn-success   { background: var(--success); color: #fff; }
.btn-danger    { background: var(--danger);  color: #fff; }
.btn-outline   { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-sm        { padding: 6px 14px; font-size: 13px; }
.btn-icon      { padding: 7px; border-radius: 6px; }
.btn-block     { width: 100%; justify-content: center; }

/* ── Status badges ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.badge-awaiting_applicant { background: #fef9c3; color: #a16207; }
.badge-submitted          { background: #dbeafe; color: #1d4ed8; }
.badge-approved           { background: #dcfce7; color: #15803d; }
.badge-executed           { background: #dcfce7; color: #15803d; }
.badge-rejected           { background: #fee2e2; color: #b91c1c; }
.badge-disputed           { background: #fee2e2; color: #b91c1c; }
.badge-cancelled          { background: #f1f5f9; color: #64748b; }

/* ── Stat cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card  { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-value { font-size: 32px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-card.vacant   { border-color: #fed7aa; }
.stat-card.occupied { border-color: #bfdbfe; }
.stat-card.paid     { border-color: #bbf7d0; }
.stat-card.unpaid   { border-color: #fecaca; }

/* ── Table / List ── */
.table-wrap  { overflow-x: auto; }
table        { width: 100%; border-collapse: collapse; font-size: 13px; }
th           { text-align: left; padding: 10px 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 2px solid var(--border); background: #f8fafc; }
td           { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td  { background: #f8fafc; }

/* ── Household list item ── */
.hh-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.hh-item:last-child { border-bottom: none; }
.hh-number { font-weight: 700; font-size: 15px; }
.hh-meta   { flex: 1; }
.hh-meta .street { font-size: 13px; color: var(--muted); }
.hh-right  { text-align: right; font-size: 13px; color: var(--muted); }

/* ── Occupant repeater ── */
.occupant-row { display: grid; grid-template-columns: 1fr 1fr 28px; gap: 8px; align-items: center; margin-bottom: 8px; }
.btn-remove   { color: var(--danger); background: none; border: none; cursor: pointer; font-size: 18px; padding: 0 4px; }

/* ── Alert ── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-warn    { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-danger  { background: #fff1f2; border: 1px solid #fecdd3; color: #9f1239; }

/* ── Spinner ── */
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .6s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast { padding: 12px 18px; border-radius: 8px; font-size: 13px; font-weight: 500; color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.15); animation: toast-in .2s ease; }
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-info    { background: var(--brand); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Section header ── */
.section-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

/* ── Photo preview ── */
.photo-preview { width: 96px; height: 96px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); }

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

.hidden { display: none !important; }
.mt-4 { margin-top: 16px; }
.mt-2 { margin-top: 8px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--muted); }
.w-full { width: 100%; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
  .main-content { padding: 16px; }
  .input, select.input, textarea.input { font-size: 16px; }
  .occupant-row { grid-template-columns: 1fr 1fr 28px; }
}
