/* Baro House — Tòa nhà 316 MVP */
:root {
  --primary: #6D28D9;
  --primary-light: #8B5CF6;
  --primary-dark: #5B21B6;
  --primary-bg: #F5F3FF;
  --primary-border: #DDD6FE;
  --success: #059669;
  --success-bg: #ECFDF5;
  --warning: #D97706;
  --warning-bg: #FFFBEB;
  --danger: #DC2626;
  --danger-bg: #FEF2F2;
  --info: #0284C7;
  --info-bg: #F0F9FF;
  --vacant: #EF4444;
  --vacant-bg: #FEE2E2;
  --deposit: #EA580C;
  --deposit-bg: #FFF7ED;
  --purple-badge: #7C3AED;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --text: #0F172A;
  --text-muted: #64748B;
  --sidebar-w: 260px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, 0.12);
  --font: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: #3b2f2a;
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  padding: 1.5rem 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}

.sidebar-brand h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-brand .sub {
  font-size: 0.85rem;
  opacity: 0.85;
  margin-top: 0.15rem;
}

.sidebar-brand .meta {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-top: 0.5rem;
  padding: 0.35rem 0.6rem;
  background: rgba(255,255,255,0.12);
  border-radius: 6px;
  display: inline-block;
}

.nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  text-align: left;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  width: 100%;
}

.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: #5c463c; color: #fff; font-weight: 600; }
.nav-item .icon { font-size: 1.15rem; width: 1.4rem; text-align: center; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  font-size: 0.7rem;
  opacity: 0.55;
  border-top: 1px solid rgba(255,255,255,0.1);
}

/* ── Main ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

.topbar h2 { font-size: 1.2rem; font-weight: 700; line-height: 1.25; margin: 0; }
.topbar .breadcrumb { color: var(--text-muted); font-size: 0.85rem; }
.topbar .breadcrumb:empty,
.topbar .breadcrumb[hidden],
.topbar.is-building .breadcrumb { display: none !important; }

.topbar-left { min-width: 0; flex: 1; }
.topbar-title-block { min-width: 0; }

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text);
  padding: 0.25rem;
  flex-shrink: 0;
  order: 0;
}
.btn-back { order: 1; flex-shrink: 0; }
.topbar-title-block { order: 2; }

.topbar-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

/* Building tools dropdown */
.topbar-tools {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.topbar-tools-btn {
  min-width: 2.25rem;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 700;
}
.topbar-tools-btn:hover,
.topbar-tools.open .topbar-tools-btn {
  background: var(--primary-bg);
  border-color: var(--primary-border);
  color: var(--primary);
}
.topbar-tools-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 11.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
  padding: 0.35rem;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.topbar-tools-menu[hidden] { display: none !important; }
.topbar-tools-menu button {
  appearance: none;
  border: none;
  background: transparent;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 550;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.topbar-tools-menu button:hover {
  background: var(--primary-bg);
  color: var(--primary);
}

.topbar.is-building {
  gap: 0.5rem;
}
.topbar.is-building .topbar-bldg .addr-line { display: none; }

.content {
  padding: 1.5rem;
  flex: 1;
}

.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 550;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn:hover { background: #F1F5F9; }
.btn:active { transform: scale(0.98); }

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

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

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #FECACA;
}
.btn-danger:hover { background: #FEE2E2; }

.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.btn-xs { padding: 0.2rem 0.45rem; font-size: 0.75rem; border-radius: 6px; }

/* ── Cards / Stats ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
}

.stat-card .label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }
.stat-card .value { font-size: 1.5rem; font-weight: 700; margin-top: 0.2rem; color: var(--text); }
.stat-card .value.primary { color: var(--primary); }
.stat-card .value.success { color: var(--success); }
.stat-card .value.danger { color: var(--danger); }
.stat-card .value.warning { color: var(--warning); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.card-header h3 { font-size: 1rem; font-weight: 650; }
.card-body { padding: 1.25rem; }

/* ── Room map ── */
.floor-block { margin-bottom: 1.5rem; }

.floor-label {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.floor-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.room-tile {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.room-tile:hover {
  border-color: var(--primary-light);
  box-shadow: 0 4px 16px rgba(109, 40, 217, 0.15);
  transform: translateY(-1px);
}

.room-tile.vacant {
  background: var(--vacant-bg);
  border-color: #FCA5A5;
}

.room-tile.vacant:hover { border-color: var(--vacant); }

.room-tile.deposit {
  background: var(--deposit-bg);
  border-color: #FDBA74;
}

.room-tile .room-id {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.room-tile .room-tenant {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
  flex: 1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
  width: fit-content;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-vacant { background: #FEE2E2; color: #B91C1C; }
.badge-deposit { background: var(--deposit-bg); color: var(--deposit); }
.badge-purple { background: #EDE9FE; color: var(--purple-badge); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

/* ── Contract cards ── */
.contract-list {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scroll-snap-type: x mandatory;
}

.contract-card {
  min-width: 280px;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  scroll-snap-align: start;
  box-shadow: var(--shadow);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

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

.contract-card .code {
  font-size: 0.78rem;
  font-family: ui-monospace, monospace;
  color: var(--text-muted);
}

.contract-card .room-name {
  font-size: 1.15rem;
  font-weight: 700;
}

.contract-card .tenant-name { font-weight: 550; font-size: 0.9rem; }
.contract-card .phone { font-size: 0.8rem; color: var(--text-muted); }
.contract-card .dates { font-size: 0.8rem; color: var(--text-muted); }
.contract-card .rent { font-weight: 700; color: var(--primary); font-size: 0.95rem; }
.contract-card .actions { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.25rem; }

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.table-wrap table {
  min-width: 980px;
  width: 100%;
}
#tab-customers .card-body.table-wrap {
  padding-bottom: 0.75rem;
}
#tab-customers .table-wrap::-webkit-scrollbar {
  height: 10px;
}
#tab-customers .table-wrap::-webkit-scrollbar-thumb {
  background: #c4b5a5;
  border-radius: 999px;
}
#tab-customers .table-wrap::-webkit-scrollbar-track {
  background: #f1ebe6;
  border-radius: 999px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th, td {
  padding: 0.7rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #F8FAFC;
  white-space: nowrap;
}

tr:hover td { background: #F8FAFC; }

td input[type="number"],
td input[type="text"] {
  width: 100%;
  min-width: 80px;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

td input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.15);
}

.period-section { margin-bottom: 2rem; }

.period-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.period-header h3 { font-size: 1.05rem; font-weight: 650; }

.note-box {
  background: var(--primary-bg);
  border: 1px solid var(--primary-border);
  border-radius: 10px;
  padding: 0.85rem 1.1rem;
  font-size: 0.85rem;
  color: var(--primary-dark);
  margin-bottom: 1.25rem;
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}

.locked-period {
  opacity: 0.55;
  pointer-events: none;
  position: relative;
}

.locked-banner {
  background: #FEF3C7;
  border: 1px solid #FDE68A;
  color: #92400E;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

/* ── Detail panel / Modal ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.overlay.open { opacity: 1; visibility: visible; }

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 100vw);
  background: var(--surface);
  z-index: 210;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.panel.open { transform: none; }

.panel-header {
  padding: 1.15rem 1.35rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  background: var(--primary-bg);
}

.panel-header h2 { font-size: 1.2rem; font-weight: 700; }
.panel-header .sub { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.2rem; }

.panel-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 0.2rem;
}
.panel-close:hover { color: var(--text); }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.35rem;
}

.section {
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.section-title {
  padding: 0.7rem 1rem;
  background: #F8FAFC;
  font-weight: 650;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.section-title:hover { background: #F1F5F9; }
.section-body { padding: 1rem; }
.section.collapsed .section-body { display: none; }
.section-title .chevron { transition: transform 0.2s; color: var(--text-muted); }
.section.collapsed .section-title .chevron { transform: rotate(-90deg); }

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.kv-list { display: flex; flex-direction: column; gap: 0.5rem; }
.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.875rem;
}
.kv-row .k { color: var(--text-muted); }
.kv-row .v { font-weight: 550; text-align: right; }

.person-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  background: #F8FAFC;
  border-radius: 8px;
  margin-bottom: 0.4rem;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.person-chip .info { flex: 1; min-width: 0; }
.person-chip .name { font-weight: 600; font-size: 0.875rem; }
.person-chip .meta { font-size: 0.75rem; color: var(--text-muted); }

.asset-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.asset-tag {
  padding: 0.3rem 0.65rem;
  background: var(--primary-bg);
  color: var(--primary-dark);
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
}

.history-item {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.history-item:last-child { border-bottom: none; }
.history-item .period { font-weight: 600; }
.history-item .note { color: var(--text-muted); font-size: 0.8rem; }

/* ── Modal form ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal.open { opacity: 1; visibility: visible; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}

.modal-box {
  position: relative;
  background: var(--surface);
  border-radius: 14px;
  width: min(480px, 100%);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
}

.modal-box.modal-wide {
  width: min(560px, 100%);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.modal-box header {
  padding: 1.15rem 1.35rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-box header h3 { font-size: 1.05rem; font-weight: 700; }

.modal-box .modal-body {
  padding: 1.25rem 1.35rem;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  max-height: calc(90vh - 8.5rem);
}

.modal-box header,
.modal-box footer {
  flex-shrink: 0;
}

.form-hint {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.form-section-title {
  margin: 1.1rem 0 0.75rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}

.form-group input[readonly] {
  background: #f8fafc;
  color: var(--text-muted);
}

.form-group select:disabled {
  background: #f1f5f9;
  color: var(--text-muted);
  cursor: not-allowed;
}

.modal-box footer {
  padding: 1rem 1.35rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.15);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.add-room-helper {
  margin: 0 0 1rem;
  font-size: 0.8rem;
}

.default-asset-groups {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.asset-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 0.7rem 0.85rem 0.8rem;
}

.asset-group-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.55rem;
  cursor: pointer;
  user-select: none;
}

.asset-group-header input {
  width: auto;
  margin: 0;
  accent-color: var(--primary);
}

.asset-group-items {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 0.85rem;
}

.asset-item-label {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  line-height: 1.35;
  margin: 0;
}

.asset-item-label input {
  width: auto;
  margin: 0.15rem 0 0;
  flex-shrink: 0;
  accent-color: var(--primary);
}

@media (max-width: 520px) {
  .asset-group-items {
    grid-template-columns: 1fr;
  }
}

/* ── Vehicles ── */
.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.vehicle-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.vehicle-photo {
  height: 120px;
  background: linear-gradient(135deg, #EDE9FE, #F5F3FF);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--primary-light);
  border-bottom: 1px solid var(--border);
}

.vehicle-card .body { padding: 1rem; }
.vehicle-card .plate {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  letter-spacing: 0.04em;
}
.vehicle-card .meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.35rem; }

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: #1E293B;
  color: #fff;
  padding: 0.75rem 1.15rem;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 360px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}

.empty-state .emoji { font-size: 2.5rem; margin-bottom: 0.5rem; }

.total-row td {
  font-weight: 700;
  background: var(--primary-bg) !important;
  color: var(--primary-dark);
}

.deleted-row { opacity: 0.45; text-decoration: line-through; }

/* ── Mobile ── */
@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .content { padding: 1rem; }
  .topbar { padding: 0.75rem 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .room-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 99;
}

.sidebar-backdrop.open { display: block; }

.money { font-variant-numeric: tabular-nums; }


/* ── v2 additions: sub-tabs, chips, reports, CSV, bills ── */
.sub-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}
.sub-tab {
  background: transparent;
  border: none;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
}
.sub-tab:hover { background: var(--primary-bg); color: var(--primary); }
.sub-tab.active {
  background: #E67E22;
  color: #fff;
}
.sub-tab.active:hover { background: #D35400; color: #fff; }

.building-picker {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.building-picker select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  font-family: inherit;
  font-size: 0.875rem;
  background: var(--surface);
}

.deposit-banner {
  background: linear-gradient(135deg, #EDE9FE, #F5F3FF);
  border: 1px solid #DDD6FE;
  color: #5B21B6;
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.clickable-stats .filter-tile { cursor: pointer; transition: box-shadow 0.15s, transform 0.15s; }
.clickable-stats .filter-tile:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.clickable-stats .filter-tile.active {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.status-chip {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  line-height: 1.2;
}
.chip-empty { background: #FEE2E2; color: #B91C1C; }
.chip-renting { background: #DCFCE7; color: #15803D; }
.chip-deposit { background: #FEF3C7; color: #B45309; }
.chip-expiring { background: #FFEDD5; color: #C2410C; }
.chip-maint { background: #E2E8F0; color: #475569; }
.chip-overdue { background: #FEE2E2; color: #DC2626; }
.chip-ban { background: #EDE9FE; color: #6D28D9; }

.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 860px) {
  .report-grid { grid-template-columns: 1fr; }
}

.csv-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.search-bar {
  margin-bottom: 1rem;
}
.search-bar input {
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--surface);
}
.search-bar input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.badge.bill-state { white-space: nowrap; }

.bill-table input[type="number"],
.bill-table input[type="text"] {
  width: 72px;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.35rem;
  font-size: 0.8rem;
  font-family: inherit;
}
.bill-table input[type="text"] { width: 100px; }
.bill-table input:disabled { opacity: 0.55; background: #F8FAFC; }

.bill-check-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
  background: var(--surface);
}
.bill-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  margin: 0.65rem 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.bill-breakdown span {
  background: #F8FAFC;
  border-radius: 6px;
  padding: 0.2rem 0.45rem;
}

.bill-preview-header {
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border);
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.65rem;
  min-height: 180px;
  padding: 0.5rem 0.25rem;
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}
.bar-col .bar {
  width: 100%;
  max-width: 36px;
  background: linear-gradient(180deg, var(--primary), #8B5CF6);
  border-radius: 8px 8px 4px 4px;
  min-height: 4px;
}
.bar-label { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; }
.bar-val { font-size: 0.7rem; color: var(--primary); font-weight: 700; }

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.donut-svg {
  width: 140px;
  height: 140px;
}
.donut-seg {
  fill: transparent;
  stroke-width: 3.5;
}
.donut-legend { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; }
.donut-leg-item { display: flex; align-items: center; gap: 0.45rem; }
.donut-leg-item .swatch {
  width: 10px; height: 10px; border-radius: 3px; display: inline-block;
}

.vehicle-card.dup-warn {
  border-color: #F59E0B;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.period-section { margin-bottom: 1.5rem; }
.period-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}
.period-header h3 { font-size: 1.05rem; font-weight: 700; }
.locked-banner {
  background: #F1F5F9;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: 0.9rem;
}

.badge-maint { background: #E2E8F0; color: #475569; }


/* Clickable customer/room filter stat cards */
.stat-card.clickable {
  cursor: pointer;
  border: 2px solid transparent;
  background: var(--surface, #fff);
  text-align: left;
  font: inherit;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.stat-card.clickable:hover {
  border-color: #c4b5fd;
  box-shadow: 0 2px 8px rgba(109, 40, 217, 0.12);
}
.stat-card.clickable.active {
  border-color: var(--primary, #6D28D9);
  box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.15);
}


/* ── Hierarchy shell (MD building picker) ── */
.shell-pane { display: none; }
.shell-pane.active { display: block; animation: fadeIn 0.2s ease; }

.shell-sidebar {
  width: var(--sidebar-w);
  background: #3b2f2a;
  color: #fff;
  display: none;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
  transition: transform 0.25s ease;
}
.shell-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1.35rem 1.15rem 1.15rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.md-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #E67E22;
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.shell-brand-title { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.shell-brand-sub { font-size: 0.75rem; opacity: 0.65; margin-top: 0.1rem; }
.shell-nav {
  flex: 1;
  padding: 0.9rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  overflow-y: auto;
}
.shell-nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.82);
  cursor: pointer;
  text-align: left;
  font-weight: 500;
  width: 100%;
  transition: background 0.15s, color 0.15s;
}
.shell-nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.shell-nav-item.active {
  background: #5c463c;
  color: #fff;
  font-weight: 600;
}
.shell-nav-item .icon { width: 1.35rem; text-align: center; font-size: 1.05rem; }
.shell-sidebar-footer {
  padding: 1rem 1.15rem;
  font-size: 0.7rem;
  opacity: 0.5;
  border-top: 1px solid rgba(255,255,255,0.08);
}

body.mode-shell .sidebar { display: none !important; }
body.mode-shell .shell-sidebar { display: flex; }
body.mode-shell .main { margin-left: var(--sidebar-w); }

body.mode-building .shell-sidebar { display: none !important; }
body.mode-building .sidebar { display: flex; }

.btn-back {
  background: var(--primary-bg);
  color: var(--primary);
  border-color: var(--primary-border);
  font-weight: 600;
}
.btn-back:hover { background: var(--primary-border); }

.btn-accent {
  background: #E67E22;
  color: #fff;
  border: 1px solid #D35400;
  font-weight: 600;
}
.btn-accent:hover { background: #D35400; }
.btn-accent-outline {
  background: #fff;
  color: #E67E22;
  border: 1.5px solid #E67E22;
  font-weight: 600;
}
.btn-accent-outline:hover { background: #FFF7ED; }

.md-home-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.md-home-header-text { flex: 1 1 auto; min-width: 12rem; }
.md-home-header h3 {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.md-home-header p { margin-top: 0.25rem; }

.md-home-manager-filter {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 0 0 auto;
  min-width: 14rem;
  max-width: 100%;
}
.md-home-manager-filter label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}
.md-home-manager-filter select {
  appearance: none;
  -webkit-appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748B' d='M1.4 0.6L6 5.2 10.6.6 12 2 6 8 0 2z'/%3E%3C/svg%3E") no-repeat right 0.75rem center;
  background-size: 10px 7px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 2rem 0.55rem 0.85rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  min-width: 14rem;
  max-width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.md-home-manager-filter select:hover,
.md-home-manager-filter select:focus {
  border-color: #E67E22;
  outline: none;
  box-shadow: 0 0 0 3px rgba(230, 126, 34, 0.15);
}

.md-filter-tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.md-filter-tile--manager {
  cursor: default;
  pointer-events: none;
  border-style: dashed;
  background: #FAFBFC;
}
.md-filter-tile--manager.has-manager {
  border-style: solid;
  border-color: #5DADE2;
  background: #F7FBFE;
  box-shadow: 0 0 0 3px rgba(93, 173, 226, 0.14);
  pointer-events: none;
}
.md-filter-tile--manager.has-manager .sub {
  color: #2980B9;
}
.md-filter-tile--manager.is-empty .value.muted-dash {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 1.2rem;
  opacity: 0.7;
}
.md-filter-tile--manager.is-empty .sub.hint {
  color: var(--text-muted);
  font-weight: 500;
  opacity: 0.85;
}
.md-filter-tile--manager .label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.md-filter-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.95rem 1.1rem;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  width: 100%;
  color: inherit;
  font: inherit;
}
.md-filter-tile:hover {
  border-color: #E67E22;
  box-shadow: 0 4px 14px rgba(230, 126, 34, 0.12);
}
.md-filter-tile.active {
  border-color: #E67E22;
  box-shadow: 0 0 0 3px rgba(230, 126, 34, 0.18);
  background: #FFFBF7;
}
.md-filter-tile .label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}
.md-filter-tile .value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.md-filter-tile .sub {
  font-size: 0.88rem;
  font-weight: 600;
  color: #E67E22;
  line-height: 1.2;
  margin-top: 0.1rem;
}
.md-filter-tile.active .sub {
  color: #D35400;
}
.md-chip.rooms {
  background: #FFF7ED;
  color: #C2410C;
  border-color: #FDBA74;
}

.md-home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0 0 1.15rem;
}

.md-building-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.md-bldg-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 1.1rem 1.25rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}
.md-bldg-card:hover {
  border-color: #d4a574;
  box-shadow: 0 6px 18px rgba(59, 47, 42, 0.1);
  transform: translateY(-1px);
}
.md-bldg-code {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #1a1a1a;
  line-height: 1.1;
  margin-bottom: 0.25rem;
}
.md-bldg-addr {
  font-size: 0.92rem;
  color: #334155;
  margin-bottom: 0.55rem;
}
.md-bldg-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.md-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #F5F0EB;
  color: #5c463c;
  border: 1px solid #E8DFD6;
}
.md-chip.kv { background: #FFF7ED; color: #C2410C; border-color: #FED7AA; }
.md-chip.mgr { background: #F0FDF4; color: #166534; border-color: #BBF7D0; }
.md-chip.rate { background: #F8FAFC; color: #475569; border-color: #E2E8F0; }

.section-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0.5rem 0 0.75rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.85rem;
}
.card-grid-2 {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.nav-card {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  text-align: left;
  padding: 1.1rem 1.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  width: 100%;
  color: inherit;
}
.nav-card:hover {
  border-color: var(--primary-border);
  box-shadow: 0 6px 20px rgba(109, 40, 217, 0.12);
  transform: translateY(-1px);
}
.nav-card-icon {
  font-size: 1.6rem;
  width: 2.4rem;
  height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-bg);
  border-radius: 10px;
  flex-shrink: 0;
}
.nav-card strong { display: block; font-size: 1.05rem; color: var(--text); }
.nav-card .muted, .muted { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.15rem; }

.home-actions { margin-top: 1rem; }

.empty-hint {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  grid-column: 1 / -1;
}

@media (max-width: 860px) {
  body.mode-shell .shell-sidebar {
    transform: translateX(-100%);
  }
  body.mode-shell .shell-sidebar.open { transform: none; }
  body.mode-shell .main { margin-left: 0 !important; }
  .md-filter-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md-home-header { flex-direction: column; align-items: stretch; }
  .md-home-manager-filter select { min-width: 0; width: 100%; }
  .md-bldg-code { font-size: 1.55rem; }
}

@media (max-width: 520px) {
  .md-filter-tiles { grid-template-columns: 1fr; }
}



.vehicle-card.vehicle-moved {
  opacity: 0.72;
  border-style: dashed;
}


/* ── MD room map (Ô trạng thái) ── */
.md-room-stats {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 1.15rem;
}
@media (max-width: 1100px) {
  .md-room-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .md-room-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.md-room-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.85rem 0.95rem;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.md-room-stat:hover { border-color: #E67E22; }
.md-room-stat.active {
  border-color: #E67E22;
  box-shadow: 0 0 0 3px rgba(230, 126, 34, 0.18);
  background: #FFFBF7;
}
.md-room-stat.danger-tile.active,
.md-room-stat.danger-tile {
  /* Quá hạn tile can look reddish when active */
}
.md-room-stat.danger-tile.active {
  border-color: #DC2626;
  background: #FEF2F2;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}
.md-room-stat .n {
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.1;
  color: #0F172A;
}
.md-room-stat .lbl {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}
.md-room-stat.danger-tile .n { color: #DC2626; }

.md-floor-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 0.85rem;
  align-items: start;
  margin-bottom: 1.1rem;
}
.md-floor-num {
  font-size: 1.75rem;
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1.1;
  padding-top: 0.55rem;
  letter-spacing: -0.03em;
}
.md-floor-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding-top: 0.85rem;
  white-space: nowrap;
}
.md-floor-rooms {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}
.md-room-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(15,23,42,0.05), 0 4px 12px rgba(15,23,42,0.04);
  padding: 0.85rem 0.95rem 0.75rem;
  min-width: 148px;
  max-width: 200px;
  flex: 1 1 148px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: left;
  color: inherit;
  font: inherit;
}
.md-room-card:hover {
  border-color: #d4a574;
  box-shadow: 0 6px 18px rgba(59, 47, 42, 0.1);
  transform: translateY(-1px);
}
.md-room-code {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #0F172A;
  line-height: 1.15;
}
.md-room-tenant {
  font-size: 0.82rem;
  color: #334155;
  line-height: 1.3;
  min-height: 1.3em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.md-room-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.15rem;
}
.md-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 650;
  white-space: nowrap;
  line-height: 1.2;
}
.md-pill-renting { background: #DBEAFE; color: #1D4ED8; }
.md-pill-vacant { background: #374151; color: #fff; }
.md-pill-maint { background: #6B7280; color: #fff; }
.md-pill-new { background: #E5E7EB; color: #4B5563; }
.md-pill-expiring { background: #FCE7F3; color: #BE185D; }
.md-pill-overdue { background: #7F1D1D; color: #fff; }
.md-pill-renew { background: #FEF3C7; color: #B45309; }
.md-pill-ban { background: #E0E7FF; color: #3730A3; }
.md-pill-nohd { background: #F3F4F6; color: #374151; }
.md-pill-deposit { background: #DCFCE7; color: #166534; }

.btn-accent-primary {
  background: #E67E22 !important;
  color: #fff !important;
  border-color: #D35400 !important;
}
.btn-accent-primary:hover { background: #D35400 !important; }

.bldg-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2rem;
  height: 1.7rem;
  padding: 0 0.45rem;
  border-radius: 8px;
  background: #E67E22;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
}
.topbar-bldg {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}
.topbar-bldg .title-line {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}
.topbar-bldg .addr-line {
  display: none;
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 420px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 860px) {
  .topbar.is-building {
    padding: 0.65rem 0.85rem;
  }
  .topbar.is-building h2 {
    font-size: 1.05rem;
  }
  .topbar.is-building .btn-back {
    padding: 0.35rem 0.55rem;
    font-size: 0.82rem;
  }
  .topbar-tools-menu {
    min-width: 10.5rem;
  }
}

#roomLegend { display: none !important; }


/* ── MD contracts ── */
.md-deposit-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: #0f766e;
  color: #fff;
  border-radius: 12px;
  padding: 0.85rem 1.15rem;
  margin-bottom: 1rem;
  font-weight: 550;
  font-size: 0.92rem;
}
.md-deposit-bar .money { font-size: 1.15rem; font-weight: 700; }
.md-contract-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}
.md-contract-stats .md-cstat:nth-child(n+5) {
  /* second row aligns under first */
}
@media (max-width: 900px) {
  .md-contract-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.md-cstat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  padding: 0.85rem 0.95rem;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.md-cstat:hover { border-color: #E67E22; }
.md-cstat.active {
  border-color: #E67E22;
  box-shadow: 0 0 0 3px rgba(230, 126, 34, 0.18);
  background: #FFFBF7;
}
.md-cstat.danger-tile.active {
  border-color: #DC2626;
  background: #FEF2F2;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}
.md-cstat .n { font-size: 1.4rem; font-weight: 700; line-height: 1.1; }
.md-cstat .lbl { font-size: 0.78rem; color: var(--text-muted); }
.md-cstat.danger-tile .n { color: #DC2626; }

.md-contract-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.md-hd-card {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  background: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: transform 0.12s, box-shadow 0.15s;
}
.md-hd-card:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(15,23,42,0.08); }
.md-hd-card.tone-renew { background: #FFFBEB; border-color: #FDE68A; }
.md-hd-card.tone-new { background: #fff; }
.md-hd-card.tone-deposit { background: #ECFDF5; border-color: #A7F3D0; }
.md-hd-card.tone-overdue { background: #7F1D1D; border-color: #7F1D1D; color: #fff; }
.md-hd-card.tone-overdue .meta,
.md-hd-card.tone-overdue .link { color: rgba(255,255,255,0.85); }
.md-hd-card.tone-liquidated { background: #F8FAFC; opacity: 0.92; }
.md-hd-card.tone-ok { background: #fff; }
.md-hd-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}
.md-hd-title { font-size: 1.05rem; font-weight: 700; }
.md-hd-card .meta { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.2rem; line-height: 1.45; }
.md-hd-card .link {
  display: inline-block;
  margin-top: 0.65rem;
  color: #E67E22;
  font-weight: 650;
  font-size: 0.85rem;
}
.md-hd-card.tone-overdue .link { color: #FDE68A; }
.md-hd-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}
.md-hd-pill.renew { background: #FEF3C7; color: #B45309; }
.md-hd-pill.new { background: #E5E7EB; color: #4B5563; }
.md-hd-pill.deposit { background: #DCFCE7; color: #166534; }
.md-hd-pill.overdue { background: #FEE2E2; color: #991B1B; }
.md-hd-card.tone-overdue .md-hd-pill.overdue { background: rgba(255,255,255,0.2); color: #fff; }
.md-hd-pill.ok { background: #DBEAFE; color: #1D4ED8; }
.md-hd-pill.expiring { background: #FCE7F3; color: #BE185D; }
.md-hd-pill.ban { background: #E0E7FF; color: #3730A3; }
.md-hd-pill.liquidated { background: #E2E8F0; color: #475569; }


/* ── Nhân sự: khu vực filter + badge ── */
.emp-area-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0 1.25rem 0.75rem;
}
.emp-area-chip {
  border: 1px solid var(--border, #E2E8F0);
  background: #F8FAFC;
  color: #475569;
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 550;
  cursor: pointer;
  font-family: inherit;
}
.emp-area-chip:hover { background: #F1F5F9; }
.emp-area-chip.active {
  background: #EEF2FF;
  color: #4338CA;
  border-color: #C7D2FE;
}
.emp-area-badge {
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}


/* ── Pricing formulas page ── */
.formulas-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.formulas-page-header h3 {
  margin: 0 0 0.25rem;
  color: #5C3317;
  font-size: 1.25rem;
}
.formula-type-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.formula-type-tab {
  border: 1px solid #E8D5C4;
  background: #FFF9F5;
  color: #5C3317;
  border-radius: 999px;
  padding: 0.4rem 0.95rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.formula-type-tab:hover { background: #F5E6D8; }
.formula-type-tab.active {
  background: linear-gradient(135deg, #C45C26, #E07A3D);
  border-color: transparent;
  color: #fff;
}
.formula-section-card {
  background: #fff;
  border: 1px solid #E8D5C4;
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(92, 51, 23, 0.06);
  overflow: hidden;
}
.formula-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #F0E2D6;
  background: #FFF9F5;
}
.formula-card-header h3 { margin: 0; color: #5C3317; }
.formula-table { width: 100%; border-collapse: collapse; }
.formula-table th,
.formula-table td {
  padding: 0.7rem 1rem;
  text-align: left;
  border-bottom: 1px solid #F3E9DF;
  vertical-align: top;
}
.formula-table th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: #8B6914;
  background: #FFFCF9;
}
.formula-rate {
  font-weight: 600;
  color: #C45C26;
}
.formula-notes { font-size: 0.85rem; margin-top: 0.2rem; }
.formula-actions {
  white-space: nowrap;
  text-align: right;
}
.btn-danger-ghost {
  color: #B91C1C;
  border-color: #FECACA;
  background: #FEF2F2;
}
.btn-danger-ghost:hover { background: #FEE2E2; }
.formula-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}
@media (max-width: 720px) {
  .formula-overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.formula-mini-card {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-align: left;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid #E8D5C4;
  background: #fff;
  cursor: pointer;
  font: inherit;
  color: #5C3317;
}
.formula-mini-card .label { font-size: 0.85rem; color: #8B6914; }
.formula-mini-card .value { font-size: 1.35rem; font-weight: 700; color: #C45C26; }
.formula-mini-card .sub { font-size: 0.8rem; color: #9A7B5A; }
.formula-mini-card.active {
  border-color: #C45C26;
  background: #FFF4EC;
  box-shadow: 0 0 0 2px rgba(196, 92, 38, 0.15);
}
.formula-pick {
  display: block;
  width: 100%;
  font-size: 0.9rem;
  min-width: 0;
}


/* ── Login gate ── */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background:
    radial-gradient(ellipse at top, rgba(245, 166, 35, 0.18), transparent 55%),
    linear-gradient(160deg, #2c241f 0%, #3b2f2a 45%, #1f1a17 100%);
}
.login-screen[hidden] { display: none !important; }

.login-card {
  width: 100%;
  max-width: 440px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  padding: 2.25rem 1.5rem 1.75rem;
}

.login-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-logo {
  display: block;
  width: min(280px, 88%);
  height: auto;
  margin: 0 auto 0.85rem;
  object-fit: contain;
}
.login-subtitle {
  font-size: 1.05rem;
  font-weight: 500;
  color: #4A4A4A;
  letter-spacing: 0.01em;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.login-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: #4A4A4A;
  margin-top: 0.55rem;
}
.login-input {
  width: 100%;
  font-size: 16px;
  line-height: 1.35;
  min-height: 3rem;
  padding: 0.95rem 1rem;
  border: 1.5px solid #D0D0D0;
  border-radius: 10px;
  color: #4A4A4A;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-input:focus {
  border-color: #F5A623;
  box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.22);
}
.login-password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.login-password-wrap .login-input {
  padding-right: 4.25rem;
}
.login-toggle-pw {
  position: absolute;
  right: 0.45rem;
  border: none;
  background: transparent;
  color: #F5A623;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
}
.login-toggle-pw:hover { background: rgba(245, 166, 35, 0.12); }

.login-error {
  margin-top: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  background: #FEF2F2;
  color: #DC2626;
  font-size: 0.85rem;
  font-weight: 500;
}
.login-error[hidden] { display: none !important; }

.login-submit {
  margin-top: 1rem;
  width: 100%;
  padding: 1.05rem 1rem;
  background: #F5A623 !important;
  border-color: #E09812 !important;
  color: #fff !important;
  font-weight: 700;
  font-size: 1.1rem;
  border-radius: 10px;
}
.login-submit:hover { background: #FFB800 !important; border-color: #F5A623 !important; }

.login-hint {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.75rem;
  color: #888;
}

body.logged-out .shell-sidebar,
body.logged-out .sidebar,
body.logged-out .main,
body.logged-out .sidebar-backdrop,
body.logged-out #panelOverlay,
body.logged-out #roomPanel,
body.logged-out #modal,
body.logged-out #toasts {
  visibility: hidden !important;
  pointer-events: none !important;
}

.sidebar-footer,
.shell-sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  align-items: stretch;
}
.sidebar-user {
  font-size: 0.78rem;
  font-weight: 600;
  opacity: 0.9;
  color: #fff;
  line-height: 1.3;
  word-break: break-word;
}
.btn-logout {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8rem;
  text-align: center;
  transition: background 0.15s;
}
.btn-logout:hover { background: rgba(245, 166, 35, 0.35); border-color: #F5A623; }
.sidebar-footer-meta {
  font-size: 0.68rem;
  opacity: 0.5;
}


/* ── Sidebar brand logos ── */
.shell-sidebar-brand {
  justify-content: center;
  padding: 1.1rem 1rem 1rem;
}
.shell-brand-logo {
  display: block;
  width: 100%;
  max-width: 180px;
  height: auto;
  max-height: 64px;
  object-fit: contain;
  margin: 0 auto;
  filter: brightness(1.05);
}
.sidebar-brand-logo {
  display: block;
  height: 32px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  margin-bottom: 0.55rem;
}


/* Login — mobile: fill width, bigger tap targets */
@media (max-width: 720px) {
  .login-screen {
    align-items: stretch;
    padding: 0.75rem;
  }
  .login-card {
    max-width: none;
    width: 100%;
    margin: auto 0;
    border-radius: 18px;
    padding: 1.75rem 1.25rem 1.5rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  }
  .login-logo {
    width: min(320px, 92%);
  }
  .login-subtitle {
    font-size: 1.15rem;
  }
  .login-label {
    font-size: 1.05rem;
    margin-top: 0.75rem;
  }
  .login-input {
    font-size: 18px;
    min-height: 3.35rem;
    padding: 1rem 1.1rem;
    border-radius: 12px;
  }
  .login-password-wrap .login-input {
    padding-right: 4.75rem;
  }
  .login-toggle-pw {
    font-size: 1rem;
    padding: 0.55rem 0.7rem;
  }
  .login-submit {
    margin-top: 1.25rem;
    min-height: 3.5rem;
    font-size: 1.2rem;
    padding: 1.1rem 1rem;
    border-radius: 12px;
  }
  .login-hint {
    font-size: 0.9rem;
    margin-top: 1.15rem;
  }
  .login-error {
    font-size: 1rem;
  }
}
@media (max-width: 420px) {
  .login-screen { padding: 0.5rem; }
  .login-card { padding: 1.5rem 1rem 1.35rem; border-radius: 14px; }
  .login-logo { width: 95%; }
}
