/* ═══════════════════════════════════════════════════════════════
   CSS VARIABLES & RESET
   ═══════════════════════════════════════════════════════════════ */
:root {
  --bg: #f5f7fa;
  --bg2: #edf0f5;
  --surface: #ffffff;
  --surface2: #f0f2f7;
  --surface3: #e5e8ef;
  --border: #e0e4ec;
  --border2: #cdd3df;
  --text: #1a1f36;
  --text2: #5e6687;
  --text3: #8f95b2;
  --primary: #e8247c;
  --primary-hover: #f0408e;
  --primary-dim: rgba(232,36,124,0.08);
  --primary-light: rgba(232,36,124,0.04);
  --green: #0cce6b;
  --green-dim: rgba(12,206,107,0.08);
  --orange: #f5a623;
  --orange-dim: rgba(245,166,35,0.08);
  --red: #e25950;
  --red-dim: rgba(226,89,80,0.08);
  --blue: #3a7bd5;
  --blue-dim: rgba(58,123,213,0.08);
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  --transition: 180ms ease;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-height: 64px;
}
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh; min-height: 100dvh;
  line-height: 1.55; -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: inherit; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ═══════════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════════ */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 6px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
input, select, textarea {
  width: 100%; padding: 10px 14px; background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 14px; outline: none;
  transition: border var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-dim);
}
input::placeholder, textarea::placeholder { color: var(--text3); }
textarea { resize: vertical; min-height: 76px; }
select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235e6687' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.form-error { color: var(--red); font-size: 12px; margin-top: 4px; }

/* ═══════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 20px;
  border-radius: 10px; border: none; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all var(--transition); white-space: nowrap;
  letter-spacing: 0.2px; min-height: 40px;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 1px 3px rgba(232,36,124,0.3); }
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 2px 8px rgba(232,36,124,0.3); }
.btn-danger { background: var(--red); color: white; box-shadow: 0 1px 3px rgba(226,89,80,0.25); }
.btn-danger:hover { background: #d04840; }
.btn-ghost { background: var(--surface); color: var(--text2); border: 1.5px solid var(--border); }
.btn-ghost:hover { border-color: var(--border2); color: var(--text); background: var(--surface2); }
.btn-sm { padding: 7px 14px; font-size: 12px; min-height: 34px; }
.btn-xs { padding: 5px 10px; font-size: 11px; min-height: 28px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-icon { padding: 8px; min-height: unset; width: 36px; height: 36px; border-radius: 10px; }

/* Global SVG sizing */
svg { display: inline-block; vertical-align: middle; }
.btn svg, button svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-sm svg, .btn-xs svg { width: 14px; height: 14px; }
h1 svg, h2 svg, h3 svg, h4 svg { width: 18px; height: 18px; }
.settings-section h3 svg { width: 16px; height: 16px; }
.topbar .page-title svg { width: 18px; height: 18px; }
.section-title svg { width: 16px; height: 16px; }
.activity-icon svg { width: 14px; height: 14px; }
.empty-state > svg { width: 48px; height: 48px; }

/* ═══════════════════════════════════════════════════════════════
   SETUP WIZARD & LOGIN
   ═══════════════════════════════════════════════════════════════ */
.setup-wrap, .login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; min-height: 100dvh; padding: 20px;
  background: linear-gradient(135deg, #f5f7fa 0%, #f0e8ee 50%, #faf5f8 100%);
}
.setup-card, .login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 40px; width: 100%; max-width: 420px; box-shadow: var(--shadow-lg);
}
.setup-card h1, .login-card h1 { font-size: 24px; margin-bottom: 4px; font-weight: 700; color: var(--text); }
.setup-card .subtitle, .login-card .subtitle { color: var(--text2); margin-bottom: 28px; font-size: 14px; }
.brand-mark { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.brand-mark .logo-icon {
  width: 42px; height: 42px; background: linear-gradient(135deg, #3a3a3a 0%, #4a4a4a 100%); border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: white; font-size: 18px;
  box-shadow: 0 3px 12px rgba(232,36,124,0.35);
}
.brand-mark .logo-icon svg { width: 22px; height: 22px; }
.brand-mark .logo-text { display: flex; flex-direction: column; }
.brand-mark .logo-text .brand-title { font-size: 18px; font-weight: 800; letter-spacing: -0.5px; color: var(--text); line-height: 1.2; }
.brand-mark .logo-text .brand-subtitle { font-size: 11px; font-weight: 500; color: var(--text3); letter-spacing: 0.5px; text-transform: uppercase; }
.forgot-link { display: block; text-align: center; margin-top: 18px; font-size: 13px; color: var(--text3); cursor: pointer; }
.forgot-link:hover { color: var(--primary); text-decoration: none; }

/* ═══════════════════════════════════════════════════════════════
   LAYOUT — DESKTOP SIDEBAR
   ═══════════════════════════════════════════════════════════════ */
.app-layout { display: flex; min-height: 100vh; min-height: 100dvh; overflow-x: hidden; }
.sidebar {
  width: 250px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 20;
  box-shadow: 1px 0 0 var(--border);
}
.sidebar-header { padding: 20px 20px 16px; border-bottom: 1px solid var(--border); }
.sidebar-header .brand { display: flex; align-items: center; gap: 12px; }
.sidebar-header .brand .logo-icon {
  width: 36px; height: 36px; background: linear-gradient(135deg, #3a3a3a 0%, #4a4a4a 100%); border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: white; font-size: 15px;
  box-shadow: 0 2px 8px rgba(232,36,124,0.3);
}
.sidebar-header .brand .logo-icon svg { width: 20px; height: 20px; }
.sidebar-header .brand-name { display: flex; flex-direction: column; line-height: 1.2; }
.sidebar-header .brand-name .sb-title { font-size: 15px; font-weight: 800; letter-spacing: -0.3px; color: var(--text); }
.sidebar-header .brand-name .sb-sub { font-size: 10px; font-weight: 500; color: var(--text3); letter-spacing: 0.4px; text-transform: uppercase; }
.sidebar-header .agency-label { font-size: 12px; color: var(--text3); margin-top: 6px; padding-left: 46px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Agency Switcher */
.agency-switcher { position: relative; margin-top: 10px; }
.agency-switcher-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 12px;
  background: var(--surface2); border: 1.5px solid var(--border); border-radius: 10px;
  cursor: pointer; transition: all var(--transition); font-size: 13px; color: var(--text);
  font-weight: 600; text-align: left;
}
.agency-switcher-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.agency-switcher-btn .agency-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.agency-switcher-btn .agency-name-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agency-switcher-btn .chevron { color: var(--text3); flex-shrink: 0; transition: transform 150ms; }
.agency-switcher-btn .chevron svg { width: 14px; height: 14px; }
.agency-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg); overflow: hidden; animation: slideUp 150ms ease;
  max-height: 280px; overflow-y: auto;
}
.agency-dropdown .agency-option {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer;
  font-size: 13px; color: var(--text2); border: none; background: none; width: 100%;
  text-align: left; transition: background 120ms;
}
.agency-dropdown .agency-option:hover { background: var(--surface2); color: var(--text); }
.agency-dropdown .agency-option.active { background: var(--primary-dim); color: var(--primary); font-weight: 600; }
.agency-dropdown .agency-option .opt-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border2); flex-shrink: 0; }
.agency-dropdown .agency-option.active .opt-dot { background: var(--primary); }
.agency-dropdown .agency-option.add-new { border-top: 1px solid var(--border); color: var(--primary); font-weight: 600; }
.agency-dropdown .agency-option.add-new .opt-dot { background: var(--primary); }
/* Scope toggle */
.scope-toggle { display: flex; background: var(--border); border-radius: 10px; padding: 3px; gap: 0; }
.scope-toggle button {
  padding: 8px 16px; border-radius: 8px; border: none; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 180ms; color: var(--text3); background: transparent; flex: 1; text-align: center;
}
.scope-toggle button.active { background: var(--primary); color: white; box-shadow: 0 2px 8px rgba(232,36,124,0.25); }
.scope-toggle button:active:not(.active) { background: var(--surface2); }
/* Agency badge on property cards */
.property-info .agency-badge { font-size: 11px; color: var(--primary); font-weight: 600; margin-bottom: 2px; display: flex; align-items: center; gap: 4px; }
.property-info .agency-badge .ab-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav .nav-section { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 1px; padding: 14px 14px 6px; font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 14px;
  border-radius: 10px; color: var(--text2); font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: all 150ms; border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--primary-dim); color: var(--primary); font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); }
.user-info { display: flex; align-items: center; gap: 11px; padding: 8px; border-radius: 10px; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 10px; background: rgba(232,36,124,0.08);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #e8247c;
}
.user-details { flex: 1; min-width: 0; }
.user-details .name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.user-details .role { font-size: 11px; color: var(--text3); text-transform: capitalize; }

.main-content { flex: 1; margin-left: 250px; padding-bottom: 40px; }

/* ═══════════════════════════════════════════════════════════════
   TOPBAR
   ═══════════════════════════════════════════════════════════════ */
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 14px 28px;
  border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.topbar .page-title { font-size: 17px; font-weight: 700; white-space: nowrap; color: var(--text); }
.topbar .spacer { flex: 1; }
.search-input-wrap { position: relative; flex: 1; max-width: 420px; }
.search-input-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text3); width: 16px; height: 16px; }
.search-input-wrap input { padding-left: 38px; background: var(--surface2); font-size: 13px; border-color: transparent; }
.search-input-wrap input:focus { background: var(--surface); border-color: var(--primary); }

/* ═══════════════════════════════════════════════════════════════
   CONTENT AREA
   ═══════════════════════════════════════════════════════════════ */
.page-content { padding: 28px; max-width: 1400px; }

/* ═══════════════════════════════════════════════════════════════
   STAT CARDS
   ═══════════════════════════════════════════════════════════════ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; transition: all var(--transition); box-shadow: var(--shadow-xs);
}
.stat-card:hover { box-shadow: var(--shadow-md); border-color: var(--border2); transform: translateY(-1px); }
.stat-card[onclick] { cursor: pointer; }
.stat-card[onclick]:active { transform: scale(0.97); }
.stat-card .stat-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; font-size: 16px; }
.stat-card .stat-label { font-size: 12px; color: var(--text3); margin-bottom: 4px; font-weight: 600; letter-spacing: 0.3px; text-transform: uppercase; }
.stat-card .stat-value { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; color: var(--text); }

/* ═══════════════════════════════════════════════════════════════
   ACTIVITY FEED
   ═══════════════════════════════════════════════════════════════ */
.dash-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.section-title { font-size: 14px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; color: var(--text); }
.activity-list { display: flex; flex-direction: column; gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-xs); max-height: 480px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.activity-item + .activity-item { border-top: 1px solid var(--border); }
.activity-item { padding: 13px 16px; background: var(--surface); display: flex; align-items: center; gap: 14px; transition: background var(--transition); position: relative; }
.activity-item:hover { background: var(--surface2); }
.activity-item:active { background: var(--surface3); }
.activity-item::after { content: ''; position: absolute; right: 14px; top: 50%; width: 7px; height: 7px; border-right: 2px solid var(--text3); border-bottom: 2px solid var(--text3); transform: translateY(-50%) rotate(-45deg); opacity: 0.35; }
.activity-icon { width: 40px; height: 40px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; overflow: hidden; }
.activity-icon img { width: 100%; height: 100%; object-fit: cover; }
.activity-text { flex: 1; min-width: 0; padding-right: 16px; }
.activity-text .title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.activity-text .meta { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ═══════════════════════════════════════════════════════════════
   FILTERS BAR
   ═══════════════════════════════════════════════════════════════ */
.filters-bar { display: flex; gap: 8px; margin-bottom: 16px; align-items: center; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
.filters-bar select { width: auto; min-width: 110px; font-size: 13px; padding: 8px 30px 8px 10px; background: var(--surface); flex-shrink: 0; }
.filters-bar .clear-btn { font-size: 12px; color: white; background: var(--red); cursor: pointer; padding: 8px 12px; border-radius: 8px; white-space: nowrap; flex-shrink: 0; font-weight: 600; }
.filters-bar .clear-btn:hover { background: #d04840; }

/* ═══════════════════════════════════════════════════════════════
   PROPERTY GRID
   ═══════════════════════════════════════════════════════════════ */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.section-header h2 { font-size: 16px; font-weight: 700; }
.property-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.property-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: all var(--transition); box-shadow: var(--shadow-xs);
}
.property-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.property-thumb {
  height: 170px; background: var(--surface2); position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.property-thumb img { width: 100%; height: 100%; object-fit: cover; }
.property-thumb .no-image { color: var(--text3); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.property-thumb .no-image svg { width: 32px; height: 32px; opacity: 0.3; }
.property-thumb .media-badge {
  position: absolute; bottom: 10px; right: 10px; background: rgba(255,255,255,0.92); backdrop-filter: blur(10px);
  padding: 5px 12px; border-radius: 8px; font-size: 11px; display: flex; gap: 10px; font-weight: 600;
  color: var(--text2); box-shadow: var(--shadow-xs);
}
.property-info { padding: 16px 18px; }
.property-info h3 { font-size: 15px; font-weight: 700; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.property-info .address { font-size: 13px; color: var(--text2); margin-bottom: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.property-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 11px; padding: 4px 10px; border-radius: 6px; font-weight: 600;
  background: var(--surface2); color: var(--text2); text-transform: capitalize;
}
.tag-available { background: var(--green-dim); color: #059651; }
.tag-let { background: var(--orange-dim); color: #b37a12; }
.tag-maintenance { background: var(--red-dim); color: #c0392b; }
.tag-sold { background: var(--blue-dim); color: #2a5fa8; }
.tag-withdrawn { background: var(--surface3); color: var(--text3); }

/* ═══════════════════════════════════════════════════════════════
   PAGINATION
   ═══════════════════════════════════════════════════════════════ */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 28px; }
.pagination button {
  min-width: 38px; height: 38px; border: 1.5px solid var(--border); background: var(--surface);
  color: var(--text2); border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 600;
  transition: all var(--transition); display: flex; align-items: center; justify-content: center;
}
.pagination button:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.pagination button.active { background: var(--primary); border-color: var(--primary); color: white; }
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }
.pagination .page-info { font-size: 12px; color: var(--text3); padding: 0 8px; }

/* ═══════════════════════════════════════════════════════════════
   DETAIL VIEW
   ═══════════════════════════════════════════════════════════════ */
.detail-header { margin-bottom: 28px; }
.detail-back { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; color: var(--primary); cursor: pointer; margin-bottom: 12px; padding: 10px 14px 10px 0; font-weight: 600; }
.detail-back:hover { color: var(--primary); text-decoration: none; }
.detail-back svg { width: 20px; height: 20px; }
.detail-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.detail-title-row h1 { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1.2; }
.detail-title-row .actions { display: flex; gap: 8px; }
.detail-address { font-size: 15px; color: var(--text2); margin-top: 6px; line-height: 1.4; }
.detail-meta { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.detail-notes { margin-top: 16px; font-size: 13px; color: var(--text2); line-height: 1.7; background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.tenancy-section { margin-bottom: 24px; }
.tenancy-card { background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.tenancy-card .tenant-name { font-size: 17px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tenancy-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 20px; margin-top: 14px; }
.tenancy-field { font-size: 13px; }
.tenancy-field .label { color: var(--text3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.tenancy-field .value { color: var(--text); font-weight: 600; }
.tenancy-field .value a { color: var(--primary); }
.tenancy-empty { font-size: 13px; color: var(--text2); background: var(--surface2); border: 1px dashed var(--border); border-radius: 10px; padding: 16px; }
.tenancy-notes { margin-top: 14px; font-size: 13px; color: var(--text2); line-height: 1.6; border-top: 1px solid var(--border); padding-top: 12px; }
.tenancy-docs { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.tenancy-docs-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text3); margin-bottom: 8px; }
.tenancy-doc { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 0; flex-wrap: wrap; }
.tenancy-doc a { color: var(--primary); display: inline-flex; align-items: center; gap: 6px; word-break: break-all; }
.tenancy-doc svg { width: 14px; height: 14px; flex-shrink: 0; }
.cat-chip { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,0.72); color: #fff; font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 6px; text-transform: uppercase; letter-spacing: 0.03em; }

/* ═══════════════════════════════════════════════════════════════
   UPLOAD ZONE
   ═══════════════════════════════════════════════════════════════ */
.upload-zone {
  border: 2px dashed var(--border2); border-radius: var(--radius); padding: 36px;
  text-align: center; cursor: pointer; transition: all var(--transition); margin-bottom: 28px;
  background: var(--primary-light);
}
.upload-zone:hover { border-color: var(--primary); background: var(--primary-dim); }
.upload-zone.dragging { border-color: var(--primary); background: var(--primary-dim); }
.upload-zone svg { width: 28px; height: 28px; color: var(--primary); margin-bottom: 10px; opacity: 0.7; }
.upload-zone p { color: var(--text2); font-size: 14px; font-weight: 500; }
.upload-zone .sub { font-size: 12px; color: var(--text3); margin-top: 4px; }

.upload-progress { margin-bottom: 24px; }
.upload-file-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; box-shadow: var(--shadow-xs); }
.upload-file-item .file-name { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.upload-file-item .file-status { font-size: 11px; font-weight: 700; }
.upload-file-item .file-status.success { color: var(--green); }
.upload-file-item .file-status.error { color: var(--red); }
.upload-file-item .file-status.uploading { color: var(--primary); }
.progress-bar { flex: 1; height: 4px; background: var(--surface2); border-radius: 2px; overflow: hidden; max-width: 120px; }
.progress-fill { height: 100%; background: var(--primary); transition: width 150ms; border-radius: 2px; }

/* ═══════════════════════════════════════════════════════════════
   MEDIA GRID
   ═══════════════════════════════════════════════════════════════ */
.media-section { margin-top: 4px; }
.media-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.media-section-header h3 { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; color: var(--text); }
.media-section-header .count { font-size: 12px; color: var(--text3); font-weight: 400; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.media-item {
  position: relative; border-radius: 10px; overflow: hidden; aspect-ratio: 4/3;
  background: var(--surface2); cursor: pointer; transition: all var(--transition);
  box-shadow: var(--shadow-xs); border: 1px solid var(--border);
}
.media-item:hover { transform: scale(1.02); box-shadow: var(--shadow-md); }
.media-item img, .media-item video { width: 100%; height: 100%; object-fit: cover; }
.media-item .overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(transparent 50%, rgba(0,0,0,0.5));
  opacity: 0; transition: opacity var(--transition);
  display: flex; align-items: flex-end; justify-content: space-between; padding: 10px;
}
.media-item:hover .overlay { opacity: 1; }
.media-item .overlay .note-text { font-size: 11px; color: rgba(255,255,255,0.9); max-width: 70%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-item .view-btn {
  position: absolute; top: 8px; right: 40px; background: rgba(255,255,255,0.9); backdrop-filter: blur(4px);
  border: none; color: var(--text2); width: 28px; height: 28px; border-radius: 7px;
  cursor: pointer; display: none; align-items: center; justify-content: center;
  transition: all var(--transition); box-shadow: var(--shadow-xs);
}
.media-item .view-btn svg { width: 16px; height: 16px; }
.media-item .view-btn:active { background: var(--primary); color: white; }
.media-item .delete-btn {
  position: absolute; top: 8px; right: 8px; background: rgba(255,255,255,0.9); backdrop-filter: blur(4px);
  border: none; color: var(--text2); width: 28px; height: 28px; border-radius: 7px;
  cursor: pointer; font-size: 12px; display: none; align-items: center; justify-content: center;
  transition: all var(--transition); box-shadow: var(--shadow-xs);
}
.media-item .delete-btn:hover { background: var(--red); color: white; }
.media-item:hover .delete-btn, .media-item:hover .view-btn { display: flex; }
@media (max-width: 768px) { .media-item .view-btn, .media-item .delete-btn { display: flex !important; } }
.media-item .check-box {
  position: absolute; top: 8px; left: 8px; width: 22px; height: 22px;
  border-radius: 6px; border: 2px solid rgba(255,255,255,0.7); background: rgba(255,255,255,0.5);
  cursor: pointer; display: none; align-items: center; justify-content: center;
  transition: all var(--transition); backdrop-filter: blur(4px);
}
.media-item:hover .check-box, .media-item.selected .check-box { display: flex; }
@media (max-width: 768px) { .media-item .check-box { display: flex !important; } }
.media-item.selected .check-box { background: var(--primary); border-color: var(--primary); }
.media-item.selected { outline: 2px solid var(--primary); outline-offset: -2px; }
.media-item .video-badge {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 44px; height: 44px; background: rgba(255,255,255,0.85); backdrop-filter: blur(6px);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
.media-item .video-badge svg { width: 18px; height: 18px; color: var(--text); margin-left: 2px; }
.media-item .cover-chip {
  position: absolute; top: 8px; left: 38px; background: rgba(255,255,255,0.94); color: var(--primary);
  border: 1px solid rgba(232,36,124,0.14); border-radius: 999px; padding: 4px 8px;
  font-size: 10px; font-weight: 800; letter-spacing: 0.3px; text-transform: uppercase;
  box-shadow: var(--shadow-xs);
}
.media-item .doc-icon {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; height: 100%; background: var(--surface2);
}
.media-item .doc-icon svg { width: 36px; height: 36px; color: var(--red); margin-bottom: 6px; }
.media-item .doc-icon span { font-size: 11px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90%; text-align: center; font-weight: 500; }
.bulk-actions { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--primary-dim); border: 1.5px solid var(--primary); border-radius: 10px; margin-bottom: 16px; }
.bulk-actions .count { font-size: 13px; font-weight: 700; color: var(--primary); }
.bulk-actions .spacer { flex: 1; }

/* ═══════════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3); backdrop-filter: blur(6px);
  z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeIn 150ms ease;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 32px; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto;
  animation: slideUp 200ms ease; box-shadow: var(--shadow-lg);
}
.modal h2 { font-size: 18px; margin-bottom: 24px; font-weight: 700; color: var(--text); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 28px; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } }

.confirm-content { font-size: 14px; color: var(--text2); margin-bottom: 24px; line-height: 1.7; }
.confirm-content strong { color: var(--text); }

/* ═══════════════════════════════════════════════════════════════
   LIGHTBOX
   ═══════════════════════════════════════════════════════════════ */
.lightbox {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.95); z-index: 200; display: flex; flex-direction: column;
  animation: fadeIn 200ms ease;
}
.lightbox .lb-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; flex-shrink: 0; z-index: 1;
}
.lightbox .lb-topbar .lb-counter { color: rgba(255,255,255,0.7); font-size: 13px; font-weight: 600; }
.lightbox .lb-topbar .lb-actions { display: flex; gap: 8px; }
.lightbox .lb-btn {
  background: rgba(255,255,255,0.15); border: none; color: white;
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px); font-size: 16px;
}
.lightbox .lb-btn:active { background: rgba(255,255,255,0.3); }
.lightbox .lb-btn svg { width: 20px; height: 20px; }
.lightbox .lb-content { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; touch-action: pan-y; }
.lightbox .lb-content img, .lightbox .lb-content video { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox .lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.15); border: none; color: white;
  width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); z-index: 2;
}
.lightbox .lb-nav:active { background: rgba(255,255,255,0.3); }
.lightbox .lb-nav.prev { left: 12px; }
.lightbox .lb-nav.next { right: 12px; }
.lightbox .lb-nav svg { width: 20px; height: 20px; }
.lightbox .lb-bottom {
  padding: 12px 16px calc(env(safe-area-inset-bottom, 0px) + 12px);
  text-align: center; flex-shrink: 0;
}
.lightbox .lb-filename { color: rgba(255,255,255,0.6); font-size: 12px; margin-bottom: 4px; }
.lightbox .media-note-display { background: rgba(255,255,255,0.1); padding: 8px 16px; border-radius: 8px; font-size: 13px; color: rgba(255,255,255,0.85); display: inline-block; }
@media (max-width: 768px) {
  .lightbox .lb-nav { width: 36px; height: 36px; }
  .lightbox .lb-nav.prev { left: 6px; }
  .lightbox .lb-nav.next { right: 6px; }
}

/* ═══════════════════════════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════════════════════════ */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 13px 20px; border-radius: 10px; font-size: 13px; font-weight: 600;
  animation: toastIn 250ms ease; display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow-lg); max-width: 380px;
}
.toast-success { background: var(--green); color: white; }
.toast-error { background: var(--red); color: white; }
.toast-info { background: var(--blue); color: white; }
@keyframes toastIn { from { transform: translateY(16px); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(-8px); opacity: 0; } }

/* ═══════════════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════════════ */
.empty-state { text-align: center; padding: 56px 24px; }
.empty-state svg { width: 48px; height: 48px; color: var(--text3); margin-bottom: 16px; opacity: 0.4; }
.empty-state p { color: var(--text3); font-size: 14px; margin-bottom: 18px; }

/* ═══════════════════════════════════════════════════════════════
   LOADING SKELETON
   ═══════════════════════════════════════════════════════════════ */
.skeleton { background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ═══════════════════════════════════════════════════════════════
   TABLE (USERS)
   ═══════════════════════════════════════════════════════════════ */
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-xs); }
.data-table th { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 700; padding: 14px 18px; text-align: left; background: var(--surface2); border-bottom: 1px solid var(--border); }
.data-table td { padding: 14px 18px; font-size: 13px; border-bottom: 1px solid var(--border); color: var(--text); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 7px; }
.status-dot.active { background: var(--green); }
.status-dot.inactive { background: var(--red); }

/* ═══════════════════════════════════════════════════════════════
   SETTINGS
   ═══════════════════════════════════════════════════════════════ */
.settings-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; margin-bottom: 22px; box-shadow: var(--shadow-xs); }
.settings-section h3 { font-size: 15px; font-weight: 700; margin-bottom: 18px; color: var(--text); display: flex; align-items: center; gap: 8px; }

/* ═══════════════════════════════════════════════════════════════
   LIVE CLOCK
   ═══════════════════════════════════════════════════════════════ */
.live-clock { font-size: 14px; color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; background: var(--surface2); padding: 6px 14px; border-radius: 8px; letter-spacing: 0.3px; border: 1px solid var(--border); }

/* ═══════════════════════════════════════════════════════════════
   MOBILE — BOTTOM NAV
   ═══════════════════════════════════════════════════════════════ */

/* Mobile-friendly card list for agencies/users */
.card-list { display: flex; flex-direction: column; gap: 12px; }
.card-list-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-xs);
}
.card-list-item .cli-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.card-list-item .cli-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.card-list-item .cli-name { font-size: 15px; font-weight: 700; color: var(--text); }
.card-list-item .cli-sub { font-size: 12px; color: var(--text3); }
.card-list-item .cli-stats { display: flex; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.card-list-item .cli-stat { display: flex; flex-direction: column; }
.card-list-item .cli-stat .cs-val { font-size: 16px; font-weight: 700; color: var(--text); }
.card-list-item .cli-stat .cs-label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.3px; }
.card-list-item .cli-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Mobile Header — agency switcher + branding */
.mobile-header {
  display: none; padding: 12px 18px; background: var(--surface);
  border-bottom: 1px solid var(--border); align-items: center; gap: 10px;
}
.mobile-header .mh-brand { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.mobile-header .mh-brand .mh-logo {
  width: 32px; height: 32px; background: linear-gradient(135deg, #3a3a3a 0%, #4a4a4a 100%);
  border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.mobile-header .mh-brand .mh-logo svg { width: 18px; height: 18px; }
.mobile-header .mh-brand .mh-name { font-size: 15px; font-weight: 800; white-space: nowrap; min-width: 0; }
.mobile-header .mh-agency-btn {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px; background: var(--surface2);
  border: 1.5px solid var(--border); border-radius: 8px; font-size: 12px; font-weight: 600;
  color: var(--text); cursor: pointer; max-width: 55%; flex-shrink: 1; min-width: 0;
}
.mobile-header .mh-agency-btn span:last-child {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mobile-header .mh-agency-btn .mh-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.mobile-header .mh-agency-btn:active { background: var(--primary-dim); border-color: var(--primary); }
/* Mobile agency dropdown */
.mobile-agency-dd {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 60;
  background: rgba(0,0,0,0.3); backdrop-filter: blur(4px);
  display: flex; flex-direction: column; justify-content: flex-end;
  animation: fadeIn 150ms ease;
}
.mobile-agency-dd .mdd-sheet {
  background: var(--surface); border-radius: 16px 16px 0 0;
  padding: 20px 0 calc(var(--safe-bottom) + 20px); max-height: 60vh; overflow-y: auto;
  animation: slideUpMobile 200ms ease;
}
.mobile-agency-dd .mdd-title { padding: 0 20px 12px; font-size: 15px; font-weight: 700; border-bottom: 1px solid var(--border); }
.mobile-agency-dd .mdd-item {
  display: flex; align-items: center; gap: 10px; padding: 14px 20px; cursor: pointer;
  font-size: 14px; color: var(--text2); border: none; background: none; width: 100%; text-align: left;
}
.mobile-agency-dd .mdd-item:active { background: var(--surface2); }
.mobile-agency-dd .mdd-item.active { color: var(--primary); font-weight: 700; }
.mobile-agency-dd .mdd-item .mdd-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border2); flex-shrink: 0; }
.mobile-agency-dd .mdd-item.active .mdd-dot { background: var(--primary); }
.mobile-agency-dd .mdd-item.add-new { border-top: 1px solid var(--border); color: var(--primary); font-weight: 700; }

@media (max-width: 768px) {
  .sidebar { display: none !important; overflow: hidden; width: 0; }
  .app-layout { flex-direction: column; }
  .mobile-header { display: flex; }
  .main-content { margin-left: 0; padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px); }
  .mobile-header + .main-content { margin-top: 0; }
  .bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--nav-height) + var(--safe-bottom));
    -webkit-transform: translateZ(0); transform: translateZ(0);
    background: var(--surface); border-top: 1px solid var(--border); display: flex;
    align-items: flex-start; padding-top: 6px; padding-bottom: var(--safe-bottom); z-index: 50;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.04);
  }
  .bottom-nav .bnav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 4px; cursor: pointer; color: var(--text3); font-size: 10px;
    font-weight: 600; transition: color var(--transition); border: none; background: none;
    min-height: 44px; justify-content: center;
  }
  .bottom-nav .bnav-item.active { color: var(--primary); }
  .bottom-nav .bnav-item svg { width: 22px; height: 22px; }
  .page-content { padding: 18px; }
  .topbar { padding: 12px 18px; }
  .live-clock { font-size: 11px; padding: 4px 10px; }
  .topbar .page-title { font-size: 15px; }
  .property-grid { grid-template-columns: 1fr; }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .stat-value { font-size: 22px; }
  .stat-card .stat-icon { width: 32px; height: 32px; margin-bottom: 10px; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    padding: 0; margin: 0; max-width: 100%; width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 90vh; animation: slideUpMobile 250ms ease;
    display: flex; flex-direction: column;
  }
  .modal::before {
    content: ''; display: block; width: 36px; height: 4px;
    background: var(--border2); border-radius: 2px; margin: 10px auto 0; flex-shrink: 0;
  }
  .modal h2 {
    position: sticky; top: 0; background: var(--surface); z-index: 1;
    padding: 14px 20px 12px; margin: 0 0 0; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    font-size: 17px;
  }
  .modal h2::after {
    content: '✕'; font-size: 18px; color: var(--text3); cursor: pointer;
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    border-radius: 8px; font-weight: 400;
  }
  .modal h2:active::after { background: var(--surface2); }
  .modal form, .modal .confirm-content, .modal > div:not(.modal-actions) { padding: 16px 20px 0; overflow-y: auto; flex: 1; }
  .modal .modal-actions { padding: 12px 20px calc(var(--safe-bottom) + 12px); border-top: 1px solid var(--border); background: var(--surface); position: sticky; bottom: 0; }
  .modal .form-group { margin-bottom: 14px; }
  @keyframes slideUpMobile { from { transform: translateY(100%); } }
  .toast-container { bottom: calc(var(--nav-height) + var(--safe-bottom) + 8px); right: 12px; left: 12px; }
  .toast { width: 100%; }
  /* Ensure Add Property button stays above bottom nav */
  .page-content .btn-primary.btn-block, .page-content > div > .btn-primary { margin-bottom: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr; }
  .data-table { font-size: 12px; }
  .desktop-only { display: none !important; }
  .mobile-only { display: flex !important; }
  .data-table th, .data-table td { padding: 10px 12px; }
  .filters-bar select { min-width: 100px; font-size: 12px; }
  .detail-title-row { flex-direction: column; }
  .detail-title-row .actions { width: 100%; }
  .detail-title-row .actions .btn { flex: 1; }
  /* Dashboard: stack status + activity vertically on mobile */
  .dash-two-col { grid-template-columns: 1fr !important; }
  .activity-item { padding: 10px 12px; gap: 10px; }
  .activity-icon { width: 44px; height: 44px; border-radius: 10px; }
  .activity-text .title { font-size: 14px; }
  .activity-text .meta { font-size: 12px; }
}

@media (min-width: 769px) {
  .bottom-nav { display: none; }
  .mobile-only { display: none !important; }
  .desktop-only { display: block !important; }
}

/* ═══════════════════════════════════════════════════════════════
   WIDE SCREENS
   ═══════════════════════════════════════════════════════════════ */
@media (min-width: 1200px) {
  .property-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}

/* ═══════════════════════════════════════════════════════════════
   FOCUS / ACCESSIBILITY
   ═══════════════════════════════════════════════════════════════ */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}
