:root {
  --ink: #202124;
  --muted: #626a73;
  --line: #dce2ea;
  --line-strong: #c4ceda;
  --panel: #ffffff;
  --page: #f6f8fb;
  --rail: #ffffff;
  --accent: #8e1a3a;
  --accent-dark: #681129;
  --accent-soft: #fbedf2;
  --info: #1f6aa5;
  --info-soft: #edf5fb;
  --good: #217a52;
  --good-soft: #edf8f2;
  --warn: #a84d0f;
  --danger: #a32035;
  --danger-soft: #fff0f2;
  --shadow: 0 10px 28px rgba(32, 33, 36, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.authenticated .login-screen {
  display: none;
}

body:not(.authenticated) .topbar,
body:not(.authenticated) .app-shell {
  display: none;
}

.master-only {
  display: none !important;
}

body.master-user .tab-button.master-only {
  display: grid !important;
}

body.master-user .tab-panel.master-only.active {
  display: block !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0 0 4px;
}

.login-status {
  min-height: 20px;
  color: var(--danger);
}

.user-badge {
  align-self: center;
  color: var(--muted);
  font-weight: 700;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  min-height: 72px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 22px;
}

h3,
h4 {
  margin: 0;
  color: var(--ink);
  line-height: 1.2;
}

h3 {
  font-size: 18px;
}

h4 {
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
}

.app-shell {
  display: grid;
  grid-template-columns: 238px minmax(0, 1fr);
  gap: 18px;
  width: min(1540px, calc(100% - 32px));
  margin: 16px auto 48px;
  align-items: start;
}

.side-rail {
  position: sticky;
  top: 88px;
  display: grid;
  gap: 14px;
  align-self: start;
}

.workspace {
  min-width: 0;
}

.panel,
.source-block,
.stats {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tab-button {
  width: 100%;
  display: grid;
  gap: 2px;
  border: 1px solid transparent;
  border-left: 4px solid transparent;
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.tab-button span {
  font-weight: 800;
}

.tab-button .step-kicker {
  color: var(--info);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.tab-button small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.tab-button:hover {
  border-color: var(--line);
  border-left-color: var(--info);
  background: var(--info-soft);
}

.tab-button.active {
  border-color: #b8d3e7;
  border-left-color: var(--info);
  color: var(--ink);
  background: var(--info-soft);
}

.tab-button.active small {
  color: #4f687c;
}

.tab-button.active .step-kicker {
  color: #15557f;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
}

.stats div {
  min-width: 0;
  padding: 12px;
  border-left: 4px solid var(--info);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.stats div:nth-child(2) {
  border-left-color: var(--good);
}

.stats div:nth-child(3) {
  border-left-color: var(--warn);
  border-bottom: 0;
}

.stats div:nth-child(4) {
  border-left-color: var(--accent);
  border-bottom: 0;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.stats strong {
  display: block;
  margin-top: 2px;
  font-size: 22px;
}

.source-block {
  padding: 12px;
}

.source-block p {
  overflow-wrap: anywhere;
  font-size: 12px;
}

.recipient-panel {
  min-width: 0;
}

.send-column {
  order: -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-self: start;
  padding-bottom: 2px;
}

.filters,
.composer-grid,
.contact-form,
.settings-form {
  display: grid;
  gap: 12px;
  align-items: end;
}

.filters {
  grid-template-columns: minmax(145px, 1fr) minmax(145px, 1fr) minmax(220px, 1.4fr) auto;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.section-strip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.composer-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.template-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.2fr) auto auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.merge-toolbar {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto minmax(220px, 1.2fr);
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.merge-context-menu {
  position: fixed;
  z-index: 30;
  display: grid;
  gap: 3px;
  width: 270px;
  max-height: min(440px, calc(100vh - 24px));
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(32, 33, 36, 0.16);
}

.merge-context-menu[hidden] {
  display: none;
}

.merge-context-menu button {
  display: grid;
  gap: 1px;
  width: 100%;
  border: 0;
  border-radius: 6px;
  padding: 8px 9px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.merge-context-menu button:hover {
  color: var(--ink);
  background: var(--info-soft);
}

.merge-context-menu span,
.merge-context-menu small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.merge-context-menu span {
  font-weight: 750;
}

.merge-context-menu small {
  color: var(--muted);
}

.composer {
  padding: 20px;
}

#campaignBody {
  min-height: 360px;
  font-size: 16px;
  line-height: 1.55;
}

.contact-form,
.settings-form,
.import-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.import-form {
  display: grid;
  gap: 12px;
  align-items: end;
}

.import-form .wide {
  grid-column: span 2;
}

.import-check {
  align-self: center;
}

.import-help {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.import-help h3 {
  margin: 0 0 4px;
  font-size: 17px;
}

.import-result {
  margin-top: 18px;
}

.import-summary {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.import-summary dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 12px 0 0;
}

.import-summary dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.import-summary dd {
  margin: 2px 0 0;
  font-size: 22px;
  font-weight: 800;
}

.import-errors {
  margin-top: 12px;
}

.field-admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
  align-items: start;
}

.field-admin-section {
  min-width: 0;
}

.category-admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.2fr);
  gap: 28px;
  align-items: start;
}

.category-admin-section {
  min-width: 0;
}

.category-add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin: 14px 0;
}

.category-admin-list {
  display: grid;
  gap: 8px;
}

.category-row {
  display: grid;
  grid-template-columns: auto minmax(150px, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.category-row.selected {
  border-color: #b8d3e7;
  background: var(--info-soft);
}

.category-row.inactive {
  opacity: 0.62;
}

.category-row .meta {
  margin: 0;
  white-space: nowrap;
}

#category2AdminList .category-row {
  grid-template-columns: minmax(140px, 1fr) minmax(150px, 0.9fr) auto auto auto;
}

.field-section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.field-section-head p {
  font-size: 13px;
}

.field-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.field-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.field-row.locked {
  background: #f8fafc;
}

.field-row strong,
.field-row span {
  display: block;
}

.field-row span {
  color: var(--muted);
  font-size: 12px;
}

.lock-badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  color: #4f5965;
  background: #e9edf2;
  font-size: 12px;
  font-weight: 750;
}

.field-add-form {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(130px, 0.7fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.custom-fields-form {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.custom-field-heading {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.custom-field-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.custom-check {
  align-self: center;
}

.empty-state {
  margin: 0;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfe;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.check {
  grid-auto-flow: column;
  justify-content: start;
  align-items: center;
  padding-bottom: 9px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c8d0da;
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(31, 106, 165, 0.16);
  border-color: var(--info);
}

input[type="checkbox"] {
  width: auto;
}

textarea {
  resize: vertical;
}

.full {
  grid-column: 1 / -1;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

.actions,
.primary-actions,
.secondary-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.primary-actions {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(170px, 1fr);
  margin-top: 12px;
}

.secondary-actions {
  margin-top: 10px;
}

.primary-actions button,
.secondary-actions button {
  justify-content: center;
}

button,
.button {
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 9px 13px;
  color: #fff;
  background: var(--accent);
  font: inherit;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: var(--accent-dark);
}

button.secondary,
.button.secondary {
  color: var(--accent);
  background: #fff;
}

button.secondary:hover,
.button.secondary:hover {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

button.secondary.danger {
  color: var(--danger);
  border-color: #e0a7b1;
}

button.secondary.danger:hover {
  color: #7d1426;
  background: var(--danger-soft);
}

button:disabled,
button:disabled:hover {
  border-color: #cfd4dc;
  color: #8b9199;
  background: #eef0f3;
  cursor: default;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  color: #4f5965;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

tbody tr:hover {
  background: #fbf7f8;
}

.select-col {
  width: 44px;
}

.contacts-table {
  min-width: 1180px;
  table-layout: fixed;
}

.contacts-table .business-col {
  width: 40%;
}

.contacts-table .category-col {
  width: 13%;
}

.contacts-table .date-col {
  width: 9%;
}

.contacts-table .suppress-col {
  width: 7%;
}

.contacts-table .notes-col {
  width: 21%;
}

.contacts-table .edit-col {
  width: 78px;
}

.contacts-table td {
  padding: 12px 10px;
}

.contacts-table .select-cell,
.contacts-table .date-cell,
.contacts-table .suppress-cell,
.contacts-table .edit-cell {
  padding-top: 16px;
}

.contacts-table .suppress-cell,
.contacts-table .edit-cell {
  text-align: center;
}

.contacts-table .business-cell,
.contacts-table .category-cell,
.contacts-table .notes-cell {
  min-width: 0;
}

.company-summary-row td {
  padding-bottom: 8px;
  border-bottom: 0;
}

.company-people-row td {
  padding-top: 0;
}

.company-people-row:hover {
  background: #fff;
}

.people-spacer {
  width: 44px;
}

.people-detail-cell {
  padding-right: 16px;
  padding-bottom: 16px;
}

.business {
  display: block;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.pill {
  display: inline-block;
  margin: 0 4px 4px 0;
  padding: 3px 7px;
  border: 1px solid #d7c2ca;
  border-radius: 999px;
  color: var(--accent);
  background: #fff7fa;
  font-size: 12px;
}

.email {
  color: var(--good);
  font-weight: 700;
}

.missing {
  color: var(--warn);
}

.company-contact-block {
  max-width: 100%;
  padding-top: 6px;
}

.people-cell-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.count-pill {
  margin-bottom: 0;
}

.people-list {
  display: grid;
  gap: 0;
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

.people-list.single {
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

.person-list-head,
.person-line {
  display: grid;
  grid-template-columns: minmax(230px, 1.1fr) minmax(280px, 1.2fr) minmax(140px, 0.75fr) minmax(120px, 0.65fr) 82px;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.person-list-head {
  padding: 0 0 5px 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.person-line {
  padding: 7px 0;
  border-top: 1px solid #edf0f4;
  background: transparent;
}

.person-line.disabled {
  color: var(--muted);
}

.person-recipient {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
  min-width: 0;
}

.person-recipient input {
  margin: 0;
}

.person-name,
.person-line .email,
.person-line .missing,
.person-flags {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

.person-flags {
  white-space: nowrap;
}

.person-line small {
  color: var(--muted);
  font-size: 12px;
}

.person-line .email,
.person-line .missing {
  font-size: 14px;
  line-height: 1.25;
}

.person-role,
.person-phone {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.website-link {
  margin-top: 8px;
}

.email-preview {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.preview-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.preview-head strong {
  display: block;
  font-size: 16px;
}

.preview-body {
  max-height: 220px;
  overflow: auto;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid #e5e8ed;
  border-radius: 6px;
  background: #fbfbfb;
}

.recipient-preview-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  margin: 8px 0 0;
  padding-left: 18px;
}

.recipient-preview-list li {
  padding-right: 8px;
}

.recipient-preview-list strong,
.recipient-preview-list span,
.recipient-preview-list a {
  display: block;
}

.email-send-ok {
  color: var(--good);
  font-weight: 700;
}

.notes-input {
  width: 100%;
  min-width: 0;
}

.entry-navigator {
  display: grid;
  grid-template-columns: 44px minmax(260px, 560px) 44px;
  gap: 10px;
  align-items: end;
  margin-bottom: 8px;
}

.entry-search {
  min-width: 0;
}

.icon-button {
  width: 44px;
  height: 41px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.icon-button:disabled {
  border-color: #cfd4dc;
  color: #a3a8b0;
  background: #f3f4f6;
  cursor: default;
}

.entry-search-meta {
  display: flex;
  gap: 18px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.contact-form {
  align-items: start;
}

.contact-form .wide,
.person-form .wide {
  grid-column: span 2;
}

.people-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.communication-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.compact-head {
  margin-bottom: 10px;
}

.compact-head h2 {
  font-size: 19px;
}

.people-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
}

.people-table {
  min-width: 760px;
}

.person-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.form-check {
  align-self: center;
  padding: 0;
}

.form-actions,
.settings-actions {
  display: flex;
  gap: 10px;
  align-self: end;
  flex-wrap: wrap;
}

.settings-actions {
  grid-column: span 2;
}

.edit-row-btn {
  white-space: nowrap;
}

.history h2 {
  font-size: 19px;
}

.account-list {
  display: grid;
  gap: 10px;
}

.account-create-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.account-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.account-row strong,
.account-row span {
  display: block;
}

.account-row span {
  color: var(--muted);
  font-size: 13px;
}

.history {
  max-height: 220px;
  overflow: auto;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.history-item:last-child {
  border-bottom: 0;
}

.history-item p {
  font-size: 13px;
}

.communication-panel {
  min-height: 520px;
}

.communication-list {
  display: grid;
  gap: 10px;
}

.communication-list.compact {
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.communication-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.communication-item.failed {
  border-color: #e0a7b1;
  background: var(--danger-soft);
}

.communication-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
}

.communication-title {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.communication-head time {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.status-pill.sent {
  color: var(--good);
  border-color: #a7d7bd;
  background: var(--good-soft);
}

.status-pill.logged {
  color: var(--info);
  border-color: #b8d3e7;
  background: var(--info-soft);
}

.status-pill.failed {
  color: var(--danger);
  border-color: #e0a7b1;
  background: #fff;
}

.communication-details {
  margin-top: 10px;
}

.communication-details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
}

.communication-message {
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.error-text {
  color: var(--danger);
  font-weight: 700;
}

#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #24272b;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1450px) {
  .send-column {
    position: static;
    grid-template-columns: minmax(0, 1fr);
    max-height: none;
    overflow: visible;
  }

  .composer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-rail {
    position: static;
    grid-template-columns: 1.3fr 1fr;
    align-items: start;
  }

  .tabs {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .source-block {
    grid-column: 1 / -1;
  }

  .send-column {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-shell {
    width: min(100% - 20px, 1540px);
    margin-top: 10px;
  }

  .side-rail,
  .tabs,
  .stats,
  .send-column,
  .filters,
  .composer-grid,
  .template-toolbar,
  .merge-toolbar,
  .contact-form,
  .settings-form,
  .import-form,
  .person-form,
  .category-admin-grid,
  .category-add-form,
  .category-row,
  .field-admin-grid,
  .field-add-form,
  .account-create-form,
  .custom-field-grid {
    grid-template-columns: 1fr;
  }

  .primary-actions {
    grid-template-columns: 1fr;
  }

  .communication-head {
    grid-template-columns: 1fr;
  }

  .entry-navigator {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
  }

  .contact-form .wide,
  .import-form .wide,
  .person-form .wide,
  .settings-actions {
    grid-column: auto;
  }
}
