/* ===========================
   TrọBill — style.css
   =========================== */

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

:root {
  /* Light Theme (Default) */
  --bg: #f8fafc;
  --bg2: #ffffff;
  --bg3: #f1f5f9;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #4f46e5;
  --primary-d: #4338ca;
  --primary-light: rgba(79, 70, 229, 0.1);
  --electric: #d97706;
  --water: #0891b2;
  --wifi: #7c3aed;
  --green: #16a34a;
  --red: #dc2626;
  --danger: #dc2626;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(0, 0, 0, .04);
  --transition: .18s ease;
}

[data-theme="dark"] {
  /* Dark Theme */
  --bg: #0f1117;
  --bg2: #161b27;
  --bg3: #1e2535;
  --bg-card: #161b27;
  --border: #2a3148;
  --text: #e8eaf0;
  --text-muted: #8892a4;
  --primary: #6c63ff;
  --primary-d: #574fd6;
  --primary-light: rgba(108, 99, 255, 0.15);
  --electric: #f59e0b;
  --water: #06b6d4;
  --wifi: #a78bfa;
  --green: #10b981;
  --red: #ef4444;
  --danger: #ef4444;
  --shadow: 0 4px 24px rgba(0, 0, 0, .45);
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg2);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ===========================
   NAV
   =========================== */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg2);
  opacity: 0.97;
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top, 0px);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-icon {
  font-size: 1.4rem;
}

.brand-name {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--primary);
  letter-spacing: -.5px;
}

.nav-tabs {
  display: flex;
  gap: 4px;
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .78rem;
  font-weight: 600;
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}

.nav-tab .tab-icon {
  font-size: 1.1rem;
}

.nav-tab:hover {
  color: var(--text);
  background: var(--bg3);
}

.nav-tab.active {
  color: var(--primary);
  background: var(--primary-light);
}

.btn-theme-toggle {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), transform var(--transition);
  color: var(--text);
}

.btn-theme-toggle:hover {
  background: var(--bg3);
  transform: scale(1.08);
}

/* ===========================
   MAIN / PAGES
   =========================== */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 76px 20px 32px;
}

.page {
  display: none;
}

.page.active {
  display: block;
  animation: fadeIn .2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ----- Page Header ----- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -.5px;
}

.page-sub {
  font-size: .9rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ----- Period Switcher ----- */
.period-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
}

.period-label {
  font-weight: 700;
  font-size: 1rem;
  min-width: 76px;
  text-align: center;
}

.btn-icon {
  width: 30px;
  height: 30px;
  border: none;
  background: var(--bg3);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.15rem;
  font-weight: 700;
  transition: background var(--transition), color var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--primary);
  color: #fff;
}

/* ===========================
   CARDS
   =========================== */
.cards-grid {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 10px !important;
  margin-bottom: 20px;
}

@media (min-width: 769px) {
  .cards-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 16px !important;
  }
}

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 10px;
  position: relative;
  overflow: hidden;
  min-width: 0 !important;
  box-sizing: border-box;
  transition: transform var(--transition), border-color var(--transition);
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.card--primary::before {
  background: linear-gradient(90deg, var(--primary), #a78bfa);
}

.card--electric::before {
  background: var(--electric);
}

.card--water::before {
  background: var(--water);
}

.card--status::before {
  background: var(--green);
}

.card--danger::before {
  background: linear-gradient(90deg, #f97316, #ef4444);
}

.card-label {
  font-size: .75rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-value {
  font-size: clamp(1rem, 4vw, 1.25rem);
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-sub {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===========================
   SECTION HEADER
   =========================== */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
}

/* ===========================
   ROOM STATUS LIST
   =========================== */
.room-status-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.room-status-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: border-color var(--transition);
}

.room-status-item:hover {
  border-color: var(--primary);
}

.room-status-name {
  font-weight: 700;
  font-size: .95rem;
}

.room-status-total {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--primary);
}

.room-status-detail {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
  white-space: nowrap;
}

.badge--ok {
  background: rgba(16, 185, 129, .15);
  color: var(--green);
}

.badge--empty {
  background: rgba(136, 146, 164, .1);
  color: var(--text-muted);
}

.badge--paid {
  background: rgba(108, 99, 255, .15);
  color: var(--primary);
}

/* ===========================
   SETTINGS
   =========================== */
.settings-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: .85rem;
  color: var(--text-muted);
}

.settings-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-input {
  width: 130px;
  padding: 6px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: .85rem;
}

.inline-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ===========================
   ROOMS LIST
   =========================== */
.rooms-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.room-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  transition: border-color var(--transition);
}

.room-card:hover {
  border-color: var(--primary);
}

.room-card-info {
  flex: 1;
}

.room-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
  margin-bottom: 8px;
}

.room-card-name {
  font-size: 1.08rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}

.room-card-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: .84rem;
  color: var(--text-muted);
}

.room-detail-chip {
  background: var(--bg3);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: .82rem;
  font-weight: 500;
}

.room-card-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ===========================
   BILLING TABLE
   =========================== */
.billing-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.billing-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg2);
}

.billing-table th {
  padding: 12px 12px;
  text-align: left;
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.billing-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: .92rem;
  vertical-align: middle;
}

.billing-table th:first-child,
.billing-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--bg2);
  border-right: 1px solid var(--border);
}

.billing-table th:first-child {
  z-index: 11;
  background: var(--bg3);
}

/* Billing Table Property Separator Header Row */
.billing-property-header-row td {
  background: var(--bg3) !important;
  padding: 10px 14px !important;
  border-top: 2px solid var(--primary-light) !important;
  border-bottom: 1px solid var(--border) !important;
  position: sticky;
  left: 0;
  z-index: 9;
}

.billing-property-header-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.billing-property-header-title {
  font-weight: 800;
  font-size: 0.88rem;
  color: var(--primary);
  letter-spacing: 0.3px;
}

.billing-property-header-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.billing-table tr:last-child td {
  border-bottom: none;
}

.billing-table tr:hover td {
  background: var(--bg3);
}

.billing-table input[type="number"] {
  width: 100%;
  padding: 7px 9px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: .95rem;
  font-weight: 600;
  transition: border-color var(--transition);
  min-width: 84px;
}

.billing-table input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg);
}

.kwh-cell {
  font-weight: 700;
  color: var(--electric);
}

.total-cell {
  font-weight: 700;
  color: var(--green);
  white-space: nowrap;
}

.empty-cell {
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
}

/* Wifi toggle in billing */
.wifi-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: .82rem;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--border);
  border-radius: 20px;
  transition: .2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: .2s;
}

.toggle-switch input:checked+.toggle-slider {
  background: var(--wifi);
}

.toggle-switch input:checked+.toggle-slider::before {
  transform: translateX(16px);
}

.billing-legend {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  padding: 10px 4px;
  font-size: .85rem;
  color: var(--text-muted);
}

.billing-legend strong {
  color: var(--text);
}

/* ===========================
   REPORT CARDS
   =========================== */
.report-summary-bar {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.report-summary-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg3);
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.88rem;
  font-weight: 600;
  box-sizing: border-box;
}

.report-summary-val {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--primary);
}

.report-deduction-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.88rem;
}

.report-deduction-header {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.deduction-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.deduction-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}

.deduction-delete-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 0 0 2px;
  line-height: 1;
}

.btn-add-deduction-chip {
  background: transparent;
  border: 1px dashed var(--primary);
  color: var(--primary);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-add-deduction-chip:hover {
  background: rgba(37, 99, 235, 0.1);
}

.deduction-props-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 10px;
}

.deduction-prop-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-sizing: border-box;
  width: 100%;
}

.deduction-prop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.deduction-prop-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text);
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
}

.deduction-prop-total {
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--danger);
  white-space: nowrap;
  margin-left: auto;
}

.deduction-prop-items {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.report-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bill-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition);
}

.bill-card:hover {
  border-color: var(--primary);
}

.bill-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}

.bill-room-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.bill-total-big {
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--primary);
}

.bill-body {
  padding: 14px 18px;
}

.bill-rows {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 12px;
}

.bill-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  font-size: .9rem;
  gap: 8px;
}

.bill-row-label {
  color: var(--text-muted);
}

.bill-row-formula {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.bill-row-val {
  font-weight: 600;
  white-space: nowrap;
}

.bill-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}

.bill-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* ===========================
   HISTORY
   =========================== */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.property-history-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.property-history-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.15) 0%, rgba(124, 58, 237, 0.1) 100%);
  border-bottom: 1px solid var(--border);
}

.property-history-block-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.property-history-block-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.property-history-block-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-month-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.history-month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

.history-month-header:hover {
  background: var(--bg3);
}

.history-month-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.history-month-meta {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.history-month-total {
  font-weight: 800;
  color: var(--primary);
  font-size: 1.05rem;
}

.history-month-body {
  padding: 12px 18px;
  display: none;
}

.history-month-body.open {
  display: block;
}

.history-room-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(42, 49, 72, .4);
  font-size: .9rem;
}

.history-room-row:last-child {
  border-bottom: none;
}

.history-room-name {
  font-weight: 600;
}

.history-room-total {
  font-weight: 700;
  color: var(--green);
}

.history-badges {
  display: flex;
  gap: 6px;
}

.history-actions {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  justify-content: flex-end;
}

/* ===========================
   BUTTONS
   =========================== */
.btn {
  padding: 9px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn--primary {
  background: var(--primary);
  color: #fff;
}

.btn--primary:hover {
  background: var(--primary-d);
  transform: translateY(-1px);
}

.btn--ghost {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn--ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn--danger {
  background: rgba(239, 68, 68, .12);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, .3);
}

.btn--danger:hover {
  background: var(--red);
  color: #fff;
}

.btn--sm {
  padding: 6px 12px;
  font-size: .82rem;
}

.btn--paid {
  background: rgba(16, 185, 129, .12);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, .3);
}

.btn--paid.is-paid {
  background: var(--green);
  color: #fff;
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  font-weight: 600;
  text-decoration: underline;
}

/* ===========================
   MODAL
   =========================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, .75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn .15s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal {
  background: var(--bg2, #1e293b);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.15));
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  min-height: 420px;
  max-height: 88%;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  overflow: hidden;
  margin: auto;
  flex-shrink: 0;
}

#confirm-modal {
  z-index: 99999 !important;
}

#confirm-modal .modal,
#edit-old-modal .modal,
#donate-modal .modal {
  min-height: 160px !important;
  max-height: 80% !important;
}

/* Mobile Responsive Overlay Padding & Heights (Pure px & % - 100% vh/dvh-free) */
@media (max-width: 640px) {
  .modal-overlay {
    padding: 12px 12px 76px !important;
    align-items: center !important;
  }

  .modal {
    min-height: 400px !important;
    max-height: 85% !important;
    margin: auto !important;
  }

  #confirm-modal .modal,
  #edit-old-modal .modal,
  #donate-modal .modal {
    min-height: 160px !important;
    max-height: 80% !important;
    margin: auto !important;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg3);
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--red);
  color: #fff;
}

.modal-body {
  flex: 1 1 auto;
  min-height: 220px;
  overflow-y: auto;
  padding: 16px 20px;
  -webkit-overflow-scrolling: touch;
}

.modal-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1 1 auto;
  min-height: 220px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.help-section {
  margin-bottom: 12px;
  padding: 12px 14px;
  background: var(--bg3);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.help-section h3 {
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0 0 6px 0;
  color: var(--primary-light);
}

.help-section p {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row--2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row--3col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.form-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .3px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .9rem;
  color: var(--text);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}

.form-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-input {
  padding: 9px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: .9rem;
  transition: border-color var(--transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 4px;
  flex-shrink: 0;
}

/* ===========================
   EMPTY STATE
   =========================== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: .9rem;
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

/* ===========================
   TOAST
   =========================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: .88rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 100000;
  animation: fadeIn .2s ease;
  white-space: nowrap;
}

.toast[hidden] {
  display: none !important;
}

.toast--success {
  border-color: var(--green);
  color: var(--green);
}

.toast--error {
  border-color: var(--red);
  color: var(--red);
}

.toast--info {
  border-color: var(--primary);
  color: var(--primary);
}

/* ===========================
   PRINT AREA (hidden on screen)
   =========================== */
.print-area {
  display: none;
}

/* ===========================
   RESPONSIVE
   =========================== */
/* Bottom nav: hidden on desktop */
.bottom-nav {
  display: none;
}

#btn-open-auth-modal {
  white-space: nowrap !important;
  flex-shrink: 0;
}

#auth-btn-label {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: middle;
}

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 960px) {
  #auth-btn-label {
    display: none !important;
  }

  #btn-open-auth-modal {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    padding: 0 !important;
    border-radius: 8px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
  }

  /* Ẩn tabs trên desktop-nav khi ở mobile, foldable & tablet */
  .nav-tabs--desktop {
    display: none !important;
  }

  /* Mở bottom nav */
  .bottom-nav {
    display: grid !important;
    grid-template-columns: repeat(6, 1fr);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--bg2);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.10);
    z-index: 200;
  }

  /* Tab styles trong bottom nav */
  .bottom-nav .nav-tab {
    height: 100%;
    border-radius: 0;
    padding: 4px 2px;
    justify-content: center;
    background: none !important;
  }

  .bottom-nav .nav-tab .tab-label {
    display: block !important;
    font-size: 0.58rem;
    margin-top: 2px;
    line-height: 1.2;
  }

  /* Đẩy nội dung lên để không bị bottom-nav che */
  .main {
    padding: calc(72px + env(safe-area-inset-top, 0px)) 16px calc(72px + env(safe-area-inset-bottom, 0px));
  }
}

/* Force bottom nav by JS overflow detection if needed on any custom screen */
body.force-bottom-nav .nav-tabs--desktop {
  display: none !important;
}

body.force-bottom-nav .bottom-nav {
  display: grid !important;
  grid-template-columns: repeat(6, 1fr);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(56px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--bg2);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.10);
  z-index: 200;
}

body.force-bottom-nav .main {
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
}

@media (max-width: 640px) {
  .form-row--2col,
  .form-row--3col {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
  }

  .period-switcher {
    align-self: flex-start;
  }
}

/* ===========================
   @MEDIA PRINT
   =========================== */
@media print {

  /* Hide everything */
  body>* {
    display: none !important;
  }

  /* Show only print area */
  .print-area {
    display: block !important;
    font-family: 'Inter', sans-serif;
    color: #111;
    background: #fff;
    padding: 0;
  }

  .print-header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid #ddd;
  }

  .print-header h1 {
    font-size: 20pt;
    margin-bottom: 4px;
  }

  .print-header p {
    font-size: 11pt;
    color: #555;
  }

  .print-summary {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 12px;
    background: #f5f5f5;
    border-radius: 6px;
  }

  .print-summary-item {
    flex: 1;
    min-width: 120px;
  }

  .print-summary-label {
    font-size: 8pt;
    color: #666;
    text-transform: uppercase;
    letter-spacing: .5px;
  }

  .print-summary-val {
    font-size: 13pt;
    font-weight: 700;
  }

  .print-bill {
    margin-bottom: 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-bill-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #f0f0f0;
    border-bottom: 1px solid #ddd;
    font-weight: 700;
  }

  .print-bill-header .room {
    font-size: 11pt;
  }

  .print-bill-header .total {
    font-size: 12pt;
    color: #4c46d6;
  }

  .print-bill-body {
    padding: 0;
  }

  .print-bill-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9pt;
  }

  .print-bill-table td {
    padding: 6px 14px;
    border-bottom: 1px solid #eee;
  }

  .print-bill-table tr:last-child td {
    border-bottom: none;
  }

  .print-bill-table .label {
    color: #555;
  }

  .print-bill-table .formula {
    color: #888;
    font-size: 8pt;
  }

  .print-bill-table .amount {
    text-align: right;
    font-weight: 600;
  }

  .print-footer {
    text-align: center;
    margin-top: 28px;
    font-size: 9pt;
    color: #888;
    padding-top: 12px;
    border-top: 1px solid #ddd;
  }

  @page {
    size: A4;
    margin: 16mm 14mm;
  }
}

/* ===========================
   OCR CAMERA MODULE
   =========================== */

/* Wrapper input + camera button trong billing table */
.ocr-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Nút camera nhỏ bên cạnh input số điện */
.btn-ocr {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: background var(--transition), transform var(--transition);
}

.btn-ocr:hover {
  background: var(--primary);
  color: #fff;
  transform: scale(1.1);
}

.btn-ocr:active {
  transform: scale(0.95);
}

/* Modal OCR: wider để chứa camera */
.ocr-modal-inner {
  max-width: 560px;
  width: calc(100% - 32px);
}

/* Video wrapper với guide box overlay */
.ocr-video-wrap {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 16/9;
  margin-top: 6px;
  margin-bottom: 12px;
}

.ocr-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: move;
}

/* Khung ngắm màu đỏ ở giữa video/canvas */
.ocr-guide-box {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60%;
  height: 15.3%;
  border: 2.5px solid #ff3b3b;
  border-radius: 6px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.38);
  pointer-events: none;
}

.ocr-guide-box::before,
.ocr-guide-box::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: #ff3b3b;
  border-style: solid;
}

.ocr-guide-box::before {
  top: -3px;
  left: -3px;
  border-width: 3px 0 0 3px;
  border-radius: 4px 0 0 0;
}

.ocr-guide-box::after {
  bottom: -3px;
  right: -3px;
  border-width: 0 3px 3px 0;
  border-radius: 0 0 4px 0;
}

.ocr-guide-hint {
  position: absolute;
  bottom: 8px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

/* Controls row (Zoom & Invert) */
.ocr-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.ocr-zoom-container {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 200px;
}

.ocr-zoom-slider {
  flex: 1;
  cursor: pointer;
}

/* Cropped Image preview styles */
.ocr-crop-preview-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  background: var(--bg3);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
}

.ocr-crop-preview-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.ocr-crop-canvas {
  height: 35px;
  width: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  display: block;
}

/* Hàng kết quả OCR */
.ocr-result-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.ocr-result-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.ocr-result-input {
  width: 130px;
  padding: 6px 10px;
  font-size: 1.1rem;
  font-weight: 700;
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  text-align: center;
}

.ocr-result-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Status text */
.ocr-status {
  min-height: 1.4em;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

/* Action buttons row */
.ocr-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Green success button variant */
.btn--success {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.btn--success:hover {
  filter: brightness(1.1);
}

.btn--success:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

/* ============================================================
   TENANTS MANAGEMENT & CCCD QR SCANNER (CR3)
   ============================================================ */
.tenants-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 4px;
}

.tenant-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  gap: 12px;
  transition: border-color var(--transition);
}

.tenant-item:hover {
  border-color: var(--primary);
}

.tenant-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.tenant-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tenant-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

#tenant-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

#cccd-qr-reader {
  position: relative;
  width: 100%;
  aspect-ratio: 1/1;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border);
}

#cccd-qr-reader video {
  object-fit: cover !important;
  width: 100% !important;
  height: 100% !important;
}

/* Edit Old Meter Reading Button & Monthly Bill Note */
.btn-edit-old {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 1px 3px;
  border-radius: 4px;
  opacity: 0.7;
  transition: opacity 0.2s, background 0.2s;
}

.btn-edit-old:hover {
  opacity: 1;
  background: rgba(127, 127, 127, 0.15);
}

.bill-note-input {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.8rem;
  width: 110px;
  transition: border-color 0.2s;
}

.bill-note-input:focus {
  outline: none;
  border-color: var(--primary);
}

.report-bill-note {
  font-size: 0.82rem;
  color: var(--primary);
  background: rgba(59, 130, 246, 0.08);
  padding: 6px 10px;
  border-radius: 6px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Responsive Navigation Bar for Mobile vs Desktop */
@media (max-width: 640px) {
  .nav-tabs--desktop {
    display: none !important;
  }

  .bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    justify-content: space-around;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    backdrop-filter: blur(12px);
  }

  .bottom-nav .nav-tab {
    flex: 1;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 2px;
  }

  .bottom-nav .tab-icon {
    font-size: 1.15rem;
  }
}

@media (min-width: 641px) {
  .bottom-nav {
    display: none !important;
  }

  .nav-tabs--desktop {
    display: flex !important;
    gap: 4px;
    align-items: center;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  .nav-tabs--desktop::-webkit-scrollbar {
    display: none;
  }
}

/* Tablet Mini / Foldable / Medium Screen (641px to 959px): Icon-on-top, Text-below vertical stack */
@media (min-width: 641px) and (max-width: 959px) {
  .nav-inner {
    padding: 0 10px !important;
    gap: 6px !important;
    height: 56px !important;
  }

  .nav-brand {
    gap: 4px !important;
  }

  .brand-name {
    font-size: 0.98rem !important;
  }

  .property-select {
    max-width: 115px !important;
    font-size: 0.75rem !important;
    padding: 3px 6px !important;
  }

  .nav-tabs--desktop .nav-tab {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 1px !important;
    padding: 3px 6px !important;
    font-size: 0.68rem !important;
    line-height: 1.1 !important;
    flex-shrink: 0;
  }

  .nav-tabs--desktop .nav-tab .tab-icon {
    font-size: 1.05rem !important;
  }
}

/* Large Desktop (960px+): Icon & Text side-by-side */
@media (min-width: 960px) {
  .nav-tabs--desktop .nav-tab {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 5px !important;
    padding: 6px 10px !important;
    font-size: 0.83rem !important;
    flex-shrink: 0;
  }

  .nav-tabs--desktop .nav-tab .tab-icon {
    font-size: 0.95rem !important;
  }
}

/* Ultra-Narrow Mobile Screen (width <= 380px) */
@media (max-width: 380px) {
  html {
    font-size: 14.5px;
  }

  .bottom-nav .nav-tab {
    font-size: 0.65rem;
    padding: 2px 1px;
  }

  .bottom-nav .tab-icon {
    font-size: 1rem;
  }
}

/* Room Card Responsive Layout (<768px): Full-width chips and clean vertical stacking */
@media (max-width: 768px) {
  .room-card {
    flex-direction: column;
    align-items: stretch;
    padding: 14px 16px;
    gap: 10px;
  }

  .room-card-info {
    width: 100%;
  }

  .room-card-details {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .room-card-actions {
    width: 100%;
    justify-content: flex-end;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
  }
}

/* ===========================
   PROPERTY SWITCHER & BADGES
   =========================== */
.property-switcher-wrap {
  display: flex;
  align-items: center;
  margin-left: 8px;
}

.property-select {
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 6px);
  padding: 5px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  max-width: 180px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.property-select:hover,
.property-select:focus {
  border-color: var(--primary);
}

.room-property-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary);
  border: 1px solid rgba(37, 99, 235, 0.2);
  margin-bottom: 6px;
}

.property-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.property-item-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.property-item-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===========================
   IN-APP GUIDE & TUTORIAL
   =========================== */
.help-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.help-section h3 {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 6px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.help-section p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.45;
}

/* ===========================
   PROPERTY COMPARISON CARD (QoL 2)
   =========================== */
.prop-comp-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.prop-comp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.prop-comp-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text);
}

.prop-comp-amount {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--primary);
}

.prop-comp-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
}

.prop-comp-progress-bg {
  width: 100%;
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}

.prop-comp-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--green));
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* MoMo Button & PayOS Modal Custom Styles */
.btn--momo {
  background: #a50064 !important;
  color: #ffffff !important;
  border: none !important;
  font-weight: 600;
  transition: background 0.18s ease, transform 0.1s ease;
}

.btn--momo:hover {
  background: #8e0055 !important;
  transform: translateY(-1px);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(79, 70, 229, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(79, 70, 229, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  display: inline-block;
  vertical-align: middle;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===========================
   AUTH SPLIT-PANEL MODAL (Landing Page Dark Glassmorphism Chrome)
   =========================== */
.auth-modal-card {
  max-width: 840px !important;
  padding: 0 !important;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 30px rgba(124, 58, 237, 0.15) !important;
  border-radius: 20px !important;
  background: #0f172a !important;
}

.auth-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 20;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.auth-close-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
}

.auth-close-btn:hover {
  color: #f8fafc;
  background: rgba(124, 58, 237, 0.3);
  border-color: rgba(124, 58, 237, 0.5);
  transform: rotate(90deg);
}

.auth-split-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 500px;
}

/* Left Panel: Purple -> Teal Gradient Glass */
.auth-left-panel {
  background: linear-gradient(135deg, #090d16 0%, #1e1b4b 50%, #2e1065 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  padding: 44px 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}

.auth-left-panel::before {
  content: '';
  position: absolute;
  top: -20%;
  left: -20%;
  width: 140%;
  height: 140%;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.15) 0%, transparent 60%);
  pointer-events: none;
}

.auth-left-panel::before {
  content: '';
  position: absolute;
  top: -50px;
  left: -50px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(124, 58, 237, 0.35);
  filter: blur(50px);
  pointer-events: none;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 28px;
}

.auth-brand-name {
  background: linear-gradient(135deg, #ffffff 0%, #a78bfa 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-hero-title {
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.4;
  margin-bottom: 28px;
  background: linear-gradient(135deg, #ffffff 0%, #ddd6fe 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #cbd5e1;
}

.auth-feature-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.check-icon {
  background: rgba(124, 58, 237, 0.25);
  color: #c084fc;
  border: 1px solid rgba(192, 132, 252, 0.35);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(16, 185, 129, 0.35);
}

/* Right Panel: Form Styling */
.auth-right-panel {
  padding: 40px 36px;
  background: #0f172a;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-header {
  margin-bottom: 24px;
}

.auth-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #f8fafc;
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 0.85rem;
  color: #94a3b8;
}

/* Form inputs & labels */
.auth-form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  width: 100%;
  box-sizing: border-box;
}

.auth-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
}

.auth-input {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 14px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: #f8fafc;
  font-family: inherit;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.auth-input:focus {
  outline: none;
  border-color: #a855f7;
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.25);
  background: rgba(30, 41, 59, 1);
}

#btn-toggle-password {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent !important;
  border: none !important;
  color: #94a3b8 !important;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
  transition: opacity 0.2s ease;
}

#btn-toggle-password:hover {
  opacity: 1;
}

/* Auth Buttons */
.auth-btn-primary {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%) !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  font-size: 0.95rem !important;
  border-radius: 10px !important;
  padding: 12px !important;
  width: 100% !important;
  border: none !important;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.4) !important;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 8px;
  transition: all 0.2s ease !important;
}

.auth-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.6) !important;
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 20px 0;
  color: #64748b;
  font-size: 0.8rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-divider span {
  padding: 0 12px;
}

.auth-btn-google {
  background: rgba(30, 41, 59, 0.6) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  color: #f8fafc !important;
  font-size: 0.9rem !important;
  font-weight: 600 !important;
  border-radius: 10px !important;
  padding: 11px !important;
  width: 100% !important;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s ease !important;
}

.auth-btn-google:hover {
  background: rgba(51, 65, 85, 0.8) !important;
  border-color: rgba(255, 255, 255, 0.25) !important;
}

.auth-footer-switch {
  margin-top: 20px;
  text-align: center;
  font-size: 0.85rem;
  color: #94a3b8;
}

.auth-footer-switch a {
  color: #c084fc;
  font-weight: 700;
  text-decoration: none;
  margin-left: 6px;
}

.auth-footer-switch a:hover {
  text-decoration: underline;
}

@media (max-width: 768px) {
  .auth-split-container {
    grid-template-columns: 1fr;
  }

  .auth-left-panel {
    display: none;
  }

  .auth-right-panel {
    padding: 30px 24px;
  }

  .auth-modal-card {
    max-width: 420px !important;
  }
}

/* Mobile Topbar Auth Icon Optimization */
@media (max-width: 640px) {
  #btn-open-auth-modal #auth-btn-label {
    display: none !important;
  }

  #btn-open-auth-modal {
    padding: 6px 8px !important;
    font-size: 0.95rem !important;
    min-width: 34px !important;
    height: 34px !important;
    justify-content: center !important;
    white-space: nowrap !important;
    border-radius: 8px !important;
  }
}

/* Room Status Badge Alignment Fix */
.room-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  line-height: 1.3;
  vertical-align: middle;
}

.room-status-badge.status-occupied {
  color: var(--green);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.room-status-badge.status-vacant {
  color: var(--red);
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

/* ============================================================
   NARROW SCREEN & FOLDABLE PHONE COMPATIBILITY FIXES (< 380px)
   ============================================================ */
@media (max-width: 380px) {

  /* Topbar Header Adjustments */
  .nav-brand {
    font-size: 0.9rem !important;
    gap: 4px !important;
  }

  #property-switcher {
    max-width: 125px !important;
    font-size: 0.72rem !important;
    padding: 3px 6px !important;
  }

  /* Property Block Header Layout */
  .property-history-block-header {
    padding: 10px 12px !important;
  }

  .property-history-block-title {
    font-size: 0.95rem !important;
  }

  .property-history-block-sub {
    font-size: 0.75rem !important;
  }

  /* Page Header Action Buttons Grid */
  .page-header-actions {
    width: 100% !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  .page-header-actions .btn {
    flex: 1 1 calc(50% - 4px) !important;
    font-size: 0.75rem !important;
    padding: 6px 6px !important;
    justify-content: center !important;
  }

  /* Report Card Footer Action Buttons (2x2 Grid) */
  .bill-footer {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .bill-footer .btn {
    width: 100% !important;
    padding: 6px 4px !important;
    font-size: 0.75rem !important;
    justify-content: center !important;
    text-align: center !important;
  }

  /* Report Card Inputs (Chiết khấu & Đã trả) */
  .report-card-input-row {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 6px !important;
  }

  .report-card-input-row label {
    font-size: 0.76rem !important;
    white-space: nowrap !important;
  }

  .report-card-input-row input {
    width: 95px !important;
    padding: 3px 6px !important;
    font-size: 0.78rem !important;
  }

  /* Room Card Header on Narrow Screens */
  .room-card-header {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  .room-card-actions {
    width: 100% !important;
    justify-content: flex-start !important;
    gap: 4px !important;
  }

  .room-card-actions .btn {
    padding: 4px 6px !important;
    font-size: 0.72rem !important;
  }

  /* Deductions Breakdown Card Padding */
  .deduction-prop-card {
    padding: 8px 10px !important;
  }

  .deduction-prop-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 2px !important;
  }

  /* Main Container Padding on Foldable screens */
  .main {
    padding: 64px 8px 80px !important;
  }

  /* Billing Card Narrow & Foldable Fixes (<380px) */
  .billing-cards-wrap {
    gap: 10px !important;
  }

  .billing-card {
    padding: 10px 10px !important;
  }

  .billing-card-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
  }

  .billing-card-total-box {
    text-align: left !important;
    width: 100% !important;
  }

  .billing-card-total-breakdown {
    font-size: 0.68rem !important;
  }

  .billing-card-label {
    font-size: 0.72rem !important;
  }

  .ocr-input-wrap {
    gap: 4px !important;
  }

  .btn-ocr {
    width: 28px !important;
    height: 28px !important;
    font-size: 0.8rem !important;
  }
}

/* ============================================================
   SPRINT V2.4 NEW FEATURES & UI COMPONENT STYLES
   ============================================================ */

/* 1. Pull-to-Refresh Indicator (Chỉ hiển thị khi đang swipe down) */
.ptr-indicator {
  display: none !important;
}

.ptr-indicator[hidden] {
  display: none !important;
}

.ptr-indicator.active {
  display: flex !important;
  position: fixed;
  top: calc(64px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg2);
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
  align-items: center;
  gap: 6px;
  z-index: 9999;
  animation: fadeIn 0.15s ease;
}

.ptr-spinning {
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

/* 2. View Mode Toggle (📊 Bảng / 📇 Thẻ) */
.view-toggle-wrap {
  display: flex;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.view-toggle-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-toggle-btn.active {
  background: var(--bg2);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* 3. Billing Entry Filter Tabs & Progress Bar */
.billing-filter-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.billing-filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg3);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.billing-filter-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.billing-filter-tab.active {
  background: var(--primary);
  color: #fff;
}

.billing-progress-container {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 180px;
  justify-content: flex-end;
}

.billing-progress-bar-wrap {
  width: 100px;
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.billing-progress-bar {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.billing-progress-text {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

/* 4. Card View Layout (Mobile Billing Card View) */
/* 4. Card View Layout (Mobile Billing Card View) */
.billing-cards-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.billing-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  min-width: 0;
}

.billing-card.entered {
  border-left: 4px solid var(--green);
}

.billing-card.pending {
  border-left: 4px solid var(--amber);
}

.billing-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.billing-card-room {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.billing-card-total-box {
  text-align: right;
  min-width: 0;
  max-width: 100%;
}

.billing-card-total {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary);
  white-space: nowrap;
}

.billing-card-total-breakdown {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: normal;
  margin-top: 2px;
  word-break: break-word;
  overflow-wrap: break-word;
}

.billing-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.billing-card-input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0 !important;
  width: 100%;
  box-sizing: border-box;
}

.billing-card-input-group .ocr-input-wrap {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 6px;
}

.billing-card-input-group .ocr-input-wrap input,
.billing-card-input-group .ocr-input-wrap .form-input {
  min-width: 0 !important;
  flex: 1 1 0% !important;
  width: 100%;
  box-sizing: border-box;
}

.billing-card-label {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.billing-card-calc-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  word-break: break-word;
}

.billing-card-services-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--bg3);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 4px;
  box-sizing: border-box;
  width: 100%;
}

.billing-card-row-full {
  grid-column: span 2;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

@media (max-width: 768px) {
  .billing-card {
    padding: 12px 12px;
  }

  .billing-card-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .billing-card-row-full {
    grid-column: span 1;
  }

  .billing-card-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
  }
}

/* 5. Actionable Alert Banners */
.dashboard-alert-banners {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.dashboard-alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.dashboard-alert-item:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.dashboard-alert-warning {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #d97706;
}

.dashboard-alert-danger {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #dc2626;
}

/* 6. Debt Ranking Board */
.debt-ranking-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.debt-ranking-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.debt-ranking-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.debt-ranking-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.debt-ranking-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.debt-ranking-item:hover {
  border-color: var(--red);
}

.debt-rank-badge {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 8px;
}

.debt-rank-1 {
  background: rgba(239, 68, 68, 0.2);
  color: var(--red);
}

.debt-rank-2 {
  background: rgba(245, 158, 11, 0.2);
  color: var(--amber);
}

.debt-rank-3 {
  background: rgba(99, 102, 241, 0.2);
  color: var(--primary);
}

/* 7. Collection Rate KPI Card */
.collection-rate-display {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 700;
}

.collection-rate-good {
  color: var(--green);
}

.collection-rate-warn {
  color: var(--amber);
}

.collection-rate-danger {
  color: var(--red);
}

/* 8. CH Play CTA Floating Pill */
.app-download-banner {
  position: fixed;
  z-index: 150;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (min-width: 961px) {
  .app-download-banner {
    bottom: 24px;
    right: 24px;
  }
}

@media (max-width: 960px) {
  .app-download-banner {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    right: 14px;
  }
}

body.force-bottom-nav .app-download-banner {
  bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
}

.app-download-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #7c3aed 0%, #4c1d95 100%);
  color: #ffffff !important;
  font-size: 0.92rem;
  font-weight: 700;
  border-radius: 9999px;
  text-decoration: none;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.45);
  border: 1px solid rgba(167, 139, 250, 0.35);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.app-download-cta-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(124, 58, 237, 0.65);
  background: linear-gradient(135deg, #8b5cf6 0%, #5b21b6 100%);
  color: #ffffff !important;
}

.app-download-cta-btn .play-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex-shrink: 0;
}

.app-download-close-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #94a3b8;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.app-download-close-btn:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
  transform: scale(1.1);
}

/* Quick Language Toggle Button on Topbar (ala Landing Page) */
.btn-top-lang-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  padding: 0 9px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  transition: all 0.2s ease;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
}

[data-theme="dark"] .btn-top-lang-toggle {
  background: rgba(124, 58, 237, 0.15);
  border-color: rgba(167, 139, 250, 0.35);
  color: #c4b5fd;
}

[data-theme="light"] .btn-top-lang-toggle {
  background: rgba(124, 58, 237, 0.08);
  border-color: rgba(124, 58, 237, 0.25);
  color: #6d28d9;
}

.btn-top-lang-toggle:hover {
  background: rgba(124, 58, 237, 0.25);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.btn-top-lang-toggle .lang-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.btn-top-lang-toggle .lang-flag svg {
  width: 18px;
  height: 12px;
  border-radius: 2px;
  display: block;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.btn-top-lang-toggle .lang-label {
  display: inline-block;
  line-height: 1;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Compact Top Header Download App Button (Desktop & Mobile) */
.btn-top-download-app {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: #ffffff !important;
  background: linear-gradient(135deg, #7c3aed 0%, #4c1d95 100%);
  border: 1px solid rgba(167, 139, 250, 0.4);
  border-radius: 8px;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(124, 58, 237, 0.35);
  transition: all 0.2s ease;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-top-download-app:hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #8b5cf6 0%, #5b21b6 100%);
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.55);
  color: #ffffff !important;
}

.btn-top-download-app .play-icon {
  flex-shrink: 0;
}

/* Responsive Topbar for Narrow Screens (<640px and <380px Foldable) */
@media (max-width: 640px) {
  .nav-inner {
    padding: 0 8px !important;
    gap: 4px !important;
  }
  .nav-brand {
    gap: 4px !important;
    font-size: 0.95rem !important;
  }
  .nav-brand .brand-name {
    font-size: 0.98rem !important;
  }
  .nav-brand .brand-icon {
    font-size: 1.15rem !important;
  }
  #property-switcher {
    max-width: 95px !important;
    font-size: 0.72rem !important;
    padding: 3px 4px !important;
    border-radius: 8px !important;
  }
  .nav-nav-wrap {
    gap: 4px !important;
  }
  .btn-top-lang-toggle {
    height: 29px !important;
    padding: 0 6px !important;
    font-size: 0.75rem !important;
    gap: 3px !important;
    border-radius: 8px !important;
  }
  .btn-top-lang-toggle .lang-flag svg {
    width: 15px !important;
    height: 10px !important;
  }
  .btn-theme-toggle {
    width: 29px !important;
    height: 29px !important;
    min-width: 29px !important;
    padding: 0 !important;
    font-size: 0.95rem !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
  }
  .btn-top-download-app {
    width: 29px !important;
    height: 29px !important;
    min-width: 29px !important;
    padding: 0 !important;
    border-radius: 8px !important;
    display: inline-flex;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
  }
  .btn-top-download-app .play-icon {
    width: 14px !important;
    height: 14px !important;
  }
  #btn-open-auth-modal {
    width: 29px !important;
    height: 29px !important;
    min-width: 29px !important;
    padding: 0 !important;
    border-radius: 8px !important;
    display: inline-flex;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
  }
  #btn-open-auth-modal #auth-btn-label {
    display: none !important;
  }
  #btn-open-auth-modal #auth-btn-icon {
    margin: 0 !important;
    font-size: 0.85rem !important;
  }
}

/* Feature #15 Narrow Screen Fix for Galaxy S20 Ultra & Z Fold (<412px) */
@media (max-width: 412px) {
  .room-card-details {
    font-size: clamp(0.75rem, 3.2vw, 0.84rem) !important;
  }
  .billing-card-grid {
    grid-template-columns: 1fr !important;
  }
  .billing-card-row-full {
    grid-column: span 1 !important;
  }
}

/* Premium IAP Card in Settings */
@media (max-width: 480px) {
  .premium-actions-wrap {
    width: 100%;
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .premium-actions-wrap .btn {
    width: 100%;
    justify-content: center;
    text-align: center;
    font-size: 0.76rem;
    padding: 6px 4px;
  }
}

/* Meter Override / Auto Badges */
.badge-edited {
  font-size: 0.65rem;
  font-weight: 700;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 4px;
  padding: 1px 5px;
  display: inline-block;
  line-height: 1.3;
  letter-spacing: 0.2px;
  vertical-align: middle;
}

[data-theme="light"] .badge-edited,
:root:not([data-theme="dark"]) .badge-edited {
  color: #d97706;
  background: rgba(217, 119, 6, 0.12);
  border-color: rgba(217, 119, 6, 0.3);
}

.badge-auto {
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0.85;
  display: inline-block;
  line-height: 1.3;
  vertical-align: middle;
}

/* ============================================================
   NATIVE ANDROID / IOS STRICT SUPPRESSION
   ============================================================ */
body.is-native-app #btn-open-auth-modal,
html.is-native-app #btn-open-auth-modal,
body.is-native-app #auth-modal,
html.is-native-app #auth-modal,
body.is-native-app .btn-top-download-app,
html.is-native-app .btn-top-download-app,
body.is-native-app #btn-top-download-app,
html.is-native-app #btn-top-download-app,
body.is-native-app .app-download-banner,
html.is-native-app .app-download-banner,
body.is-native-app #app-download-banner,
html.is-native-app #app-download-banner {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}