/*@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@300;400;500;600;700&display=swap');*/
@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700&display=swap');

/* ─── HubSpot Design Tokens ──────────────────────────────────────────────── */
:root {
  /* Colours — warm ground, navy actions, red reserved for brand + destructive */
  --hs-navy:          #22365c;
  --hs-navy-hover:    #1b2b4a;
  --hs-navy-active:   #152339;
  --hs-brand:         #ad1826;   /* logo mark + avatar ONLY */
  --hs-orange:        #22365c;   /* kept as an alias so no existing rule breaks */
  --hs-orange-hover:  #1b2b4a;
  --hs-orange-dark:   #1b2b4a;
  --hs-teal:          #0f6f72;
  --hs-teal-light:    #e6f2f1;
  --hs-navy-soft:     #eaeef6;
  --hs-bg:            #f6f3ef;
  --hs-bg-soft:       #faf9f7;
  --hs-white:         #ffffff;
  --hs-text:          #241f1b;
  --hs-text-light:    #574f48;
  --hs-text-muted:    #6b635c;
  --hs-border:        #ece8e3;
  --hs-border-dark:   #d9d2ca;
  --hs-success:       #0f6f72;
  --hs-success-bg:    #e6f2f1;
  --hs-warning:       #8a5500;
  --hs-warning-bg:    #fbf0dc;
  --hs-danger:        #ad1826;
  --hs-danger-bg:     #f7e3e5;
  --hs-sidebar-w:     220px;
  --hs-topbar-h:      56px;

  /* Typography */
  /*--font:             'Lexend', 'Inter', system-ui, sans-serif;*/
  --font:             'Figtree', 'Inter', system-ui, sans-serif;

  /* Radii */
  --r-sm:             8px;
  --r-md:             11px;
  --r-lg:             14px;

  /* Shadows — two layers: a contact edge plus a wide soft spread. This is what
     replaces the borders, so it has to carry the whole separation on its own. */
  --shadow-sm:        0 1px 2px rgba(36,31,27,.04), 0 6px 20px -8px rgba(36,31,27,.10);
  --shadow-md:        0 2px 4px rgba(36,31,27,.05), 0 12px 28px -10px rgba(36,31,27,.14);
  --shadow-lg:        0 8px 40px -8px rgba(36,31,27,.22);
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--hs-bg);
  color: var(--hs-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--hs-teal); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--hs-sidebar-w);
  background: var(--hs-bg);
  border-right: 1px solid var(--hs-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: width .2s ease;
  overflow: hidden;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: var(--hs-topbar-h);
  border-bottom: 1px solid var(--hs-border);
  flex-shrink: 0;
}
.sidebar-logo-icon {
  width: 30px; height: 30px;
  background: var(--hs-brand);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo-icon svg { width: 16px; height: 16px; fill: white; }
.sidebar-logo-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--hs-text);
  letter-spacing: -.2px;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--hs-text-muted);
  padding: 16px 18px 5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 8px;
  padding: 8px 10px;
  color: var(--hs-text-muted);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  transition: background .15s, color .15s;
  text-decoration: none;
  white-space: nowrap;
  border-radius: var(--r-sm);
  position: relative;
}
.nav-item, .nav-item:hover, .nav-item:focus { text-decoration: none !important; }
.nav-item:hover {
  background: rgba(34,54,92,.05);
  color: var(--hs-text);
  text-decoration: none;
}
.nav-item.active {
  background: var(--hs-white);
  color: var(--hs-navy);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(36,31,27,.06);
}
.nav-item.active::before { content: none; }
.nav-item svg {
  width: 16px; height: 16px;
  flex-shrink: 0;
  opacity: .8;
}
.nav-item.active svg, .nav-item:hover svg { opacity: 1; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--hs-border);
  flex-shrink: 0;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--hs-text-muted);
  font-size: 12.5px;
}
.sidebar-avatar {
  width: 30px; height: 30px;
  background: var(--hs-brand);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

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

/* ─── Top bar ────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--hs-topbar-h);
  background: var(--hs-bg);
  border-bottom: 1px solid var(--hs-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--hs-text);
  flex: 1;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  line-height: 1;
  white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; }

.btn-primary {
  background: var(--hs-orange);
  color: white;
  border-color: var(--hs-orange);
}
.btn-primary:hover {
  background: var(--hs-orange-dark);
  border-color: var(--hs-orange-dark);
  text-decoration: none;
  color: white;
}

.btn-secondary {
  background: var(--hs-white);
  color: var(--hs-text);
  border-color: transparent;
  box-shadow: 0 1px 2px rgba(36,31,27,.08);
}
.btn-secondary:hover {
  background: var(--hs-white);
  box-shadow: 0 2px 6px rgba(36,31,27,.12);
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--hs-text-light);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--hs-bg);
  color: var(--hs-text);
  text-decoration: none;
}

.btn-danger {
  background: var(--hs-danger);
  color: white;
  border-color: var(--hs-danger);
}
.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
  border-radius: var(--r-sm);
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--hs-white);
  border: none;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--hs-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--hs-text);
}
.card-body { padding: 22px; }

/* ─── Collapsible cards ──────────────────────────────────────────────────── */
.card-toggle {
  background: none;
  border: none;
  padding: 2px 6px;
  margin-right: 2px;
  color: var(--hs-text-muted);
  display: inline-flex;
  align-items: center;
  border-radius: var(--r-sm);
  flex-shrink: 0;
}
.card-toggle:hover { background: var(--hs-bg); color: var(--hs-text); }
.card-toggle svg { transition: transform .15s ease; }
.card.collapsed .card-toggle svg { transform: rotate(-90deg); }
.card.collapsed .card-collapsible { display: none; }
.card-header-left { display: flex; align-items: center; gap: 4px; min-width: 0; }

/* ─── Stat cards (dashboard) ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--hs-white);
  border: none;
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 13.5px;
  font-weight: 400;
  color: var(--hs-text-muted);
  margin-bottom: 10px;
}
.stat-value {
  font-size: 30px;
  font-weight: 600;
  color: var(--hs-text);
  line-height: 1;
  letter-spacing: -1px;
  margin-bottom: 4px;
}
.stat-sub {
  font-size: 12.5px;
  color: var(--hs-text-muted);
}
.stat-card.orange .stat-value { color: var(--hs-orange); }
.stat-card.teal .stat-value   { color: var(--hs-teal); }
.stat-card.danger .stat-value { color: var(--hs-danger); }
.stat-card.success .stat-value { color: var(--hs-success); }

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  background: transparent;
  color: var(--hs-text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 12px 18px;
  text-align: left;
  border-bottom: 1px solid var(--hs-border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--hs-border);
  transition: background .1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #fcfbfa; }
tbody td {
  padding: 15px 18px;
  color: var(--hs-text);
  vertical-align: middle;
}
.td-name a {
  font-weight: 500;
  color: var(--hs-text);
}
.td-name a:hover { text-decoration: underline; text-decoration-color: var(--hs-border-dark); text-underline-offset: 3px; }
.td-muted { color: var(--hs-text-muted); font-size: 13px; }

/* Sortable column headers */
thead th a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }
thead th a:hover { color: var(--hs-text); text-decoration: none; }
thead th a.is-sorted { color: var(--hs-text); font-weight: 600; }
thead th a .caret { font-size: 9px; line-height: 1; opacity: .7; }

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-success  { background: var(--hs-success-bg);  color: var(--hs-success); }
.badge-warning  { background: var(--hs-warning-bg);  color: var(--hs-warning); }
.badge-danger   { background: var(--hs-danger-bg);   color: var(--hs-danger); }
.badge-muted    { background: #f1efec;               color: var(--hs-text-muted); }
.badge-teal     { background: var(--hs-teal-light);  color: var(--hs-teal); }
.badge::before  { content: none; }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--hs-text);
  margin-bottom: 5px;
}
.form-label .required { color: var(--hs-danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--hs-border);
  border-radius: var(--r-md);
  font-size: 14px;
  color: var(--hs-text);
  background: var(--hs-bg-soft);
  transition: border-color .15s, box-shadow .15s, background .15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--hs-navy);
  background: var(--hs-white);
  box-shadow: 0 0 0 3px rgba(34,54,92,.12);
}
.form-control::placeholder { color: var(--hs-text-muted); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2390a4ae'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11.5px; color: var(--hs-text-muted); margin-top: 4px; }

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

/* ─── Search / filter bar ────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 340px;
}
.search-wrap svg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--hs-text-muted);
}
.search-input {
  width: 100%;
  padding: 9px 13px 9px 34px;
  border: 1px solid var(--hs-border);
  border-radius: var(--r-md);
  font-size: 14px;
  color: var(--hs-text);
  background: var(--hs-bg-soft);
  outline: none;
  font-family: var(--font);
}
.search-input:focus {
  border-color: var(--hs-navy);
  background: var(--hs-white);
  box-shadow: 0 0 0 3px rgba(34,54,92,.12);
}

/* ─── Record detail layout (like HubSpot's 2-col record page) ────────────── */
.record-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  align-items: start;
}
.record-sidebar { display: flex; flex-direction: column; gap: 12px; }
.record-main    { display: flex; flex-direction: column; gap: 16px; }

.property-section {}
.property-section-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--hs-text-muted);
  padding: 14px 18px 8px;
  border-bottom: 1px solid var(--hs-border);
}
.property-row {
  display: flex;
  flex-direction: column;
  padding: 10px 16px;
  border-bottom: 1px solid var(--hs-border);
  gap: 2px;
}
.property-row:last-child { border-bottom: none; }
.property-key {
  font-size: 12px;
  color: var(--hs-text-muted);
  font-weight: 500;
}
.property-val {
  font-size: 13px;
  color: var(--hs-text);
  font-weight: 400;
}
.property-val.empty { color: var(--hs-text-muted); font-style: italic; }

/* ─── Tabs ───────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--hs-border);
  margin-bottom: 16px;
}
.tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--hs-text-light);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
  text-decoration: none;
}
.tab:hover { color: var(--hs-text); text-decoration: none; }
.tab.active {
  color: var(--hs-orange);
  border-bottom-color: var(--hs-orange);
}

/* ─── Notes / activity feed ──────────────────────────────────────────────── */
.note-item {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--hs-border);
}
.note-item:last-child { border-bottom: none; }
.note-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--hs-teal-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--hs-teal);
  flex-shrink: 0;
  margin-top: 2px;
}
.note-body {}
.note-meta { font-size: 11.5px; color: var(--hs-text-muted); margin-bottom: 4px; }
.note-text { font-size: 13px; color: var(--hs-text); line-height: 1.5; }

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--hs-text-muted);
}
.empty-state svg {
  width: 48px; height: 48px;
  margin-bottom: 16px;
  opacity: .3;
}
.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--hs-text-light);
  margin-bottom: 6px;
}
.empty-state-sub { font-size: 13px; }

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  background: white;
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--hs-border);
  flex-shrink: 0;
}
.modal-title { font-size: 15px; font-weight: 600; color: var(--hs-text); }
.modal-close {
  background: none; border: none;
  color: var(--hs-text-muted);
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
}
.modal-close:hover { background: var(--hs-bg); color: var(--hs-text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--hs-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* ─── Toast notifications ────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--hs-navy);
  color: white;
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  animation: slideUp .2s ease;
}
.toast.success { background: var(--hs-success); }
.toast.error   { background: var(--hs-danger); }
@keyframes slideUp {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ─── Pagination ─────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--hs-border);
  font-size: 12.5px;
  color: var(--hs-text-muted);
}
.pagination-pages { display: flex; gap: 4px; }
.page-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--hs-border-dark);
  border-radius: var(--r-sm);
  background: white;
  font-size: 12.5px;
  color: var(--hs-text);
  cursor: pointer;
  transition: background .1s, border-color .1s;
}
.page-btn:hover { background: var(--hs-bg); }
.page-btn.active {
  background: var(--hs-orange);
  border-color: var(--hs-orange);
  color: white;
}
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --hs-sidebar-w: 0px; }
  .sidebar {
    width: 220px;
    transform: translateX(-220px);
    transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .record-layout { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
  .page-content { padding: 16px; }
  .mobile-menu-btn { display: flex !important; }
}
@media (max-width: 540px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 22px; }
}

/* ─── Phone (max 480px) ───────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .page-content { padding: 12px; }
  .topbar { padding: 0 12px; }
  .topbar-title { font-size: 14px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 20px; }
  .stat-label { font-size: 12.5px; }
  .stat-sub { font-size: 11px; }
  .card-header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  .card-body { padding: 14px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 480px; }
  thead th { padding: 8px 10px; font-size: 12px; }
  tbody td { padding: 10px; font-size: 12px; }
  .filter-bar { gap: 6px; }
  .filter-bar .btn { padding: 5px 10px; font-size: 12px; }
    /* The search field gets the whole first row on a phone. With flex:1 and
     min-width:0 it was free to shrink instead of forcing a wrap, and the two
     filter buttons plus the per-page select left it 17px wide at 390 — a
     magnifier icon and nothing else. flex-basis:100% makes it claim a line of
     its own and pushes the buttons below it. */
  .search-wrap { flex: 1 0 100%; min-width: 0; max-width: none; }
  /* Safari on iOS zooms the page when a focused input is under 16px. The rest
     of the form controls already get 16px here; .search-input is its own class
     and was missed, so tapping search zoomed the whole list. */
  .search-input { font-size: 16px; }
  .pagination { flex-direction: column; gap: 8px; align-items: flex-start; }
  .pagination-pages { flex-wrap: wrap; }
  .page-btn { width: 32px; height: 32px; font-size: 12px; }
  .record-layout { gap: 12px; }
  .property-row { padding: 8px 12px; }
  .property-section-title { padding: 10px 12px 6px; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; width: 100%; border-radius: 12px 12px 0 0; max-height: 90vh; }
  .btn { font-size: 12.5px; }
  .btn-sm { padding: 4px 8px; font-size: 11.5px; }
  .note-item { gap: 8px; padding: 12px 0; }
  .note-avatar { width: 24px; height: 24px; font-size: 10px; }
  .note-text { font-size: 12.5px; }
  .note-meta { font-size: 11px; }
  .form-control { font-size: 16px; }
  .form-label { font-size: 12px; }
  .badge { font-size: 11.5px; padding: 3px 9px; }

  /* Dashboard two-column grid → single column */
  div[style*="grid-template-columns:1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Company detail — prevent bleed */
  .record-layout { overflow: hidden; }
  .record-main { min-width: 0; overflow: hidden; }
  .record-sidebar { min-width: 0; }

  /* Tables — constrain to screen width */
  table { min-width: 0; width: 100%; }
  .table-wrap { max-width: calc(100vw - 24px); }

  /* Email panel full screen */
  #emailPanel { width: 100% !important; }

  /* Note body text wrap */
  .note-body { min-width: 0; overflow: hidden; word-break: break-word; }

  /* Toast — full width on phone */
  .toast-container { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; width: 100%; }

  /* Topbar actions — compress */
  .topbar-actions { gap: 4px; }
  .topbar-actions .btn-ghost { padding: 4px 6px; }

  .hide-on-mobile { display: none !important; }
  .show-on-mobile { display: block !important; }
}

.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  background: none;
  border: none;
  color: var(--hs-text-light);
  border-radius: var(--r-sm);
  margin-right: 4px;
}
.mobile-menu-btn:hover { background: var(--hs-bg); }

/* ─── Utilities ──────────────────────────────────────────────────────────── */
.text-muted  { color: var(--hs-text-muted); }
.text-light  { color: var(--hs-text-light); }
.text-danger { color: var(--hs-danger); }
.text-success{ color: var(--hs-success); }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fs-12  { font-size: 12px; }
.fs-13  { font-size: 13px; }
.mt-4   { margin-top: 4px; }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.mb-16  { margin-bottom: 16px; }
.mb-24  { margin-bottom: 24px; }
.gap-8  { gap: 8px; }
.flex   { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.hidden { display: none !important; }
.hide-on-mobile { display: flex; }
.show-on-mobile { display: none; }

/* .hide-on-mobile sets display:flex, which is right for a toolbar but would
   turn a table cell into a flex container and collapse the column grid. These
   two put cells back to table-cell at desktop width; the !important inside the
   480px block still wins there, so the column disappears on a phone exactly as
   it does for anything else carrying the class. */
th.hide-on-mobile, td.hide-on-mobile { display: table-cell; }

/* ─── Quill 2 line break spacing ─────────────────────────────────────────── */
#quillEditor .ql-editor p,
#panelEditor .ql-editor p { margin-bottom: 0.8em; }
#quillEditor .ql-editor br,
#panelEditor .ql-editor br { display: block; content: ''; margin-top: 0.2em; }

/* A grid/flex item will not shrink below its content unless told to. Without
   this, one wide element inside one email sets the width of the whole page. */
.record-layout,
.record-main { min-width: 0; }

/* The collapsed preview is the wrapper clipping a frame that is already its
   full height, so opening it is one height change and no reflow of the frame
   itself. */
.email-frame-wrap { position: relative; height: 72px; overflow: hidden; margin-top: 6px; }
.email-frame { display: block; width: 100%; height: 72px; border: 0; background: #fff; }
.email-fade {
  position: absolute; left: 0; right: 0; bottom: 0; height: 24px;
  background: linear-gradient(transparent, #fff); pointer-events: none;
}
.email-frame-wrap.is-open { height: auto; overflow: visible; }
.email-frame-wrap.is-open .email-fade { display: none; }

/* ─── Dashboard split ────────────────────────────────────────────────────── */
/* Left card is content-sized; the right column stretches to match it and
   divides that height between two panes. The min-height:0 on each pane is the
   whole mechanism — grid and flex children default to min-height:auto and grow
   to fit every row, so without it nothing ever scrolls. The minmax floor stops
   the panes collapsing to 40px on a quiet week when Expiring Soon has two rows;
   on those weeks the right column simply runs taller than the left. */
.dash-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: stretch;
}
.dash-stack {
  display: grid;
  grid-template-rows: minmax(180px, 1fr) minmax(180px, 1fr);
  gap: 20px;
  min-height: 0;
}
.dash-stack > .card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;          /* so the scrolling table is clipped by the radius */
}
.dash-stack > .card > .card-header { flex: 0 0 auto; }
.dash-stack > .card > .table-wrap,
.dash-stack > .card > .empty-state { flex: 1 1 auto; min-height: 0; overflow-y: auto; }

/* The redesign made thead transparent, so a sticky header would have rows
   sliding visibly underneath it. Opaque only inside these two panes. */
.dash-stack .table-wrap thead th {
  position: sticky;
  top: 0;
  background: var(--hs-white);
  z-index: 1;
}

@media (max-width: 900px) {
  /* One column, auto heights, no sticky. A scroll region inside a scrolling
     page is miserable on touch — you never find the bottom of either list. */
  .dash-split { grid-template-columns: 1fr; }
  .dash-stack { grid-template-rows: auto auto; }
  .dash-stack .table-wrap thead th { position: static; }
}