/* =====================================================================
   Brattleboro Local App - admin UI styles
   Mobile-first. Brand-consistent with the marketing site.
   ===================================================================== */

:root {
  /* Brand colors - exact match to the marketing site palette.
     River Navy, Wantastiquet Spruce, Downtown Brick (accent),
     Paper Cream, River Mist. --brand-gold* keep their names (used widely
     as "the accent" across the app) but now carry Downtown Brick. */
  --brand-navy:        #16324F;   /* River Navy */
  --brand-navy-soft:   #0f2740;
  --brand-cream:       #F3EBDD;   /* Paper Cream */
  --brand-cream-soft:  #e7dcc6;
  --brand-gold:        #B34A36;   /* Downtown Brick (accent) */
  --brand-gold-soft:   #c96a54;   /* soft brick, for hovers */
  --brand-teal:        #2F5D50;   /* Wantastiquet Spruce */
  --brand-mist:        #D6E3E0;   /* River Mist */

  /* Surfaces */
  --surface-bg:        #f7f4ec;
  --surface-1:         #ffffff;
  --surface-2:         #fdfcf8;
  --surface-sidebar:   #F3EBDD;   /* Paper Cream - logo reads clearly on it */

  /* Text */
  --text-1:            #16324F;
  --text-2:            #3a4a60;
  --text-3:            #5e6c80;
  --text-on-navy:      #F3EBDD;
  --text-on-navy-soft: rgba(243, 235, 221, 0.7);

  /* Sidebar (light/cream theme - navy ink on Paper Cream) */
  --sidebar-text:      #16324F;
  --sidebar-text-soft: rgba(22, 50, 79, 0.55);
  --sidebar-hover:     rgba(22, 50, 79, 0.06);
  --sidebar-line:      rgba(22, 50, 79, 0.12);

  /* Borders */
  --border-subtle:     #e8e4d6;
  --border-strong:     #cfc9b8;

  /* States */
  --color-success:     #2f7d4d;
  --color-error:       #b73e3e;
  --color-warn:        #c87d2b;
  --color-info:        #2563eb;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, monospace;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(22, 50, 79, 0.05);
  --shadow-md: 0 4px 12px rgba(22, 50, 79, 0.08);
  --shadow-lg: 0 12px 32px rgba(22, 50, 79, 0.15);

  /* Sidebar */
  --sidebar-width: 240px;
  --sidebar-z: 100;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-1);
  background: var(--surface-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--brand-teal); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; color: var(--text-1); }
p  { margin: 0 0 var(--space-3); color: var(--text-2); }

hr { border: 0; border-top: 1px solid var(--border-subtle); margin: var(--space-5) 0; }

/* =====================================================================
   AUTH PAGES (login, forgot, reset, invite)
   ===================================================================== */

body.auth {
  min-height: 100vh;
  background: var(--brand-navy);
  background-image: radial-gradient(circle at 30% 20%, rgba(210,154,61,0.12), transparent 50%),
                    radial-gradient(circle at 70% 80%, rgba(44,95,93,0.15), transparent 50%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}

.auth__shell {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
}

.auth__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--brand-cream);
  text-decoration: none;
}
.auth__brand:hover { text-decoration: none; }

.auth__brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--brand-gold);
  color: var(--brand-navy);
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: var(--radius-md);
}

.auth__brand-text {
  font-size: 17px;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.auth__card {
  width: 100%;
  background: var(--surface-1);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-lg);
}

.auth__title {
  margin: 0 0 var(--space-2);
  font-size: 24px;
}

.auth__lede {
  color: var(--text-3);
  font-size: 14px;
  margin: 0 0 var(--space-5);
}

.auth__alt {
  text-align: center;
  margin: var(--space-5) 0 0;
  font-size: 14px;
  color: var(--text-3);
}

/* =====================================================================
   ADMIN SHELL (sidebar + main)
   ===================================================================== */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: var(--surface-sidebar);
  color: var(--sidebar-text);
  border-right: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  z-index: var(--sidebar-z);
  /* Mobile: hidden by default, slid in via transform */
  transform: translateX(-100%);
  transition: transform 200ms ease;
}

.sidebar.is-open { transform: translateX(0); }

.sidebar__brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--sidebar-line);
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--sidebar-text);
  text-decoration: none;
}
.sidebar__logo:hover { text-decoration: none; }

.sidebar__close {
  background: none;
  border: 0;
  color: var(--sidebar-text);
  font-size: 28px;
  line-height: 1;
  width: 32px;
  height: 32px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.sidebar__close:hover { background: var(--sidebar-hover); }

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) 0;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-list__heading {
  padding: var(--space-4) var(--space-5) var(--space-2);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sidebar-text-soft);
  font-weight: 600;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px var(--space-5);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background 80ms ease, border-color 80ms ease;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  text-decoration: none;
}

.nav-link.is-active {
  background: rgba(179, 74, 54, 0.12);
  border-left-color: var(--brand-gold);
  color: var(--brand-gold);
  font-weight: 600;
}

.badge {
  display: inline-block;
  background: rgba(22, 50, 79, 0.08);
  color: rgba(22, 50, 79, 0.7);
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 999px;
  text-transform: uppercase;
}

.sidebar__footer {
  padding: var(--space-3);
  border-top: 1px solid var(--sidebar-line);
}

.user-menu summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius-sm);
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--sidebar-hover); }

.user-menu__avatar {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-gold);
  color: #fff;
  font-weight: 700;
  border-radius: 50%;
  font-size: 13px;
}

.user-menu__name {
  flex: 1;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-menu ul {
  list-style: none;
  margin: var(--space-2) 0 0;
  padding: 0;
  background: rgba(22, 50, 79, 0.04);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.user-menu__role {
  padding: var(--space-2) var(--space-3);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-text-soft);
  border-bottom: 1px solid var(--sidebar-line);
}

.user-menu li a,
.user-menu__logout {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--space-2) var(--space-3);
  background: none;
  border: 0;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.user-menu li a:hover,
.user-menu__logout:hover {
  background: var(--sidebar-hover);
  text-decoration: none;
}

/* Mobile sidebar toggle button (top-left of viewport when sidebar closed) */
.sidebar-toggle {
  position: fixed;
  top: var(--space-3);
  left: var(--space-3);
  width: 44px;
  height: 44px;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  z-index: calc(var(--sidebar-z) - 1);
  box-shadow: var(--shadow-sm);
}
.sidebar-toggle__bar {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-1);
  border-radius: 1px;
}

.main {
  min-height: 100vh;
  padding: var(--space-6) var(--space-4) var(--space-7);
}

.main__inner {
  max-width: 1200px;
  margin: 0 auto;
  /* Push down so the sidebar toggle button doesn't overlap */
  padding-top: var(--space-7);
}

@media (min-width: 900px) {
  .sidebar { transform: translateX(0); }
  .sidebar__close { display: none; }
  .sidebar-toggle { display: none; }
  .main { margin-left: var(--sidebar-width); padding: var(--space-6); }
  .main__inner { padding-top: 0; }
}

/* =====================================================================
   PAGE LAYOUT - page-head, panels, dash-grid
   ===================================================================== */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.page-head__title {
  font-size: 26px;
  margin: 0 0 var(--space-1);
}

.page-head__lede {
  margin: 0;
  color: var(--text-3);
  font-size: 14px;
}

.page-head__actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}

.panel__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.panel__title {
  font-size: 16px;
  margin: 0;
}

.dash-grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .dash-grid { grid-template-columns: 1.6fr 1fr; }
}

/* =====================================================================
   STAT CARDS
   ===================================================================== */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.stat-card {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
}

.stat-card__value {
  font-size: 32px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--brand-navy);
}

.stat-card__label {
  margin-top: var(--space-1);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* =====================================================================
   ACTIVITY LIST
   ===================================================================== */

.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.activity {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 14px;
}
.activity:last-child { border-bottom: 0; }

.activity__action {
  color: var(--text-3);
  margin-left: var(--space-2);
}

.activity__entity {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-3);
  margin-left: var(--space-2);
}

.activity__time {
  color: var(--text-3);
  font-size: 12px;
  white-space: nowrap;
}

/* =====================================================================
   TABLES
   ===================================================================== */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th, .table td {
  padding: var(--space-3) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.table th {
  font-weight: 600;
  color: var(--text-3);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--surface-2);
}

.table tbody tr:hover { background: var(--surface-2); }

/* Scroll the table on small screens instead of wrapping */
.panel:has(> .table) { padding: 0; overflow-x: auto; }
.panel:has(> .table) > .table { margin: 0; }

/* =====================================================================
   PILLS / BADGES (status, role)
   ===================================================================== */

.pill {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  color: var(--text-2);
  white-space: nowrap;
}

.pill--role-super_admin { background: #fef3e2; color: #8a5a16; border-color: #f0c97a; }
.pill--role-admin       { background: #e8f0ff; color: #1d4a8a; border-color: #b8cdf0; }
.pill--role-sales       { background: #e6f4ea; color: #2f7d4d; border-color: #b0d8be; }
.pill--role-designer    { background: #f0e8ff; color: #5a2a9c; border-color: #c8b3e8; }
.pill--role-client      { background: #fff4e0; color: #8a5500; border-color: #f0d090; }

.pill--status-active   { background: #e6f4ea; color: #2f7d4d; border-color: #b0d8be; }
.pill--status-pending  { background: #fff4e0; color: #8a5500; border-color: #f0d090; }
.pill--status-disabled { background: #fde8e8; color: #8a2a2a; border-color: #f0bbbb; }

/* =====================================================================
   FORMS
   ===================================================================== */

.form { display: flex; flex-direction: column; gap: var(--space-4); }
.form--narrow { max-width: 480px; }
.form--inline { flex-direction: row; align-items: flex-end; gap: var(--space-3); flex-wrap: wrap; }
.form--inline label { display: block; font-size: 13px; margin-bottom: var(--space-1); color: var(--text-3); }

.form-row { display: flex; flex-direction: column; gap: var(--space-2); }
.form-row label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.form-row--two-col {
  flex-direction: row;
  gap: var(--space-3);
}
.form-row--two-col > div { flex: 1; display: flex; flex-direction: column; gap: var(--space-2); }

.form input[type="text"],
.form input[type="email"],
.form input[type="password"],
.form select,
.form textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-1);
}

.form input:focus,
.form select:focus,
.form textarea:focus {
  outline: 2px solid var(--brand-gold);
  outline-offset: -1px;
  border-color: var(--brand-gold);
}

.form input:disabled,
.form select:disabled {
  background: var(--surface-2);
  color: var(--text-3);
  cursor: not-allowed;
}

.form-hint {
  font-size: 12px;
  color: var(--text-3);
}

/* =====================================================================
   BUTTONS
   ===================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background 80ms ease, border-color 80ms ease, color 80ms ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }

.btn--primary {
  background: var(--brand-gold);
  color: var(--brand-navy);
  border-color: var(--brand-gold);
}
.btn--primary:hover { background: var(--brand-gold-soft); border-color: var(--brand-gold-soft); }

.btn--secondary {
  background: var(--surface-1);
  color: var(--text-1);
  border-color: var(--border-strong);
}
.btn--secondary:hover { background: var(--surface-2); border-color: var(--text-3); }

.btn--ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}
.btn--ghost:hover { background: var(--surface-2); }

.btn--danger {
  background: var(--color-error);
  color: white;
  border-color: var(--color-error);
}
.btn--danger:hover { background: #9b3535; border-color: #9b3535; }

.btn--full { width: 100%; }
.btn--sm { padding: 6px 12px; font-size: 13px; }

/* =====================================================================
   FLASH MESSAGES
   ===================================================================== */

.flash-stack { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-5); }

.flash {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 14px;
  border: 1px solid transparent;
}

.flash--success { background: #e6f4ea; color: #225f3a; border-color: #b0d8be; }
.flash--error   { background: #fde8e8; color: #7a2424; border-color: #f0bbbb; }
.flash--warning { background: #fff4e0; color: #6e4400; border-color: #f0d090; }
.flash--info    { background: #e8f0ff; color: #15376a; border-color: #b8cdf0; }

/* Spacing for inline flashes inside auth cards */
body.auth .flash { margin-bottom: var(--space-3); }

/* =====================================================================
   DETAIL LIST (definition list for user/account info)
   ===================================================================== */

.detail-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-2) var(--space-4);
  margin: 0;
  font-size: 14px;
}
.detail-list dt {
  font-weight: 600;
  color: var(--text-3);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.detail-list dd { margin: 0; }

/* =====================================================================
   MISC
   ===================================================================== */

.empty {
  color: var(--text-3);
  font-size: 14px;
  text-align: center;
  padding: var(--space-5) 0;
}

.link { color: var(--brand-teal); }

/* =====================================================================
   CMS - page editor form components
   ===================================================================== */

.form-row__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
}

.form-row__reset {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-3);
  font-family: inherit;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: color 80ms ease, text-decoration-color 80ms ease;
}

.form-row__reset:hover {
  color: var(--brand-teal);
  text-decoration-color: var(--brand-teal);
}

/* Section panels in the editor */
.form .panel {
  margin-bottom: var(--space-5);
}

.form .panel__head {
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
}

.form .panel__title {
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* Image preview block */
.image-preview {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
}

.image-preview img {
  display: block;
  width: 200px;
  height: auto;
  border-radius: var(--radius-sm);
}

.image-preview__meta {
  font-size: 13px;
  color: var(--text-3);
  line-height: 1.5;
}

.image-preview__meta strong {
  color: var(--text-1);
  font-size: 14px;
}

input[type="file"] {
  font-size: 13px;
  padding: 8px 0;
}

input[type="file"]::file-selector-button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-right: var(--space-3);
  color: var(--text-1);
}

input[type="file"]::file-selector-button:hover {
  background: var(--surface-2);
  border-color: var(--text-3);
}

/* =====================================================================
   CMS - Media library
   ===================================================================== */

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

.media-card {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.media-card--used { border-color: var(--brand-gold-soft); }

.media-card__preview {
  background: var(--surface-2);
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border-subtle);
}

.media-card__preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-card__body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
}

.media-card__name {
  font-size: 13px;
  word-break: break-all;
  color: var(--text-1);
}

.media-card__meta {
  margin: var(--space-1) 0;
}

.media-card__details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px var(--space-3);
  margin: 0;
  font-size: 12px;
  color: var(--text-3);
}

.media-card__details dt {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.04em;
  align-self: center;
}

.media-card__details dd { margin: 0; }

/* ============================================================
   CRM (Phase 2)
   ============================================================ */

/* Grid utilities (used by CRM views) */
.grid {
  display: grid;
  gap: var(--space-4);
}
.grid--2-strict {
  grid-template-columns: 1fr;
}
@media (min-width: 880px) {
  .grid--2-strict { grid-template-columns: 1fr 1fr; }
}
.grid--3 {
  grid-template-columns: 1fr;
}
@media (min-width: 720px) {
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
}
.grid--4 {
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 880px) {
  .grid--4 { grid-template-columns: repeat(4, 1fr); }
}
.grid--5 {
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 700px) {
  .grid--5 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1100px) {
  .grid--5 { grid-template-columns: repeat(5, 1fr); }
}

/* Stat cards (clickable summary tiles) */
.stat-cards { gap: var(--space-3); margin-top: var(--space-4); }
.stat-cards .stat-card {
  display: block;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-2);
  padding: var(--space-4);
  text-align: left;
  text-decoration: none;
  color: inherit;
  transition: border-color 120ms ease, transform 120ms ease;
}
.stat-cards .stat-card:hover {
  border-color: var(--brand-gold-soft);
  text-decoration: none;
  transform: translateY(-1px);
}
.stat-cards .stat-card--alert { border-color: #d97a4d; }
.stat-cards .stat-card--alert .stat-card__value { color: #b85a30; }

/* Inputs (a generic class that pairs with .field labels) */
.input {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface-1);
  color: var(--text-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-1);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
}
.input:focus {
  outline: none;
  border-color: var(--brand-gold-soft);
  box-shadow: 0 0 0 3px rgba(193, 158, 89, 0.18);
}
textarea.input,
textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface-1);
  color: var(--text-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-1);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
}
textarea:focus {
  outline: none;
  border-color: var(--brand-gold-soft);
  box-shadow: 0 0 0 3px rgba(193, 158, 89, 0.18);
}

/* Field wrapper - replaces .form-row in newer pages */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
}
.field > span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
}

/* Form layout */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
}
.form-stack .grid { gap: var(--space-4); }
.form-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin-top: var(--space-2);
}
.form-toggle {
  border-bottom: 1px solid var(--border-1);
  padding: var(--space-3) var(--space-4);
}
.form-toggle:last-child { border-bottom: 0; }
.form-toggle > summary {
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  list-style: none;
  padding: 4px 0;
}
.form-toggle > summary::-webkit-details-marker { display: none; }
.form-toggle > summary::before {
  content: "+ ";
  color: var(--brand-gold);
  font-weight: 600;
}
.form-toggle[open] > summary::before { content: "− "; }
.form-toggle .form-stack { padding: var(--space-3) 0 var(--space-2); }

/* Filter bar */
.filter-bar {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
  padding: var(--space-3) 0 var(--space-4);
}
.filter-bar .input { flex: 1 1 200px; max-width: 320px; }
.filter-bar select.input { max-width: 200px; }
.filter-bar .link.is-active { color: var(--brand-gold); font-weight: 600; }

/* Alerts */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-1);
  border: 1px solid;
  margin-bottom: var(--space-4);
}
.alert--error { background: #fde8e8; color: #7a2424; border-color: #f0bbbb; }
.alert ul { margin: 0; padding-left: 18px; }

/* Task list */
.task-list { list-style: none; margin: 0; padding: 0; }
.task-list__item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-1);
  align-items: flex-start;
}
.task-list__item:last-child { border-bottom: 0; }
.task-list__item.is-overdue { background: #fff8f0; }
.task-list__item.is-done { opacity: 0.55; }
.task-list__item.is-done .task-list__body strong { text-decoration: line-through; }
.task-list__check {
  flex: 0 0 18px;
  width: 18px; height: 18px;
  border: 2px solid var(--text-3);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  margin-top: 3px;
  transition: background 120ms;
}
.task-list__check:hover { border-color: var(--brand-gold); }
.task-list__check.is-checked,
.is-done .task-list__check {
  background: var(--brand-gold);
  border-color: var(--brand-gold);
  position: relative;
}
.task-list__check.is-checked::after,
.is-done .task-list__check::after {
  content: "✓";
  color: #fff;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
}
.task-list__body { flex: 1; min-width: 0; font-size: 14px; }
.task-list__body strong { font-weight: 500; }

/* Activity timeline */
/*
 * Note: there is a conflicting .activity rule earlier in this file (around
 * line 529) that applies display:flex (intended for the dashboard's
 * single-line activity rows where .activity is on a <li>). Use ul.activity
 * here so this timeline-list version doesn't get flex'd into horizontal
 * columns.
 */
ul.activity { list-style: none; margin: 0; padding: 0; display: block; }
.activity__item {
  position: relative;
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-1);
}
.activity__item:last-child { border-bottom: 0; }
.activity__dot {
  flex: 0 0 10px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--brand-gold);
  margin-top: 6px;
}
.activity__item--task .activity__dot { background: #4a8ad4; }
.activity__item--file .activity__dot { background: #6a9c5e; }
.activity__body { flex: 1; min-width: 0; font-size: 14px; }
.activity__head { margin-bottom: 4px; }
.activity__subject { font-weight: 500; margin-bottom: 4px; }
.activity__msg {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 13.5px;
  color: var(--text-2);
  background: var(--surface-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-1);
  margin-top: var(--space-2);
}

/* Key-value display list */
.kv {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 6px var(--space-3);
  padding: var(--space-4);
  margin: 0;
  font-size: 14px;
}
.kv dt { color: var(--text-3); font-size: 13px; }
.kv dd { margin: 0; word-wrap: break-word; }

/* File list */
.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li {
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border-1);
  font-size: 14px;
}
.file-list li:last-child { border-bottom: 0; }

/* Quote / message block */
.quote-block {
  background: var(--surface-2);
  padding: var(--space-3);
  border-radius: var(--radius-1);
  border-left: 3px solid var(--brand-gold);
  white-space: pre-wrap;
  font-size: 14px;
  color: var(--text-2);
  margin: 0 var(--space-4) var(--space-4);
}

/* Prose block (ticket descriptions, etc.) */
.prose {
  padding: var(--space-4);
  font-size: 14.5px;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* Code block (for error logs) */
.code-block {
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-1);
  padding: var(--space-3);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  white-space: pre-wrap;
  overflow-x: auto;
  margin: 0 var(--space-4) var(--space-4);
}

/* Bullet list (for help text panels) */
.bullet-list { padding-left: 20px; margin: var(--space-3) var(--space-4) var(--space-4); }
.bullet-list li { margin-bottom: var(--space-2); font-size: 14px; line-height: 1.5; }

/* Muted text */
.muted { color: var(--text-3); }

/* Link variants */
.link--sm { font-size: 13px; }
.link--danger { color: #b85a30; cursor: pointer; background: none; border: none; padding: 0; font-family: inherit; }
.link--danger:hover { color: #8a3e1f; }

/* Compact table variant (for in-panel summary tables) */
.table--compact th,
.table--compact td { padding: 8px 10px; font-size: 13.5px; }

/* Lead status pills */
.pill--status-new         { background: #e8f0ff; color: #1d4a8a; border-color: #b8cdf0; }
.pill--status-contacted   { background: #f0e8ff; color: #5a2a9c; border-color: #c8b3e8; }
.pill--status-qualified   { background: #e6f4ea; color: #2f7d4d; border-color: #b0d8be; }
.pill--status-unqualified { background: #f0f0f0; color: #555;    border-color: #d0d0d0; }
.pill--status-converted   { background: #fef3e2; color: #8a5a16; border-color: #f0c97a; }
.pill--status-closed_lost { background: #fde8e8; color: #8a2a2a; border-color: #f0bbbb; }

/* Ticket status pills */
.pill--status-in_progress { background: #fef3e2; color: #8a5a16; border-color: #f0c97a; }
.pill--status-waiting     { background: #fff4e0; color: #8a5500; border-color: #f0d090; }
.pill--status-resolved    { background: #e6f4ea; color: #2f7d4d; border-color: #b0d8be; }
.pill--status-closed      { background: #f0f0f0; color: #555;    border-color: #d0d0d0; }

/* Import status pills */
.pill--status-pending     { background: #fff4e0; color: #8a5500; border-color: #f0d090; }
.pill--status-processing  { background: #e8f0ff; color: #1d4a8a; border-color: #b8cdf0; }
.pill--status-done        { background: #e6f4ea; color: #2f7d4d; border-color: #b0d8be; }
.pill--status-failed      { background: #fde8e8; color: #8a2a2a; border-color: #f0bbbb; }

/* Priority pills */
.pill--priority-low    { background: #f0f0f0; color: #555;    border-color: #d0d0d0; }
.pill--priority-normal { background: #e8f0ff; color: #1d4a8a; border-color: #b8cdf0; }
.pill--priority-high   { background: #fff4e0; color: #8a5500; border-color: #f0d090; }
.pill--priority-urgent { background: #fde8e8; color: #8a2a2a; border-color: #f0bbbb; }

/* Company type pills */
.pill--ctype-lead     { background: #e8f0ff; color: #1d4a8a; border-color: #b8cdf0; }
.pill--ctype-prospect { background: #f0e8ff; color: #5a2a9c; border-color: #c8b3e8; }
.pill--ctype-client   { background: #e6f4ea; color: #2f7d4d; border-color: #b0d8be; }
.pill--ctype-former   { background: #f0f0f0; color: #555;    border-color: #d0d0d0; }
.pill--ctype-lost     { background: #fde8e8; color: #8a2a2a; border-color: #f0bbbb; }


/* ===================================================================
 * Phase 2.5a -- Pipeline Kanban
 * =================================================================*/

.kanban {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: var(--space-4);
  margin-top: var(--space-4);
}

.kanban__col {
  flex: 0 0 280px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
}

.kanban__col--terminal {
  flex: 0 0 220px;
  border-style: dashed;
  background: rgba(245, 243, 238, 0.5);
}

.kanban__col-head {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.kanban__col-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.kanban__col-title--won { color: var(--color-success); }
.kanban__col-title--lost { color: var(--color-error); }

.kanban__col-count {
  background: var(--brand-cream-soft);
  color: var(--text-2);
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
}

.kanban__col-value {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.kanban__cards {
  padding: var(--space-2);
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 100px;
}

.kanban__cards--terminal {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kanban__drop-hint {
  color: var(--text-3);
  font-size: 12px;
  text-align: center;
  padding: var(--space-3);
  font-style: italic;
}

/* ---- Kanban cards ---- */

.kanban-card {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: var(--space-3);
  margin-bottom: var(--space-2);
  cursor: grab;
  font-size: 13px;
  transition: box-shadow 0.15s ease;
}

.kanban-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.kanban-card--ghost {
  opacity: 0.4;
}

.kanban-card--drag {
  cursor: grabbing;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.kanban-card.temp-hot   { border-left: 3px solid #d9482b; }
.kanban-card.temp-warm  { border-left: 3px solid var(--brand-gold); }
.kanban-card.temp-cold  { border-left: 3px solid var(--text-3); }

.kanban-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: 2px;
}

.kanban-card__name {
  font-weight: 600;
  color: var(--text-1);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.3;
}

.kanban-card__name:hover {
  color: var(--brand-teal);
  text-decoration: underline;
}

.kanban-card__temp {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

.temp-hot  .kanban-card__temp { background: #d9482b; }
.temp-warm .kanban-card__temp { background: var(--brand-gold); }
.temp-cold .kanban-card__temp { background: var(--text-3); }

.kanban-card__company {
  color: var(--text-2);
  font-size: 12px;
  margin-bottom: var(--space-2);
}

.kanban-card__title {
  color: var(--text-3);
  font-size: 12px;
  font-style: italic;
  margin-bottom: var(--space-2);
}

.kanban-card__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
  font-size: 12px;
}

.kanban-card__amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
}

.kanban-card__amount.muted { color: var(--text-3); font-weight: 400; }

.kanban-card__days {
  font-variant-numeric: tabular-nums;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
}

.kanban-card__days.days-green  { background: #e6f4ea; color: #2f7d4d; }
.kanban-card__days.days-yellow { background: #fff4e0; color: #8a5500; }
.kanban-card__days.days-red    { background: #fde8e8; color: #8a2a2a; }

.kanban-card__action {
  background: var(--brand-cream);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: var(--space-2);
  font-size: 12px;
  color: var(--text-1);
  margin-bottom: var(--space-2);
  cursor: text;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.kanban-card__action.is-overdue {
  background: #fde8e8;
  border-color: #f0bbbb;
  color: #8a2a2a;
}

.kanban-card__action--missing {
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--text-3);
  cursor: pointer;
  text-align: center;
  font-style: italic;
}

.kanban-card__action--missing:hover {
  background: var(--brand-cream-soft);
  color: var(--text-1);
}

.kanban-card__due {
  color: var(--text-3);
}

.kanban-card.temp-hot .kanban-card__action.is-overdue { /* keep overdue styling priority */ }

.kanban-card__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-3);
}

.kanban-card__owner {
  display: inline-flex;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand-teal);
  color: #fff;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 11px;
}

.kanban-card__activity { font-size: 11px; }

/* ===================================================================
 * Modals
 * =================================================================*/

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.modal.is-open { display: flex; }

.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(22, 50, 79, 0.5);
}

.modal__panel {
  position: relative;
  background: var(--surface-1);
  border-radius: 8px;
  padding: var(--space-5);
  width: 100%;
  max-width: 480px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal__title {
  margin: 0 0 var(--space-2) 0;
  font-size: 20px;
  color: var(--text-1);
}

.modal__lede {
  color: var(--text-2);
  font-size: 14px;
  margin: 0 0 var(--space-4) 0;
}

.modal__panel .form-label {
  display: block;
  font-weight: 500;
  margin-top: var(--space-3);
  margin-bottom: var(--space-1);
  font-size: 13px;
  color: var(--text-2);
}

.modal__panel .input {
  display: block;
  width: 100%;
  margin-bottom: 0;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

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

.btn--danger:hover {
  background: #8e2e2e;
}

/* ===================================================================
 * Global search
 * =================================================================*/

.search-container {
  position: relative;
  flex: 1 1 auto;
  max-width: 400px;
  margin: 0 var(--space-4);
}

.search-input {
  width: 100%;
  padding: 8px 12px;
  background: rgba(245, 243, 238, 0.1);
  border: 1px solid rgba(245, 243, 238, 0.2);
  color: var(--text-on-navy);
  border-radius: 6px;
  font-size: 14px;
}

.search-input::placeholder {
  color: var(--text-on-navy-soft);
}

.search-input:focus {
  outline: none;
  background: rgba(245, 243, 238, 0.15);
  border-color: var(--brand-gold-soft);
}

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  max-height: 480px;
  overflow-y: auto;
  display: none;
  z-index: 100;
}

.search-results.is-open { display: block; }

.search-result {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  text-decoration: none;
  color: var(--text-1);
  border-bottom: 1px solid var(--border-subtle);
}

.search-result:last-child { border-bottom: none; }

.search-result:hover, .search-result:focus {
  background: var(--surface-2);
  outline: none;
}

.search-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.search-badge--company  { background: #e8f0ff; color: #1d4a8a; }
.search-badge--contact  { background: #f0e8ff; color: #5a2a9c; }
.search-badge--lead     { background: #fff4e0; color: #8a5500; }
.search-badge--deal     { background: #e6f4ea; color: #2f7d4d; }
.search-badge--task     { background: #f0f0f0; color: #555; }
.search-badge--ticket   { background: #fde8e8; color: #8a2a2a; }

.search-result__body { flex: 1 1 auto; min-width: 0; }
.search-result__title {
  font-weight: 500;
  color: var(--text-1);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result__sub {
  color: var(--text-3);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-empty {
  padding: var(--space-3);
  color: var(--text-3);
  font-size: 13px;
  text-align: center;
}

/* Topbar layout adjustment to fit search */
.admin-topbar {
  display: flex;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  background: var(--brand-navy);
  border-bottom: 1px solid rgba(245, 243, 238, 0.1);
}


/* =============================================================================
   CONFIG WARNINGS BANNER - surfaces critical config issues at the top of every
   admin page. Loud and unmissable so silent failures (empty SMTP creds, broken
   APP_URL, etc.) get noticed instead of going undiscovered for days.
   ============================================================================= */
.config-warnings {
  display: grid;
  gap: var(--space-2);
  margin-block-end: var(--space-4);
}
.config-warning {
  padding: var(--space-3) var(--space-4);
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.5;
  border: 1px solid;
}
.config-warning strong {
  font-weight: 600;
  margin-right: 4px;
}
.config-warning--critical {
  background: #fde7e7;
  border-color: #d96a6a;
  color: #6b1a1a;
}
.config-warning--warning {
  background: #fff4e0;
  border-color: #d4a350;
  color: #6b4500;
}

/* =============================================================================
   LOGO IMAGE - admin sidebar
   SVG vector - scales to any height with zero quality loss + zero file-size cost.
   ============================================================================= */
.sidebar__logo {
  display: block;
  padding: 0;
}
.sidebar__logo-img {
  display: block;
  /* Enlarged logo: fill the sidebar content width (brand padding trimmed below).
     Stacked logo ratio ~1.37:1, so ~224px wide renders ~163px tall - roughly
     double the previous 120px-tall / 165px-wide footprint. width drives the
     size; height auto keeps the ratio. */
  width: 100%;
  height: auto;
  max-width: 100%;
}

/* Phone numbers should never wrap mid-number. Applies to tel: links anywhere
   in the admin. The same defensive default lives in client.css too. */
a[href^="tel:"] {
  white-space: nowrap;
}

/* ========================================================================
   Tasks tally header (2026-05-29 CRM consolidation)
   Compact summary tile shown above /crm/tasks and inside dashboard My-tasks
   panel: Mine Open/Overdue/Done today, Unassigned, All Open.
   ======================================================================== */
.tasks-tally {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
  align-items: center;
  padding: var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md, 6px);
  background: rgba(243, 235, 221, 0.04);
}
.tasks-tally__group {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}
.tasks-tally__label {
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2);
}
.tasks-tally__cell {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text-1);
  padding: 0 var(--space-2);
  min-width: 64px;
  border-left: 1px solid var(--border-subtle);
  transition: opacity .12s;
}
.tasks-tally__cell:first-of-type {
  border-left: none;
}
.tasks-tally__group + .tasks-tally__group .tasks-tally__cell:first-of-type {
  border-left: none;
}
.tasks-tally__cell:hover {
  opacity: .75;
  text-decoration: none;
}
.tasks-tally__num {
  font-size: var(--text-xl, 1.4rem);
  font-weight: 700;
  line-height: 1.1;
}
.tasks-tally__sub {
  font-size: var(--text-xs, 0.75rem);
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tasks-tally__cell--alert .tasks-tally__num {
  color: var(--color-error);
}

/* ========================================================================
   Multi-contact editor (2026-05-29 CRM consolidation)
   Inline rows on the Prospect/Client detail page for multiple contacts
   per company (Owner, Manager, Billing, Site Admin, etc.).
   ======================================================================== */
.contacts-editor {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.contact-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md, 6px);
  background: var(--surface, #fff);
  position: relative;
}
.contact-row.is-primary {
  border-left: 3px solid var(--color-brand-gold, #d4a437);
}
.contact-row__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
}
.contact-row__role {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.contact-row__role-pill {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(243, 235, 221, 0.18);
  color: var(--text-2);
}
.contact-row__primary-pill {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--color-brand-gold, #d4a437);
  color: #000;
}
.contact-row__fields {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
}
@media (min-width: 700px) {
  .contact-row__fields {
    grid-template-columns: repeat(3, 1fr);
  }
}
.contact-row__actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  margin-top: var(--space-2);
}
.contact-add-form {
  margin-top: var(--space-3);
  padding: var(--space-3);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-md, 6px);
}

/* ========================================================================
   Email integration (2026-05-29 Phase 2.5b MVP)
   Conversation panel on Prospect/Client detail page.
   ======================================================================== */
.email-thread {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.email-message {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md, 6px);
  background: var(--surface, #fff);
}
.email-message--inbound {
  border-left: 3px solid var(--color-info, #2563eb);
}
.email-message--outbound {
  border-left: 3px solid var(--color-success, #2f7d4d);
  background: rgba(243, 235, 221, 0.04);
}
.email-message summary {
  display: grid;
  grid-template-columns: 56px 1fr 2fr auto;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  align-items: baseline;
  font-size: var(--text-sm);
}
.email-message[open] summary {
  border-bottom: 1px solid var(--border-subtle);
}
.email-message__direction {
  font-weight: 700;
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
}
.email-message--inbound .email-message__direction {
  color: var(--color-info, #2563eb);
}
.email-message--outbound .email-message__direction {
  color: var(--color-success, #2f7d4d);
}
.email-message__from {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.email-message__subject {
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.email-message__when {
  color: var(--text-3);
  font-size: var(--text-xs);
  text-align: right;
}
.email-message__body {
  padding: var(--space-3);
}
.email-message__text {
  font-family: inherit;
  font-size: var(--text-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
  color: var(--text-1);
  background: transparent;
}
.email-compose summary {
  list-style: none;
}
.email-compose summary::-webkit-details-marker {
  display: none;
}
