/* ═══════════════════════════════════════════════════════════════════════════
   Rental CRM — Close.com-inspired modern design system
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ───────────────────────────────────────────────────────── */
:root {
  /* Sidebar */
  --sidebar-bg:           #0F172A;
  --sidebar-width:        240px;
  --sidebar-text:         #94A3B8;
  --sidebar-text-hover:   #F1F5F9;
  --sidebar-item-hover:   rgba(148,163,184,0.08);
  --sidebar-active-bg:    rgba(16,185,129,0.14);
  --sidebar-active-text:  #34D399;
  --sidebar-border:       rgba(148,163,184,0.1);

  /* App Chrome */
  --topbar-height:        56px;
  --topbar-bg:            #FFFFFF;
  --topbar-border:        #E2E8F0;
  --content-bg:           #F1F5F9;

  /* Accent */
  --accent:               #10B981;
  --accent-hover:         #059669;
  --accent-rgb:           16, 185, 129;

  /* Semantic colors */
  --color-danger:         #EF4444;
  --color-danger-bg:      #FEF2F2;
  --color-danger-border:  #FECACA;
  --color-warning:        #F59E0B;
  --color-warning-bg:     #FFFBEB;
  --color-warning-border: #FDE68A;
  --color-success:        #10B981;
  --color-success-bg:     #F0FDF4;
  --color-success-border: #A7F3D0;
  --color-info:           #3B82F6;
  --color-info-bg:        #EFF6FF;
  --color-info-border:    #BFDBFE;

  /* Text */
  --text-primary:         #0F172A;
  --text-secondary:       #475569;
  --text-muted:           #94A3B8;

  /* Surfaces */
  --border-color:         #E2E8F0;
  --card-bg:              #FFFFFF;
  --card-shadow:          0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --card-radius:          0.5rem;
  --input-radius:         0.375rem;

  /* Bootstrap variable overrides */
  --bs-font-sans-serif:   'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --bs-body-bg:           #F1F5F9;
  --bs-body-color:        #0F172A;
  --bs-border-color:      #E2E8F0;
  --bs-border-radius:     0.375rem;
  --bs-primary:           #10B981;
  --bs-primary-rgb:       16, 185, 129;
}

/* ── Base Reset ──────────────────────────────────────────────────────────── */
html { font-size: 14px; }

body {
  font-family: var(--bs-font-sans-serif);
  background-color: var(--content-bg);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LAYOUT SHELL
   ═══════════════════════════════════════════════════════════════════════════ */

.crm-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.crm-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(148,163,184,0.2) transparent;
}
.crm-sidebar::-webkit-scrollbar { width: 4px; }
.crm-sidebar::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.2); border-radius: 2px; }

/* Sidebar header (brand) */
.crm-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  height: var(--topbar-height);
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.crm-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
}

.crm-brand__icon {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.crm-brand__icon-svg {
  flex-shrink: 0;
  display: block;
}

.crm-brand__name {
  font-size: 13.5px;
  font-weight: 600;
  color: #F1F5F9;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.crm-brand__365 {
  color: #34D399;
  font-weight: 700;
}

.crm-sidebar__close {
  display: none;
  background: none; border: none; padding: 5px;
  color: var(--sidebar-text);
  cursor: pointer;
  border-radius: 5px;
  align-items: center; justify-content: center;
}
.crm-sidebar__close:hover { background: var(--sidebar-item-hover); color: var(--sidebar-text-hover); }

/* Sidebar navigation */
.crm-sidebar__nav {
  flex: 1;
  padding: 10px 0;
}

.crm-nav-section-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--sidebar-text);
  padding: 14px 16px 4px;
  opacity: 0.55;
}

.crm-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  margin: 1px 8px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  transition: background 0.12s, color 0.12s;
  user-select: none;
}
.crm-nav-item:hover {
  background: var(--sidebar-item-hover);
  color: var(--sidebar-text-hover);
  text-decoration: none;
}
.crm-nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}
.crm-nav-item.active .crm-nav-icon { opacity: 1; }
.crm-nav-icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
  opacity: 0.75;
}
.crm-nav-item:hover .crm-nav-icon { opacity: 1; }

.crm-nav-divider {
  height: 1px;
  background: var(--sidebar-border);
  margin: 6px 14px;
}

/* Sidebar footer (user area) */
.crm-sidebar__footer {
  border-top: 1px solid var(--sidebar-border);
  padding: 10px;
  flex-shrink: 0;
}

.crm-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 2px;
}

.crm-user__avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.crm-user__info {
  flex: 1;
  min-width: 0;
}

.crm-user__name {
  font-size: 12.5px;
  font-weight: 600;
  color: #E2E8F0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.crm-user__role {
  font-size: 11px;
  color: var(--sidebar-text);
  text-transform: capitalize;
  line-height: 1.2;
}

.crm-logout-btn {
  background: none;
  border: none;
  padding: 5px;
  color: var(--sidebar-text);
  cursor: pointer;
  border-radius: 5px;
  display: flex;
  align-items: center;
  transition: color 0.12s, background 0.12s;
  flex-shrink: 0;
}
.crm-logout-btn:hover {
  background: rgba(239,68,68,0.12);
  color: #F87171;
}

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

/* ── Top Bar ─────────────────────────────────────────────────────────────── */
.crm-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}

.crm-topbar__toggle {
  display: none;
  background: none; border: none;
  padding: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 5px;
  align-items: center; justify-content: center;
  transition: background 0.12s;
}
.crm-topbar__toggle:hover { background: #F1F5F9; color: var(--text-primary); }

.crm-topbar__right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.crm-topbar__greeting {
  font-size: 13.5px;
  color: var(--text-secondary);
}

.crm-topbar__greeting strong {
  color: var(--text-primary);
  font-weight: 600;
}

.crm-topbar__support-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
}
.crm-topbar__support-btn:hover { background: var(--accent-hover); color: #fff; }
.crm-topbar__support-btn svg  { flex-shrink: 0; }

/* ── Page Content ────────────────────────────────────────────────────────── */
.crm-content {
  flex: 1;
  padding: 24px;
}

/* Mobile overlay */
.crm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.6);
  z-index: 99;
  backdrop-filter: blur(2px);
}
.crm-overlay.active { display: block; }

/* ═══════════════════════════════════════════════════════════════════════════
   BOOTSTRAP COMPONENT OVERRIDES
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 12px 16px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-body { padding: 16px; }
.card-footer {
  background: transparent;
  border-top: 1px solid var(--border-color);
  padding: 12px 16px;
}

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table {
  --bs-table-bg:           transparent;
  --bs-table-hover-bg:     #F8FAFC;
  --bs-table-border-color: var(--border-color);
  font-size: 13.5px;
  margin-bottom: 0;
  color: var(--text-primary);
}

.table > thead > tr > th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  background: #F8FAFC;
  border-bottom: 1px solid var(--border-color);
  padding: 10px 14px;
  white-space: nowrap;
  vertical-align: middle;
}

.table > tbody > tr > td {
  padding: 10px 14px;
  vertical-align: middle;
  border-bottom: 1px solid #F1F5F9;
  color: var(--text-primary);
}

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

.table-bordered { border: none; }
.table-bordered > :not(caption) > * { border-width: 0; }
.table-bordered > :not(caption) > * > * { border-width: 0; }

.table-sm > :not(caption) > * > * { padding: 7px 12px; }
.table-sm > thead > tr > th { padding: 8px 12px; }

.table-responsive {
  border-radius: var(--card-radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--card-shadow);
  background: var(--card-bg);
}

.table-hover > tbody > tr:hover > * {
  --bs-table-color-state: var(--text-primary);
  background-color: #F8FAFC;
}

.table-light { --bs-table-bg: #F8FAFC; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  font-family: var(--bs-font-sans-serif);
  font-weight: 500;
  font-size: 13px;
  border-radius: 6px;
  padding: 6px 14px;
  line-height: 1.5;
  transition: all 0.12s ease;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.btn-sm {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 5px;
}

.btn-primary {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover, .btn-primary:focus {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.2);
}
.btn-primary:active { transform: translateY(1px); box-shadow: none; }

.btn-secondary {
  background-color: #475569;
  border-color: #475569;
  color: #fff;
}
.btn-secondary:hover { background-color: #334155; border-color: #334155; color: #fff; }

.btn-success {
  background-color: #059669;
  border-color: #059669;
  color: #fff;
}
.btn-success:hover { background-color: #047857; border-color: #047857; color: #fff; }

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

.btn-outline-primary {
  color: var(--accent);
  border-color: #A7F3D0;
  background: transparent;
}
.btn-outline-primary:hover {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-outline-secondary {
  color: var(--text-secondary);
  border-color: var(--border-color);
  background: #fff;
}
.btn-outline-secondary:hover {
  background-color: #F1F5F9;
  border-color: #CBD5E1;
  color: var(--text-primary);
}

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

.btn-outline-success {
  color: #059669;
  border-color: #A7F3D0;
  background: transparent;
}
.btn-outline-success:hover {
  background-color: #059669;
  border-color: #059669;
  color: #fff;
}

.btn-outline-warning {
  color: #D97706;
  border-color: var(--color-warning-border);
  background: transparent;
}
.btn-outline-warning:hover {
  background-color: #D97706;
  border-color: #D97706;
  color: #fff;
}

/* ── Form Controls ────────────────────────────────────────────────────────── */
.form-control,
.form-select {
  border-color: var(--border-color);
  border-radius: var(--input-radius);
  font-size: 13.5px;
  font-family: var(--bs-font-sans-serif);
  color: var(--text-primary);
  padding: 7px 12px;
  background: #fff;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
  outline: none;
}

.form-control-sm,
.form-select-sm {
  font-size: 12.5px;
  padding: 5px 10px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.form-text {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-control[readonly] { background: #F8FAFC; color: var(--text-secondary); }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
  border: none;
  border-radius: var(--card-radius);
  font-size: 13.5px;
  padding: 12px 16px;
  border-left: 3px solid transparent;
}
.alert-danger {
  background: var(--color-danger-bg);
  color: #7F1D1D;
  border-left-color: var(--color-danger);
}
.alert-warning {
  background: var(--color-warning-bg);
  color: #78350F;
  border-left-color: var(--color-warning);
}
.alert-success {
  background: var(--color-success-bg);
  color: #14532D;
  border-left-color: var(--color-success);
}
.alert-info {
  background: var(--color-info-bg);
  color: #1E3A5F;
  border-left-color: var(--color-info);
}
.alert a { color: inherit; font-weight: 600; }
.alert .btn-outline-danger { background: transparent; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.02em;
  font-family: var(--bs-font-sans-serif);
}

/* Status badge palette (pill style, light background + dark text) */
.badge-paid,
.badge-active,
.badge-resolved,
.badge-low      { background-color: #D1FAE5 !important; color: #065F46 !important; }

.badge-overdue,
.badge-urgent   { background-color: #FEE2E2 !important; color: #991B1B !important; }

.badge-pending,
.badge-high,
.badge-owner    { background-color: #FEF3C7 !important; color: #92400E !important; }

.badge-medium   { background-color: #EDE9FE !important; color: #5B21B6 !important; }

.badge-open,
.badge-admin    { background-color: #DBEAFE !important; color: #1E40AF !important; }

.badge-inprog   { background-color: #E0F2FE !important; color: #075985 !important; }

.badge-closed,
.badge-inactive { background-color: #F1F5F9 !important; color: #475569 !important; }

.badge-tenant   { background-color: #CCFBF1 !important; color: #0F766E !important; }

.badge-support  { background-color: #EDE9FE !important; color: #5B21B6 !important; }

.badge-auditor  { background-color: #F1F5F9 !important; color: #334155 !important; }

/* ── Elevated-access banner ──────────────────────────────────────────────────
   Deep red, sticky, above everything. This must read as "you are being recorded",
   not as a dismissible warning — reading another person's data should never feel
   like a normal session. */
.crm-elevation-banner {
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    background: #7F1D1D;
    color: #fff;
    font-size: 13px;
    line-height: 1.4;
}

.crm-elevation-banner__text { flex: 1; }

.crm-elevation-banner__form { margin: 0; }

/* ── Payment / ledger badge palette ─────────────────────────────────────── */
.badge-cleared  { background-color: #D1FAE5 !important; color: #065F46 !important; }
.badge-bounced  { background-color: #FEE2E2 !important; color: #991B1B !important; }
.badge-partial  { background-color: #FEF3C7 !important; color: #92400E !important; }
.badge-void     { background-color: #F1F5F9 !important; color: #94A3B8 !important; }
.badge-advance  { background-color: #E0F2FE !important; color: #0369A1 !important; }
.badge-deposit  { background-color: #DBEAFE !important; color: #1E40AF !important; }
.badge-credit   { background-color: #D1FAE5 !important; color: #065F46 !important; }
.badge-charge   { background-color: #FEF9C3 !important; color: #713F12 !important; }

/* Bootstrap bg- badge overrides */
.badge.bg-success  { background-color: #D1FAE5 !important; color: #065F46 !important; }
.badge.bg-primary  { background-color: #DBEAFE !important; color: #1E40AF !important; }
.badge.bg-danger   { background-color: #FEE2E2 !important; color: #991B1B !important; }
.badge.bg-warning  { background-color: #FEF3C7 !important; color: #92400E !important; }
.badge.bg-secondary{ background-color: #F1F5F9 !important; color: #475569 !important; }
.badge.bg-info     { background-color: #E0F2FE !important; color: #075985 !important; }
.badge.text-dark   { color: inherit !important; }

/* ── Pagination ──────────────────────────────────────────────────────────── */
.pagination { gap: 3px; margin-bottom: 0; }
.page-link {
  border-radius: 5px !important;
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 10px;
  border-color: var(--border-color);
  color: var(--text-secondary);
  background: #fff;
  transition: all 0.12s;
}
.page-link:hover {
  background: #F1F5F9;
  color: var(--text-primary);
  border-color: #CBD5E1;
}
.page-item.active .page-link {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 4px rgba(var(--accent-rgb), 0.35);
}
.page-item.disabled .page-link {
  color: var(--text-muted);
  background: transparent;
  border-color: #F1F5F9;
}

/* ── Headings & Typography ───────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--bs-font-sans-serif);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.h3 { font-size: 1.15rem; }
.h4 { font-size: 1rem; }
.h5 { font-size: 0.9rem; }

.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-success { color: var(--accent) !important; }
.text-danger  { color: var(--color-danger) !important; }
.text-warning { color: var(--color-warning) !important; }
.text-primary { color: var(--accent) !important; }

small { font-size: 12px; }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* ── Details/Summary inline panels ──────────────────────────────────────── */
details { position: relative; }
details .card {
  position: absolute;
  z-index: 20;
  min-width: 220px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
details summary { list-style: none; }
details summary::-webkit-details-marker { display: none; }

/* ═══════════════════════════════════════════════════════════════════════════
   COMPONENT PATTERNS
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Page Header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-header__title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.03em;
}
.page-header .btn { flex-shrink: 0; }

/* ── Filter Bar ──────────────────────────────────────────────────────────── */
.filter-bar {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: var(--card-shadow);
}

/* ── Stat Cards ──────────────────────────────────────────────────────────── */
.stat-val {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 16px 20px;
  height: 100%;
}
.stat-card .text-muted {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  display: block;
}

/* ── Section Headers ─────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  margin-top: 8px;
}
.section-header h2 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
  margin: 0;
}

/* ── Alert banners (dashboard critical notices) ──────────────────────────── */
.crm-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--card-radius);
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 500;
}
.crm-notice--danger {
  background: #FEF2F2;
  color: #7F1D1D;
  border: 1px solid #FECACA;
}
.crm-notice--warning {
  background: #FFFBEB;
  color: #78350F;
  border: 1px solid #FDE68A;
}

/* ═══════════════════════════════════════════════════════════════════════════
   STANDALONE PAGES (Auth, Errors)
   ═══════════════════════════════════════════════════════════════════════════ */
.auth-bg {
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.auth-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.auth-logo__icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: #fff;
}

.auth-logo__icon-svg {
  flex-shrink: 0;
  display: block;
}

.auth-logo__name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.auth-logo__365 {
  color: var(--accent);
  font-weight: 800;
}
.auth-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}
.auth-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.auth-footer a { color: var(--accent); font-weight: 500; }

/* Auth helpers — replaces inline styles on login/register/otp pages */
.auth-footer-link { font-size: 13px; color: var(--text-muted); }
.auth-link        { color: var(--accent); font-weight: 500; }
.auth-link-sm     { color: var(--accent); font-size: 12px; font-weight: 500; }
.btn-auth-submit  { padding: 9px; font-size: 14px; font-weight: 600; }

/* ═══════════════════════════════════════════════════════════════════════════
   LOGIN — split layout with animated security checklist
   ═══════════════════════════════════════════════════════════════════════════ */
.login-bg {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 20%, rgba(16,185,129,0.16), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(59,130,246,0.14), transparent 45%),
    var(--sidebar-bg);
}
.login-bg::before,
.login-bg::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}
.login-bg::before {
  width: 420px; height: 420px;
  background: rgba(16,185,129,0.20);
  top: -120px; left: -120px;
}
.login-bg::after {
  width: 480px; height: 480px;
  background: rgba(59,130,246,0.16);
  bottom: -160px; right: -140px;
}

.auth-split-shell {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
  max-width: 940px;
  min-height: 560px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,0.35);
}

/* ── Left panel: security checklist ─────────────────────────────────────── */
.auth-security-panel {
  flex: 1 1 46%;
  background:
    linear-gradient(165deg, rgba(16,185,129,0.10), transparent 55%),
    #0B1220;
  color: #E2E8F0;
  padding: 44px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-security-panel .auth-logo__name { color: #F8FAFC; }
.auth-security-panel__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-active-text);
  background: var(--sidebar-active-bg);
  border: 1px solid rgba(52,211,153,0.3);
  border-radius: 999px;
  padding: 4px 10px;
  margin-bottom: 16px;
  width: fit-content;
}
.auth-security-panel__eyebrow .pulse-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--sidebar-active-text);
  animation: pulseDot 1.4s ease-in-out infinite;
}
.auth-security-panel h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.auth-security-panel p.lead-sm {
  font-size: 13px;
  color: #94A3B8;
  margin-bottom: 26px;
}

.security-checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.security-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  opacity: 0;
  transform: translateY(6px);
  animation: secItemIn 0.45s ease-out forwards;
}
.security-item:nth-child(1) { animation-delay: 0.15s; }
.security-item:nth-child(2) { animation-delay: 0.55s; }
.security-item:nth-child(3) { animation-delay: 0.95s; }
.security-item:nth-child(4) { animation-delay: 1.35s; }
.security-item:nth-child(5) { animation-delay: 1.75s; }
.security-item:nth-child(6) { animation-delay: 2.15s; }

.security-item__check {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(148,163,184,0.12);
  border: 1px solid rgba(148,163,184,0.25);
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.security-item__check svg {
  width: 12px; height: 12px;
  stroke: var(--sidebar-active-text);
  stroke-width: 3;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 16;
  stroke-dashoffset: 16;
  animation: secCheckDraw 0.35s ease-out forwards;
  animation-delay: inherit;
}
.security-item:nth-child(1) .security-item__check { animation: secCheckPop 0.3s ease-out forwards; animation-delay: 0.45s; }
.security-item:nth-child(2) .security-item__check { animation: secCheckPop 0.3s ease-out forwards; animation-delay: 0.85s; }
.security-item:nth-child(3) .security-item__check { animation: secCheckPop 0.3s ease-out forwards; animation-delay: 1.25s; }
.security-item:nth-child(4) .security-item__check { animation: secCheckPop 0.3s ease-out forwards; animation-delay: 1.65s; }
.security-item:nth-child(5) .security-item__check { animation: secCheckPop 0.3s ease-out forwards; animation-delay: 2.05s; }
.security-item:nth-child(6) .security-item__check { animation: secCheckPop 0.3s ease-out forwards; animation-delay: 2.45s; }
.security-item:nth-child(1) .security-item__check svg { animation-delay: 0.55s; }
.security-item:nth-child(2) .security-item__check svg { animation-delay: 0.95s; }
.security-item:nth-child(3) .security-item__check svg { animation-delay: 1.35s; }
.security-item:nth-child(4) .security-item__check svg { animation-delay: 1.75s; }
.security-item:nth-child(5) .security-item__check svg { animation-delay: 2.15s; }
.security-item:nth-child(6) .security-item__check svg { animation-delay: 2.55s; }

.security-item__title { font-size: 13.5px; font-weight: 600; color: #F1F5F9; }
.security-item__desc  { font-size: 12px; color: #8593A8; margin-top: 1px; line-height: 1.4; }

.auth-security-panel__footer {
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px solid rgba(148,163,184,0.14);
  font-size: 11.5px;
  color: #64748B;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  animation: secItemIn 0.45s ease-out forwards;
  animation-delay: 2.7s;
}

/* ── Right panel: login form ─────────────────────────────────────────────── */
.auth-card--split {
  flex: 1 1 54%;
  max-width: none;
  width: auto;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.auth-card__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px;
}

@keyframes secItemIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes secCheckPop {
  from { background: rgba(148,163,184,0.12); border-color: rgba(148,163,184,0.25); }
  to   { background: rgba(16,185,129,0.18); border-color: rgba(52,211,153,0.5); }
}
@keyframes secCheckDraw {
  to { stroke-dashoffset: 0; }
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.7); }
}

@media (max-width: 900px) {
  .auth-split-shell { flex-direction: column; max-width: 460px; min-height: 0; }
  .auth-security-panel { padding: 32px 28px; }
  .auth-card__body { padding: 32px 28px; }
  .auth-trust-bar { padding: 16px 28px 20px; }
}

/* ── Login trust footer: shield, badges, legal links — pinned to card bottom ── */
.auth-trust-bar {
  position: relative;
  flex-shrink: 0;
  background: #0B1220;
  padding: 20px 40px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.auth-trust-bar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, #34D399, #60A5FA, #FBBF24);
}
.auth-trust-bar__shield {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: #E2E8F0;
}
.auth-trust-bar__shield svg { flex-shrink: 0; stroke: var(--sidebar-active-text); }

.auth-trust-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.auth-trust-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 999px;
  padding: 6px 13px;
}
.auth-trust-badge svg { flex-shrink: 0; }

.auth-trust-badge--green {
  color: #6EE7B7;
  background: rgba(16,185,129,0.16);
  border: 1px solid rgba(52,211,153,0.4);
}
.auth-trust-badge--blue {
  color: #93C5FD;
  background: rgba(59,130,246,0.16);
  border: 1px solid rgba(96,165,250,0.4);
}
.auth-trust-badge--amber {
  color: #FCD34D;
  background: rgba(245,158,11,0.16);
  border: 1px solid rgba(251,191,36,0.4);
}

.auth-trust-links { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.auth-trust-links a { color: #34D399; font-weight: 700; }
.auth-trust-links a:hover { color: #6EE7B7; text-decoration: underline; }
.auth-trust-links span { color: rgba(148,163,184,0.4); }

/* OTP / TOTP input — large monospaced digits */
.otp-input {
  font-size: 1.5rem;
  letter-spacing: 0.3em;
  text-align: center;
  font-weight: 600;
}

/* TOTP setup page */
.totp-qr             { display: inline-block; }
.totp-qr img,
.totp-qr canvas      { border: 6px solid #fff; border-radius: 8px; box-shadow: 0 0 0 1px var(--border-color); }
.totp-secret-display { display: block; font-size: 14px; letter-spacing: 0.1em; word-break: break-all; margin-top: 4px; }
.totp-manual-toggle  { cursor: pointer; }

/* MFA settings page */
.mfa-option-row { border-bottom: 1px solid var(--border-color); }
.mfa-option-row:last-child { border-bottom: none; }

/* Error pages */
.error-page {
  min-height: 100vh;
  background: var(--content-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}
.error-page__code {
  font-size: 5rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 12px;
  color: var(--border-color);
}
.error-page__code span { color: var(--accent); }

/* ═══════════════════════════════════════════════════════════════════════════
   MISC HELPERS & PRESERVED UTILITIES
   ═══════════════════════════════════════════════════════════════════════════ */

/* Hot days (overdue indicator) */
.days-hot { color: var(--color-danger) !important; font-weight: 700; }

/* Dynamic form field visibility (controlled by app.js) */
#payment_date_row  { display: none; }
.resolution-fields { display: none; }

/* Monospace code / log blocks */
pre.log-trace {
  background: #0F172A;
  color: #94A3B8;
  font-size: 0.79em;
  line-height: 1.65;
  border-radius: var(--card-radius);
  padding: 16px;
  overflow-x: auto;
  white-space: pre;
  border: 1px solid #1E293B;
}

code { color: var(--accent); font-size: 0.88em; }

/* Receipt print */
.receipt-amount { font-size: 2rem; font-weight: 800; color: var(--accent); letter-spacing: -0.04em; }
.receipt-stamp {
  text-align: center;
  border-top: 2px dashed var(--border-color);
  padding-top: 14px;
  margin-top: 14px;
  color: var(--accent);
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 3px;
  text-transform: uppercase;
}

/* ── Ledger / payments module ────────────────────────────────────────────── */

/* Running balance color states */
.balance-positive { color: #DC2626 !important; }
.balance-negative { color: #16A34A !important; }
.balance-zero     { color: #64748B !important; }

/* Ledger balance display in lease cards */
.ledger-balance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--content-bg);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 8px;
}

.ledger-balance {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Full-size balance for the ledger header banner */
.ledger-balance-xl {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

/* Bank-statement style ledger table */
.ledger-table {
  font-size: 13px;
}

.ledger-table thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.ledger-table tfoot tr {
  background: var(--content-bg);
}

.ledger-debit  { color: #DC2626; font-weight: 500; }
.ledger-credit { color: #16A34A; font-weight: 500; }

/* Stat value (summary cards) */
.stat-val {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1.2;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .crm-sidebar { transform: translateX(-100%); }
  .crm-sidebar.open { transform: translateX(0); }
  .crm-sidebar__close { display: flex; }
  .crm-main { margin-left: 0; }
  .crm-topbar__toggle { display: flex; }
  .crm-content { padding: 16px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .stat-val { font-size: 1.35rem; }
}

@media (max-width: 576px) {
  .auth-card { padding: 28px 20px; }
  .crm-content { padding: 12px; }
  .filter-bar { padding: 10px 12px; }
}

/* ── Dashboard stat color modifiers ─────────────────────────────────────── */
.stat-accent  { color: var(--accent); }
.stat-warning { color: var(--color-warning); }
.stat-danger  { color: var(--color-danger); }
.stat-info    { color: var(--color-info); }
.stat-meta    { font-size: 11px; margin-top: 4px; }

/* Expiring-lease date cell */
.td-overdue { color: var(--color-danger); font-weight: 600; }

/* Inline SVG alignment in notice banners */
.notice-icon { margin-right: 6px; vertical-align: -2px; }

/* ── Onboarding widget ───────────────────────────────────────────────────── */
.ob-card               { border: 1.5px solid var(--accent); border-radius: 10px; }
.ob-heading            { color: var(--accent); }
.ob-count              { font-size: 13px; }
.ob-progress           { height: 6px; border-radius: 4px; }
.ob-progress-bar       { background: var(--accent); border-radius: 4px; }
.ob-step-wrap--done    { background: rgba(16,185,129,0.08); border: 1px solid rgba(16,185,129,0.25); }
.ob-step-wrap--pending { background: var(--bg-card); border: 1px solid var(--border); }
.ob-icon               { flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.ob-icon--done         { background: var(--accent); color: #fff; }
.ob-icon--pending      { background: var(--bg-sidebar); color: var(--text-muted); }
.ob-step-content       { flex: 1; min-width: 0; }
.ob-label--done        { font-size: 13px; font-weight: 500; color: var(--text-muted); text-decoration: line-through; }
.ob-label--pending     { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.ob-link               { font-size: 11px; padding: 3px 10px; }
.ob-done-lbl           { font-size: 11px; color: var(--accent); font-weight: 500; }

/* Income forecast chart canvas max height */
#incomeChart { max-height: 300px; }

/* ── Support Tickets ─────────────────────────────────────────────────────── */

/* Status / priority pills */
.st-badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge-st-open     { background: #EFF6FF; color: #2563EB; }
.badge-st-progress { background: #FFFBEB; color: #D97706; }
.badge-st-closed   { background: #F0FDF4; color: #16A34A; }
.badge-st-high     { background: #FEF2F2; color: #DC2626; }
.badge-st-medium   { background: #FFFBEB; color: #D97706; }
.badge-st-low      { background: #F1F5F9; color: #64748B; }

/* Clickable table row */
.st-row { cursor: pointer; }
.st-row:hover td { background: var(--sidebar-item-hover); }

/* Ticket description block */
.st-description { font-size: 14px; color: var(--text-secondary); line-height: 1.7; white-space: pre-wrap; }

/* Comment thread */
.st-thread { display: flex; flex-direction: column; gap: 16px; }

.st-comment {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
}
.st-comment--admin {
  background: rgba(16,185,129,0.05);
  border-color: rgba(16,185,129,0.2);
}

.st-comment__avatar {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--sidebar-bg);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.st-comment--admin .st-comment__avatar { background: var(--accent); }

.st-comment__body  { flex: 1; min-width: 0; }
.st-comment__meta  { font-size: 12.5px; margin-bottom: 6px; }
.st-comment__text  { font-size: 13.5px; color: var(--text-secondary); line-height: 1.6; white-space: pre-wrap; }

/* "Support Team" badge on admin comments */
.badge.bg-accent-soft { background: rgba(16,185,129,0.12); color: var(--accent); font-size: 10.5px; }

/* ── User approval status badges ─────────────────────────────────────────── */
.badge-pending  { background-color: #FEF3C7 !important; color: #92400E !important; }
.badge-rejected { background-color: #FEE2E2 !important; color: #991B1B !important; }

/* ── CRM Tab Nav (underline style — used in Users, Support, etc.) ────────── */
.crm-tabs {
  display: flex;
  border-bottom: 1.5px solid var(--border-color);
  margin-bottom: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.crm-tabs::-webkit-scrollbar { display: none; }

.crm-tab {
  display: inline-block;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1.5px;          /* sits on top of container border */
  transition: color 0.14s, border-color 0.14s;
}
.crm-tab:hover {
  color: var(--text-primary);
}
.crm-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ── Attachments ─────────────────────────────────────────────────────────── */
.attachment-list { margin-bottom: 0; }

.attachment-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}
.attachment-item:last-child { border-bottom: none; }

.attachment-icon {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
}
.attachment-icon--doc   { background: #FEF3C7; color: #92400E; }
.attachment-icon--image { background: #D1FAE5; color: #065F46; }
.attachment-icon--video { background: #EDE9FE; color: #5B21B6; }

.attachment-meta { flex: 1; min-width: 0; }

.attachment-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-name a { color: var(--text-primary); text-decoration: none; }
.attachment-name a:hover { color: var(--accent); text-decoration: underline; }

.attachment-info { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

.attachment-delete-btn {
  padding: 4px 7px;
  flex-shrink: 0;
}

.file-upload-area {
  display: block;
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  padding: 20px 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.file-upload-area:hover {
  border-color: var(--accent);
  background: rgba(16,185,129,0.03);
}
.file-upload-selected {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
  word-break: break-word;
}

/* Anti-bot honeypot. Positioned off-screen rather than display:none/visibility:hidden on
   purpose — many bots skip inputs hidden those two ways but still fill an off-screen one, which
   is exactly the signal we want. A real user never sees or focuses this field. */
.hp-field {
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}
