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

:root {
  --navy: #091F44;
  --gold: #C8A14A;
  --navy-light: #16305C;
  --gold-light: #D4B26A;

  --bg-app: #f4f5f7;
  --bg-panel: #ffffff;
  --bg-hover: #f8fafc;

  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --border-subtle: #f1f5f9;
  --border-light: #e2e8f0;
  --border-med: #cbd5e1;
  --border-focus: var(--navy);

  --topbar-h: 56px;
  --sidebar-w: 270px;

  --radius: 4px;
  --radius-card: 6px;
  --transition: 150ms ease;

  --font: 'Inter', system-ui, -apple-system, sans-serif;

  --selected-bg: #f0f4fa;
  --selected-border: var(--navy);
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-main);
  background: var(--bg-app);
  letter-spacing: -0.01em;
}

/* ── GLOBALS / FORMS ── */
input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
}

.num-input, .proj-dialog-input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text-main);
  transition: border-color var(--transition);
}
.num-input:focus, .proj-dialog-input:focus {
  border-color: var(--navy);
}
.num-input::placeholder, .proj-dialog-input::placeholder {
  color: var(--text-muted);
}
.num-input.full-w {
  width: 100%;
}
.prefix-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.prefix {
  position: absolute;
  left: 10px;
  font-size: 13px;
  color: var(--text-muted);
  pointer-events: none;
}
.num-input.with-prefix {
  padding-left: 22px;
}
.form-group {
  margin-top: 12px;
}

/* ── LOADING OVERLAY ── */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; backdrop-filter: blur(4px);
}
.loading-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-card);
  padding: 32px;
  max-width: 400px; width: 90%;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  box-shadow: 0 12px 32px rgba(9, 31, 68, 0.08);
  text-align: center;
}
.loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border-light);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-title {
  font-size: 16px; font-weight: 700; color: var(--navy);
}
.loading-title-brand {
  color: var(--gold); font-weight: 500; font-size: 12px;
}
.loading-msg {
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
}
.loading-note {
  font-size: 12px; color: var(--text-muted); line-height: 1.5;
}
.loading-retry-btn {
  margin-top: 12px; padding: 8px 20px;
  background: var(--navy); color: #fff;
  border: none; border-radius: var(--radius);
  font-weight: 600; cursor: pointer;
  transition: background var(--transition);
}
.loading-retry-btn:hover {
  background: var(--navy-light);
}

/* ── TOAST ── */
.toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 600; }
.toast { padding: 10px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 500; color: #fff; background: var(--navy); box-shadow: 0 4px 12px rgba(9,31,68,0.2); animation: toastIn 0.2s ease; max-width: 320px; }
.toast.error { background: #b91c1c; }
.toast.success { background: #15803d; }
@keyframes toastIn { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: translateY(0); } }

/* ── TOPBAR ── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--navy);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; z-index: 100;
  color: #fff;
}
.topbar-left {
  display: flex; align-items: center; gap: 32px;
}
.app-brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: #fff;
}
.app-logo {
  height: 28px; width: auto; object-fit: contain; border-radius: 4px;
}
.app-brand-text { display: flex; flex-direction: column; }
.app-title { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }
.app-title-accent { color: var(--gold); }
.app-subtitle { display: none; }

.app-switcher {
  display: flex; align-items: center; gap: 4px;
}
.switcher-link {
  color: rgba(255,255,255,0.7);
  text-decoration: none; font-size: 13px; font-weight: 500;
  padding: 6px 12px; border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
}
.switcher-link:hover {
  color: #fff; background: rgba(255,255,255,0.1);
}
.switcher-link.active {
  color: var(--navy); background: #fff; font-weight: 600;
}

.topbar-center {
  flex: 1; display: flex; justify-content: center; padding: 0 20px;
}
.search-wrap {
  position: relative; width: 100%; max-width: 480px;
}
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: rgba(255,255,255,0.5); pointer-events: none;
}
.search-input {
  width: 100%; height: 32px;
  padding: 0 12px 0 36px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 16px; color: #fff;
  font-size: 13px;
  transition: background var(--transition), border-color var(--transition);
}
.search-input:focus {
  background: rgba(255,255,255,0.15);
  border-color: var(--gold);
}
.search-input::placeholder { color: rgba(255,255,255,0.5); }

/* Search dropdown */
.search-dropdown {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-panel); border: 1px solid var(--border-light);
  border-radius: var(--radius-card); box-shadow: 0 8px 32px rgba(9,31,68,0.15);
  z-index: 300; max-height: 420px; overflow-y: auto; color: var(--text-main);
}
.search-result-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  cursor: pointer; border-bottom: 1px solid var(--border-subtle);
}
.search-result-item:hover { background: var(--bg-hover); }
.type-chip {
  display: inline-flex; align-items: center; padding: 2px 6px;
  border-radius: 4px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
}
.type-chip-owner { background: #e0e7ff; color: #3730a3; }
.type-chip-manager { background: #fae8ff; color: #86198f; }
.type-chip-building { background: #fef3c7; color: #92400e; }
.search-result-body { flex: 1; min-width: 0; }
.search-result-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-sub { font-size: 11px; color: var(--text-secondary); }
.search-no-results { padding: 16px; font-size: 13px; color: var(--text-muted); text-align: center; }

.topbar-right {
  display: flex; align-items: center; gap: 12px; min-width: 200px; justify-content: flex-end;
}
.header-action-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff; font-size: 13px; font-weight: 600;
  padding: 6px 12px; border-radius: var(--radius);
  cursor: pointer; transition: background var(--transition);
}
.header-action-btn:hover { background: rgba(255, 255, 255, 0.2); }
.stat-chips {
  display: flex; align-items: center; gap: 6px;
}
.chip {
  display: inline-flex; align-items: center; padding: 3px 8px;
  border-radius: 4px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.chip-gray { background: rgba(255,255,255,0.1); color: #fff; }
.chip-blue { background: rgba(59,130,246,0.2); color: #93c5fd; }
.chip-green { background: rgba(34,197,94,0.2); color: #86efac; }

.refresh-wrap {
  display: flex; align-items: center; gap: 8px;
}
.refresh-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  background: transparent; border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius); color: #fff;
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: background var(--transition);
}
.refresh-btn:hover { background: rgba(255,255,255,0.1); }
.refresh-icon.spinning { animation: spin 0.8s linear infinite; }
.refresh-ts { font-size: 11px; color: rgba(255,255,255,0.6); white-space: nowrap; }

.auth-box { position: relative; }
.auth-user-btn {
  background: transparent; border: none; color: #fff;
  font-size: 13px; font-weight: 500; cursor: pointer;
  padding: 6px 8px; border-radius: var(--radius);
}
.auth-user-btn:hover { background: rgba(255,255,255,0.1); }
.user-menu {
  position: absolute; top: calc(100% + 4px); right: 0;
  background: var(--bg-panel); border: 1px solid var(--border-light);
  border-radius: var(--radius-card); box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  min-width: 180px; padding: 6px 0; z-index: 300;
}
.user-menu-item {
  width: 100%; text-align: left; padding: 8px 16px;
  background: transparent; border: none; color: var(--text-main);
  font-size: 13px; font-weight: 500; cursor: pointer;
}
.user-menu-item:hover { background: var(--bg-hover); color: var(--navy); }
.user-menu-divider { height: 1px; background: var(--border-subtle); margin: 4px 0; }

/* ── LAYOUT ── */
.layout {
  display: flex; position: fixed; top: var(--topbar-h); left: 0; right: 0; bottom: 0;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--border-light);
  overflow-y: auto; flex-shrink: 0;
}
.sidebar-inner {
  padding: 16px; display: flex; flex-direction: column; gap: 20px;
}
.filter-section {
  display: flex; flex-direction: column; gap: 10px;
}
.filter-label {
  font-size: 10px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.quick-filters { display: flex; flex-direction: column; gap: 4px; }
.qf-btn {
  width: 100%; text-align: left; padding: 6px 10px;
  background: var(--bg-app); border: 1px solid var(--border-light);
  border-radius: var(--radius); color: var(--text-secondary);
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: all var(--transition);
}
.qf-btn:hover { border-color: var(--border-med); color: var(--text-main); }
.qf-btn.active { background: var(--navy); border-color: var(--navy); color: #fff; }

.checkbox-group { display: flex; flex-direction: column; gap: 6px; }
.checkbox-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-main); cursor: pointer; user-select: none;
}
.checkbox-item input[type="checkbox"] { width: 14px; height: 14px; accent-color: var(--navy); cursor: pointer; }

.range-inputs { display: flex; gap: 8px; }
.range-field { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.range-lbl { font-size: 11px; color: var(--text-secondary); }

.status-filter-group { display: flex; flex-wrap: wrap; gap: 6px; }
.sf-chip {
  padding: 4px 10px; border-radius: 4px; font-size: 11px; font-weight: 500;
  border: 1px solid var(--border-light); background: var(--bg-app);
  color: var(--text-secondary); cursor: pointer; transition: all var(--transition);
}
.sf-chip:hover { border-color: var(--border-med); color: var(--text-main); }
.sf-chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; }
.toggle-lbl { font-size: 13px; color: var(--text-main); }
.toggle { position: relative; width: 32px; height: 18px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute; inset: 0; background: var(--border-med);
  border-radius: 18px; transition: background var(--transition);
}
.toggle-track::after {
  content: ''; position: absolute; left: 2px; top: 2px;
  width: 14px; height: 14px; background: #fff; border-radius: 50%;
  transition: transform var(--transition);
}
.toggle input:checked + .toggle-track { background: var(--navy); }
.toggle input:checked + .toggle-track::after { transform: translateX(14px); }

.filter-actions { margin-top: 8px; border-top: 1px solid var(--border-light); padding-top: 16px; }
.reset-btn {
  width: 100%; padding: 8px; background: transparent;
  border: 1px solid var(--border-light); border-radius: var(--radius);
  color: var(--text-secondary); font-size: 12px; font-weight: 500; cursor: pointer;
}
.reset-btn:hover { background: var(--bg-hover); color: var(--text-main); border-color: var(--border-med); }

/* ── MAIN AREA ── */
.main-area { display: flex; flex: 1; overflow: hidden; }

/* ── LIST PANE ── */
.list-pane {
  width: 440px; min-width: 320px; max-width: 500px;
  display: flex; flex-direction: column; background: var(--bg-panel);
  border-right: 1px solid var(--border-light); flex-shrink: 0;
}
.tab-bar-wrap {
  padding: 16px 20px 0;
  background: var(--bg-app);
  position: relative;
  z-index: 495;
}
.tab-bar-wrap::-webkit-scrollbar { display: none; }
.tab-bar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--border-subtle);
  padding: 4px;
  border-radius: 8px;
  gap: 2px;
}
.tab-btn {
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active {
  background: var(--bg-panel);
  color: var(--navy);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.tab-count {
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(9, 31, 68, 0.1); color: var(--navy);
  font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 12px;
}
.tab-btn.active .tab-count { background: var(--navy); color: #fff; }

.mgr-type-bar {
  display: flex; align-items: center; gap: 6px; padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle); background: var(--bg-panel);
}
.filter-group-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.mtype-chip, .ichip {
  padding: 4px 10px; border: 1px solid var(--border-light); border-radius: 4px;
  background: var(--bg-app); color: var(--text-secondary); font-size: 11px; font-weight: 600; cursor: pointer;
}
.mtype-chip.active, .ichip.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.ibar-sep { width: 1px; height: 16px; background: var(--border-light); margin: 0 4px; }
.ifu-chip { display: inline-flex; align-items: center; }

.list-header-wrapper {
  background: var(--bg-panel); border-bottom: 1px solid var(--border-light);
}
.list-header {
  display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 36px;
}
.sort-col {
  font-size: 11px; font-weight: 600; color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; gap: 4px; text-transform: uppercase;
}
.sort-col:hover, .sort-col.active-sort { color: var(--navy); }
.sa { font-size: 10px; }
.lh-name { flex: 1; min-width: 80px; }
.lh-count { width: 60px; text-align: center; justify-content: center; flex-shrink: 0; }
.lh-viol { width: 52px; text-align: center; justify-content: center; flex-shrink: 0; }
.lh-balance { width: 78px; text-align: right; justify-content: flex-end; flex-shrink: 0; }
.lh-score { width: 56px; text-align: right; justify-content: flex-end; flex-shrink: 0; }
.lh-type { width: 62px; text-align: center; justify-content: center; flex-shrink: 0; }
.lh-follow { width: 92px; text-align: right; justify-content: flex-end; flex-shrink: 0; }

.list-status { padding: 6px 16px; font-size: 11px; color: var(--text-muted); background: var(--bg-app); border-bottom: 1px solid var(--border-subtle); }
.entity-list { flex: 1; overflow-y: auto; }
.entity-list::-webkit-scrollbar { width: 6px; }
.entity-list::-webkit-scrollbar-thumb { background: var(--border-med); border-radius: 4px; }

.load-more-wrap { padding: 12px; border-top: 1px solid var(--border-light); display: flex; align-items: center; gap: 10px; background: var(--bg-panel); }
.load-more-btn { padding: 6px 12px; border: 1px solid var(--border-light); border-radius: var(--radius); background: var(--bg-app); font-size: 12px; font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.load-more-btn:hover { background: var(--border-subtle); color: var(--text-main); }
.load-more-count { font-size: 11px; color: var(--text-muted); }

/* Entity row */

/* ── PROSPECTS-STYLE GRID & CARDS ── */
.entity-list.grid-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  padding: 16px;
  align-items: start;
}

/* Card Root */
.entity-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.entity-card:hover {
  border-color: rgba(9, 31, 68, 0.3);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.entity-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold);
}

/* Building row variant spans full width or looks different? */
.entity-card.building-card {
  flex-direction: row;
  grid-column: 1 / -1; /* buildings span full width if we wanted, or just standard 2 col */
}
@media(min-width: 768px) {
  .entity-card.building-card {
    grid-column: span 2;
  }
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.card-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card-name {
  font-family: Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-sub {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-sub-icon {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.card-badge {
  background: var(--bg-hover);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
}
.card-badge.similar {
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
}
.card-badge.hpd {
  background: #e0e7ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
}

.card-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  margin-top: auto;
}
.stat-col {
  display: flex;
  flex-direction: column;
}
.stat-lbl {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat-val {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-val.text-red {
  color: #dc2626;
}
.stat-icon {
  width: 12px;
  height: 12px;
  color: var(--text-muted);
}

.interested-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}
.interested-toggle:hover {
  background: var(--bg-hover);
}
/* Building Card specific styling */
.building-card-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.building-card-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  justify-content: flex-end;
  border-left: 1px solid var(--border-light);
  padding-left: 16px;
  min-width: 140px;
}
@media(max-width: 639px) {
  .entity-card.building-card { flex-direction: column; }
  .building-card-right { border-left: none; border-top: 1px solid var(--border-light); padding-left: 0; padding-top: 12px; flex-direction: row; justify-content: space-between; align-items: flex-end;}
}
.bldg-relations {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 8px;
}
.bldg-relation {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.bldg-relation-lbl {
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 10px;
}
.bldg-relation-val {
  font-weight: 500;
  color: var(--navy);
}
.bldg-relation-val:hover {
  text-decoration: underline;
}



/* ── DETAIL PANE ── */
.detail-pane { flex: 1; min-width: 0; background: var(--bg-app); overflow-y: auto; }
.detail-pane::-webkit-scrollbar { width: 8px; }
.detail-pane::-webkit-scrollbar-thumb { background: var(--border-med); border-radius: 4px; border: 2px solid var(--bg-app); }

.detail-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 16px; color: var(--text-muted); font-size: 14px; }
.empty-icon-wrap { width: 48px; height: 48px; border-radius: 50%; background: var(--border-light); display: flex; align-items: center; justify-content: center; color: var(--text-secondary); }

.detail-content { padding: 32px; max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }

.detail-top { display: flex; flex-direction: column; gap: 8px; }
.detail-type-row { display: flex; align-items: center; gap: 8px; }
.detail-type-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.05em; }
.detail-type-owner { background: #e0e7ff; color: #3730a3; }
.detail-type-manager { background: #fae8ff; color: #86198f; }
.detail-type-building { background: #fef3c7; color: #92400e; }

.detail-name { font-size: 24px; font-weight: 700; color: var(--navy); line-height: 1.2; letter-spacing: -0.02em; }
.detail-sub { font-size: 14px; color: var(--text-secondary); font-weight: 500; }
.detail-aliases { font-size: 12px; color: var(--text-muted); font-style: italic; }

.detail-status-row { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid var(--border-light); }
.status-select { height: 32px; padding: 0 12px; border: 1px solid var(--border-med); border-radius: var(--radius); font-weight: 600; color: var(--text-main); background: var(--bg-panel); cursor: pointer; }

/* Action buttons */
.action-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.act-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--radius); font-size: 12px; font-weight: 600; cursor: pointer; transition: background var(--transition); border: 1px solid transparent; }
.act-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-call { background: var(--navy); color: #fff; }
.btn-call:hover { background: var(--navy-light); }
.btn-email { background: #475569; color: #fff; }
.btn-email:hover { background: #334155; }
.btn-interested { background: #f0fdf4; color: #15803d; border-color: #86efac; }
.btn-interested:hover { background: #dcfce7; }
.btn-interested-active { background: #16a34a; color: #fff; border-color: #15803d; }
.btn-interested-active:hover { background: #15803d; }

/* Stats grid */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat-tile { background: var(--bg-panel); border: 1px solid var(--border-light); border-radius: var(--radius-card); padding: 16px; display: flex; flex-direction: column; gap: 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.02); }
.stat-num { font-size: 24px; font-weight: 700; color: var(--navy); line-height: 1; letter-spacing: -0.02em; }
.stat-lbl { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.red-tile { background: #fef2f2; border-color: #fecaca; }
.red-num { color: #b91c1c; }

.recent-stats-line { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius); font-size: 12px; font-weight: 600; }
.recent-stats-line.rsl-warn { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.recent-stats-line.rsl-none { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }

.recent-bldg-list { margin-top: 8px; border: 1px solid #fecaca; border-radius: var(--radius-card); background: var(--bg-panel); max-height: 240px; overflow-y: auto; }
.recent-bldg-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 12px; border-bottom: 1px solid #fee2e2; }
.recent-bldg-row:last-child { border-bottom: none; }
.rb-addr { flex: 1; font-weight: 600; color: var(--text-main); }
.rb-boro { color: var(--text-secondary); font-size: 11px; }
.rb-count { color: #b91c1c; font-weight: 700; }
.recent-bldg-more { padding: 8px 12px; font-size: 11px; color: var(--text-muted); font-style: italic; background: #fff5f5; }

/* Notes */
.detail-section { display: flex; flex-direction: column; gap: 12px; }
.section-lbl { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.notes-lbl { font-size: 12px; font-weight: 600; color: var(--text-main); }
.notes-ta { width: 100%; padding: 12px; border: 1px solid var(--border-med); border-radius: var(--radius-card); background: var(--bg-panel); resize: vertical; min-height: 80px; font-size: 13px; line-height: 1.5; color: var(--text-main); }

/* Contacts & Portfolio */
.contact-card { position: relative; background: var(--bg-panel); border: 1px solid var(--border-light); border-radius: var(--radius-card); padding: 16px; display: flex; flex-direction: column; gap: 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.02); }
.contact-name { font-size: 14px; font-weight: 600; color: var(--navy); padding-right: 60px; }
.contact-sub { font-size: 12px; color: var(--text-secondary); }
.copy-btn { position: absolute; top: 12px; right: 12px; padding: 4px 8px; background: var(--bg-app); border: 1px solid var(--border-light); border-radius: var(--radius); font-size: 11px; font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.copy-btn:hover { background: var(--border-light); color: var(--text-main); }

.contact-inputs { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: 8px; }
.contact-input-row { display: flex; align-items: center; gap: 8px; }
.contact-input { flex: 1; height: 32px; padding: 0 10px; border: 1px solid var(--border-light); border-radius: var(--radius); font-size: 12px; }
.contact-input-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border-light); border-radius: var(--radius); background: var(--bg-app); color: var(--text-secondary); cursor: pointer; text-decoration: none; }
.contact-input-btn:hover { background: var(--border-med); color: var(--text-main); }

.portfolio-list { border: 1px solid var(--border-light); border-radius: var(--radius-card); background: var(--bg-panel); overflow: hidden; }
.portfolio-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border-subtle); text-decoration: none; color: inherit; }
.portfolio-row:last-child { border-bottom: none; }
.portfolio-row:hover { background: var(--bg-hover); }
.portfolio-row-addr { flex: 1; font-size: 13px; font-weight: 500; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portfolio-row-boro { font-size: 11px; color: var(--text-muted); }
.portfolio-row-viol { font-size: 12px; font-weight: 700; color: #b91c1c; }
.portfolio-row-viol.zero { color: var(--text-muted); font-weight: 500; }
.portfolio-more { padding: 10px; text-align: center; font-size: 12px; font-weight: 600; color: var(--navy); background: var(--bg-app); }

.contacts-list { display: flex; flex-direction: column; gap: 8px; }
.contact-item { background: var(--bg-panel); border: 1px solid var(--border-light); border-radius: var(--radius-card); padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.contact-item-type { font-size: 10px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.contact-item-name { font-size: 13px; font-weight: 600; color: var(--navy); }
.contact-item-corp { font-size: 12px; color: var(--text-secondary); }

.hpd-link { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; background: #e0e7ff; color: #3730a3; border-radius: var(--radius); font-size: 12px; font-weight: 600; text-decoration: none; }
.hpd-link:hover { background: #c7d2fe; }

/* Activity Log */
.activity-log { display: flex; flex-direction: column; }
.activity-entry { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-subtle); }
.activity-entry:last-child { border-bottom: none; }
.activity-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--bg-app); border: 1px solid var(--border-light); display: flex; align-items: center; justify-content: center; color: var(--text-secondary); }
.activity-body { flex: 1; }
.activity-desc { font-size: 13px; font-weight: 500; color: var(--text-main); }
.activity-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── OVERLAYS / DIALOGS ── */
.proj-popover-overlay, .proj-dialog-overlay, .mail-overlay, .auth-overlay, .users-overlay {
  position: fixed; inset: 0; background: rgba(9, 31, 68, 0.4); z-index: 400; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px);
}
.proj-popover {
  position: absolute; background: var(--bg-panel); border-radius: var(--radius-card); box-shadow: 0 12px 32px rgba(9,31,68,0.15); border: 1px solid var(--border-light); width: 300px; z-index: 410; display: flex; flex-direction: column; overflow: hidden;
}
.proj-popover-header { padding: 12px 16px; background: var(--bg-app); border-bottom: 1px solid var(--border-light); display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: 13px; color: var(--navy); }
.proj-popover-close, .mail-close { background: transparent; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; padding: 4px; line-height: 1; }
.proj-popover-close:hover, .mail-close:hover { color: var(--text-main); }
.proj-popover-list { max-height: 240px; overflow-y: auto; }
.proj-popover-item { padding: 10px 16px; border-bottom: 1px solid var(--border-subtle); display: flex; flex-direction: column; cursor: pointer; }
.proj-popover-item:hover { background: var(--bg-hover); }
.proj-popover-item-name { font-size: 13px; font-weight: 600; color: var(--text-main); }
.proj-popover-item-sub { font-size: 11px; color: var(--text-secondary); }
.proj-popover-footer { padding: 12px 16px; border-top: 1px solid var(--border-light); background: var(--bg-app); }
.proj-new-btn { width: 100%; padding: 8px; background: var(--navy); color: #fff; border: none; border-radius: var(--radius); font-weight: 600; cursor: pointer; }
.proj-new-btn:hover { background: var(--navy-light); }

.proj-dialog { background: var(--bg-panel); border-radius: var(--radius-card); width: 440px; max-width: 90%; z-index: 410; box-shadow: 0 20px 40px rgba(9,31,68,0.2); }
.proj-dialog-header { padding: 16px 20px; border-bottom: 1px solid var(--border-light); display: flex; justify-content: space-between; font-size: 16px; font-weight: 700; color: var(--navy); }
.proj-dialog-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.proj-dialog-label { font-size: 12px; font-weight: 600; color: var(--text-main); margin-bottom: 6px; display: block; }
.proj-dialog-footer { padding: 16px 20px; background: var(--bg-app); border-top: 1px solid var(--border-light); display: flex; justify-content: flex-end; gap: 12px; border-radius: 0 0 var(--radius-card) var(--radius-card); }
.proj-dialog-cancel { padding: 8px 16px; background: transparent; border: 1px solid var(--border-med); border-radius: var(--radius); font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.proj-dialog-save { padding: 8px 16px; background: var(--navy); border: none; border-radius: var(--radius); font-weight: 600; color: #fff; cursor: pointer; }

.proj-type-picker { display: flex; flex-direction: column; gap: 8px; }
.proj-type-option { display: flex; align-items: flex-start; gap: 12px; padding: 12px; border: 1px solid var(--border-light); border-radius: var(--radius); cursor: pointer; transition: all var(--transition); }
.proj-type-option:hover { background: var(--bg-hover); }
.proj-type-option.selected { border-color: var(--navy); background: var(--selected-bg); }
.proj-type-option input { margin-top: 4px; accent-color: var(--navy); }
.proj-type-name { font-weight: 600; font-size: 13px; color: var(--navy); }
.proj-type-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* Mail Now */
.mail-panel { background: var(--bg-panel); border-radius: var(--radius-card); width: 800px; max-width: 95%; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 40px rgba(9,31,68,0.2); }
.mail-panel-head { padding: 16px 20px; border-bottom: 1px solid var(--border-light); display: flex; justify-content: space-between; align-items: flex-start; }
.mail-panel-title { font-size: 18px; font-weight: 700; color: var(--navy); }
.mail-panel-sub { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.mail-panel-body { padding: 20px; overflow-y: auto; flex: 1; background: var(--bg-app); }
.mail-loading { text-align: center; padding: 40px; color: var(--text-muted); font-weight: 500; }
.mail-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.mail-card { background: var(--bg-panel); border: 1px solid var(--border-light); border-radius: var(--radius-card); padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.mail-card-head { font-weight: 600; color: var(--navy); font-size: 14px; margin-bottom: 4px; }
.mail-card-addr { font-size: 12px; color: var(--text-secondary); line-height: 1.4; white-space: pre-wrap; margin-bottom: 12px; }
.mail-card-meta { padding-top: 12px; border-top: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--text-secondary); }
.mail-card-meta strong { color: var(--text-main); }
.mail-card.has-error { border-color: #fca5a5; background: #fef2f2; }
.mail-err-badge { display: inline-block; padding: 2px 6px; background: #b91c1c; color: #fff; font-size: 10px; font-weight: 700; border-radius: 3px; margin-bottom: 8px; text-transform: uppercase; }
.mail-panel-foot { padding: 16px 20px; border-top: 1px solid var(--border-light); display: flex; justify-content: space-between; align-items: center; background: var(--bg-panel); }
.mail-foot-info { font-size: 13px; font-weight: 500; color: var(--navy); }
.mail-foot-actions { display: flex; gap: 12px; }
.mail-cancel-btn { padding: 8px 16px; background: transparent; border: 1px solid var(--border-med); border-radius: var(--radius); font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.mail-validate-btn { padding: 8px 16px; background: var(--bg-app); border: 1px solid var(--navy); border-radius: var(--radius); font-weight: 600; color: var(--navy); cursor: pointer; }
.mail-send-btn { padding: 8px 16px; background: var(--navy); border: none; border-radius: var(--radius); font-weight: 600; color: #fff; cursor: pointer; }
.mail-send-btn:disabled, .mail-validate-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Auth / Chooser */
.auth-card { background: var(--bg-panel); border-radius: var(--radius-card); padding: 40px; width: 400px; max-width: 90%; box-shadow: 0 20px 40px rgba(9,31,68,0.15); display: flex; flex-direction: column; align-items: center; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-brand img { height: 32px; }
.auth-title { font-size: 20px; font-weight: 700; color: var(--navy); margin-bottom: 8px; text-align: center; }
.auth-sub { font-size: 13px; color: var(--text-secondary); text-align: center; margin-bottom: 24px; line-height: 1.5; }
#authForm { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field label { font-size: 12px; font-weight: 600; color: var(--text-main); }
.auth-error { padding: 10px 12px; background: #fef2f2; color: #b91c1c; border-left: 3px solid #b91c1c; font-size: 12px; font-weight: 600; border-radius: 0 4px 4px 0; }
.auth-submit { width: 100%; padding: 10px; background: var(--navy); color: #fff; border: none; border-radius: var(--radius); font-size: 14px; font-weight: 600; cursor: pointer; margin-top: 8px; transition: background var(--transition); }
.auth-submit:hover { background: var(--navy-light); }

.chooser-card { width: 480px; }
.chooser-btns { width: 100%; display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.chooser-btn { background: var(--bg-panel); border: 1px solid var(--border-light); border-radius: var(--radius-card); padding: 16px; text-align: left; cursor: pointer; transition: all var(--transition); display: flex; flex-direction: column; gap: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.chooser-btn:hover { border-color: var(--navy); box-shadow: 0 4px 12px rgba(9,31,68,0.08); transform: translateY(-1px); }
.chooser-btn-title { font-size: 15px; font-weight: 700; color: var(--navy); }
.chooser-btn-sub { font-size: 12px; color: var(--text-secondary); }

/* Users Modal */
.users-card { background: var(--bg-panel); border-radius: var(--radius-card); width: 600px; max-width: 95%; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 40px rgba(9,31,68,0.2); }
.users-head { padding: 16px 20px; border-bottom: 1px solid var(--border-light); display: flex; justify-content: space-between; align-items: center; }
.users-title { font-size: 16px; font-weight: 700; color: var(--navy); }
.users-list { overflow-y: auto; flex: 1; padding: 0; background: var(--bg-app); }
.users-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--border-light); background: var(--bg-panel); }
.users-row-main { display: flex; align-items: center; gap: 12px; }
.users-row-name { font-weight: 600; color: var(--text-main); font-size: 13px; }
.users-row-email { color: var(--text-secondary); font-size: 12px; }
.users-row-role { padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; background: var(--border-light); color: var(--text-secondary); }
.users-row-role.role-admin { background: #e0e7ff; color: #3730a3; }
.users-row-actions { display: flex; gap: 8px; }
.auth-mini-btn { padding: 4px 10px; background: var(--bg-app); border: 1px solid var(--border-med); border-radius: var(--radius); font-size: 11px; font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.auth-mini-btn:hover { background: var(--border-light); color: var(--text-main); }
.users-del-btn { border-color: #fca5a5; color: #b91c1c; }
.users-del-btn:hover { background: #fef2f2; }
.users-add { padding: 20px; border-top: 1px solid var(--border-light); background: var(--bg-panel); }
.users-add-title { font-size: 13px; font-weight: 700; color: var(--navy); margin-bottom: 12px; }
.users-add-row { display: flex; gap: 12px; }
.users-add-row input { flex: 1; }
.users-add-btn { margin-top: var(--topbar-h); padding: 0 16px; height: 32px; width: auto; flex-shrink: 0; }
.users-empty { padding: 20px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* Partners Page */
.partners-page { position: fixed; inset: 0; background: var(--bg-app); z-index: 100; overflow-y: auto; padding-top: var(--topbar-h); }
.partners-inner { max-width: 1000px; margin: 0 auto; padding: 32px 20px; display: flex; flex-direction: column; gap: 24px; }
.partners-head { display: flex; justify-content: space-between; align-items: flex-start; }
.partners-title { font-size: 24px; font-weight: 700; color: var(--navy); letter-spacing: -0.02em; }
.partners-sub { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }
.partners-add { background: var(--bg-panel); border: 1px solid var(--border-light); border-radius: var(--radius-card); padding: 24px; box-shadow: 0 2px 8px rgba(9,31,68,0.04); }
.partners-add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.partners-list { display: flex; flex-direction: column; gap: 16px; }
.partner-card { background: var(--bg-panel); border: 1px solid var(--border-light); border-radius: var(--radius-card); padding: 20px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.02); }
.partner-card-top { display: flex; gap: 12px; align-items: center; }
.partner-name-input { flex: 1; font-size: 16px; font-weight: 700; color: var(--navy); border: 1px solid transparent; padding: 4px 8px; border-radius: 4px; background: transparent; transition: background 0.2s, border-color 0.2s; }
.partner-name-input:focus, .partner-name-input:hover { background: var(--bg-hover); border-color: var(--border-med); }
.partner-status { padding: 4px 10px; border-radius: var(--radius); font-size: 12px; font-weight: 600; border: 1px solid var(--border-med); background: var(--bg-app); cursor: pointer; }
.partner-status-discovered { background: #fef9c3; color: #854d0e; border-color: #fde047; }
.partner-status-in_contact { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; }
.partner-status-established { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.partner-card-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; background: var(--bg-app); padding: 12px; border-radius: var(--radius); border: 1px solid var(--border-subtle); }
.partner-card-meta label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; display: flex; flex-direction: column; gap: 4px; }
.partner-card-meta input { background: transparent; border: 1px solid transparent; font-size: 13px; color: var(--text-main); font-weight: 500; padding: 4px; border-radius: 4px; transition: all 0.2s; }
.partner-card-meta input:focus, .partner-card-meta input:hover { background: #fff; border-color: var(--border-med); }
.partner-notes { border: 1px solid transparent; background: transparent; font-size: 13px; color: var(--text-main); line-height: 1.5; padding: 8px; border-radius: 4px; resize: vertical; min-height: 60px; transition: all 0.2s; }
.partner-notes:focus, .partner-notes:hover { background: var(--bg-hover); border-color: var(--border-med); }
.partner-card-foot { font-size: 11px; color: var(--text-muted); text-align: right; }

/* ── RESPONSIVE ── */
.mobile-only { display: none; }
.mobile-back-bar { display: none; }
@media (max-width: 768px) {
  .sidebar { position: fixed; inset: 0; top: var(--topbar-h); transform: translateX(-100%); transition: transform var(--transition); z-index: 200; width: 85%; max-width: 320px; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .mobile-only { display: inline-flex; }

  .layout { flex-direction: column; }
  .list-pane { width: 100%; max-width: none; border-right: none; }

  .detail-pane { position: fixed; inset: 0; top: var(--topbar-h); z-index: 250; transform: translateX(100%); transition: transform var(--transition); }
  .detail-pane.open { transform: translateX(0); }
  .mobile-back-bar { display: flex; align-items: center; gap: 8px; padding: 12px 16px; background: var(--bg-app); border-bottom: 1px solid var(--border-light); font-weight: 600; color: var(--navy); cursor: pointer; }

  .topbar-left { gap: 12px; }
  .app-switcher { display: none; }
  .stat-chips { display: none; }
  .search-wrap { display: none; }
}

/* Projects overrides */
.projects-panel { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.projects-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--border-light); background: var(--bg-panel); }
.projects-panel-title { font-size: 14px; font-weight: 700; color: var(--navy); }
.proj-new-top-btn { padding: 6px 12px; background: var(--navy); color: #fff; border: none; border-radius: var(--radius); font-size: 12px; font-weight: 600; cursor: pointer; }
.proj-new-top-btn:hover { background: var(--navy-light); }
.projects-list { flex: 1; overflow-y: auto; }
.project-list-item { display: flex; align-items: center; padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--border-subtle); gap: 12px; }
.project-list-item:hover { background: var(--bg-hover); }
.project-list-item.selected { background: var(--selected-bg); border-right: 3px solid var(--selected-border); }
.proj-list-icon { width: 36px; height: 36px; background: #e0e7ff; color: #3730a3; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; flex-shrink: 0; }
.proj-list-body { flex: 1; min-width: 0; }
.proj-list-name { font-size: 13px; font-weight: 600; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-list-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.proj-list-count { font-size: 12px; font-weight: 600; color: var(--text-secondary); flex-shrink: 0; }


/* ── NEW LAYOUT OVERRIDES ── */
.layout {
  display: flex; flex-direction: column; position: fixed; top: var(--topbar-h); left: 0; right: 0; bottom: 0;
  background: var(--bg-app); overflow: hidden;
}
.main-area { display: flex; flex-direction: column; width: 100%; height: 100%; overflow: hidden; }

/* Filter Bar */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 12px; padding: 16px;
  background: var(--bg-panel); border: 1px solid var(--border-light);
  border-radius: var(--radius);
  align-items: center; margin: 16px 20px 0 20px;
  box-shadow: var(--shadow-sm);
}

.filter-item { flex-shrink: 0; display: flex; align-items: center; gap: 6px; font-size: 12px; }
.compact-select, .compact-num {
  height: 28px; padding: 0 8px; border: 1px solid var(--border-light);
  border-radius: var(--radius); background: var(--bg-app); font-size: 12px; color: var(--text-main);
  outline: none;
}
.compact-select:focus, .compact-num:focus { border-color: var(--navy); }
.compact-num { width: 60px; }
.compact-num.w-full { width: 100%; }
.search-input.compact { min-width: 200px; padding-left: 28px; height: 28px; border-radius: 14px; border: 1px solid var(--border-light); background: var(--bg-app); font-size: 12px; color: var(--text-main); transition: border 0.15s; outline: none; }
.search-input.compact:focus { border-color: var(--navy); }
.search-icon { position: absolute; left: 8px; color: var(--text-muted); pointer-events: none; }

.dropdown-wrap { position: relative; }
.dropdown-label {
  height: 28px; display: inline-flex; align-items: center; padding: 0 10px;
  background: var(--bg-app); border: 1px solid var(--border-light); color: var(--text-main);
  border-radius: var(--radius); cursor: pointer; font-weight: 500; user-select: none;
}
.dropdown-label:hover { border-color: var(--border-med); }
.dropdown-popover {
  position: absolute; top: 100%; left: 0; margin-top: 4px;
  background: var(--bg-panel); border: 1px solid var(--border-light);
  border-radius: var(--radius); padding: 12px; box-shadow: 0 10px 24px rgba(0,0,0,0.1);
  display: none; flex-direction: column; gap: 8px; z-index: 200; min-width: 180px;
}
.dropdown-wrap:hover .dropdown-popover, .dropdown-wrap:focus-within .dropdown-popover {
  display: flex;
}
.flex-row { display: flex; align-items: center; gap: 8px; }
.sep { color: var(--text-muted); }
.lbl { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }

/* Grid List */
.grid-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px; padding: 16px; overflow-y: auto; align-content: start; flex: 1;
}

/* Card */
.entity-card {
  background: var(--bg-panel); border: 1px solid var(--border-light);
  border-radius: var(--radius-card); padding: 16px; cursor: pointer;
  display: flex; flex-direction: column; gap: 12px; transition: all var(--transition);
  position: relative; box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.entity-card:hover { border-color: rgba(9, 31, 68, 0.3); box-shadow: 0 4px 12px rgba(9,31,68,0.06); }
.entity-card.selected { border-color: var(--navy); box-shadow: 0 0 0 1px var(--navy); }

.card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.card-title-group { display: flex; flex-direction: column; gap: 4px; }
.card-name { font-size: 16px; font-weight: 700; color: var(--navy); margin: 0; line-height: 1.2; font-family: Georgia, serif; }
.card-sub { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 4px; }

.card-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.borough-pill { font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 4px; background: var(--bg-app); border: 1px solid var(--border-light); text-transform: uppercase; color: var(--text-secondary); }

.card-stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding-top: 12px; border-top: 1px solid var(--border-subtle); }
.stat-col { display: flex; flex-direction: column; gap: 4px; }
.stat-lbl { font-size: 10px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); }
.stat-val { font-size: 13px; font-weight: 500; display: flex; align-items: center; color: var(--text-main); }
.text-red { color: #b91c1c; }
.card-footer { padding-top: 10px; margin-top: 2px; }

/* Detail Drawer */
.detail-drawer {
  position: fixed; top: var(--topbar-h); right: 0; bottom: 0; width: 100%; max-width: 600px;
  background: var(--bg-panel); border-left: 1px solid var(--border-light);
  box-shadow: -4px 0 24px rgba(0,0,0,0.1); z-index: 500;
  transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex; flex-direction: column;
}
.detail-drawer.open { transform: translateX(0); }
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(9, 31, 68, 0.4);
  z-index: 490; display: none; backdrop-filter: blur(2px);
  pointer-events: none;
}
.drawer-overlay.open { display: block; }

.drawer-header {
  padding: 16px 24px; border-bottom: 1px solid var(--border-light);
  display: flex; justify-content: flex-end; align-items: flex-start;
  background: var(--bg-panel); flex-shrink: 0; height: 56px;
}
.drawer-close { background: none; border: none; cursor: pointer; color: var(--text-muted); }
.drawer-close:hover { color: var(--text-main); }

.detail-content { flex: 1; overflow-y: auto; padding: 0 24px 32px; display: flex; flex-direction: column; gap: 24px; }
.detail-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-muted); font-size: 14px; gap: 16px; }
.user-menu-item.refresh-ts:hover { background: transparent; color: var(--text-muted); cursor: default; }
.qf-btn.active { background: var(--navy); color: white; border-color: var(--navy); }

.how-to-btn { display: flex; align-items: center; background: transparent; border: 1px solid rgba(255,255,255,0.25); color: rgba(255,255,255,0.6); border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; transition: all 0.2s; margin-left: 16px; } .how-to-btn:hover { color: #fff; border-color: rgba(255,255,255,0.5); background: rgba(255,255,255,0.1); }
/* ── RESPONSIVE OVERRIDES ── */
@media (max-width: 899px) {
  .app-switcher, .how-to-btn { display: none !important; }
  .mobile-menu-btn { display: flex; align-items: center; justify-content: center; background: transparent; border: none; color: #fff; cursor: pointer; padding: 4px; border-radius: 4px; }
  .mobile-menu-btn:hover { background: rgba(255,255,255,0.1); }

  .mobile-nav-dropdown {
    position: absolute; top: var(--topbar-h); left: 0; background: var(--bg-panel);
    border: 1px solid var(--border-light); border-radius: 0 0 8px 0;
    box-shadow: var(--shadow-md); z-index: 900; display: none; flex-direction: column;
    min-width: 200px;
  }
  .mobile-nav-dropdown.open { display: flex; }
  .mobile-nav-link { padding: 12px 16px; color: var(--navy); text-decoration: none; font-weight: 600; font-size: 14px; border-left: 3px solid transparent; background: none; text-align: left; cursor: pointer; border-bottom: 1px solid transparent; border-top: none; border-right: none; }
  .mobile-nav-link:hover, .mobile-nav-link.active { background: var(--bg-hover); border-left-color: var(--navy); }
  .mobile-nav-divider { height: 1px; background: var(--border-light); margin: 4px 0; }

  .topbar-right .user-dropdown-btn { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-left { gap: 12px; }
  .topbar-right { min-width: auto; }
  .app-title { font-size: 14px; }
}

@media (max-width: 767px) {
  /* Filter bar toggle */
  .mobile-filter-toggle {
    display: flex !important; align-items: center; background: var(--bg-app);
    border: 1px solid var(--border-med); border-radius: var(--radius);
    padding: 0 12px; height: 28px; font-size: 12px; font-weight: 600; cursor: pointer;
  }
  .filter-bar.portfolio-search-only .mobile-filter-toggle { display: none !important; }
  .filter-bar.portfolio-search-only .filter-item.search-wrap {
    display: flex !important;
    width: 100%;
  }
  .filter-badge {
    background: var(--navy); color: #fff; border-radius: 50%; width: 16px; height: 16px;
    display: inline-flex; align-items: center; justify-content: center; font-size: 10px; margin-left: 6px;
  }
  .filter-bar {
    margin: 12px 12px 0 12px; padding: 12px; gap: 8px; flex-wrap: wrap; align-items: flex-start;
  }
  .filter-bar:not(.expanded) .filter-item:not(#resetFilters):not(.mobile-filter-toggle) {
    display: none !important;
  }
  .filter-bar.expanded { flex-direction: column; align-items: stretch; }
  .filter-bar.expanded .filter-item { width: 100%; justify-content: space-between; }
  .filter-bar.expanded .flex-row { flex-wrap: wrap; }
  .filter-bar.expanded .dropdown-popover { position: relative; top: auto; left: auto; width: 100%; border: none; box-shadow: none; padding-left: 12px; border-left: 2px solid var(--border-light); margin-top: 4px; display: none; }
  .filter-bar.expanded .dropdown-wrap:focus-within .dropdown-popover { display: flex; }
  .filter-bar.expanded .dropdown-label { width: 100%; text-align: left; display: block; padding: 6px 0; border-bottom: 1px solid var(--border-light); }
  .filter-bar.expanded .reset-btn { width: 100%; margin-top: 8px; }
  .filter-bar.expanded .compact-select { max-width: 60%; }

  /* Drawer */
  .detail-drawer { width: 100%; max-width: 100vw; }
  .detail-content { padding: 0 16px 32px; }
  .drawer-header { position: sticky; top: 0; z-index: 10; padding: 12px 16px; height: auto; }
  .detail-content .stat-grid { grid-template-columns: 1fr; }
  .card-stats-grid { grid-template-columns: 1fr 1fr !important; }

  /* Modals max width */
  .proj-dialog, .auth-card, .chooser-card, .users-card, .modal { max-width: calc(100vw - 24px) !important; width: 100% !important; margin: 0 12px; }
  .mail-panel { width: 100vw !important; max-width: 100vw !important; right: 0 !important; border-radius: 0 !important; top: var(--topbar-h); bottom: 0; }
  .users-card { max-width: calc(100vw - 24px); }
  .partners-add-grid, .partner-card-meta { grid-template-columns: 1fr; }
  .partners-inner { padding: 16px 12px; }
  .partners-title { font-size: 20px; }
  .partners-add { padding: 16px; }
  .auth-card, .chooser-card { padding: 24px !important; }
  .users-row { flex-direction: column; align-items: flex-start; gap: 12px; }
  .users-add-row { flex-direction: column; height: auto; }
  .users-add-row input { width: 100%; height: 36px; border-radius: 4px; border: 1px solid var(--border-med); }
  .users-add-btn { width: 100%; margin-top: 8px; }
  .proj-dialog-body, .modal-body, .users-list, .auth-card, .chooser-card, .proj-popover-list { max-height: calc(100vh - 120px); overflow-y: auto; }
  .proj-popover { max-width: calc(100vw - 24px) !important; width: 100% !important; margin: 0 12px; }

  /* Make inputs 16px to prevent iOS zoom */
  input[type="text"], input[type="search"], input[type="number"], input[type="password"], input[type="email"], select, textarea,
  .filter-bar input, .filter-bar select, .compact-select, .compact-input {
    font-size: 16px !important;
  }
}

@media (max-width: 639px) {
  .grid-list { grid-template-columns: 1fr !important; padding: 12px; }
  .tab-bar-wrap { padding: 12px 12px 0; }
  .tab-bar { gap: 8px; }
  .tab-btn { padding: 8px 16px; font-size: 14px; }
  /* Ensure tab-bar scrolls with momentum */
  .tab-bar-wrap { -webkit-overflow-scrolling: touch; }
  .list-header { flex-direction: column; align-items: flex-start; padding: 12px; }
}

@media (min-width: 768px) {
  .mobile-filter-toggle { display: none !important; }
}
@media (min-width: 900px) {
  .mobile-menu-btn { display: none !important; }
  .mobile-nav-dropdown { display: none !important; }
}
