:root {
  --navy: #17324d;
  --navy-deep: #12263a;
  --teal: #176b87;
  --teal-hover: #145a72;
  --accent: #2563eb;
  --ink: #1d2939;
  --muted: #5b6b79;
  --panel-border: #d9e1e7;
  --surface: #f4f7fa;
  --surface-card: #ffffff;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --radius: 8px;
  --shadow-sm: 0 1px 2px rgba(23, 50, 77, 0.06);
  color: var(--ink);
  background: var(--surface);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; }
a { color: #175c8c; text-decoration: none; }
a:hover { text-decoration: underline; }

/* —— App chrome —— */
.app-header,
header.app-header,
header {
  background: var(--navy);
  color: #fff;
  padding: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.7rem 1.25rem;
}
header .demo-banner {
  margin: 0;
  width: 100%;
  padding: 0.45rem 1.25rem;
  background: #3d3420;
  color: #f5e9c0;
  border-bottom: 1px solid #e6d59a;
  font-size: 0.9rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: #fff;
  text-decoration: none;
}
.brand:hover { text-decoration: none; opacity: 0.95; }
.brand-mark {
  display: block;
  border-radius: 7px;
  flex-shrink: 0;
}
.brand-name { line-height: 1.15; }


.app-nav,
nav.app-nav,
nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  flex: 1 1 auto;
  justify-content: flex-end;
}
.nav-menu {
  position: relative;
}
.nav-menu > summary {
  list-style: none;
}
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: rgba(255, 255, 255, 0.9);
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  border: 0;
  background: transparent;
}
.nav-menu-trigger:hover,
.nav-menu[open] > .nav-menu-trigger,
.nav-menu.is-active > .nav-menu-trigger {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.nav-menu-trigger-icon .nav-menu-trigger-label {
  font-size: 0.92rem;
}
.nav-chevron {
  opacity: 0.75;
  transition: transform 0.15s ease;
}
.nav-menu[open] > .nav-menu-trigger .nav-chevron {
  transform: rotate(180deg);
}
.nav-menu-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  min-width: 11.5rem;
  padding: 0.35rem;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(15, 36, 56, 0.18);
  z-index: 50;
  display: grid;
  gap: 0.15rem;
}
.nav-menu-panel-end {
  left: auto;
  right: 0;
}
.nav-menu-panel a,
.nav-menu-panel .nav-menu-item-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 550;
  text-decoration: none;
  background: transparent;
  border: 0;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.nav-menu-panel a:hover,
.nav-menu-panel .nav-menu-item-btn:hover {
  background: #eef3f6;
  text-decoration: none;
}
.nav-menu-panel a.active {
  background: #e8f3f7;
  color: var(--teal);
  font-weight: 700;
}
.nav-menu-panel .nav-icon { color: var(--muted); }
.nav-logout { margin: 0; }
.nav-menu-panel .nav-badge {
  margin-left: auto;
}


main {
  max-width: 1160px;
  width: 100%;
  min-width: 0;
  margin: 0 auto;
  padding: var(--space-5) 1.25rem var(--space-6);
}
h1, h2, h3 { color: var(--navy); }
h1 { margin: 0; font-size: 1.65rem; letter-spacing: -0.02em; line-height: 1.2; }
h2 { margin: 0; font-size: 1.1rem; letter-spacing: -0.01em; }
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}
.page-head-copy { max-width: 40rem; }
.eyebrow {
  margin: 0 0 var(--space-1);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--teal);
}
.lede {
  margin: var(--space-2) 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  max-width: 36rem;
}
.cta-row { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
a.button, .button,
button:not(.nav-logout-btn):not(.nav-menu-item-btn) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: var(--teal);
  color: #fff;
  padding: 0.55rem 0.95rem;
  border-radius: 6px;
  font-weight: 650;
  border: 0;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  line-height: 1.2;
}
a.button:hover, .button:hover,
button:not(.nav-logout-btn):not(.nav-menu-item-btn):hover:not(:disabled) {
  background: var(--teal-hover);
  text-decoration: none;
}
a.button.secondary, .button.secondary {
  background: #4a6274;
}
a.button.secondary:hover, .button.secondary:hover {
  background: #3d5262;
}
form { display: grid; gap: 0.8rem; max-width: 650px; }
form.filters {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  max-width: none;
  align-items: end;
}
.filter-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: var(--space-3);
  align-items: end;
  max-width: none;
  margin: 0 0 var(--space-5);
  padding: var(--space-4);
  background: var(--surface-card);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.filter-field { margin: 0; min-width: 0; }
.filter-field input,
.filter-field select {
  width: 100%;
  min-width: 0;
}
.filter-actions {
  display: flex;
  align-items: end;
}
.filter-actions button { white-space: nowrap; }
.table-block { margin-top: 0; }
.section-block { margin-top: var(--space-5); }
.empty-state.tight { margin: 0; }
.page-settings .panel + .panel { margin-top: var(--space-4); }
.settings-subnav,
.page-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 var(--space-5);
  padding: 0.3rem;
  background: #e8eef2;
  border-radius: 8px;
  width: fit-content;
  max-width: 100%;
}
.settings-subnav a,
.page-subnav a {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  color: var(--navy);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
}
.settings-subnav a:hover,
.page-subnav a:hover { background: rgba(255,255,255,0.7); text-decoration: none; }
.settings-subnav a.active,
.page-subnav a.active {
  background: #fff;
  color: var(--teal);
  box-shadow: var(--shadow-sm);
}
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-4);
}
.pager-link {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: #fff;
  color: var(--navy);
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
}
.pager-link:hover { border-color: var(--teal); color: var(--teal); text-decoration: none; }
.pager-link.is-disabled,
.pager-link.is-disabled:hover {
  opacity: 0.45;
  pointer-events: none;
  color: var(--muted);
  border-color: var(--panel-border);
}
.pager-status {
  color: var(--muted);
  font-size: 0.88rem;
}
.action-stack {
  display: grid;
  gap: var(--space-4);
}
.action-block {
  display: grid;
  gap: var(--space-2);
  max-width: none;
  margin: 0;
  padding: var(--space-3);
  background: #f7fafc;
  border: 1px solid var(--panel-border);
  border-radius: 7px;
}
.action-block .hint { margin: 0; }
.danger-block {
  background: #fff8f8;
  border-color: #f0c4c8;
}
.import-form { max-width: none; }
label { display: grid; gap: 0.25rem; font-weight: 600; }
input, select, textarea {
  font: inherit;
  padding: 0.55rem 0.65rem;
  border: 1px solid #b8c4ce;
  border-radius: 6px;
  background: #fff;
  max-width: 100%;
  box-sizing: border-box;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(23, 107, 135, 0.28);
  outline-offset: 1px;
  border-color: var(--teal);
}
button:disabled { background: #9aa7b0; cursor: not-allowed; }
button.danger { background: #a31b1b; }

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  /* Prevent wide tables from expanding the document scrollport (esp. inside .panel). */
  contain: paint;
}
table.data-table {
  border-collapse: collapse;
  width: 100%;
  background: #fff;
  table-layout: fixed;
  border: 1px solid #d9e1e7;
  border-radius: 6px;
  overflow: hidden;
}
table.data-table th,
table.data-table td {
  padding: 0.75rem 0.85rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #d9e1e7;
  word-break: break-word;
}
table.data-table thead th {
  background: #eef3f6;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #3d4f5f;
}
table.data-table tbody tr:last-child td { border-bottom: 0; }
table.data-table tbody tr:hover { background: #f0f6fa; }
.col-company { width: 18%; }
.col-suburb { width: 10%; }
.col-status { width: 10%; }
.col-offer { width: 12%; }
.col-source { width: 8%; }
.col-contact { width: 22%; }
.col-when { width: 14%; }
.col-type { width: 12%; }
.col-summary { width: 40%; }
.contact-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
}
.contact-stack a { display: inline-block; }
.contact-links { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; }
.summary-cell { font-size: 0.92rem; }
.live-hint { color: #176b87; font-weight: 600; }

/* Shared async / in-flight wait UI */
.app-spinner {
  width: 0.95rem;
  height: 0.95rem;
  border: 2px solid #d5e0e7;
  border-top-color: var(--teal);
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: -0.15em;
  animation: app-spin 0.7s linear infinite;
}
@keyframes app-spin {
  to { transform: rotate(360deg); }
}
.live-wait {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 var(--space-4);
  padding: 0.75rem 1rem;
  background: #eef7fa;
  border: 1px solid #c5dde6;
  border-radius: var(--radius);
  color: var(--teal);
  font-weight: 650;
  font-size: 0.95rem;
}
.live-wait .live-wait-label { color: var(--navy); font-weight: 600; }
.live-wait-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 var(--space-3);
  color: var(--teal);
  font-weight: 650;
  font-size: 0.92rem;
}
button.is-busy,
.button.is-busy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  opacity: 0.92;
  cursor: wait;
}
button.is-busy .app-spinner,
.button.is-busy .app-spinner {
  border-color: rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
}
@media (prefers-reduced-motion: reduce) {
  .app-spinner {
    animation: none;
    border-top-color: #d5e0e7;
    background: var(--teal);
    opacity: 0.45;
  }
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.85rem;
}
.status-cards { margin-bottom: 1.5rem; }
.cards article, .card-link article {
  background: #fff;
  border: 1px solid #d9e1e7;
  padding: 1rem;
  border-radius: 6px;
  transition: border-color 0.15s;
}
.card-link { color: inherit; }
.card-link:hover article { border-color: #176b87; }
.cards span { display: block; font-size: 1.8rem; font-weight: 700; }
.badge {
  display: inline-block;
  background: #e8eef2;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.85rem;
}
.badge.status-succeeded { background: #d8f3e0; }
.badge.status-failed { background: #f8d7da; }
.badge.status-running, .badge.status-queued { background: #fff3cd; }
.banner { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.banner.success { background: #d8f3e0; color: #0f5132; }
.banner.error, .error { color: #a31b1b; }
.banner.warn { background: #fff3cd; color: #664d03; }
.banner.banner-wait {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: #eef7fa;
  color: var(--navy);
  border: 1px solid #c5dde6;
}
.banner.banner-wait::before {
  content: "";
  width: 0.95rem;
  height: 0.95rem;
  border: 2px solid #c5dde6;
  border-top-color: var(--teal);
  border-radius: 50%;
  flex-shrink: 0;
  animation: app-spin 0.7s linear infinite;
}
.panel-live {
  border-color: #b7d4df;
  box-shadow: 0 0 0 1px rgba(23, 107, 135, 0.08);
}
.run-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.run-failure {
  border-color: #e5b4b4;
  background: #fdf4f4;
}
.run-failure-msg {
  margin: 0 0 var(--space-3);
  color: #a31b1b;
  font-weight: 600;
  font-size: 1.02rem;
}
.inline-form { display: inline; margin: 0; }
.runs-live-hint {
  margin: 0 0 var(--space-3);
}
.empty-state {
  padding: 1.25rem;
  background: #fff;
  border: 1px dashed #b8c4ce;
  border-radius: 6px;
}
.login {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at top right, rgba(37, 99, 235, 0.18), transparent 50%),
    linear-gradient(160deg, #17324d 0%, #1e3a54 45%, #0f2438 100%);
}
.login main {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 2rem;
  box-shadow: 0 18px 40px rgba(15, 36, 56, 0.25);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}
.login-brand h1 {
  margin: 0;
  font-size: 1.45rem;
}
.login-tagline {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
}
.login-captcha {
  display: flex;
  justify-content: center;
  margin: 0 0 1rem;
}
.demo-login-hero {
  margin: 0 0 1.25rem;
  text-align: center;
}
.demo-login-hero-button {
  width: 100%;
  background: #1b6b3a;
  border-color: #1b6b3a;
}
.demo-login-hero-button:hover:not(:disabled) {
  background: #155530;
  border-color: #155530;
}
.demo-login-hero-button:disabled,
.demo-login-hero-button[aria-disabled="true"] {
  background: #9aa7b0;
  border-color: #9aa7b0;
  color: #f4f7f8;
  cursor: not-allowed;
  opacity: 0.72;
  pointer-events: none;
}
.demo-login-hero-hint {
  margin: 0.55rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}
.demo-login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.demo-login-divider::before,
.demo-login-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--panel-border);
}
code {
  background: #e8eef2;
  padding: 0.15rem 0.3rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.hint { color: #5b6b79; font-size: 0.9rem; }
.webhook-box {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #e8eef2;
  max-width: 720px;
}
.webhook-box h2 { margin: 0 0 0.5rem; font-size: 1rem; }
.copy-row {
  display: grid;
  gap: 0.35rem;
  margin: 0.85rem 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #3d4f5f;
}
.copy-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: center;
}
.copy-controls input {
  min-width: 0;
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  font-weight: 400;
  color: #1d2939;
  background: #f4f7f9;
}
.copy-controls button {
  white-space: nowrap;
  padding: 0.45rem 0.75rem;
}
.team-section { margin-top: 2rem; max-width: 900px; }
.team-section h2 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.invite-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: end;
  max-width: 520px;
  margin: 1rem 0;
}
.temp-password-box {
  background: #fff8f3;
  border: 1px solid #e8a06a;
  border-radius: 6px;
  padding: 0.85rem 1rem;
  margin: 0.75rem 0 1rem;
  max-width: 520px;
}
.temp-password-box p { margin: 0 0 0.5rem; }
.team-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.team-actions form { display: inline; max-width: none; margin: 0; }
.ok { color: #1b7a3d; }
.warn { color: #9a6700; }
.demo-banner {
  margin: 0;
  padding: 0.55rem 1rem;
  background: #fff3cd;
  color: #664d03;
  border-bottom: 1px solid #e6d59a;
  font-size: 0.92rem;
  text-align: center;
}
.action-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.draft {
  background: #fff;
  border: 1px solid #d9e1e7;
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}
.rich-editor {
  border: 1px solid #d9e1e7;
  border-radius: 8px;
  overflow: visible;
  position: relative;
  background: #fff;
}
.editor-tabs {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 0.65rem;
  background: #eef3f6;
  border-bottom: 1px solid #d9e1e7;
  border-radius: 8px 8px 0 0;
}
.editor-tabs .tab {
  background: #fff;
  color: #3d4f5f;
  border: 1px solid #d9e1e7;
  border-radius: 6px;
  border-bottom: 1px solid #d9e1e7;
  padding: 0.45rem 0.95rem;
  font-weight: 600;
  line-height: 1.2;
}
.editor-tabs .tab:hover {
  border-color: #b8c5cf;
  color: #17324d;
}
.editor-tabs .tab.active {
  background: #17324d;
  color: #fff;
  border-color: #17324d;
}
.quill-wrap { background: #fff; border-radius: 0 0 8px 8px; overflow: visible; }
.quill-wrap .ql-toolbar.ql-snow {
  border: 0;
  border-bottom: 1px solid #d9e1e7;
}
.quill-wrap .ql-container.ql-snow {
  border: 0;
  overflow: visible !important;
  min-height: 12rem;
  font-size: 1rem;
  position: relative;
}
.quill-wrap .ql-editor {
  min-height: 12rem;
  max-height: 22rem;
  overflow-y: auto;
  padding-bottom: 1rem;
}
/* Hide Quill snow link tooltip — we use prompt-based link edit instead (no clipping). */
.quill-wrap .ql-tooltip {
  display: none !important;
}
.email-preview {
  width: 100%;
  min-height: 220px;
  border: 0;
  border-top: 1px solid #d9e1e7;
  background: #fff;
}
.template-edit .draft-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}
.templates-table .template-subject {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 28rem;
}
.template-edit form { max-width: 720px; }
.prompt-body {
  width: 100%;
  max-width: 720px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.45;
  resize: vertical;
  white-space: pre-wrap;
}
.reset-prompt { margin-top: 1.25rem; }
.sms-preview {
  background: #fff;
  border: 1px solid #d9e1e7;
  border-radius: 6px;
  padding: 0.75rem 1rem;
}
.sms-preview h2 { margin: 0 0 0.5rem; font-size: 1rem; }
.sms-preview-body {
  margin: 0;
  white-space: pre-wrap;
  font-family: system-ui, sans-serif;
  font-size: 0.95rem;
  line-height: 1.4;
}
.timeline { list-style: none; padding: 0; }
.timeline li { padding: 0.75rem 0; border-bottom: 1px solid #e8eef2; }
.danger-zone {
  border: 1px solid #f5c2c7;
  background: #fff5f5;
  padding: 1rem;
  border-radius: 6px;
  margin-top: 2rem;
}
.settings-dl {
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr;
  gap: 0.75rem 1.25rem;
  margin: 0;
}
.settings-dl dt {
  color: var(--muted);
  font-weight: 650;
  font-size: 0.86rem;
}
.settings-dl dd { margin: 0; }
.settings-dl dd.ok,
.settings-dl .ok { color: #1b7a3d; }
.settings-dl dd.warn,
.settings-dl .warn { color: #9a6700; }
.nav-with-badge { position: relative; }
.nav-badge {
  display: inline-block;
  min-width: 1.25rem;
  padding: 0.05rem 0.35rem;
  margin-left: 0.25rem;
  border-radius: 999px;
  background: #c45c26;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
  vertical-align: text-top;
}
.badge-unread {
  background: #fde8d8;
  color: #8a3b12;
  font-weight: 700;
}
.card-unread { border-color: #e8a06a; background: #fff8f3; }
/* Must beat `.timeline li { padding: … 0 }` — negative margins + overflow clip text. */
.timeline li.timeline-unread {
  background: #fff8f3;
  margin: 0;
  padding: 0.55rem 0.65rem;
  border-radius: 6px;
  border-left: 3px solid #e8a06a;
}
.read-toggle {
  margin-top: 0.75rem;
  display: inline;
  max-width: none;
}
button.btn-read-toggle {
  background: #fff;
  color: #17324d;
  border: 1px solid #c5d0d8;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 650;
  border-radius: 4px;
  cursor: pointer;
}
button.btn-read-toggle:hover {
  background: #eef3f6;
  border-color: #176b87;
  color: #176b87;
}
@media (max-width: 600px) {
  header { padding: 0; align-items: flex-start; }
  nav.app-nav { flex-wrap: wrap; }
  main { margin: 0 auto; }
  .settings-dl { grid-template-columns: 1fr; }
}

/* —— Lead detail workspace —— */
.lead-workspace {
  max-width: 1180px;
  margin-top: 1.25rem;
}
.crumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: #5b6b79;
  margin-bottom: 0.75rem;
}
.crumb a { font-weight: 600; }
.lead-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid #d9e1e7;
  border-radius: 8px;
  padding: 1rem 1.15rem;
  margin-bottom: 1rem;
}
.lead-title-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.lead-title-row h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.2;
}
.lead-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0;
  margin: 0.4rem 0 0.55rem;
  color: #5b6b79;
  font-size: 0.92rem;
}
.lead-meta > span:not(:empty)::after {
  content: "·";
  margin: 0 0.55rem;
  color: #b8c4ce;
}
.lead-meta > span:last-child:not(:empty)::after { content: none; }
.lead-actions form { display: inline; max-width: none; }
.lead-actions button.secondary,
button.secondary {
  background: #4a6274;
}
button.ghost {
  background: transparent;
  color: #a31b1b;
  border: 1px solid #f5c2c7;
}
button.ghost:hover { background: #fff5f5; }

.lead-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 1rem;
  align-items: start;
}
.lead-col {
  display: grid;
  gap: 1rem;
  overflow: visible;
  min-width: 0;
}
.panel {
  background: #fff;
  border: 1px solid #d9e1e7;
  border-radius: 8px;
  padding: 0.9rem 1rem 1rem;
  overflow: visible;
}
.panel-muted { background: #f4f7f9; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.panel-head h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.01em;
}
.panel-save { padding: 0.4rem 0.85rem; font-size: 0.9rem; }

.lead-form {
  display: block;
  max-width: none;
  gap: 0;
}
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem 0.75rem;
}
.field-grid .span-2 { grid-column: 1 / -1; }
.field-grid label { font-size: 0.85rem; font-weight: 600; color: #3d4f5f; }
.field-grid input,
.field-grid select,
.field-grid textarea {
  padding: 0.45rem 0.55rem;
  font-weight: 400;
  color: #1d2939;
}
.field-grid textarea[name="notes"] {
  min-height: 9rem;
  line-height: 1.45;
  resize: vertical;
  overflow-y: hidden; /* height grows with content; user can still drag-resize */
  box-sizing: border-box;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  align-items: start;
  max-width: none;
}
.inline-form textarea { min-height: 2.6rem; }
.consent-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #d9e1e7;
}
.consent-row form { display: inline; max-width: none; }
.consent-unsub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}
.consent-unsub .consent-row {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.draft-create {
  display: grid;
  grid-template-columns: 7.5rem 1fr auto;
  gap: 0.5rem;
  align-items: end;
  max-width: none;
  margin-bottom: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid #e8eef2;
}
.draft-create .grow { min-width: 0; }
.draft-create label { font-size: 0.85rem; color: #3d4f5f; }
.empty-inline {
  margin: 0;
  padding: 0.65rem 0;
  color: #5b6b79;
  font-size: 0.92rem;
}

.draft { padding: 0.85rem; margin-bottom: 0.75rem; overflow: visible; }
.draft:last-child { margin-bottom: 0; }
.draft-head h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  color: #17324d;
}
.draft-edit, .draft-send {
  max-width: none;
  gap: 0.55rem;
}
.draft-footer {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.75rem;
  padding: 0.75rem 0 0.35rem;
  border-top: 1px solid #e8eef2;
}
.draft-footer .draft-send {
  margin: 0;
  gap: 0.45rem;
}
.draft-footer .check-label {
  margin: 0 0 0.15rem;
  padding-bottom: 0.15rem;
}
.draft-footer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.draft-footer-actions button {
  width: 100%;
  margin: 0;
}
.follow-up-row {
  display: grid;
  grid-template-columns: 1.4fr 0.7fr 0.7fr;
  gap: 0.4rem;
}
.follow-up-row select { min-width: 0; }
.check-label {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-weight: 500;
  font-size: 0.88rem;
  color: #5b6b79;
}
.check-label input { width: auto; margin-top: 0.2rem; }

.timeline { margin: 0; max-height: 28rem; overflow-y: auto; }
.timeline li {
  padding: 0.55rem 0;
  border-bottom: 1px solid #e8eef2;
}
.timeline li:last-child { border-bottom: 0; }
.timeline-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
}
.timeline-meta time { color: #5b6b79; font-weight: 500; }
.timeline-body {
  margin-top: 0.2rem;
  font-size: 0.9rem;
  color: #3d4f5f;
}
.timeline-body-plain { white-space: pre-wrap; }
.timeline-email p { margin: 0 0 0.4rem; }
.timeline-email p:last-child { margin-bottom: 0; }
.timeline-inbound .email-meta {
  font-size: 0.82rem;
  color: #5b6b79;
  margin-bottom: 0.45rem;
  line-height: 1.35;
}
.timeline-inbound .email-reply {
  color: #1f2d3a;
  line-height: 1.45;
  margin-bottom: 0.5rem;
}
.timeline-inbound .email-quote {
  margin-top: 0.35rem;
  margin-bottom: 0.85rem;
  border-left: 3px solid #d5dee6;
  padding-left: 0.65rem;
  padding-bottom: 0.15rem;
}
.timeline-inbound .email-quote summary {
  cursor: pointer;
  color: #5b6b79;
  font-size: 0.82rem;
  font-weight: 600;
  list-style: none;
}
.timeline-inbound .email-quote summary::-webkit-details-marker { display: none; }
.timeline-inbound .email-quote summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.12s ease;
}
.timeline-inbound .email-quote[open] summary::before { transform: rotate(90deg); }
.timeline-inbound .email-quote-body {
  margin-top: 0.35rem;
  margin-bottom: 0.25rem;
  font-size: 0.82rem;
  color: #6a7a88;
  line-height: 1.4;
  max-height: 12rem;
  overflow: auto;
}

.badge.status-new { background: #e8eef2; }
.badge.status-queued { background: #fff3cd; }
.badge.status-researched { background: #d6eaf8; }
.badge.status-emailed { background: #d4edda; }
.badge.status-sms_sent { background: #d4edda; }
.badge.status-replied { background: #c3e6cb; }
.badge.status-meeting { background: #b8daff; }
.badge.status-quoted { background: #b8daff; }
.badge.status-won { background: #d8f3e0; }
.badge.status-lost { background: #f8d7da; }
.badge.status-unsubscribed { background: #e2e3e5; }

@media (max-width: 900px) {
  .lead-layout { grid-template-columns: 1fr; }
  .draft-create { grid-template-columns: 1fr 1fr; }
  .draft-create button { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .field-grid { grid-template-columns: 1fr; }
  .field-grid .span-2 { grid-column: auto; }
  .inline-form { grid-template-columns: 1fr; }
  .draft-create { grid-template-columns: 1fr; }
  .draft-footer-actions { grid-template-columns: 1fr; }
}


/* —— Panels / Agents hub —— */
.panel {
  background: var(--surface-card);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: var(--space-4) 1.15rem;
  box-shadow: var(--shadow-sm);
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
.panel-head .hint { margin: var(--space-1) 0 0; }
.panel-body {
  margin: 0 0 var(--space-3);
  color: var(--ink);
  font-size: 0.95rem;
}
.panel-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: var(--space-3);
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: #e8f3f7;
  color: var(--teal);
  white-space: nowrap;
}
.chip-safe {
  background: #e7f6ec;
  color: #1b6b3a;
}
.meta-list {
  display: grid;
  gap: 0.55rem;
  margin: 0;
}
.meta-list > div {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.5rem;
  align-items: baseline;
  font-size: 0.9rem;
}
.meta-list dt {
  margin: 0;
  font-weight: 700;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.meta-list dd { margin: 0; color: var(--ink); }

.agent-overview { margin-bottom: var(--space-5); }
.pipeline {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-2);
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
}
.pipeline li {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  padding: 0.7rem 0.75rem;
  background: #eef3f6;
  border-radius: 7px;
  min-width: 0;
}
.pipeline li > .pipeline-step {
  flex-shrink: 0;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--teal);
  color: #ffffff !important;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.05rem;
  line-height: 1;
}
.pipeline li div {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.pipeline li strong {
  font-size: 0.88rem;
  color: var(--navy);
}
.pipeline li div > span {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.agent-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
}
@media (min-width: 960px) {
  .agent-grid {
    grid-template-columns: 1.35fr 1fr;
    align-items: start;
  }
  .agent-card#scout { grid-column: 1 / -1; }
}
.agent-card .panel-head { margin-bottom: var(--space-2); }
.scout-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: var(--space-3);
  max-width: none;
  align-items: end;
  margin: var(--space-3) 0;
  padding: var(--space-3);
  background: #f7fafc;
  border: 1px solid var(--panel-border);
  border-radius: 7px;
}
.scout-actions { display: flex; align-items: end; }
.scout-hint { grid-column: 1 / -1; margin: 0; }
.scout-coverage-slot { grid-column: 1 / -1; min-height: 0; }
.scout-coverage { margin: 0; }
.scout-coverage-recent { color: #8a5a00; }
.runs-block { margin-top: var(--space-4); }
.runs-heading-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.runs-heading {
  margin: 0;
  font-size: 0.95rem;
  color: var(--navy);
}
.prompt-guide {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--ink);
  font-size: 0.92rem;
}
.prompt-guide li { margin: 0.3rem 0; }

@media (max-width: 900px) {
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .filter-actions { grid-column: 1 / -1; }
  .filter-actions button { width: 100%; }
  .pipeline { grid-template-columns: 1fr 1fr; }
  .scout-form { grid-template-columns: 1fr 1fr; }
  .scout-actions { grid-column: 1 / -1; }
  .scout-actions button { width: 100%; }
  /* fixed + top:100% from base rule = off-screen (100% of viewport). Pin below trigger via JS. */
  .nav-menu-panel {
    position: fixed;
    top: var(--nav-dropdown-top, 3.75rem);
    left: 1rem;
    right: 1rem;
    width: auto;
    min-width: 0;
    max-height: min(70vh, calc(100dvh - var(--nav-dropdown-top, 3.75rem) - 1rem));
    overflow-y: auto;
  }
  .nav-menu-panel-end { left: 1rem; right: 1rem; }
}
@media (max-width: 560px) {
  .filter-bar { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: 1fr; }
  .scout-form { grid-template-columns: 1fr; }
  .header-inner { padding: 0.65rem 1rem; }
  main { padding: var(--space-4) 1rem var(--space-5); }
  .meta-list > div { grid-template-columns: 1fr; gap: 0.15rem; }
}


/* Single-task pages (password, etc.) — center the focused form */
.page-focus {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: calc(100vh - 4.5rem);
  padding-top: var(--space-6);
  padding-bottom: var(--space-6);
}
.page-focus-inner {
  width: min(26rem, 100%);
}
.page-head-center {
  justify-content: center;
  text-align: center;
  margin-bottom: var(--space-4);
}
.page-head-center .page-head-copy {
  max-width: none;
}
.page-head-center .lede { margin-left: auto; margin-right: auto; }
.focus-form {
  max-width: none;
  width: 100%;
}
.panel-actions-stretch button {
  width: 100%;
}

.code-block {
  margin: 0;
  padding: 0.85rem 1rem;
  overflow: auto;
  max-height: 28rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  background: #f4f7f9;
  border: 1px solid #d9e1e7;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.runs-table .col-actions { width: 5.5rem; }

.bulk-leads-form {
  display: block;
  max-width: none;
  gap: 0;
}
.bulk-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: 0 0 var(--space-3);
}
.bulk-hint { margin: 0 0 var(--space-3); }
.leads-table .col-check {
  width: 2.5rem;
  text-align: center;
  vertical-align: middle;
}
.check-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  cursor: pointer;
}
.check-only input {
  width: auto;
  margin: 0;
}

/* —— Mobile baseline (all pages) ——
   Tables: horizontal scroll instead of crushing fixed columns.
   Filters/forms/CTAs: stack and fill width. */
@media (max-width: 900px) {
  /* Keep wide tables inside .table-wrap — don't expand the page. */
  html, body {
    overflow-x: hidden;
  }
  main {
    overflow-x: hidden;
  }
  .panel,
  .bulk-leads-form,
  #runs-live {
    min-width: 0;
    max-width: 100%;
  }
  .table-wrap {
    margin-inline: -0.15rem;
    padding-bottom: 0.25rem;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }
  table.data-table {
    table-layout: auto;
    width: max-content;
    min-width: 100%;
    max-width: none;
    overflow: visible;
    font-size: 0.9rem;
  }
  table.data-table th,
  table.data-table td {
    word-break: normal;
    overflow-wrap: normal;
    white-space: nowrap;
  }
  table.data-table .contact-stack {
    white-space: normal;
  }
  table.data-table .contact-stack a {
    white-space: nowrap;
  }
  table.data-table .summary-cell {
    white-space: normal;
    max-width: 22rem;
  }
  table.data-table td[colspan] {
    white-space: normal;
  }
  .page-head {
    flex-direction: column;
    align-items: stretch;
  }
  .page-head .cta-row {
    width: 100%;
  }
  .page-head .cta-row > .button,
  .page-head .cta-row > a.button {
    flex: 1 1 calc(50% - var(--space-2));
    text-align: center;
  }
  .bulk-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .bulk-toolbar button {
    width: 100%;
  }
  .panel-head {
    flex-direction: column;
  }
  .settings-subnav,
  .page-subnav {
    width: 100%;
  }
  .lead-hero {
    flex-direction: column;
    align-items: stretch;
  }
  .lead-actions {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }
  .brand { align-self: flex-start; }
  .app-nav,
  nav.app-nav {
    width: 100%;
    justify-content: flex-start;
    gap: 0.25rem;
  }
  .nav-menu-trigger {
    padding: 0.45rem 0.55rem;
    font-size: 0.86rem;
  }
  .nav-menu-trigger-label { /* keep Account readable */
    display: inline;
  }
  form {
    max-width: none;
  }
  .page-head .cta-row > .button,
  .page-head .cta-row > a.button {
    flex: 1 1 100%;
  }
  .lead-actions,
  .lead-actions.cta-row {
    width: 100%;
  }
  .lead-actions .button,
  .lead-actions a.button,
  .lead-actions button {
    width: 100%;
  }
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .status-cards .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .agent-grid {
    grid-template-columns: 1fr;
  }
  .invite-form {
    grid-template-columns: 1fr;
  }
  .invite-form button {
    width: 100%;
  }
  .copy-controls {
    grid-template-columns: 1fr;
  }
  .copy-controls button {
    width: 100%;
  }
  .consent-unsub {
    flex-direction: column;
    align-items: stretch;
  }
}

/* AusPost suburb suggest */
.suburb-suggest-wrap {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
}
.suburb-suggest-wrap > input,
.suburb-suggest-input {
  width: 100%;
}
/* Lead forms (stacked): short hint under suburb is fine */
.suburb-suggest-hint {
  display: block;
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--muted);
}
/* Scout: one form-level note keeps the input row aligned */
.scout-form-note {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0 0 0.15rem;
  font-size: 0.86rem;
}
/* Fixed to body — escapes mobile overflow clipping on main/panel */
.suburb-suggest-list {
  position: fixed;
  z-index: 4000;
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(23, 50, 77, 0.16);
  max-height: min(40vh, 15rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: manipulation;
}
.suburb-suggest-list[hidden] {
  display: none !important;
}
.suburb-suggest-list li {
  padding: 0.65rem 0.85rem;
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: 500;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.suburb-suggest-list li:hover,
.suburb-suggest-list li:focus,
.suburb-suggest-list li:active {
  background: #eef6f9;
  color: var(--teal);
  outline: none;
}
.suburb-suggest-list li.suburb-suggest-tip {
  cursor: default;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--muted);
  min-height: 2.5rem;
  gap: 0.55rem;
}
.suburb-suggest-list li.suburb-suggest-tip:hover,
.suburb-suggest-list li.suburb-suggest-tip:active {
  background: transparent;
  color: var(--muted);
}
.suburb-suggest-spinner {
  width: 0.95rem;
  height: 0.95rem;
  border: 2px solid #d5e0e7;
  border-top-color: var(--teal);
  border-radius: 50%;
  flex-shrink: 0;
  animation: app-spin 0.7s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .suburb-suggest-spinner {
    animation: none;
    border-top-color: #d5e0e7;
    background: var(--teal);
    opacity: 0.45;
  }
}

@media (max-width: 900px) {
  .suburb-suggest-input,
  .suburb-suggest-wrap > input {
    font-size: 16px;
  }
  .suburb-suggest-list {
    max-height: min(45vh, 16rem);
    border-radius: 10px;
  }
  .suburb-suggest-list li {
    padding: 0.8rem 1rem;
    min-height: 3rem;
    font-size: 1rem;
  }
  .scout-form label {
    min-width: 0;
  }
  .scout-form-note {
    font-size: 0.9rem;
  }
}
