:root {
  --ink: #0f1c24;
  --ink-soft: #2a3a45;
  --teal: #0e7c7b;
  --teal-soft: #e6f3f3;
  --sand: #f4f1ec;
  --line: #d5dde3;
  --muted: #5c6b75;
  --accent: #c45c26;
  --white: #ffffff;
  --danger: #b42318;
  --ok: #067647;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--sand);
  line-height: 1.5;
}
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 20px; }

.topbar {
  background: var(--ink);
  color: var(--white);
  padding: 14px 0;
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { font-weight: 700; letter-spacing: 0.02em; color: var(--white); text-decoration: none; }
.brand span { color: #7fd4d3; }
.nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.nav a { color: #c5d2da; font-size: 0.95rem; }
.nav a:hover { color: var(--white); }

.btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  background: var(--teal);
  color: var(--white);
  text-decoration: none;
  font-size: 0.95rem;
}
.btn:hover { filter: brightness(1.05); text-decoration: none; }
.btn.secondary { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn.ghost { background: transparent; border: 1px solid #3a4d59; color: #d7e2e8; }
.btn.danger { background: var(--danger); }
.btn.block { display: block; width: 100%; text-align: center; }

.hero {
  padding: 64px 0 48px;
  background: linear-gradient(160deg, #0f1c24 0%, #16343a 55%, #0e7c7b 140%);
  color: var(--white);
}
.hero h1 { font-size: clamp(2rem, 4vw, 2.8rem); margin: 0 0 12px; max-width: 16ch; }
.hero p { color: #b8c5ce; max-width: 52ch; font-size: 1.1rem; }
.hero .actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0;
}
.card h2, .card h3 { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }

.stat {
  background: var(--teal-soft);
  border-radius: 8px;
  padding: 14px;
}
.stat .n { font-size: 1.6rem; font-weight: 700; color: var(--ink); }
.stat .l { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.checklist li:last-child { border-bottom: none; }
.dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--line); flex-shrink: 0; margin-top: 2px;
}
.dot.ok { background: var(--ok); }
.dot.no { background: #f4c7c3; }

label { display: block; font-size: 0.85rem; color: var(--muted); margin: 12px 0 4px; }
input, textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; background: #fff;
}
textarea { min-height: 120px; resize: vertical; }
.form-box { max-width: 420px; margin: 40px auto; }
.error {
  background: #fef3f2; color: var(--danger); border: 1px solid #fecdca;
  padding: 10px 12px; border-radius: 8px; margin-bottom: 12px;
}
.note {
  background: var(--teal-soft); color: var(--ink-soft);
  padding: 10px 12px; border-radius: 8px; font-size: 0.9rem;
}
.price {
  border: 2px solid var(--teal); border-radius: 12px; padding: 28px;
  background: var(--white); max-width: 420px;
}
.price .amt { font-size: 2.4rem; font-weight: 700; }
.price .amt small { font-size: 1rem; color: var(--muted); font-weight: 500; }
.price ul { padding-left: 18px; color: var(--ink-soft); }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600;
}
.badge.sent { background: #dcfae6; color: var(--ok); }
.badge.draft { background: #eef2f6; color: var(--muted); }
.badge.failed { background: #fef3f2; color: var(--danger); }
.badge.approved { background: #e6f3f3; color: var(--teal); }
.badge.spam-warn { background: #fff4e5; color: #b45309; }
.draft-spam-risk.spam-block { color: var(--danger); }
.draft-spam-risk.spam-warn-text { color: #b45309; }
.deliverability-card { margin-bottom: 16px; }

.footer {
  margin-top: 48px; padding: 24px 0; color: var(--muted); font-size: 0.85rem;
  border-top: 1px solid var(--line);
}
.section { padding: 36px 0; }
.app-section { padding: 0 0 48px; }
.muted { color: var(--muted); }
.flash { background: #fff7ed; border: 1px solid #fdba74; color: #9a3412; padding: 10px 12px; border-radius: 8px; margin: 12px 0; }

.app-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1140px;
  margin: 0 auto;
  padding: 20px;
}
.app-topbar {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(15, 28, 36, 0.06);
}
.app-topbar-user { min-width: 0; flex: 1 1 200px; }
.app-topbar-greeting { margin: 0; font-weight: 700; font-size: 1.05rem; }
.app-topbar-email { margin: 4px 0 0; font-size: 0.85rem; word-break: break-word; }
.app-nav { display: flex; gap: 6px; }
.app-nav-top {
  flex: 2 1 320px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.app-nav-link {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  background: transparent;
  color: var(--ink-soft);
  white-space: nowrap;
}
.app-nav-link:hover { background: var(--sand); color: var(--ink); }
.app-nav-link.active {
  background: var(--teal-soft);
  color: var(--teal);
}
.app-main { min-width: 0; width: 100%; }
.app-main .card { margin: 0 0 16px; }
.page-header { margin-bottom: 20px; }
.page-header h1 { margin: 0 0 6px; font-size: 1.65rem; }
.page-lead { margin: 0; max-width: 52ch; }
.dashboard-stats { margin-bottom: 16px; }
.dashboard-stats .stat { background: var(--white); border: 1px solid var(--line); }
.dashboard-stats .stat-highlight { border-color: var(--teal); background: var(--teal-soft); }
.dashboard-card h3 { font-size: 1rem; }
.setup-progress-bar {
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin: 0;
}
.setup-progress-bar span {
  display: block;
  height: 100%;
  background: var(--teal);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.setup-chips {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.setup-chips li {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--muted);
}
.setup-chips li.done { background: #dcfae6; color: var(--ok); }
.setup-chips li.todo { background: #fff4e5; color: #b45309; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.deliverability-card.compact h3 { font-size: 1rem; margin-bottom: 8px; }
.mailbox-line { margin: 0 0 4px; }
.tips-list { margin: 0; padding-left: 1.2rem; }
.tips-list li { margin-bottom: 6px; }
.smtp-summary { list-style: none; }
.smtp-panel summary { cursor: pointer; }

.mailbox-connect-card h3 { margin-bottom: 10px; }
.mailbox-note { margin: 0 0 16px; }
.connect-method-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.connect-tab {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  background: var(--white);
  color: var(--ink-soft);
}
.connect-tab:hover { border-color: var(--teal); color: var(--teal); }
.connect-tab.active {
  background: var(--teal-soft);
  border-color: var(--teal);
  color: var(--teal);
}
.connect-lead { margin: 0 0 12px; max-width: 56ch; }
.connect-steps {
  margin: 0 0 16px;
  padding-left: 1.25rem;
  color: var(--ink-soft);
}
.connect-steps li { margin-bottom: 8px; }
.connect-foot { margin: 14px 0 0; font-size: 0.9rem; max-width: 56ch; }
.btn-google {
  background: #1a73e8;
  padding-left: 20px;
  padding-right: 20px;
}
.btn-google:hover { filter: brightness(1.08); }
.oauth-uri {
  display: block;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--white);
  border: 1px dashed var(--line);
  border-radius: 6px;
  font-size: 0.82rem;
  word-break: break-all;
}
.oauth-local-hint code { font-size: 0.85em; }
.mailbox-connected-banner p { margin: 0 0 10px; }
.smtp-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.smtp-form-wide { max-width: 520px; }
.smtp-form-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 12px;
}
.readonly-field { background: var(--sand); color: var(--muted); }
.imap-optional { margin: 12px 0; font-size: 0.9rem; }
.imap-optional summary { cursor: pointer; color: var(--teal); font-weight: 600; margin-bottom: 8px; }
@media (max-width: 520px) {
  .smtp-form-row { grid-template-columns: 1fr; }
}

.doc-page { padding-top: 28px; padding-bottom: 48px; }
.doc-wrap {
  max-width: 720px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 32px 36px;
}
.doc-back { margin: 0 0 20px; font-size: 0.9rem; }
.doc-content { color: var(--ink-soft); line-height: 1.65; }
.doc-content > :first-child { margin-top: 0; }
.doc-content h1 {
  font-size: 1.75rem;
  color: var(--ink);
  margin: 0 0 12px;
  line-height: 1.25;
}
.doc-content h2 {
  font-size: 1.15rem;
  color: var(--ink);
  margin: 28px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.doc-content h3 { font-size: 1rem; margin: 20px 0 8px; color: var(--ink); }
.doc-content p { margin: 0 0 12px; }
.doc-content ul, .doc-content ol { margin: 0 0 16px; padding-left: 1.35rem; }
.doc-content li { margin-bottom: 6px; }
.doc-content li > ul, .doc-content li > ol { margin-top: 6px; margin-bottom: 0; }
.doc-content a { font-weight: 500; }
.doc-content code {
  font-size: 0.88em;
  background: var(--sand);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--ink);
}
.doc-content pre {
  background: var(--ink);
  color: #e8eef2;
  padding: 14px 16px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.85rem;
  margin: 12px 0 16px;
}
.doc-content pre code { background: none; padding: 0; color: inherit; }
.doc-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin: 12px 0 20px;
}
.doc-content th, .doc-content td {
  border: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
.doc-content th {
  background: var(--teal-soft);
  color: var(--ink);
  font-weight: 600;
  text-transform: none;
  font-size: 0.9rem;
}
.doc-content tr:nth-child(even) td { background: #faf8f5; }
.doc-content hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 28px 0;
}
@media (max-width: 600px) {
  .doc-wrap { padding: 20px 16px 28px; }
  .doc-content table { font-size: 0.82rem; }
  .doc-content th, .doc-content td { padding: 8px; }
}

@media (max-width: 720px) {
  .app-layout { padding: 12px; gap: 14px; }
  .app-topbar {
    flex-direction: column;
    align-items: stretch;
    padding: 14px;
  }
  .app-nav-top {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .app-nav-link { flex-shrink: 0; font-size: 0.85rem; padding: 8px 12px; }
}

.smtp-form {
  margin-top: 14px;
  display: grid;
  gap: 10px;
  max-width: 420px;
  padding: 14px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.smtp-form label { display: grid; gap: 4px; font-size: 0.9rem; }
.smtp-form input, .smtp-form select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.drafts-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.drafts-toolbar #selectionCount { margin-right: 8px; min-width: 6rem; }

.legal-consent {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 16px 0 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--ink-soft);
  cursor: pointer;
  font-weight: 400;
}
.legal-consent input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  margin: 2px 0 0;
  padding: 0;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--teal);
}
.legal-consent-text a {
  color: var(--teal);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.legal-consent-text a:hover { color: var(--ink); }
.table-scroll { overflow-x: auto; }
.drafts-table .col-check { width: 2.5rem; }
.draft-row { cursor: pointer; }
.draft-row:hover { background: #faf8f5; }
.draft-row:focus { outline: 2px solid var(--teal); outline-offset: -2px; }
.btn-link {
  background: none; border: none; padding: 0; font: inherit;
  color: var(--teal); cursor: pointer; text-decoration: underline;
}
.btn-link:hover { color: var(--ink); }

.draft-modal {
  border: none; border-radius: var(--radius); padding: 0;
  max-width: min(640px, 92vw); width: 100%;
  box-shadow: 0 20px 50px rgba(15, 28, 36, 0.2);
}
.draft-modal::backdrop { background: rgba(15, 28, 36, 0.45); }
.draft-modal-inner { padding: 20px 22px 24px; margin: 0; }
.draft-modal-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; margin-bottom: 16px;
}
.draft-modal-header h2 { margin: 0; font-size: 1.15rem; }
.draft-meta {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 16px;
  margin: 0 0 16px; font-size: 0.92rem;
}
.draft-meta dt { color: var(--muted); font-weight: 600; }
.draft-meta dd { margin: 0; }
.draft-body-label { font-size: 0.85rem; color: var(--muted); margin: 0 0 6px; display: block; }
.draft-body {
  margin: 0; padding: 14px; background: var(--sand); border-radius: 8px;
  border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow: auto; font-family: inherit; font-size: 0.95rem;
}
.draft-modal-hint { font-size: 0.85rem; margin: 14px 0 0; }
.draft-edit-form label { margin-top: 10px; }
.draft-edit-form textarea { min-height: 160px; }
.draft-from-line { margin: 0 0 8px; }
.draft-modal-actions {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px;
}

.import-file-btn { display: inline-block; cursor: pointer; margin: 0; }
.import-file-btn input { display: none; }
.import-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; align-items: center; }
.import-form .import-mapping { margin-top: 12px; }
.import-rules { margin: 16px 0; }
.designation-rule {
  margin: 12px 0; padding: 14px; background: var(--sand);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.import-pre {
  font-size: 0.8rem; max-height: 200px; overflow: auto;
  background: var(--white); padding: 10px; border-radius: 8px;
  border: 1px solid var(--line);
}
