/* 4L CRM — dark theme. Plain CSS, no framework. */
:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --muted: #9aa1ad;
  --accent: #5b8def;
  --accent-hover: #7aa3f3;
  --danger: #e5484d;
  --success: #3fb950;
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}

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

h1 { font-size: 1.5rem; margin: 0 0 1rem; font-weight: 600; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { color: var(--text); font-weight: 700; letter-spacing: 0.02em; }
.topbar nav { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.topbar nav a { color: var(--muted); }
.topbar nav a:hover { color: var(--text); text-decoration: none; }

.container { max-width: 1400px; margin: 2rem auto; padding: 0 1rem; }
.container.narrow { max-width: 600px; }
.container.medium { max-width: 760px; }
.container.wide { max-width: 1060px; }
.container.full { max-width: none; padding: 0 1.5rem; }
.with-sidebar { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 1.25rem; align-items: start; }
@media (max-width: 860px) { .with-sidebar { grid-template-columns: minmax(0, 1fr); } }

/* Spell check */
.spellcheck { margin: -0.25rem 0 1rem; }
#spelling-results:not(:empty) { margin-top: 0.75rem; padding: 0.75rem; background: var(--surface-2); border-radius: var(--radius); }
#spelling-results p { margin: 0; }
.spelling-list { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.spelling-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; padding: 0.3rem 0; border-top: 1px solid var(--border); }
.misspelled { text-decoration: underline wavy var(--danger); text-underline-offset: 3px; font-weight: 600; }
button.suggestion { background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 999px; padding: 0.1rem 0.6rem; font: inherit; font-size: 0.85rem; cursor: pointer; }
button.suggestion:hover { border-color: var(--accent); color: var(--accent); }
.ignore { font-size: 0.85rem; margin-left: auto; }
.ok { color: var(--success); }

/* Placeholder reference */
.placeholder-ref h2 { margin-bottom: 0.4rem; }
.placeholder-ref ul { list-style: none; padding: 0; margin: 0.75rem 0 0; }
.placeholder-ref li { display: flex; flex-direction: column; padding: 0.35rem 0; border-top: 1px solid var(--border); }
.placeholder-ref li span { font-size: 0.8rem; }
button.placeholder { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; color: var(--accent); font: inherit; }
button.placeholder:hover code { border-color: var(--accent); }
button.placeholder code { border: 1px solid transparent; }
.section { margin-top: 1.5rem; }
h2 { font-size: 1.15rem; margin: 0; font-weight: 600; }
code { background: var(--surface-2); padding: 0.05rem 0.35rem; border-radius: 4px; font-size: 0.85em; }
.container.public { margin-top: 4rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }

.muted, .empty { color: var(--muted); }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); column-gap: 0.75rem; }
.form-grid .field { grid-column: span 6; }
.form-grid .field-first_name, .form-grid .field-last_name { grid-column: span 3; }
.form-grid .field-city { grid-column: span 3; }
.form-grid .field-state { grid-column: span 1; }
.form-grid .field-postal_code { grid-column: span 2; }
.field { margin-bottom: 1rem; }
.field label { display: block; margin-bottom: 0.3rem; color: var(--muted); font-size: 0.9rem; }
.req { color: var(--danger); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="tel"], input[type="url"], select, textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.error, .errors { color: var(--danger); font-size: 0.9rem; margin: 0.3rem 0 0; }
.errors { margin-bottom: 1rem; }
.errors p { margin: 0; }
.search { margin-bottom: 1rem; }
.filters { margin-bottom: 0.75rem; }
.filter-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.filter-row + .filter-row { margin-top: 0.5rem; }
/* The dropdowns share one row evenly (long names are cut off in the box). */
.filter-dropdowns { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.filter-dropdowns select { min-width: 0; text-overflow: ellipsis; }
/* A dropdown of tick boxes (pick several). */
.multi-filter { position: relative; min-width: 0; }
.multi-filter summary {
  display: flex; align-items: center; gap: 0.4rem; list-style: none; cursor: pointer;
  padding: 0.55rem 0.7rem; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.multi-filter summary::-webkit-details-marker { display: none; }
.multi-filter summary::after { content: ""; flex: none; margin-left: auto; width: 0.45rem; height: 0.45rem; border: solid currentColor; border-width: 0 2px 2px 0; transform: translateY(-2px) rotate(45deg); }
.multi-filter[open] summary::after { transform: translateY(1px) rotate(-135deg); }
.multi-filter summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
.multi-filter.is-picked summary { border-color: var(--accent); }
.multi-filter-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multi-filter-menu {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 100%; width: max-content; max-width: min(320px, 90vw);
  max-height: 320px; overflow-y: auto; padding: 0.35rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.multi-filter-menu label { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.45rem; border-radius: 6px; cursor: pointer; }
.multi-filter-menu label:hover { background: var(--surface-2); }
.multi-filter-menu input[type="checkbox"] { flex: none; }
.multi-filter-menu p { margin: 0.35rem 0.45rem; }
.multi-filter-clear { display: block; width: calc(100% - 0.4rem); margin: 0.3rem 0.2rem 0.1rem; }
.filters input { flex: 1 1 140px; width: auto; }
.filters .filter-search { flex: 3 1 260px; }
.result-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.75rem; min-height: 2.4rem; }
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.help { color: var(--muted); font-size: 0.85rem; margin: 0.3rem 0 0; }
.small { font-size: 0.85rem; }
.inline-row { display: flex; gap: 0.5rem; }
.inline-row select { flex: 1; }

/* Settings rows */
.setting-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; padding: 1rem 0; border-top: 1px solid var(--border); }
.setting-row p { margin: 0.25rem 0 0; }
.setting-row .form-actions { margin-top: 0; }
.sender-name { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }
.sender-name input { width: 14rem; max-width: 100%; }
.signature-form { margin-top: 1rem; }
.signature-label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
/* Signatures are shown as they'll look in Gmail: white, black text. */
.signature-editor { min-height: 5rem; max-width: 36rem; padding: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; color: #222; font: 13px Arial, sans-serif; overflow-x: auto; }
.signature-editor:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.signature-editor img { max-width: 100%; height: auto; }

/* Email history */
.history { list-style: none; padding: 0; margin: 0; }
.history li { border-top: 1px solid var(--border); padding: 0.6rem 0; }
.history summary { cursor: pointer; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.email-body { white-space: pre-wrap; font: inherit; background: var(--surface-2); border-radius: var(--radius); padding: 0.75rem; margin: 0.5rem 0 0; }

/* Honeypot: off-screen rather than display:none, which some bots detect. */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.form-actions { display: flex; gap: 0.75rem; align-items: center; margin-top: 1.25rem; }
.form-actions .right { margin-left: auto; }

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.btn:hover { text-decoration: none; border-color: var(--muted); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

form.inline { display: inline; margin: 0; }
button.link { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; }
button.link:hover { color: var(--text); }

/* Table: every contact field is shown. Long values (names, addresses) wrap
   so it fits the window; it only scrolls sideways on narrow screens. */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table-wrap .table { border: 0; border-radius: 0; }
.table th, .table td.nowrap { white-space: nowrap; }
.table th.wrap { white-space: normal; hyphens: manual; }
.table { width: 100%; font-size: 0.9rem; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: 0.5rem 0.6rem; text-align: left; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 500; font-size: 0.85rem; background: var(--surface-2); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.actions { white-space: nowrap; text-align: right; }
.actions a { margin-left: 0.6rem; }
.actions a.danger { color: var(--danger); }
.tag-danger { color: var(--danger) !important; border-color: var(--danger) !important; }
.tag { font-size: 0.8rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }

.pager { display: flex; gap: 1rem; justify-content: center; align-items: center; margin-top: 1rem; color: var(--muted); }

/* Messages */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.message { padding: 0.6rem 0.9rem; border-radius: var(--radius); background: var(--surface-2); border-left: 3px solid var(--accent); }
.message.success { border-left-color: var(--success); }
.message.error { border-left-color: var(--danger); }

@media (max-width: 600px) {
  .form-grid .field-first_name, .form-grid .field-last_name,
  .form-grid .field-city, .form-grid .field-state, .form-grid .field-postal_code { grid-column: span 6; }
}

/* Mass email */
.recipients { background: var(--surface-2); border-radius: var(--radius); padding: 0.75rem 1rem; margin-bottom: 1rem; }
.recipients p { margin: 0.2rem 0; }
.confirm label { display: flex; gap: 0.6rem; align-items: flex-start; color: var(--text); font-size: 0.95rem; }
.confirm input { margin-top: 0.2rem; flex: none; }
.email-preview { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; margin-top: 0.5rem; }
.email-preview p { margin: 0 0 0.5rem; }
#bulk-preview:not(:empty) { margin-top: 0.75rem; }
.progress { height: 0.6rem; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 0.5rem 0 0.75rem; }
.progress-bar { height: 100%; background: var(--accent); transition: width 0.4s ease; }
.error-text { color: var(--danger); }

/* CSV import */
.plain-list { margin: 0.5rem 0 0; padding-left: 1.2rem; }
.plain-list li { margin: 0.3rem 0; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; gap: 0.2rem; }
.stat-number { font-size: 1.8rem; font-weight: 600; }
.page-head .form-actions { margin-top: 0; }
input[type="file"] { color: var(--muted); }

/* Support tickets */
.badge { display: inline-block; min-width: 1.3rem; padding: 0 0.4rem; border-radius: 999px; background: var(--accent); color: #fff; font-size: 0.75rem; font-weight: 600; text-align: center; line-height: 1.3rem; }
.status-open { color: var(--accent); border-color: var(--accent); }
.status-in_progress { color: #d29922; border-color: #d29922; }
.status-completed { color: var(--success); border-color: var(--success); }
.status-to_do { color: var(--accent); border-color: var(--accent); }
.status-cancelled { color: var(--muted); }
.report-details summary { cursor: pointer; font-weight: 600; }
.report-details .table-wrap { margin-top: 0.75rem; }
.filters select { flex: 1 1 160px; width: auto; }
.form-actions.stacked { flex-direction: column; align-items: stretch; margin-top: 1rem; }
.form-actions.stacked .btn, .form-actions.stacked form, .form-actions.stacked button { width: 100%; text-align: center; }
.field-consent { display: grid; grid-template-columns: auto 1fr; gap: 0.6rem; align-items: start; }
.field-consent label { grid-column: 2; grid-row: 1; color: var(--text); font-size: 0.95rem; margin: 0; }
.field-consent input { grid-column: 1; grid-row: 1; margin-top: 0.2rem; }
.field-consent .error, .field-consent .help { grid-column: 1 / -1; }

/* Archive */
.dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; width: min(480px, calc(100vw - 2rem)); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog h2 { margin-bottom: 0.75rem; }
.dialog textarea { width: 100%; }
.archived-banner { border: 1px solid var(--danger); border-radius: var(--radius); padding: 0.75rem 1rem; margin-bottom: 1rem; }
.archived-banner p { margin: 0 0 0.4rem; }
button.link.restore { color: var(--accent); margin-left: 0.6rem; }

/* Notes */
.with-notes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .with-notes { grid-template-columns: minmax(0, 1fr); } }
.notes-panel .page-head { margin-bottom: 0.75rem; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline-item { border-top: 1px solid var(--border); padding: 0.7rem 0; }
.timeline-item:first-child { border-top: 0; padding-top: 0; }
.timeline-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem; }
.timeline-body { white-space: normal; overflow-wrap: anywhere; }
.timeline-item.activity .timeline-body { color: var(--muted); font-size: 0.9rem; }
.tag-note { color: var(--accent); border-color: var(--accent); }
.event-archived .tag, .event-email_failed .tag, .event-unsubscribed .tag { color: var(--danger); border-color: var(--danger); }

/* Public forms */
.public-form .form-intro p { margin: 0 0 0.8rem; }
.public-form .form-intro { margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
.form-section { font-size: 1.1rem; margin: 2rem 0 0.75rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.question { margin-bottom: 1.4rem; }
.question fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.question-label { display: block; font-weight: 500; margin-bottom: 0.45rem; color: var(--text); }
.question-label p { margin: 0; display: inline; }
.question .help p { margin: 0.3rem 0 0; }
.parts { display: grid; gap: 0.6rem; }
.parts-name { grid-template-columns: 1fr 1fr; }
.parts-address { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.parts-address .part-1, .parts-address .part-2 { grid-column: span 6; }
.parts-address .part-3 { grid-column: span 2; }
.parts-address .part-4 { grid-column: span 2; }
.parts-address .part-5 { grid-column: span 2; }
.parts-address .part-6, .parts-address .part-7 { grid-column: span 3; }
@media (max-width: 600px) { .parts-name { grid-template-columns: 1fr; } .parts-address .part { grid-column: span 6 !important; } }
.sub-label { display: block; font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; }
.choices { display: grid; gap: 0.4rem; }
.choice { display: flex; gap: 0.6rem; align-items: flex-start; cursor: pointer; }
.choice input { margin-top: 0.25rem; flex: none; width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }
.choice label, .choices label { display: flex; gap: 0.6rem; }
.other-box { margin-top: 0.5rem; }
.word-count { font-size: 0.8rem; color: var(--muted); margin: 0.25rem 0 0; }
.word-count.met { color: var(--success); }
.draft-banner { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; border: 1px solid var(--accent); border-radius: var(--radius); padding: 0.6rem 0.9rem; margin-bottom: 1rem; }
.draft-banner p { margin: 0; }
input[type="number"], input[type="date"] { width: 100%; padding: 0.55rem 0.7rem; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); font: inherit; color-scheme: dark; }
input[type="file"] { padding: 0.4rem 0; }

/* Answers on contact pages and submission pages */
.answers h3 { font-size: 0.95rem; margin: 1.2rem 0 0.5rem; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; }
.answers dl { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.2rem 1.25rem; }
.answer { padding: 0.5rem 0; border-top: 1px solid var(--border); }
.answer-long { grid-column: 1 / -1; }
.answer dt { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.2rem; }
.answer dt p { margin: 0; }
.answer dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 700px) { .answers dl { grid-template-columns: 1fr; } }
.chip { display: inline-block; margin: 0 0.3rem 0.3rem 0; padding: 0.1rem 0.55rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 0.85rem; }
.headshot img, .card-headshot img { max-width: 160px; max-height: 160px; border-radius: var(--radius); display: block; object-fit: cover; }
.submission-card { border-top: 1px solid var(--border); padding: 1rem 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.5rem 1rem; }
.submission-card:first-of-type { border-top: 0; }
.submission-card > header { display: flex; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; grid-column: 1 / -1; }
.submission-card .tags { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.submission-card .card-headshot { grid-column: 2; grid-row: 2; }
.submission-card .card-headshot img { width: 96px; height: 96px; }
.submission-card details, .submission-card > p, .submission-card .difference { grid-column: 1 / -1; }
.submission-card summary { cursor: pointer; color: var(--accent); }
.highlights { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0.5rem 1rem; }
.highlights li { overflow-wrap: anywhere; }
.difference { color: #d29922; margin: 0.25rem 0; }
@media print {
  .topbar, .no-print, .messages { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border: 0; background: #fff; }
  .answers h3 { color: #000; }
  .answer dt, .muted { color: #444 !important; }
}

/* Merge */
.merge-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 760px) { .merge-grid { grid-template-columns: 1fr; } }
.merge-side { cursor: pointer; display: block; }
.merge-side:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.merge-pick { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.75rem; color: var(--accent); }
.merge-fields { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 1rem; margin: 0.75rem 0 0; }
.merge-fields dt { color: var(--muted); font-size: 0.85rem; }
.merge-fields dd { margin: 0; overflow-wrap: anywhere; }

/* Contact profile page: everything important above the fold */
.profile-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: 1rem; align-items: start; }
@media (max-width: 1000px) { .profile-layout { grid-template-columns: minmax(0, 1fr); } }
.profile-main > .section { margin-top: 1rem; }
.profile-header { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 1rem 1.25rem; align-items: start; }
@media (max-width: 760px) { .profile-header { grid-template-columns: auto minmax(0, 1fr); } .profile-actions { grid-column: 1 / -1; } }
.avatar img, .avatar .initials { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; display: grid; place-items: center; }
.avatar .initials { background: var(--surface-2); border: 1px solid var(--border); color: var(--accent); font-size: 1.6rem; font-weight: 600; }
.profile-title { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.profile-title h1 { margin: 0; font-size: 1.4rem; }
.profile-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.4rem 1.25rem; margin: 0; }
.profile-facts .wide { grid-column: span 2; }
@media (max-width: 600px) { .profile-facts .wide { grid-column: auto; } }
.profile-facts dt { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.profile-facts dd { margin: 0; overflow-wrap: anywhere; }
.profile-actions { display: flex; flex-direction: column; gap: 0.4rem; min-width: 130px; }
.profile-actions .btn, .profile-actions form, .profile-actions button { width: 100%; text-align: center; }
@media (max-width: 760px) { .profile-actions { flex-direction: row; flex-wrap: wrap; } .profile-actions .btn, .profile-actions form { width: auto; } }
.archived-note { color: var(--danger); margin: 0.6rem 0 0; }

/* Form tiles: all of a contact's forms side by side */
.form-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.85rem; }
.form-tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.85rem; display: flex; flex-direction: column; gap: 0.55rem; }
.form-tile header h3 { font-size: 0.95rem; margin: 0; line-height: 1.3; }
.form-tile .tags { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.tile-facts { margin: 0; display: grid; gap: 0.35rem; }
.tile-facts dt { color: var(--muted); font-size: 0.75rem; }
.tile-facts dd { margin: 0; font-size: 0.88rem; overflow-wrap: anywhere; }
.tile-actions { display: flex; gap: 0.4rem; margin-top: auto; }

/* Notes stay beside the page and scroll on their own */
.profile-notes { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; }
@media (max-width: 1000px) { .profile-notes { position: static; max-height: none; } }

/* Larger pop-ups */
.dialog-medium { width: min(640px, calc(100vw - 2rem)); }
.dialog-wide { width: min(980px, calc(100vw - 2rem)); max-height: calc(100vh - 3rem); }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; position: sticky; top: -1.5rem; background: var(--surface); padding: 0.25rem 0 0.75rem; margin-bottom: 0.5rem; border-bottom: 1px solid var(--border); z-index: 1; }
.dialog-head h2 { margin: 0; }
.dialog-head p { margin: 0.2rem 0 0; }
.dialog-head .form-actions { margin-top: 0; }

/* Social handles on the profile */
.social-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.7rem; }
.social-label { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; margin-right: 0.3rem; }
.social-chip { display: inline-flex; gap: 0.35rem; align-items: center; padding: 0.15rem 0.6rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: 0.85rem; }
.social-chip strong { color: var(--accent); font-size: 0.75rem; }
.social-chip:hover { border-color: var(--accent); text-decoration: none; color: var(--text); }
.form-grid .field-instagram, .form-grid .field-facebook, .form-grid .field-tiktok, .form-grid .field-x_handle { grid-column: span 3; }
@media (max-width: 600px) { .form-grid .field-instagram, .form-grid .field-facebook, .form-grid .field-tiktok, .form-grid .field-x_handle { grid-column: span 6; } }
.social-chip.empty { color: var(--muted); border-style: dashed; background: transparent; cursor: pointer; font: inherit; font-size: 0.85rem; }
.social-chip.empty strong { color: var(--muted); }

/* JotForm import */
.warn-text { color: #d29922; }
.import-preview td { font-size: 0.85rem; vertical-align: top; }
.import-preview tr.row-flagged td { background: rgba(210, 153, 34, 0.08); }
.import-preview tr.row-error td { background: rgba(248, 81, 73, 0.08); }
.upload-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.5rem; }
.avatar .link-button { display: block; margin: 0.35rem auto 0; }
.link-button { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; }
.import-preview td:last-child { min-width: 300px; }
.import-preview td:nth-child(7) { min-width: 160px; }

/* Tags */
.tag-label { color: var(--accent); border-color: var(--accent); text-decoration: none; }
a.tag-label:hover { background: var(--surface); }
.tag-cell { min-width: 140px; }
.tag-cell .tag { display: inline-block; margin: 0 0.15rem 0.2rem 0; }
.field-tags { grid-column: 1 / -1; }
.field-tags ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.5rem 1rem; }
.field-tags ul ul { display: block; margin-top: 0.25rem; }
.field-tags ul ul li { margin: 0.15rem 0; }
.field-tags label { font-weight: normal; }
.field-tags #id_tags { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.5rem 1rem; }

/* Social handle review */
.handles-table td { vertical-align: top; }
.handles-table .answer-cell { max-width: 520px; font-size: 0.85rem; color: var(--muted); }
tr.row-checked td { opacity: 0.6; }

/* 4L | LL switch (top left) */
.side-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 3px; background: var(--surface-2); gap: 2px; }
.side-switch a { padding: 0.25rem 0.9rem; border-radius: 999px; color: var(--muted); font-weight: 700; letter-spacing: 0.04em; }
.side-switch a:hover { color: var(--text); text-decoration: none; }
.side-switch a.active { background: var(--accent); color: #fff; }

/* Law firm (LL) pages */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.note-form textarea { width: 100%; }
.note-form .form-actions { margin: 0.5rem 0 1rem; }
.inquiry { border-top: 1px solid var(--border); padding: 0.9rem 0; }
.inquiry:first-of-type { border-top: 0; padding-top: 0.25rem; }
.inquiry header { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem; }
.inquiry p { margin: 0 0 0.6rem; }

/* LL phase 2: conflicts, trademarks, deadlines */
.badge-warn { background: #d29922; }
.tag-warn { color: #d29922; border-color: #d29922; }
.conflict-flag { color: #d29922; }
.conflict-card.conflict-needs_review { border-color: #d29922; }
.conflict-card.conflict-conflict { border-color: var(--danger); }
.conflict-matches { margin: 0.5rem 0 1rem; padding-left: 1.2rem; }
.conflict-matches li { margin: 0.25rem 0; }
.conflict-decide { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.conflict-decide input[type="text"] { flex: 1 1 260px; }
.trademark { border-top: 1px solid var(--border); padding: 1rem 0; }
.trademark:first-of-type { border-top: 0; padding-top: 0.25rem; }
.trademark header { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.trademark h3 { margin: 0; font-size: 1.1rem; }
.deadlines-table { margin-top: 0.75rem; }
.tag-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.4rem 1rem; margin-bottom: 1rem; }
tr.overdue td:first-child { color: var(--danger); font-weight: 700; }
.adverse-form .field { grid-column: span 2; }
.adverse-form .form-actions { grid-column: 1 / -1; margin-top: 0; }
@media (max-width: 700px) { .adverse-form .field { grid-column: span 6; } }

/* The TSDR mirror on a trademark */
.tsdr-mirror { margin-top: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem 0.9rem; background: var(--surface-2); }
.tsdr-mirror summary { cursor: pointer; font-weight: 600; }
.tsdr-mirror h4 { margin: 1.1rem 0 0.4rem; font-size: 0.95rem; color: var(--accent); }
.tsdr-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 0.75rem; flex-wrap: wrap; }
.tsdr-image { max-height: 70px; max-width: 320px; background: #fff; border-radius: 4px; padding: 4px; }
.tsdr-rows { display: grid; grid-template-columns: 1fr; gap: 0.15rem; margin: 0; }
.tsdr-rows > div { display: grid; grid-template-columns: minmax(160px, 260px) 1fr; gap: 0.75rem; padding: 0.25rem 0; border-bottom: 1px solid var(--border); }
.tsdr-rows dt { color: var(--muted); font-size: 0.85rem; }
.tsdr-rows dd { margin: 0; font-size: 0.9rem; }
.tsdr-subhead { font-weight: 700; font-size: 0.85rem; padding-top: 0.5rem; border: 0 !important; display: block !important; }
.tsdr-table td { font-size: 0.85rem; }
@media (max-width: 700px) { .tsdr-rows > div { grid-template-columns: 1fr; gap: 0; } }
.monitoring-form { margin-left: 0.5rem; }
.monitoring-form .link-button { margin-right: 0.6rem; }

/* Projects */
.task-tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); }
.task-tabs a { padding: 0.5rem 0.9rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.task-tabs a.active { color: inherit; font-weight: 600; border-bottom-color: var(--accent); }
/* One line to type a task straight onto the Projects page. */
.quick-add { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin: 0.75rem 0; padding: 0.6rem; }
.quick-add .quick-add-title { flex: 4 1 280px; width: auto; }
.quick-add select { flex: 1 1 140px; width: auto; }
.quick-add input[type="date"] { flex: 0 1 160px; width: auto; }
/* Task table cells that change in place on double-click. */
.task-table td.editable { cursor: cell; }
.task-table td.editable:hover { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.task-table td.inline-edit { min-width: 200px; background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--accent); }
.inline-edit form { display: grid; gap: 0.35rem; }
.inline-edit select, .inline-edit input, .inline-edit textarea { width: 100%; }
.inline-edit-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.inline-edit-actions .btn { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.task-table .task-note { min-width: 220px; overflow-wrap: anywhere; }
.task-table .task-links a { display: block; overflow-wrap: anywhere; }
.task-link-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.task-link-list li { overflow-wrap: anywhere; }
.task-link-list button.link { margin-left: 0.4rem; }
.task-timeline { margin-top: 1.25rem; }
.badge-ok { background: var(--success); }
.task-notices { margin-bottom: 1rem; border-color: var(--success); }
.task-notices .page-head { margin-bottom: 0.5rem; }
.task-notice-list { list-style: none; padding: 0; margin: 0; }
.task-notice-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; padding: 0.5rem 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.task-cancel { margin-top: 0.9rem; }
.task-cancel summary { cursor: pointer; }
.task-cancel label { display: block; margin: 0.6rem 0 0.25rem; }
.task-cancel .btn { margin-top: 0.6rem; }
.project-progress { min-width: 180px; }
.project-progress .progress { margin-bottom: 0.25rem; }

/* Form builder (templates/webforms/form_build.html) */
.builder-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.builder-settings > summary { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; cursor: pointer; list-style: none; }
.builder-settings > summary::-webkit-details-marker { display: none; }
.builder-settings > summary h2 { margin: 0; }
.builder-settings > summary::before { content: "▸"; color: var(--muted); }
.builder-settings[open] > summary { margin-bottom: 1rem; }
.builder-settings[open] > summary::before { content: "▾"; }
.builder-settings .field-tags ul, .builder-settings .field-tags > div { list-style: none; padding: 0; margin: 0; columns: 2 220px; }
.builder-settings .field-tags label { display: flex; gap: 0.4rem; align-items: center; color: var(--text); }
.builder-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: 0.75rem; }
.builder-q { padding: 0.9rem 1rem 0.6rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.builder-q.has-error { border-color: var(--danger); }
.builder-q.is-hidden { opacity: 0.55; border-style: dashed; }
.builder-q-head { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.6rem; }
.builder-q-head select { flex: 1; width: auto; min-width: 0; }
.builder-q-number { flex: none; min-width: 1.8rem; height: 1.8rem; display: grid; place-items: center; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); font-size: 0.85rem; color: var(--muted); }
.builder-q-move { display: flex; gap: 0.25rem; flex: none; }
.builder-q-move .btn { padding: 0.35rem 0.6rem; line-height: 1; }
.builder-q .field { margin-bottom: 0.6rem; }
.builder-q textarea { min-height: 0; resize: vertical; }
.builder-q [hidden] { display: none !important; }
.builder-q-row { display: flex; gap: 0.5rem 1.25rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.6rem; }
.builder-check { display: inline-flex; gap: 0.45rem; align-items: center; cursor: pointer; }
.builder-inline { display: inline-flex; gap: 0.5rem; align-items: center; color: var(--muted); font-size: 0.9rem; }
.builder-inline input, .builder-inline select { width: auto; min-width: 7rem; }
.builder-inline input[type="number"] { width: 6rem; min-width: 0; padding: 0.45rem 0.6rem; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); font: inherit; }
.builder-more { margin: 0.2rem 0 0.4rem; }
.builder-more > summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; margin-bottom: 0.5rem; }
.builder-more .builder-check { margin-bottom: 0.6rem; }
.builder-new-detail { margin-top: 0.5rem; }
.builder-add { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.builder-add select { width: auto; flex: 0 1 22rem; }
.builder-add .help { flex-basis: 100%; }
.builder-save { position: sticky; bottom: 0; z-index: 5; padding: 0.75rem 0; background: var(--bg); border-top: 1px solid var(--border); }
.copy-field { font-size: 0.85rem; }

/* Phone preview (templates/core/phone_preview.html) */
.preview-controls .preview-page { flex: 2 1 320px; width: auto; }
.phone-stage { display: flex; justify-content: center; overflow: hidden; }
.phone {
  flex: none; transform-origin: top center;
  width: calc(var(--w) + 28px); height: calc(var(--h) + 28px); padding: 14px;
  background: #111; border-radius: 42px; box-shadow: 0 0 0 2px #333, 0 18px 40px rgba(0, 0, 0, 0.5);
}
.phone iframe { display: block; width: var(--w); height: var(--h); border: 0; border-radius: 28px; background: #fff; }

/* Automations editor (templates/automations/edit.html) */
.placeholder-list { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.placeholder-list .placeholder { font-family: ui-monospace, monospace; font-size: 0.8rem; padding: 0.3rem 0.5rem; min-height: 0; }
.placeholder-list .help { flex-basis: 100%; }
