:root {
  --bg: #ececf5;
  --ink: #2f3654;
  --muted: #7b849d;
  --line: #dfe3f0;
  --panel: #ffffff;
  --primary: #5b6df6;
  --primary-dark: #4655d9;
  --primary-soft: #eeeaff;
  --primary-tint: #f6f4ff;
  --danger: #c53b4a;
  --green: #4aa77d;
  --amber: #b78328;
  --shadow: 0 10px 28px rgba(55, 62, 96, .07);
}

* { box-sizing: border-box; }

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

body.auth-pending .shell {
  visibility: hidden;
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 700;
}

button:hover { background: var(--primary-dark); }
.secondary { background: var(--primary-tint); color: var(--primary-dark); }
.secondary:hover { background: #e4e8ff; }
.danger { background: #fff0f2; color: var(--danger); }
.danger:hover { background: #ffe0e4; }

.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: #ffffff;
  color: var(--ink);
  border-right: 1px solid #e6e8f2;
  padding: 20px 14px;
}

.brand {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  padding: 8px 8px 22px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #f7f5ff;
  color: var(--primary-dark);
  box-shadow: 0 8px 22px rgba(91, 109, 246, .14);
  font-weight: 900;
}

.brand span {
  display: block;
  margin-top: 3px;
  color: #9aa2b8;
  font-size: 11px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  color: #6f7894;
  border-radius: 10px;
  font-size: 14px;
  min-height: 40px;
}

.nav-item span {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
}

.nav-item {
  min-width: 0;
}

.nav-item:not(span) {
  overflow-wrap: anywhere;
}

.nav-item.active,
.nav-item:hover {
  background: #ebe7ff;
  color: var(--primary-dark);
}

.nav-item.active {
  box-shadow: inset 3px 0 0 var(--primary);
}

.main {
  min-width: 0;
  min-height: 0;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 28px;
  background: var(--bg);
}

.topbar {
  flex: 0 0 auto;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding: 0;
  background: transparent;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: none;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.auth-screen.show {
  display: grid;
}

.auth-card.hidden {
  display: none;
}

.auth-card {
  width: min(380px, 100%);
  padding: 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 22px 60px rgba(47, 54, 84, .14);
}

.auth-card .brand-mark {
  margin-bottom: 16px;
}

.auth-card h1 {
  font-size: 24px;
}

.auth-card p,
.auth-card span {
  display: block;
  color: var(--muted);
  margin-top: 6px;
  font-size: 13px;
}

.auth-card label {
  display: grid;
  gap: 7px;
  color: #747d98;
  font-size: 12px;
  font-weight: 800;
  margin-top: 16px;
}

.auth-card input {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.auth-card input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 109, 246, .14);
}

.auth-card button {
  width: 100%;
  margin-top: 18px;
}

.auth-card .auth-link {
  width: auto;
  min-height: 0;
  margin: 12px auto 0;
  padding: 0;
  display: block;
  background: transparent;
  color: var(--primary-dark);
}

.auth-card .auth-link:hover {
  background: transparent;
  text-decoration: underline;
}

h1, h2, p { margin: 0; }
h1 { font-size: 24px; line-height: 1.15; }
h2 { font-size: 15px; }
.topbar h1 { color: #252d49; }
.topbar p { color: var(--muted); margin-top: 6px; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.view { display: none; }
.view.active {
  display: block;
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
}

#templates.view.active {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

.editor-hidden {
  display: none !important;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

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

.metric {
  position: relative;
  min-height: 104px;
  padding: 16px 16px 14px 58px;
  overflow: hidden;
}

.metric::before {
  position: absolute;
  left: 16px;
  top: 18px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: var(--primary-tint);
  color: var(--primary-dark);
  font-size: 14px;
  font-weight: 900;
}

.metric:nth-child(1)::before { content: "☷"; }
.metric:nth-child(2)::before { content: "≡"; }
.metric:nth-child(3)::before { content: "✎"; }
.metric:nth-child(4)::before { content: "↗"; }

.metric:hover,
.panel:hover,
.list-card:hover,
.template-row:hover {
  border-color: #cfd6ef;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  letter-spacing: 0;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: 12px;
}

.panel {
  padding: 16px;
}

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

.contact-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 1;
  flex-wrap: nowrap;
  min-width: 0;
}

.contact-actions .search {
  flex: 1 1 280px;
  max-width: 360px;
  min-width: 180px;
}

.contact-actions button {
  flex: 0 0 auto;
  white-space: nowrap;
  padding-inline: 12px;
}

.list-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.list-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbff;
  cursor: pointer;
}

.list-card.active {
  border-color: var(--primary);
  background: var(--primary-tint);
  box-shadow: 0 0 0 3px rgba(91, 109, 246, .12);
}

.list-card strong {
  display: block;
  font-size: 13px;
  color: var(--ink);
}

.list-card span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.list-card button {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 0 10px;
  font-size: 11px;
}

.selected-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.selected-list-head strong {
  color: var(--ink);
  font-size: 14px;
}

.wide { min-width: 0; }

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

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 8px 10px;
  outline: 0;
}

input[type="file"] {
  padding: 8px;
  background: #fbfaff;
}

textarea { resize: vertical; min-height: 150px; }
select[multiple] { min-height: 116px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(20, 99, 255, .13); }
.search { max-width: 260px; }
.hint { color: var(--muted); font-size: 11px; line-height: 1.45; }
.divider { height: 1px; background: var(--line); margin: 2px 0; }

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th, td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

th {
  background: #fbfbff;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #fbfbff;
}

tr:last-child td { border-bottom: 0; }

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.row-actions button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.stack {
  display: grid;
  gap: 10px;
}

.item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfcff;
}

.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.item small, .card small { color: var(--muted); }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 800;
}

.pill.green { background: #eaf8f2; color: var(--green); }
.pill.amber { background: #fff6e5; color: var(--amber); }

.bars {
  display: grid;
  gap: 12px;
}

.bars div {
  display: grid;
  grid-template-columns: 80px 1fr 44px;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

meter {
  width: 100%;
  height: 10px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.template-grid.compact {
  grid-template-columns: 1fr;
  max-height: 330px;
  overflow: auto;
  padding-right: 4px;
}

.template-list-panel {
  height: 100%;
  overflow: auto;
}

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

.template-list-full .template-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.template-list-full .template-row-actions {
  min-width: 0;
}

.template-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfcff;
}

.template-row-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.template-row-main strong {
  color: #2f3654;
  font-size: 13px;
}

.template-row-main span,
.template-row-main small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.template-row-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  min-width: max-content;
}

.template-row-actions button {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 9px;
  font-size: 11px;
  white-space: nowrap;
}

.card {
  display: grid;
  gap: 10px;
  min-height: 180px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfcff;
}

.card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.builder-layout {
  display: grid;
  grid-template-columns: 156px minmax(420px, 1fr) 300px;
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.builder-palette {
  display: grid;
  gap: 8px;
  align-content: start;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow-y: auto;
}

.block-tool {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 46px;
  background: #fcfcff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  cursor: grab;
  font-size: 13px;
}

.block-tool:hover {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.block-tool span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 900;
}

.builder-stage {
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.builder-meta {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.builder-toolbar {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.segmented {
  display: inline-flex;
  padding: 4px;
  border-radius: 10px;
  background: #e8e8f2;
  gap: 3px;
}

.segmented button {
  min-height: 32px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  background: white;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(17, 24, 39, .12);
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.canvas-shell {
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #f8f7fc 25%, transparent 25%),
    linear-gradient(-45deg, #f8f7fc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f8f7fc 75%),
    linear-gradient(-45deg, transparent 75%, #f8f7fc 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  padding: 18px;
}

.email-canvas {
  width: min(680px, 100%);
  min-height: 620px;
  margin: 0 auto;
  background: white;
  border: 1px solid #e2e5f1;
  box-shadow: 0 10px 24px rgba(55, 62, 96, .08);
  padding: 18px;
  transition: width .2s ease;
}

.email-canvas.mobile {
  width: 360px;
}

.drop-empty {
  display: grid;
  place-items: center;
  min-height: min(360px, 100%);
  border: 2px dashed #cfd8e8;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 22px;
}

.email-block {
  position: relative;
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 12px;
  cursor: pointer;
}

.email-block:hover {
  border-color: #cbc8ff;
}

.email-block.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(20, 99, 255, .13);
}

.email-block.drag-over {
  border-color: var(--green);
}

.block-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed #dfe3f0;
}

.block-actions button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 11px;
  border-radius: 7px;
}

.block-heading {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
  color: var(--ink);
  text-align: center;
}

.block-paragraph {
  margin: 0;
  color: #4f5c72;
  line-height: 1.65;
}

.block-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 7px;
  background: var(--primary);
  color: white;
  text-decoration: none;
  font-weight: 800;
}

.button-wrap {
  text-align: center;
}

.block-image {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: none;
  margin: 0 auto;
  object-fit: contain;
  object-position: center;
  border-radius: 12px;
  background: transparent;
}

.image-placeholder {
  display: grid;
  place-items: center;
  min-height: 210px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 800;
}

.block-divider {
  height: 1px;
  background: #dce2ed;
  margin: 8px 0;
}

.block-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.block-columns div {
  min-height: 110px;
  padding: 14px;
  border-radius: 12px;
  background: #f8f7fc;
  color: var(--muted);
  line-height: 1.5;
}

.block-social {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.block-social a {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 900;
}

.block-html {
  border-radius: 12px;
  background: #111827;
  color: #dbe7ff;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
}

.unsubscribe-block {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid #e5e7ef;
  text-align: center;
}

.unsubscribe-block a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  background: var(--primary-tint);
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}

.inspector {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow-y: auto;
}

.inspector-fields {
  display: grid;
  gap: 10px;
}

.design-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfaff;
}

.design-fields label {
  min-width: 0;
}

.design-fields input,
.design-fields select {
  min-height: 38px;
  padding: 8px 9px;
}

.design-fields input[type="color"] {
  padding: 4px;
}

.image-size-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.image-size-actions button {
  min-height: 36px;
  font-size: 12px;
}

.inspector-empty {
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}

.quick-send {
  margin-top: 12px;
}

.wizard {
  display: grid;
  gap: 12px;
  min-height: 0;
}

.wizard-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.wizard-step {
  display: grid;
  gap: 5px;
  justify-items: center;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-align: center;
}

.wizard-step b {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
}

.wizard-step.active b {
  background: var(--primary);
  color: white;
}

.wizard-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fcfcff;
  min-height: 0;
}

.send-modal .wizard {
  grid-template-rows: auto auto auto;
  height: auto;
  gap: 9px;
}

.send-modal .wizard-box {
  overflow: visible;
  gap: 8px;
  padding: 10px;
  border-radius: 10px;
}

.send-modal .wizard-box h2 {
  font-size: 15px;
}

.send-modal .wizard-step {
  gap: 4px;
  font-size: 9px;
}

.send-modal .wizard-step b {
  width: 24px;
  height: 24px;
}

.send-modal input,
.send-modal select,
.send-modal textarea {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
}

.send-modal .recipient-row {
  padding: 7px;
  border-radius: 7px;
}

.send-modal .recipient-list {
  gap: 6px;
  max-height: 185px;
}

.wizard-actions {
  display: flex;
  gap: 8px;
}

.wizard-actions button {
  flex: 1;
}

.recipient-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding-right: 4px;
}

.recipient-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: start;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
}

.recipient-row input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

.recipient-row span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.recipient-controls {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.recipient-controls button {
  min-height: 38px;
  padding: 0 10px;
}

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

.checkline {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.checkline:last-child {
  border-bottom: 0;
}

.checkline strong {
  color: var(--ink);
  text-align: right;
}

.account-list {
  margin-top: 12px;
}

.report-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.report-actions select {
  min-width: 260px;
}

.report-summary {
  display: block;
  margin-bottom: 18px;
}

.report-detail {
  display: grid;
  gap: 18px;
}

.report-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 18px;
  border-bottom: 1px solid var(--line);
}

.report-kicker {
  display: block;
  margin-bottom: 6px;
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.report-hero h2 {
  font-size: 23px;
  line-height: 1.2;
  color: #252d49;
}

.report-hero p {
  margin-top: 6px;
  color: var(--muted);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 220px;
  min-height: 58px;
  padding: 0 22px;
  border-radius: 8px;
  background: #dff7e8;
  color: #2f7f54;
  font-size: 14px;
  font-weight: 900;
  text-transform: uppercase;
}

.report-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 18px;
}

.report-meta-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
}

.report-meta-item strong {
  color: #35405f;
  font-size: 14px;
  line-height: 1.45;
}

.report-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 18px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.report-box {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fcfcff;
}

.report-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  font-size: 24px;
  font-weight: 900;
}

.report-box.green .report-icon { background: #e9f8f0; color: #45a66e; }
.report-box.blue .report-icon { background: #eaf0ff; color: #4079ff; }
.report-box.teal .report-icon { background: #e9f8f8; color: #56bebc; }
.report-box.red .report-icon { background: #fff0f0; color: #e76262; }
.report-box.orange .report-icon { background: #fff4eb; color: #eb7f4a; }

.report-box span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.report-box strong {
  display: block;
  margin-top: 6px;
  color: #2f3654;
  font-size: 25px;
  text-align: right;
}

.report-progress {
  grid-column: 1 / -1;
  height: 3px;
  border-radius: 999px;
  background: #eef0f7;
  overflow: hidden;
}

.report-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: currentColor;
}

.report-box.green { color: #45a66e; }
.report-box.blue { color: #4079ff; }
.report-box.teal { color: #56bebc; }
.report-box.red { color: #e76262; }
.report-box.orange { color: #eb7f4a; }

.report-box small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

.settings-panel {
  width: min(100%, 1180px);
  max-width: none;
  padding: 18px;
}

.settings-panel h2 {
  font-size: 16px;
  color: #252d49;
  margin-bottom: 14px;
}

.settings-panel .divider {
  margin: 20px 0 18px;
}

.settings-panel label {
  font-size: 13px;
}

.settings-panel input,
.settings-panel select {
  min-height: 40px;
  font-size: 14px;
}

.settings-panel button {
  min-height: 40px;
  font-size: 14px;
  padding: 0 18px;
}

.settings-panel .settings-grid {
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 16px 14px;
  margin-bottom: 14px;
}

.settings-panel .account-list {
  margin-top: 14px;
  max-width: none;
}

.settings-panel .item {
  min-height: 54px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #111827;
  color: white;
  box-shadow: var(--shadow);
  transform: translateY(90px);
  opacity: 0;
  transition: .2s ease;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(17, 24, 39, .48);
  z-index: 10;
}

.modal-backdrop.show {
  display: grid;
}

.modal-backdrop.modal-front {
  z-index: 20;
}

.modal {
  width: min(960px, 100%);
  max-height: min(860px, 92vh);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  border-radius: 16px;
  background: white;
  box-shadow: 0 24px 80px rgba(17, 24, 39, .28);
}

.small-modal {
  width: min(460px, 100%);
  grid-template-rows: auto minmax(0, 1fr);
}

.send-modal {
  width: min(820px, 100%);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 14px;
}

.send-wizard {
  min-height: 0;
  overflow: auto;
}

.send-modal .modal-head h2 {
  font-size: 16px;
}

.send-modal .modal-head p,
.send-modal .hint,
.send-modal label {
  font-size: 12px;
}

.send-modal button {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 11px;
}

.send-modal .wizard-box > button {
  justify-self: end;
  min-width: 92px;
}

.send-modal .wizard-actions {
  justify-content: flex-end;
}

.send-modal .wizard-actions button {
  flex: 0 0 auto;
  min-width: 96px;
}

.modal-body {
  display: none;
  gap: 12px;
}

.modal-body.active {
  display: grid;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.modal-head p {
  color: var(--muted);
  margin-top: 4px;
}

.preview-tabs {
  display: inline-flex;
  gap: 6px;
}

.preview-tabs button {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.preview-tabs button.active {
  background: var(--primary);
  color: white;
}

.preview-shell {
  overflow: auto;
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f3f2fa;
  padding: 18px;
}

.preview-email {
  width: min(680px, 100%);
  margin: 0 auto;
  background: white;
  border: 1px solid #e7ecf5;
  padding: 18px;
}

.preview-email.mobile {
  width: 360px;
}

.email-canvas.mobile .email-block,
.preview-email.mobile .email-block {
  padding: 8px;
}

@media (max-width: 980px) {
  html { height: auto; overflow: auto; }
  body { height: auto; min-height: 100vh; overflow: auto; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 2; height: auto; overflow: visible; }
  .main { display: block; height: auto; min-height: 100vh; overflow: visible; }
  .view.active, #templates.view.active { height: auto; overflow: visible; }
  .brand { padding-bottom: 12px; }
  .nav { grid-template-columns: repeat(3, 1fr); }
  .nav-item { justify-content: center; }
  .metric-grid, .split, .builder-layout, .builder-meta, .settings-grid, .report-meta, .report-card-grid { grid-template-columns: 1fr; }
  .report-hero { align-items: stretch; flex-direction: column; }
  .status-badge { width: 100%; }
  .builder-layout, .builder-stage, .builder-palette, .inspector { height: auto; overflow: visible; }
  .builder-palette { grid-template-columns: repeat(2, 1fr); }
  .panel-head { align-items: stretch; flex-direction: column; }
  .contact-actions { justify-content: flex-start; overflow-x: auto; padding-bottom: 2px; }
  .contact-actions .search { min-width: 220px; }
  .report-actions { align-items: stretch; flex-direction: column; }
  .report-actions select { min-width: 0; }
}

@media (max-width: 560px) {
  .main { padding: 16px; }
  .topbar { align-items: stretch; flex-direction: column; }
  .top-actions button { flex: 1; }
  .contact-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .contact-actions .search { grid-column: 1 / -1; max-width: none; }
  .nav { grid-template-columns: repeat(2, 1fr); }
  .nav-item { min-height: 40px; font-size: 12px; }
  h1 { font-size: 21px; }
  .builder-palette { grid-template-columns: 1fr; }
  .builder-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-actions button { flex: 1; }
  .canvas-shell { padding: 12px; }
  .email-canvas.mobile { width: 320px; }
  .preview-email.mobile { width: 300px; }
  .recipient-controls { grid-template-columns: 1fr; }
  .block-columns { grid-template-columns: 1fr; }
}
