:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #f1f4f9;
  --line: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-2: #4338ca;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --gold: #b8860b;
  --gold-2: #d4af37;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, 0.14);
  --header-grad-a: #ffffff;
  --header-grad-b: #fbfcfe;
  --input-bg: #ffffff;
  --scrim: rgba(30, 41, 59, 0.45);
}

/* Dark theme overrides */
[data-theme="dark"] {
  --bg: #0f1720;
  --panel: #17222e;
  --panel-2: #1e2c3a;
  --line: #2a3a4a;
  --text: #e7eef5;
  --muted: #90a4b7;
  --primary: #6366f1;
  --primary-2: #4f46e5;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --gold: #d4af37;
  --gold-2: #f5d67b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
  --header-grad-a: #1a2632;
  --header-grad-b: #17222e;
  --input-bg: #1e2c3a;
  --scrim: rgba(6, 12, 18, 0.72);
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background 0.2s ease, color 0.2s ease;
}
img { max-width: 100%; }

.hidden { display: none !important; }
.muted { color: var(--muted); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 24px;
  background: linear-gradient(180deg, var(--header-grad-a), var(--header-grad-b));
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.04);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-banner {
  display: block;
  height: 46px;
  width: auto;
  object-fit: contain;
}
.brand-name {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.4px;
  white-space: nowrap;
  font-family: Georgia, 'Times New Roman', serif;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--gold);
}
.header-actions { display: flex; align-items: center; gap: 10px; }
.userbox {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}
.theme-toggle {
  padding: 7px 10px;
  font-size: 16px;
  line-height: 1;
}
@media (max-width: 560px) {
  .brand-name { display: none; }
}

main { max-width: 1080px; margin: 0 auto; padding: 24px 22px 40px; }

/* Buttons */
.btn {
  border: none; border-radius: 8px; padding: 9px 14px; cursor: pointer;
  font-size: 14px; font-weight: 600; transition: 0.15s;
}
.btn-primary { background: var(--primary); color: white; box-shadow: 0 1px 2px rgba(79,70,229,0.25); }
.btn-primary:hover { background: var(--primary-2); }
.btn-ghost { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--panel-2); border-color: #cbd5e1; }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--line); }
.btn-danger:hover { background: rgba(220,38,38,0.08); }
.btn-success { background: var(--green); color: #ffffff; }
.btn-success:hover { filter: brightness(1.08); }
.btn-success:disabled { opacity: 0.6; cursor: default; }
.btn-pay { background: rgba(217,119,6,0.15); color: var(--amber); border: 1px solid rgba(217,119,6,0.4); font-weight: 600; }
.btn-pay:hover { background: rgba(217,119,6,0.25); }
.btn-pay-confirm { background: var(--amber); color: #fff; border: none; border-radius: 8px; padding: 11px; font-size: 14px; font-weight: 600; cursor: pointer; flex: 1; transition: 0.15s; }
.btn-pay-confirm:hover { filter: brightness(1.08); }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }

/* Auth */
.auth-card {
  max-width: 420px; margin: 48px auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 30px;
  box-shadow: var(--shadow-lg);
}
.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab {
  flex: 1; padding: 9px; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--muted); border-radius: 8px; cursor: pointer; font-weight: 600;
}
.tab.active { background: var(--primary); color: white; border-color: var(--primary); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form h2 { margin: 0 0 6px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
input, select {
  background: var(--input-bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; color: var(--text); font-size: 14px; transition: 0.15s;
}
input::placeholder { color: #9aa7b8; }
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.15); }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.note-hint {
  font-size: 12.5px;
  color: var(--text);
  background: rgba(79, 70, 229, 0.06);
  border: 1px solid rgba(79, 70, 229, 0.2);
  border-radius: 8px;
  padding: 9px 12px;
  margin: 0 0 14px;
}
.note-hint strong { color: var(--primary); }
.error { color: var(--red); font-size: 13px; min-height: 18px; margin: 8px 0 0; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat-card .val { font-size: 21px; font-weight: 700; letter-spacing: -0.3px; }
.stat-card .label { color: var(--muted); font-size: 11px; margin-top: 3px; text-transform: uppercase; letter-spacing: 0.5px; }

/* Panels */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h3 { margin: 0; font-size: 15px; font-weight: 600; }

/* Collapsible area groups (All Payments) */
.area-group { padding-top: 6px; }
.area-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px 0;
  text-align: left;
  color: var(--text);
}
.area-toggle h3 { margin: 0; font-size: 15px; font-weight: 600; }
.area-chevron { color: var(--muted); font-size: 12px; transition: transform 0.15s; }
.area-meta { font-size: 12px; margin-left: auto; }
.area-body { margin-top: 12px; }
.area-group.collapsed .area-body { display: none; }
.area-group.collapsed .area-chevron { transform: rotate(-90deg); }
.grid-2 { display: grid; grid-template-columns: 1fr 1.2fr; gap: 20px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

/* Sub-tab navigation (landlord dashboard sections) */
.subtabs {
  display: flex;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 5px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.subtab {
  flex: 1;
  padding: 9px 14px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 7px;
  cursor: pointer;
  transition: 0.15s;
  white-space: nowrap;
}
.subtab:hover { color: var(--text); }
.subtab.active { background: var(--primary); color: #fff; }

.inline-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.inline-form.wrap { flex-wrap: wrap; }
.inline-form input, .inline-form select { flex: 1; min-width: 90px; }
.inline-form .field-inline { flex: 1; min-width: 130px; flex-direction: row; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.inline-form .field-inline input { flex: 1; }
/* Status selector buttons (Record a Payment) */
.status-group { display: flex; gap: 6px; }
.status-btn {
  flex: 1;
  min-width: 78px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
}
.status-btn:hover { color: var(--text); }
.status-btn.pending.active { background: rgba(245,158,11,0.18); color: var(--amber); border-color: var(--amber); }
.status-btn.partial.active { background: rgba(59,130,246,0.18); color: var(--primary); border-color: var(--primary); }
.status-btn.paid.active    { background: rgba(34,197,94,0.18);  color: var(--green); border-color: var(--green); }

/* Record Payment — row-based layout */
.payment-form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row .fld {
  flex: 1;
  min-width: 130px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}
.form-row .fld input, .form-row .fld select { width: 100%; }
.form-row-actions { align-items: center; }
.form-row-actions .status-group { flex: 1; }
.form-row-actions .btn-primary { min-width: 120px; }
.form-row-period { justify-content: center; gap: 24px; }

.bs-period { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bs-label { font-size: 12px; color: var(--muted); min-width: 62px; }
.bs-sel { min-width: 70px; }
.bs-sel:first-of-type { min-width: 80px; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px;
  cursor: pointer;
}
.list li:hover { background: var(--panel-2); }
.list li.active { border-color: var(--primary); background: var(--panel-2); }
.list .sub { font-size: 12px; color: var(--muted); }

/* Detail tree */
.detail-body { max-height: 460px; overflow: auto; }
.floor-block { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.floor-block h4 { margin: 0 0 8px; }
.unit-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; background: var(--panel-2); border-radius: 6px; margin-bottom: 6px;
}
.unit-row .meta { font-size: 12px; color: var(--muted); }

/* Table */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.table .kyc-phone { width: 100%; min-width: 130px; }

.badge { padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.paid { background: rgba(22,163,74,0.12); color: var(--green); }
.badge.pending { background: rgba(217,119,6,0.12); color: var(--amber); }
.badge.partial { background: rgba(79,70,229,0.12); color: var(--primary); }

/* ============================================================
   Tenant dashboard — unit cards + payment cards
   ============================================================ */

/* ============================================================
   Tenant dashboard — unit cards + payment cards (elegant)
   ============================================================ */

/* ── Unit cards ── */
.unit-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.tcard {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: box-shadow 0.18s, transform 0.18s;
}
.tcard:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.tcard-accent {
  width: 5px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--primary), var(--gold));
}
.tcard-body { flex: 1; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.tcard-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.tcard-location { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.tcard-area { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--primary); }
.tcard-sep { color: var(--line); font-size: 11px; }
.tcard-floor { font-size: 12px; color: var(--muted); }
.tcard-unit-name { font-size: 15px; font-weight: 700; color: var(--text); }
/* Floor + unit combined on one row */
.tcard-floor-unit { font-size: 15px; font-weight: 700; color: var(--text); }
/* Clickable card */
.tcard[role="button"] { cursor: pointer; }
.tcard[role="button"]:hover .tcard-contact-hint { opacity: 1; }
.tcard-contact-hint {
  margin-left: auto;
  font-size: 11px;
  color: var(--primary);
  opacity: 0.5;
  transition: opacity 0.15s;
}

/* Contact popup body */
.contact-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 14px;
}
.contact-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.contact-info { display: flex; flex-direction: column; gap: 6px; }
.contact-name { font-size: 17px; font-weight: 700; color: var(--text); }
.contact-row { font-size: 13px; color: var(--muted); }
.contact-link { color: var(--primary); text-decoration: none; font-weight: 600; }
.contact-link:hover { text-decoration: underline; }
.contact-actions { display: flex; gap: 10px; }
.contact-actions .btn { flex: 1; padding: 11px; font-size: 14px; }

.tcard-rent-badge {
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.tcard-rent-label { font-size: 10px; font-weight: 400; opacity: 0.8; margin-left: 2px; }
.tcard-divider { height: 1px; background: var(--line); }
.tcard-footer { display: flex; gap: 14px; flex-wrap: wrap; }
.tcard-meta-item { font-size: 12px; color: var(--muted); }

/* ── Payment cards ── */
.pay-cards { display: flex; flex-direction: column; gap: 12px; }
.pcard {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-left-width: 4px;
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: box-shadow 0.18s, transform 0.18s;
}
.pcard:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.pcard--paid    { border-left-color: var(--green); }
.pcard--partial { border-left-color: var(--amber); }
.pcard--pending { border-left-color: var(--muted); }
.pcard-inner { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.pcard-top { display: flex; align-items: center; justify-content: space-between; }
.pcard-loc { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pcard-area { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--primary); }
.pcard-sep  { color: var(--line); font-size: 11px; }
.pcard-middle { display: flex; align-items: baseline; justify-content: space-between; }
.pcard-period { font-size: 15px; font-weight: 700; color: var(--text); }
.pcard-amount { font-size: 26px; font-weight: 800; color: var(--text); letter-spacing: -0.8px; }
.pcard-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.pcard-chip {
  display: flex; flex-direction: column; gap: 1px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 10px; min-width: 64px;
}
.pcard-chip--elec { border-color: rgba(217,119,6,0.3); background: rgba(217,119,6,0.06); }
.pcard-chip-k { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.pcard-chip-v { font-size: 13px; font-weight: 700; color: var(--text); }
.pcard-meter {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid rgba(217,119,6,0.25);
  border-radius: 8px; padding: 8px 12px; flex-wrap: wrap;
}
.pcard-meter-icon { font-size: 14px; }
.pcard-meter-readings { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.pcard-meter-k { font-size: 11px; color: var(--muted); }
.pcard-meter-readings strong { font-weight: 700; color: var(--text); }
.pcard-meter-arrow { color: var(--amber); font-weight: 700; }
.pcard-meter-used { margin-left: 4px; font-size: 11px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 1px 8px; }
.pcard-paidon { font-size: 12px; font-weight: 600; color: var(--green); }

@media (max-width: 640px) {
  .unit-cards { grid-template-columns: 1fr; }
  .pcard-amount { font-size: 20px; }
  .tcard-rent-badge { font-size: 13px; }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  animation: overlayIn 0.15s ease;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px 24px 20px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  line-height: 1;
}
.modal-icon.danger { background: rgba(239, 68, 68, 0.15); color: var(--red); }
.modal-icon.success { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.modal-title { margin: 0 0 8px; font-size: 18px; font-weight: 700; }
.modal-message { margin: 0 0 14px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.modal-details {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: left;
  font-size: 13px;
  margin-bottom: 20px;
}
.modal-details .row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.modal-details .row .k { color: var(--muted); }
.modal-details .row .v { font-weight: 600; text-align: right; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; padding: 11px; }

/* Balances tab — professional tenant list */
.bal-list { display: flex; flex-direction: column; gap: 2px; padding: 4px 0; }
.bal-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s;
}
.bal-row:hover { background: var(--panel-2); }
.bal-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--gold));
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.bal-tenant { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.bal-info { display: flex; flex-direction: column; gap: 2px; }
.bal-name { font-size: 14px; font-weight: 600; color: var(--text); }
.bal-unit { font-size: 11px; color: var(--muted); }
.bal-figures { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bal-amounts { display: flex; align-items: center; gap: 6px; font-size: 12px; flex-wrap: wrap; }
.bal-billed { font-weight: 700; color: var(--text); }
.bal-sep { color: var(--line); }
.bal-paid-amt { color: var(--green); font-weight: 600; }
.bal-progress {
  height: 4px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}
.bal-bar {
  height: 100%;
  background: var(--green);
  border-radius: 99px;
  transition: width 0.3s ease;
}
.bal-badge { flex-shrink: 0; text-align: right; }

@media (max-width: 640px) {
  .bal-row { flex-wrap: wrap; gap: 8px; }
  .bal-tenant { min-width: 0; }
}

/* Electricity cell in balance detail modal */
.elec-cell { white-space: nowrap; font-size: 12px; }
.elec-row { display: flex; align-items: center; gap: 3px; }
.elec-p { font-weight: 700; color: var(--muted); }
.elec-c { font-weight: 700; color: var(--primary); }
.elec-arrow { color: var(--amber); margin: 0 3px; }
.elec-used { display: block; margin-top: 3px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 20px; padding: 1px 7px; color: var(--text); font-weight: 600; font-size: 11px; text-align: center; }

/* Wide detail modal (record lists) */
.modal-wide { max-width: 640px; text-align: left; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-head .modal-title { margin: 0; }
.modal-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.modal-body { max-height: 60vh; overflow: auto; }

/* Clickable rows (balances) */
.clickable-row { cursor: pointer; transition: background 0.12s; }
.clickable-row:hover { background: var(--panel-2); }
.modal-actions .btn-confirm-danger { background: var(--red); color: #fff; }
.modal-actions .btn-confirm-danger:hover { filter: brightness(1.08); }
.modal-actions .btn-confirm-success { background: var(--green); color: #ffffff; }
.modal-actions .btn-confirm-success:hover { filter: brightness(1.08); }

/* ============================================================
   Mobile / small screens
   ============================================================ */
@media (max-width: 640px) {
  main { padding: 14px 12px 32px; }

  /* Header: keep banner + controls, smaller and tidy */
  .topbar { padding: 8px 12px; gap: 8px; }
  .brand-banner { height: 34px; }
  .userbox { gap: 8px; font-size: 12px; }
  .userbox .btn { padding: 6px 9px; font-size: 12px; }
  #userLabel { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Stats: two per row instead of trying to fit five */
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 12px; }
  .stat-card .val { font-size: 18px; }

  /* Panels: less padding so content isn't cramped */
  .panel { padding: 14px; border-radius: 10px; }
  .panel-head { flex-wrap: wrap; gap: 8px; }
  .auth-card { margin: 20px auto; padding: 20px; }

  /* Forms: stack inputs full-width, easier to tap */
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form input,
  .inline-form select,
  .inline-form .btn { width: 100%; flex: 1 1 auto; min-width: 0; }
  .inline-form .field-inline { width: 100%; }

  /* Nepali BS period selects: full width, wrap neatly */
  .bs-period { width: 100%; gap: 6px; }
  .bs-label { width: 100%; min-width: 0; }
  .bs-sel { flex: 1; min-width: 0; }
  .bs-sel:first-of-type { min-width: 0; }

  /* Unit rows: stack the info and the action buttons */
  .unit-row { flex-direction: column; align-items: stretch; }
  .unit-row > div:last-child { display: flex; gap: 6px; flex-wrap: wrap; }
  .unit-row .btn { flex: 1; }

  /* Tables scroll horizontally; tighten cells so more fits */
  .table { font-size: 13px; }
  .table th, .table td { padding: 7px 8px; white-space: nowrap; }

  .detail-body { max-height: none; }

  /* Sub-tabs: allow horizontal scroll if they don't fit, keep them tidy. */
  .subtabs { overflow-x: auto; }
  .subtab { padding: 9px 12px; font-size: 13px; }

  /* Area group header wraps so the meta doesn't crowd the title. */
  .area-toggle { flex-wrap: wrap; gap: 6px 8px; }
  .area-meta { margin-left: 0; flex-basis: 100%; }

  /* Record Payment: stack fields full-width on phones. */
  .form-row .fld { flex-basis: 100%; min-width: 0; }
  .form-row-actions { flex-direction: column; align-items: stretch; }
  .form-row-actions .btn-primary { width: 100%; }
  .bs-period { width: 100%; }
}

/* Extra-small phones */
@media (max-width: 380px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .brand-banner { height: 30px; }
}
