/* Agency Desk — Primer-inspired light ops UI */
:root {
  --canvas: #ffffff;
  --canvas-subtle: #f6f8fa;
  --canvas-inset: #f6f8fa;
  --border: #d0d7de;
  --border-muted: #d8dee4;
  --fg: #1f2328;
  --fg-muted: #656d76;
  --fg-subtle: #6e7781;
  --accent: #0969da;
  --accent-emphasis: #0550ae;
  --success-fg: #1a7f37;
  --success-subtle: #dafbe1;
  --attention-fg: #9a6700;
  --attention-subtle: #fff8c5;
  --danger-fg: #cf222e;
  --danger-subtle: #ffebe9;
  --done-fg: #8250df;
  --done-subtle: #fbefff;
  --shadow-sm: 0 1px 0 rgba(31, 35, 40, 0.04);
  --shadow-md: 0 3px 6px rgba(140, 149, 159, 0.15);
  --radius: 6px;
  --radius-lg: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, monospace;
  --header-h: 56px;
  --sidebar-w: 320px;
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  overflow: hidden;
  margin: 0;
}
body {
  font: 14px/1.5 var(--font);
  color: var(--fg);
  background: var(--canvas-subtle);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12px; }
[hidden] { display: none !important; }


/* —— Boot / skeletons —— */
@keyframes desk-skel-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.skel {
  display: block;
  border-radius: var(--radius);
  background: linear-gradient(
    90deg,
    var(--canvas-subtle) 0%,
    #eaeef2 40%,
    var(--canvas-subtle) 80%
  );
  background-size: 200% 100%;
  animation: desk-skel-shimmer 1.15s ease-in-out infinite;
}
.skel-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.skel-line {
  height: 12px;
  max-width: 100%;
}
.skel-line-sm { height: 10px; }
.skel-line-md { height: 14px; }
.skel-title {
  width: min(280px, 70%);
  height: 22px;
}
.skel-pill {
  width: 52px;
  height: 18px;
  border-radius: 2em;
  flex: 0 0 auto;
}
.skel-btn {
  width: 64px;
  height: 28px;
}
.skel-counter {
  width: 28px;
  height: 20px;
  border-radius: 2em;
}
.skel-search {
  width: 100%;
  height: 28px;
}
.skel-card {
  height: 88px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-muted);
}
.skel-card-wide { height: 140px; }
.lead-row-skeleton {
  pointer-events: none;
  cursor: default;
}
.lead-row-skeleton:hover { background: transparent; }
.lead-row-skeleton .lead-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.lead-row-skeleton .meta { display: block; margin-top: 6px; }
.overview-skel {
  min-height: calc(100vh - var(--header-h) - 72px);
}
.detail.empty-detail.is-overview {
  min-height: calc(100vh - var(--header-h) - 48px);
}
.overview-skel .stat {
  min-height: 64px;
}
.overview-skel .overview-glossary {
  min-height: 220px;
}
.boot-shell .topnav-right { gap: 8px; }
.boot-shell .sidebar-search { pointer-events: none; }
#app.is-loading .lead-list .lead-row:not(.lead-row-skeleton) { display: none; }


.mark {
  display: inline-block;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0969da, #8250df);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
  flex: 0 0 auto;
}

/* —— Login —— */
.login-screen, #login.login-screen {
  min-height: 100vh;
  height: 100%;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 10% -10%, #ddf4ff 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #fbefff 0%, transparent 50%),
    var(--canvas-subtle);
}
.login-card {
  width: min(400px, 100%);
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-md);
}
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.login-brand h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.muted { color: var(--fg-muted); margin: 2px 0 0; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field span { font-size: 14px; font-weight: 600; }
.field input {
  height: 32px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--canvas);
  color: var(--fg);
  outline: none;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.3);
}
.field.is-invalid input,
.field input[aria-invalid="true"] {
  border-color: var(--danger-fg);
  background: var(--danger-subtle);
  box-shadow: 0 0 0 3px rgba(207, 34, 46, 0.16);
}
.field.is-invalid input:focus,
.field input[aria-invalid="true"]:focus {
  border-color: var(--danger-fg);
  box-shadow: 0 0 0 3px rgba(207, 34, 46, 0.24);
}
.form-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--danger-fg);
  background: var(--danger-subtle);
  border: 1px solid rgba(207, 34, 46, 0.28);
  border-radius: var(--radius);
  margin: 0 0 12px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}
.form-error::before { content: "!"; font-weight: 700; }
.field.is-shaking { animation: field-shake 0.28s ease-in-out; }
@keyframes field-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* —— Buttons —— */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--canvas-subtle);
  color: var(--fg);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn:active { background: #ebecf0; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border-color: rgba(31,35,40,.15);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-emphasis); }
.btn-danger {
  background: var(--canvas);
  border-color: var(--border);
  color: var(--danger-fg);
}
.btn-danger:hover { background: var(--danger-subtle); }
.btn-invisible {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--fg);
}
.btn-invisible:hover { background: rgba(208,215,222,.32); }
.btn-block { width: 100%; }
.btn-lg { height: 40px; padding: 0 16px; font-size: 14px; }

/* —— App chrome (viewport-locked shell) —— */
#app.app, .app {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.topnav {
  height: var(--header-h);
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: var(--canvas);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.topnav-left, .topnav-right { display: flex; align-items: center; gap: 10px; }
.product { font-size: 14px; font-weight: 600; }
#app .topnav-left { cursor: pointer; border-radius: 6px; }
#app .topnav-left:hover .product { text-decoration: underline; text-underline-offset: 3px; }
#app .topnav-left:focus-visible { outline: 2px solid var(--accent, #0969da); outline-offset: 2px; }
.env-pill {
  font-size: 12px; font-weight: 600;
  padding: 0 8px; height: 20px; line-height: 20px;
  border-radius: 2em;
  background: var(--done-subtle);
  color: var(--done-fg);
  border: 1px solid transparent;
}

.shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  overflow: hidden;
}

/* Sidebar: head+search sticky; only .lead-list scrolls */
.sidebar {
  background: var(--canvas);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.sidebar-head {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px 6px;
  border-bottom: 1px solid transparent;
}
.sidebar-head h2 {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--fg-muted);
  font-weight: 600;
}
.counter {
  font-size: 12px; font-weight: 600;
  background: var(--canvas-subtle);
  border: 1px solid var(--border);
  border-radius: 2em;
  padding: 0 8px; height: 20px; line-height: 18px;
  color: var(--fg-muted);
}
.sidebar-search {
  flex: 0 0 auto;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border-muted);
}
.sidebar-search input {
  width: 100%;
  height: 28px;
  padding: 4px 10px 4px 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--canvas-subtle)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 16 16'%3E%3Cpath fill='%23656d76' d='M10.68 11.74a6 6 0 1 1 1.06-1.06l3.04 3.04a.75.75 0 1 1-1.06 1.06l-3.04-3.04ZM11.5 7a4.5 4.5 0 1 0-9 0 4.5 4.5 0 0 0 9 0Z'/%3E%3C/svg%3E")
    8px 50% no-repeat;
  color: var(--fg);
  outline: none;
  font-size: 13px;
}
.sidebar-search input::placeholder { color: var(--fg-subtle); }
.sidebar-search input:focus {
  border-color: var(--accent);
  background-color: var(--canvas);
  box-shadow: 0 0 0 3px rgba(9,105,218,.3);
}

.lead-row .meta .opens {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}
.lead-row .meta:empty { display: none; }


.lead-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0;
  overscroll-behavior: contain;
}

/* Lead rows — tight Primer nav-list feel */
.lead-row {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--border-muted);
  border-radius: 0;
  background: transparent;
  padding: 8px 12px;
  cursor: pointer;
  color: inherit;
  display: grid;
  gap: 2px;
  position: relative;
}
.lead-row:last-child { border-bottom: 0; }
.lead-row:hover { background: var(--canvas-subtle); }
.lead-row.active {
  background: #ddf4ff;
}
.lead-row.active:hover { background: #ddf4ff; }
.lead-row-body {
  min-width: 0;
  overflow: hidden;
  width: 100%;
}
.lead-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  width: 100%;
}
.lead-row .name {
  flex: 1 1 0;
  min-width: 0;
  max-width: 100%;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lead-row-top .lead-signals {
  flex: 0 0 auto;
}
.lead-row .meta {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--fg-muted);
  line-height: 1.3;
  min-width: 0;
}
.lead-row .meta .mono {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg-subtle);
}
.lead-row .label {
  flex: 0 0 auto;
  height: 18px;
  padding: 0 6px;
  font-size: 11px;
  line-height: 18px;
}

/* Main: independent scroll */
.main {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: auto;
  padding: 24px;
  overscroll-behavior: contain;
}
.detail {
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  min-height: 480px;
}
.blankslate { text-align: center; padding: 64px 24px; color: var(--fg-muted); }
.blankslate h2 { margin: 0 0 8px; color: var(--fg); font-size: 20px; font-weight: 600; }
.empty-detail .blankslate { text-align: center; padding: 64px 24px; color: var(--fg-muted); }

.detail-header {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: flex-start; justify-content: space-between;
  margin-bottom: 16px;
}
.detail-header-main { min-width: 0; flex: 1; }
.detail-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.detail-header-main { min-width: 0; overflow: hidden; }
.detail-status {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.detail-header-main .detail-header-actions {
  margin-top: 12px;
}
.detail-meta {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  color: var(--fg-muted); font-size: 13px;
  margin-top: 6px;
}
.detail-updated {
  flex: 0 0 auto;
  margin-left: auto;
  text-align: right;
  color: var(--fg-muted);
  font-size: 12px;
  white-space: nowrap;
  padding-top: 4px;
}
.detail-preview-url {
  display: inline-block;
  max-width: min(520px, 100%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  font-size: 12px;
}
.detail-preview-pending { font-size: 12px; }

/* Status labels (Primer Label) */
.label {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 8px;
  border-radius: 2em;
  font-size: 12px; font-weight: 600;
  border: 1px solid transparent;
  background: var(--canvas-subtle);
  color: var(--fg-muted);
}
.label-success { background: var(--success-subtle); color: var(--success-fg); }
.label-attention { background: var(--attention-subtle); color: var(--attention-fg); }
.label-danger { background: var(--danger-subtle); color: var(--danger-fg); }
.label-accent { background: #ddf4ff; color: var(--accent-emphasis); }
.label-done { background: var(--done-subtle); color: var(--done-fg); }

.flash {
  border: 1px solid #54aeff66;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 0 0 16px;
  background: #ddf4ff;
  color: var(--fg);
  font-size: 13px;
  line-height: 1.5;
}
.flash strong { font-weight: 600; }

.actions {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 0 0 20px;
}

.section { margin-top: 24px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-muted);
}
.section-head h3 { margin: 0; font-size: 14px; font-weight: 600; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.stat {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--canvas);
}
.stat .n { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.stat .l { font-size: 12px; color: var(--fg-muted); margin-top: 2px; }
.spark { display: flex; align-items: flex-end; gap: 2px; height: 28px; margin-top: 8px; }
.spark i { display: block; width: 6px; border-radius: 2px 2px 0 0; background: #54aeff; }

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel table { width: 100%; border-collapse: collapse; }
.panel th, .panel td {
  padding: 10px 12px;
  text-align: left;
  border-top: 1px solid var(--border-muted);
  vertical-align: top;
  font-size: 13px;
}
.panel tr:first-child th, .panel tr:first-child td { border-top: 0; }
.panel th {
  width: 140px;
  color: var(--fg-muted);
  font-weight: 600;
  background: var(--canvas-subtle);
}
.panel thead th {
  width: auto;
  background: var(--canvas-subtle);
  color: var(--fg-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.preview-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--canvas-subtle);
  display: grid;
  gap: 12px;
  margin-bottom: 8px;
}
.preview-card .row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.preview-card .hint { margin: 0; color: var(--fg-muted); font-size: 13px; }

/* Toast */
.toast {
  position: fixed; top: 16px; right: 16px; z-index: 100;
  background: var(--fg); color: #fff;
  padding: 10px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-md);
}
.toast.show { display: block; }

/* Modal */
.modal-root {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(31,35,40,.45);
  display: grid; place-items: center;
  padding: 16px;
}
.modal {
  width: min(520px, 100%);
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 20px;
}
.modal h3 { margin: 0 0 8px; font-size: 18px; font-weight: 600; }
.modal-body { display: grid; gap: 10px; margin: 12px 0 16px; }
.modal-url {
  width: 100%;
  font-family: var(--mono);
  font-size: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--canvas-subtle);
  color: var(--fg);
}
.modal-warning {
  font-size: 13px;
  color: var(--attention-fg);
  background: var(--attention-subtle);
  border: 1px solid #d4a72c66;
  border-radius: var(--radius);
  padding: 10px 12px;
  line-height: 1.45;
}
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.modal-actions.stack { flex-direction: column; }
.modal-actions.stack .btn { width: 100%; height: 40px; }

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(180px, 36vh) 1fr;
  }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    height: auto;
    max-height: none;
  }
  .main { padding: 12px; }
}

/* Legacy link panel helpers (desk card removed) */
.link-panel {
  display: grid;
  gap: 12px;
  margin: 0 0 20px;
}
.link-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--canvas);
  padding: 14px 16px;
  display: grid;
  gap: 10px;
}
.link-row-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.link-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}
.link-sub {
  font-size: 12px;
  color: var(--fg-muted);
  margin-top: 1px;
}
.link-timer {
  margin: 0;
  font-size: 13px;
  color: var(--fg-muted);
  line-height: 1.4;
  padding: 8px 10px;
  background: var(--canvas-subtle);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
}
.link-timer.is-expired {
  color: var(--danger-fg);
  background: var(--danger-subtle);
  border-color: rgba(207, 34, 46, 0.28);
}
.link-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* Overview home (no lead selected) */
.overview { display: grid; gap: 8px; }
.overview-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.overview-sub { margin: 6px 0 0; }
.overview-status-grid {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.overview-status-card .label { margin-top: 8px; }
.overview-glossary th { width: 140px; }

/* Client engagement / activity (no link chrome) */
.client-engagement {
  display: grid;
  gap: 14px;
}
.client-engagement-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}
.client-preview-until {
  margin: 0;
  font-size: 13px;
  color: var(--fg-muted);
  line-height: 1.4;
}
.client-preview-until.is-expired {
  color: var(--danger-fg);
  font-weight: 600;
}
.client-engagement-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.client-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  width: 100%;
  margin-top: 8px;
}
.client-link-url {
  flex: 1 1 220px;
  min-width: 0;
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  background: var(--canvas);
  color: var(--fg);
}
.modal-hint {
  font-size: 13px;
  line-height: 1.45;
  color: var(--fg-muted);
}
.modal-hint.muted { color: var(--fg-muted); }
.client-empty {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 16px 18px;
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  background: var(--canvas-subtle);
}
.client-empty-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.client-empty-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
}
.client-empty-sub {
  font-size: 13px;
  color: var(--fg-muted);
  line-height: 1.4;
}
.detail-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
}


/* Split preview additions — layered on top of the restored Desk rail/status UI. */
:root { --sidebar-w-collapsed: 52px; }
.shell { transition: grid-template-columns .15s ease; }
.shell.sidebar-collapsed,
html.desk-sidebar-collapsed .shell { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
.sidebar-head-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.sidebar-toggle { width: 28px; height: 28px; min-width: 28px; padding: 0; }
.sidebar-toggle-icon { font-size: 11px; line-height: 1; color: var(--fg-muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.shell.sidebar-collapsed .sidebar-title,
html.desk-sidebar-collapsed .shell .sidebar-title,
.shell.sidebar-collapsed .sidebar-search,
html.desk-sidebar-collapsed .shell .sidebar-search,
.shell.sidebar-collapsed .counter,
html.desk-sidebar-collapsed .shell .counter,
.shell.sidebar-collapsed .lead-row-body,
html.desk-sidebar-collapsed .shell .lead-row-body { display: none; }
.shell.sidebar-collapsed .sidebar-head,
html.desk-sidebar-collapsed .shell .sidebar-head { flex-direction: column; align-items: center; padding: 12px 6px 8px; }
.shell.sidebar-collapsed .sidebar-head-actions,
html.desk-sidebar-collapsed .shell .sidebar-head-actions { flex-direction: column; }
.shell.sidebar-collapsed .lead-row,
html.desk-sidebar-collapsed .shell .lead-row { justify-items: center; padding: 8px 4px; }
.shell.sidebar-collapsed .lead-row .lead-initial,
html.desk-sidebar-collapsed .shell .lead-row .lead-initial { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--canvas-subtle); border: 1px solid var(--border); font-size: 13px; font-weight: 700; color: var(--fg-muted); }
.shell.sidebar-collapsed .lead-row.active .lead-initial,
html.desk-sidebar-collapsed .shell .lead-row.active .lead-initial { background: #ddf4ff; border-color: #54aeff66; color: var(--accent-emphasis); }
.lead-initial { display: none; }
.main { display: flex; flex-direction: column; }
.lead-split { flex: 1; display: grid; grid-template-columns: minmax(280px, 42%) minmax(320px, 1fr); gap: 16px; min-height: calc(100vh - var(--header-h) - 48px); align-items: stretch; }
.detail-pane { min-height: 0; overflow: auto; max-height: calc(100vh - var(--header-h) - 48px); }
.preview-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--canvas); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.preview-pane-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border-muted); background: var(--canvas-subtle); flex-shrink: 0; }
.preview-pane-head-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.preview-pane-title { margin: 0; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--fg-muted); }
.preview-local-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #dafbe1; color: #116329; white-space: nowrap; }
.preview-mode { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--canvas); }
.preview-mode-btn { border: 0; border-radius: 0; box-shadow: none; height: 28px; padding: 0 10px; font-size: 12px; background: transparent; }
.preview-mode-btn + .preview-mode-btn { border-left: 1px solid var(--border); }
.preview-mode-btn.is-active { background: #ddf4ff; color: var(--accent-emphasis); }
.preview-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 12px; background: var(--canvas-inset); overflow: auto; }
.preview-frame-shell { flex: 1 1 auto; min-height: 420px; width: 100%; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--canvas); box-shadow: var(--shadow-sm); }
.preview-mode-mobile .preview-frame-shell { width: min(100%, 390px); max-width: 390px; margin: 0 auto; min-height: 640px; border-radius: 24px; box-shadow: var(--shadow-md), inset 0 0 0 1px var(--border-muted); }
.desk-preview-iframe { display: block; width: 100%; height: 100%; min-height: 420px; border: 0; background: var(--canvas); }
.preview-mode-mobile .desk-preview-iframe { min-height: 640px; }
.preview-empty { flex: 1; display: grid; place-content: center; gap: 8px; text-align: center; padding: 32px 24px; min-height: 280px; }
.preview-empty-title { margin: 0; font-size: 16px; font-weight: 600; color: var(--fg); }
.preview-empty-body { margin: 0 0 8px; max-width: 320px; }
@media (max-width: 900px) {
  .shell.sidebar-collapsed,
  html.desk-sidebar-collapsed .shell { grid-template-columns: 1fr; }
  .shell.sidebar-collapsed .sidebar-title,
  html.desk-sidebar-collapsed .shell .sidebar-title,
  .shell.sidebar-collapsed .sidebar-search,
  html.desk-sidebar-collapsed .shell .sidebar-search,
  .shell.sidebar-collapsed .counter,
  html.desk-sidebar-collapsed .shell .counter,
  .shell.sidebar-collapsed .lead-row-body,
  html.desk-sidebar-collapsed .shell .lead-row-body { display: revert; }
  .shell.sidebar-collapsed .lead-initial,
  html.desk-sidebar-collapsed .shell .lead-initial { display: none; }
  .lead-split { grid-template-columns: 1fr; min-height: auto; }
  .detail-pane { max-height: none; }
}


/* Dual signals: quiet work icon (spinner|check) + browser preview icon */
.lead-signals {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.signal-work,
.signal-preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  flex-shrink: 0;
  color: var(--fg-muted);
  opacity: 0.45;
  background: transparent;
  border: 1px solid transparent;
}
.signal-work.is-generating {
  opacity: 0.45;
  color: var(--fg-muted);
}
.signal-work.is-awaiting {
  opacity: 1;
  color: #9a6700;
  background: #fff8c5;
}
.signal-work.is-approved {
  opacity: 0.45;
  color: var(--fg-muted);
  background: transparent;
}
.signal-work.is-sent {
  opacity: 1;
  color: var(--success-fg);
  background: var(--success-subtle);
}
.signal-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: desk-spin 0.85s linear infinite;
  opacity: 1;
}
.signal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
@keyframes desk-spin {
  to { transform: rotate(360deg); }
}
.signal-preview.is-active {
  color: var(--success-fg);
  opacity: 1;
  background: var(--success-subtle);
}
.signal-preview.is-muted {
  opacity: 0.45;
  color: var(--fg-muted);
}
.signal-icon-svg { display: block; }
.lead-row-top .lead-signals { margin-left: 4px; }
.detail-status .lead-signals { gap: 6px; }
.detail-status .signal-work,
.detail-status .signal-preview { width: 26px; height: 26px; }
.detail-status .signal-spinner { width: 13px; height: 13px; }

.signal-work.is-waiting {
  opacity: 0.55;
  color: var(--fg-muted);
}

.lead-signals.is-detail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.signal-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px 0 6px;
  border-radius: 2em;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  color: var(--fg-muted);
  background: var(--canvas-subtle);
  border: 1px solid var(--border-muted);
}
.signal-row .signal-work,
.signal-row .signal-preview {
  width: 18px;
  height: 18px;
  background: transparent !important;
  opacity: 1;
  border: 0;
}
.signal-row .signal-label { line-height: 1.2; white-space: nowrap; }
.signal-row.is-generating {
  color: var(--fg-muted);
  background: var(--canvas-subtle);
  border-color: var(--border-muted);
}
.signal-row.is-waiting {
  color: var(--fg-muted);
  background: var(--canvas-subtle);
  border-color: var(--border-muted);
  border-style: dashed;
}
.signal-row.is-awaiting {
  color: #9a6700;
  background: #fff8c5;
  border-color: #d4a72c66;
}
.signal-row.is-sent {
  color: var(--success-fg);
  background: var(--success-subtle);
  border-color: transparent;
}
.signal-row.is-preview-on {
  color: var(--success-fg);
  background: var(--success-subtle);
  border-color: transparent;
}
.signal-row.is-preview-off {
  color: var(--fg-muted);
  background: var(--canvas-subtle);
  border-color: var(--border-muted);
  font-weight: 500;
}



/* —— Emails (post-pay welcome) —— */
.emails-screen {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--header-h));
  background: var(--bg, #0d1117);
}
.emails-layout {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(360px, 1fr);
  gap: 0;
  flex: 1;
  min-height: 0;
}
.emails-layout-preview-only {
  grid-template-columns: 1fr;
}
.emails-editor {
  padding: 20px 24px 40px;
  overflow: auto;
  border-right: 1px solid var(--border, #30363d);
  background: var(--panel, #161b22);
}
.emails-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.emails-editor-head h2 {
  margin: 0 0 4px;
  font-size: 18px;
}
.emails-sub { margin: 0; font-size: 13px; }
.emails-editor-actions { display: flex; gap: 8px; flex-shrink: 0; }
.emails-editor .field { margin-bottom: 14px; }
.emails-editor .field > span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--muted, #8b949e);
}
.emails-editor input[type="text"],
.emails-code {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border, #30363d);
  border-radius: 8px;
  background: var(--bg, #0d1117);
  color: var(--fg, #e6edf3);
  padding: 10px 12px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.45;
  resize: vertical;
}
.emails-editor input[type="text"] {
  font-family: inherit;
  font-size: 14px;
}
.emails-status { min-height: 1.2em; margin-top: 8px; }
.emails-status-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.emails-preview {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  /* Desk shell only — reading pane itself is white like an inbox */
  background: #ffffff;
  color: #111;
  position: relative;
}
.emails-preview-stage {
  display: flex;
  flex: 1;
  min-height: calc(100vh - var(--header-h));
  align-items: stretch;
  gap: 0;
  background: #ffffff;
}
.emails-preview-canvas {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  overflow: auto;
  background: #ffffff;
}
.emails-preview-sheet {
  width: 100%;
  max-width: none;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  background: #ffffff;
}
.emails-preview-stage[data-viewport="mobile"] .emails-preview-sheet {
  max-width: 390px;
  margin: 0 auto;
  border-left: 1px solid #e8e6e1;
  border-right: 1px solid #e8e6e1;
}
/* Thin inbox chrome — not a kicker / art title */
.emails-mail-chrome {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 12px 20px 10px;
  border-radius: 0;
  background: #ffffff;
  border: 0;
  border-bottom: 1px solid #e8e6e1;
  box-shadow: none;
  font-size: 13px;
  color: #3d3c38;
  box-sizing: border-box;
  flex-shrink: 0;
}
.emails-mail-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  padding: 2px 0;
}
.emails-mail-row-subject {
  padding-top: 4px;
  margin-top: 2px;
  border-top: 1px solid #f0eeea;
}
.emails-mail-label {
  flex-shrink: 0;
  width: 56px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: #8a8780;
}
.emails-mail-from {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 400;
  color: #3d3c38;
}
.emails-mail-subject {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  color: #111110;
}
.emails-preview-stage[data-theme="dark"] {
  background: #111;
}
.emails-preview-stage[data-theme="dark"] .emails-preview-canvas,
.emails-preview-stage[data-theme="dark"] .emails-preview-sheet {
  background: #111;
}
.emails-preview-stage[data-theme="dark"] .emails-mail-chrome {
  background: #111;
  border-bottom-color: #2a2a2a;
  box-shadow: none;
  color: #c4c1ba;
}
.emails-preview-stage[data-theme="dark"] .emails-mail-row-subject {
  border-top-color: #2a2a2a;
}
.emails-preview-stage[data-theme="dark"] .emails-mail-label {
  color: #8a8780;
}
.emails-preview-stage[data-theme="dark"] .emails-mail-from {
  color: #c4c1ba;
}
.emails-preview-stage[data-theme="dark"] .emails-mail-subject {
  color: #f2f0eb;
}

/* Message body = full white reading pane (no card, no shadow, no beige stage) */
.emails-preview-frame-wrap {
  width: 100%;
  flex: 1 1 auto;
  min-height: 520px;
  background: #ffffff;
  border-radius: 0;
  border: 0;
  box-shadow: none;
  overflow: hidden;
  transition: max-width 160ms ease;
}
.emails-preview-stage[data-viewport="mobile"] .emails-preview-frame-wrap {
  border-radius: 0;
  box-shadow: none;
}
.emails-preview-stage[data-theme="dark"] .emails-preview-frame-wrap {
  background: #111;
  border: 0;
  box-shadow: none;
}
.emails-preview-iframe {
  display: block;
  width: 100%;
  height: calc(100vh - var(--header-h) - 96px);
  min-height: 560px;
  border: 0;
  background: #ffffff;
}
.emails-preview-stage[data-theme="dark"] .emails-preview-iframe {
  background: #111;
}

/* Quiet side rail — icons only, no border chrome */
.emails-preview-rail {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: 20px 14px;
  flex-shrink: 0;
  align-self: stretch;
  background: transparent;
}
.emails-rail-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.emails-rail-btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #8a8780;
  opacity: 0.55;
  cursor: pointer;
  transition: opacity 120ms ease, color 120ms ease, background 120ms ease;
}
.emails-rail-btn:hover {
  opacity: 0.9;
  background: rgba(0, 0, 0, 0.04);
  color: #3a3936;
}
.emails-rail-btn:focus-visible {
  outline: 2px solid rgba(0, 0, 0, 0.25);
  outline-offset: 2px;
  opacity: 1;
}
.emails-rail-btn.is-active {
  opacity: 1;
  color: #111;
  font-weight: 600;
  background: transparent;
}
.emails-preview-stage[data-theme="dark"] .emails-rail-btn {
  color: #9a9790;
}
.emails-preview-stage[data-theme="dark"] .emails-rail-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e8e6e1;
}
.emails-preview-stage[data-theme="dark"] .emails-rail-btn.is-active {
  color: #f2f0eb;
}
.emails-preview-stage[data-theme="dark"] .emails-rail-btn:focus-visible {
  outline-color: rgba(255, 255, 255, 0.35);
}

@media (max-width: 960px) {
  .emails-layout { grid-template-columns: 1fr; }
  .emails-editor { border-right: 0; border-bottom: 1px solid var(--border, #30363d); }
  .emails-preview-stage {
    flex-direction: column-reverse;
  }
  .emails-preview-rail {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 8px 12px 4px;
  }
  .emails-rail-group {
    flex-direction: row;
  }
  .emails-preview-iframe {
    height: 70vh;
    min-height: 420px;
  }
}

/* —— Lead pricing editor —— */
.pricing-section-head {
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px 16px;
}
.pricing-section-intro {
  display: grid;
  gap: 4px;
  min-width: min(100%, 280px);
}
.pricing-section-lead {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  max-width: 42rem;
}
.pricing-currency-control {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  margin-left: auto;
}
.pricing-currency-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
}
.pricing-segment {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--canvas);
  box-shadow: var(--shadow-sm);
}
.pricing-segment-btn {
  appearance: none;
  border: 0;
  margin: 0;
  padding: 0 14px;
  height: 34px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--fg-muted);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.pricing-segment-btn + .pricing-segment-btn {
  border-left: 1px solid var(--border);
}
.pricing-segment-btn:hover {
  color: var(--fg);
  background: var(--canvas-subtle);
}
.pricing-segment-btn.is-active {
  background: #ddf4ff;
  color: var(--accent-emphasis);
}
.pricing-segment-btn:active {
  transform: scale(0.98);
}
.panel.pricing-panel {
  overflow: visible;
  padding: 16px;
  background: linear-gradient(165deg, var(--canvas) 0%, var(--canvas-subtle) 100%);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.pricing-panel.is-save-success {
  border-color: #54aeff99;
  box-shadow: 0 0 0 1px #54aeff44, var(--shadow-md);
}
.pricing-panel.is-save-error {
  border-color: #ff818266;
  box-shadow: 0 0 0 1px #ff818233;
}
.pricing-plans {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 560px) {
  .pricing-plans { grid-template-columns: 1fr; }
  .pricing-currency-control {
    align-items: flex-start;
    margin-left: 0;
    width: 100%;
  }
}
.pricing-plan-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--canvas);
  cursor: text;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}
.pricing-plan-card:hover {
  border-color: #afb8c1;
  box-shadow: var(--shadow-md);
}
.pricing-plan-card.is-focused,
.pricing-plan-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px #0969da26, var(--shadow-md);
  transform: translateY(-2px);
}
.pricing-plan-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pricing-plan-name {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--fg);
}
.pricing-plan-tag {
  font-size: 12px;
  color: var(--fg-muted);
}
.pricing-input-wrap {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--canvas-subtle);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.pricing-plan-card:focus-within .pricing-input-wrap {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: var(--canvas);
}
.pricing-input-prefix {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  padding: 0 10px;
  font-size: 18px;
  font-weight: 600;
  color: var(--fg-muted);
  background: var(--canvas-subtle);
  border-right: 1px solid var(--border-muted);
  user-select: none;
}
.pricing-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.pricing-input:focus {
  outline: none;
}
.pricing-input::-webkit-outer-spin-button,
.pricing-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.pricing-input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}
.pricing-savings {
  font-size: 12px;
  font-weight: 600;
  color: var(--success-fg);
  background: var(--success-subtle);
  border-radius: 999px;
  padding: 4px 10px;
  align-self: flex-start;
  line-height: 1.3;
}
.pricing-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-muted);
}
.pricing-save-btn {
  min-height: 40px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.2s ease;
}
.pricing-save-btn:active:not(:disabled) {
  transform: scale(0.98);
}
.pricing-save-btn.is-success {
  background: var(--success-fg);
  border-color: var(--success-fg);
  box-shadow: 0 4px 14px #1a7f3740;
}
.pricing-save-btn.is-success:hover {
  background: #116329;
}
.pricing-save-check {
  width: 0;
  height: 16px;
  overflow: hidden;
  opacity: 0;
  transition: width 0.2s ease, opacity 0.2s ease;
}
.pricing-save-btn.is-success .pricing-save-check {
  width: 16px;
  opacity: 1;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.5 6.5 11.5 12.5 4.5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.pricing-save-status {
  font-size: 13px;
  min-height: 1.35em;
  transition: color 0.2s ease;
}
.pricing-save-status.is-success {
  color: var(--success-fg);
  font-weight: 600;
}
.pricing-save-status.is-error {
  color: var(--danger-fg);
  font-weight: 600;
}
@media (prefers-reduced-motion: reduce) {
  .pricing-plan-card,
  .pricing-segment-btn,
  .pricing-save-btn,
  .pricing-panel,
  .pricing-save-check {
    transition: none;
  }
  .pricing-plan-card.is-focused,
  .pricing-plan-card:focus-within {
    transform: none;
  }
  .pricing-segment-btn:active,
  .pricing-save-btn:active:not(:disabled) {
    transform: none;
  }
}
