html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: #0f1115;
  color: #e8eaf0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
}

header {
  background: #171b22;
  border-bottom: 1px solid #2a303a;
  padding: 22px 28px;
}

h1 {
  margin: 0;
  font-size: 30px;
  color: #f6c84c;
}

h2 {
  margin: 0;
  color: #f2f4f8;
  font-size: 22px;
}

h3 {
  margin: 18px 0 8px;
  color: #dce2ea;
}

a {
  color: #f6c84c;
}

.shell {
  max-width: 1440px;
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 16px 28px 0;
  background: #0f1115;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: #171b22;
  border: 1px solid #2a303a;
  border-radius: 8px;
  padding: 10px 12px;
}

.sidebar-title {
  color: aqua;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
  margin: 0;
  white-space: nowrap;
}

.topbar h1 {
  margin: 0;
}

.topbar a.topbar-title-link {
  min-height: auto;
  padding: 0;
  color: #e8eaf0;
  border-radius: 0;
}

.topbar a.topbar-title-link:hover {
  background: transparent;
  color: #f6c84c;
}

.topbar-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.topbar a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  color: #e8eaf0;
  text-decoration: none;
  padding: 0 12px;
  border-radius: 6px;
}

.topbar a:hover,
.topbar a.active {
  background: #242a34;
  color: #f6c84c;
}

main {
  padding: 18px 28px 28px;
}

.login-main {
  max-width: 520px;
  margin: 0 auto;
  padding-top: 42px;
}

.login-panel {
  margin-bottom: 0;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-hint {
  margin: -4px 0 14px;
}

.login-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.login-form button {
  justify-self: start;
}

.public-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px;
}

.panel {
  background: #171b22;
  border: 1px solid #2a303a;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .22);
  scroll-margin-top: 22px;
  margin-bottom: 18px;
}

.manual-panel {
  max-width: 980px;
}

.manual-content {
  color: #dce2ea;
  line-height: 1.65;
}

.manual-content h1 {
  margin-bottom: 18px;
}

.manual-content h2 {
  margin: 30px 0 10px;
  padding-top: 10px;
  border-top: 1px solid #2a303a;
}

.manual-content h3 {
  margin-top: 22px;
}

.manual-content p,
.manual-content ul,
.manual-content ol {
  margin: 10px 0 0;
}

.manual-content li {
  margin: 6px 0;
}

.manual-content code {
  background: #0f1115;
  border: 1px solid #2a303a;
  border-radius: 4px;
  padding: 1px 5px;
  color: #f6c84c;
}

.manual-content pre {
  overflow-x: auto;
  background: #0f1115;
  border: 1px solid #2a303a;
  border-radius: 8px;
  padding: 12px;
}

.manual-content pre code {
  border: 0;
  padding: 0;
  background: transparent;
}

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

.section-head p {
    margin: 6px 0 0;
}

.head-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    align-items: center;
}

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

.modal-open {
    overflow: hidden;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .62);
}

.modal-panel {
    position: relative;
    z-index: 1;
    width: min(640px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
    background: #171b22;
    border: 1px solid #2a303a;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
}

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

.modal-head-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: 0;
    color: #c9d1dc;
}

.modal-close:hover {
    background: transparent;
    color: #f6c84c;
}

.muted {
    color: #9aa5b1;
    font-size: 14px;
}

.notice {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 38px 12px 12px;
    border-radius: 6px;
    margin-bottom: 18px;
    border: 1px solid transparent;
}

.notice span {
    min-width: 0;
}

.notice-close {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    color: inherit;
    border: 0;
    line-height: 1;
    opacity: .75;
}

.notice-close:hover {
    opacity: 1;
    background: transparent;
}

.success {
  background: #14351f;
  border-color: #2f8f4d;
  color: #d9ffe5;
}

.error {
  background: #3b1f23;
  border-color: #a0444f;
  color: #ffe0e4;
}

.info {
  background: #172739;
  border-color: #3d6f9f;
  color: #dcecff;
}

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

.metric {
  border: 1px solid #2a303a;
  background: #11151b;
  border-radius: 8px;
  padding: 14px;
}

.metric span,
.metric small {
  display: block;
  color: #9aa5b1;
}

.metric strong {
  display: block;
  font-size: 30px;
  line-height: 1.15;
  margin: 4px 0;
  color: #fff;
}

.split-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid #2a303a;
  margin-top: 16px;
  padding-top: 14px;
  color: #c9d1dc;
}

.table-wrap {
  overflow: auto;
  border: 1px solid #2a303a;
  border-radius: 8px;
}

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

th,
td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid #2a303a;
  vertical-align: top;
}

th {
  color: #9aa5b1;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #11151b;
}

.contacts-table td {
  vertical-align: middle;
}

.contacts-table {
    table-layout: fixed;
}

.contacts-table .col-email {
    width: 350px;
}

.contacts-table .col-langs {
    width: 140px;
}

.contacts-table .col-status {
    width: 113px;
}

.contacts-table .col-segments {
    width: 260px;
}

.contacts-table .col-source {
    width: 90px;
}

.contacts-table .col-updated {
    width: 150px;
}

.contact-email-cell strong {
    display: block;
    max-width: 100%;
    overflow-wrap: anywhere;
    line-height: 1.25;
}

.contact-email-cell input {
    max-width: 100%;
}

.sort-link {
  color: #cfd7e3;
  text-decoration: none;
}

.sort-link:hover {
  color: #f6c84c;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  background: #262d38;
  color: #dce2ea;
  padding: 2px 8px;
  font-size: 12px;
}

.pill.subscribed {
    background: #113d2a;
    color: #bfffd8;
    border: 1px solid #2f9d62;
}

.pill.unsubscribed {
    background: #3d3113;
    color: #ffe1a1;
    border: 1px solid #b78922;
}

.pill.cleaned {
    background: #431d24;
    color: #ffd6dc;
    border: 1px solid #b24b5a;
}

.pill.inactive {
    background: #222833;
    color: #c8d0dc;
    border: 1px solid #5c6678;
}

.status-select {
    display: block;
    width: 95px;
    min-width: 95px;
    font-size: 13px;
}

.status-subscribed {
    background: #113d2a;
    color: #bfffd8;
    border-color: #2f9d62;
}

.status-unsubscribed {
    background: #3d3113;
    color: #ffe1a1;
    border-color: #b78922;
}

.status-cleaned {
    background: #431d24;
    color: #ffd6dc;
    border-color: #b24b5a;
}

.status-inactive {
    background: #222833;
    color: #c8d0dc;
    border-color: #5c6678;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: start;
}

.new-contact {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: end;
}

.field-wide {
  grid-column: 1 / -1;
}

label,
.label-text {
  display: block;
  color: #c9d1dc;
  font-weight: 700;
}

input,
select,
button,
.button {
  box-sizing: border-box;
  border-radius: 6px;
  border: 1px solid #3a4352;
  background: #10141a;
  color: #e8eaf0;
  padding: 10px 11px;
  font: inherit;
}

label input,
label select {
  display: block;
  width: 100%;
  margin-top: 6px;
}

select {
  width: 100%;
}

button,
.button {
    background: #f6c84c;
  color: #17120a;
  border-color: #f6c84c;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
    white-space: nowrap;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    background: transparent;
    border-color: transparent;
    color: #f6c84c;
}

.icon-button:hover {
    background: #242a34;
    border-color: #3a4352;
}

.icon-button svg {
    width: 18px;
    height: 18px;
}

.button.secondary,
button.secondary {
    background: #242a34;
    border-color: #3a4352;
    color: #f2f4f8;
}

button.danger {
    background: #3b1f23;
    border-color: #a0444f;
    color: #ffe0e4;
}

.icon-button.danger {
    color: #ff9aa6;
}

.icon-button.danger:hover {
    background: #3b1f23;
    border-color: #a0444f;
}

button:disabled,
button.is-loading,
.button.is-loading {
    cursor: wait;
    opacity: .72;
}

.check-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.check-grid.compact {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.check-grid label {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #2a303a;
    border-radius: 6px;
    padding: 9px;
    font-weight: 400;
}

.check-grid input {
    width: auto;
    margin: 0;
}

.campaign-row {
  border-top: 1px solid #2a303a;
  padding: 18px 0;
}

.campaign-row:first-of-type {
    border-top: 0;
    padding-top: 0;
}

.campaigns-table {
    table-layout: auto;
}

.campaigns-table .col-campaign {
    width: auto;
}

.campaigns-table .col-segments {
    width: auto;
}

.campaigns-table .col-status {
    width: 1%;
}

.campaigns-table .col-destinations {
    width: 1%;
}

.campaigns-table .col-sent {
    width: 1%;
}

.campaigns-table .col-errors {
    width: 1%;
}

.campaigns-table .col-actions {
    width: 1%;
}

.campaigns-table td {
    vertical-align: middle;
}

.campaigns-table th {
    white-space: nowrap;
}

.campaigns-table .campaign-status-cell {
    text-align: left !important;
    white-space: nowrap;
}

.campaign-status-inner {
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.campaign-status-pill {
    min-height: 0;
    padding: 0;
    line-height: 1.2;
}

.campaigns-table th:nth-child(3),
.campaigns-table td:nth-child(3) {
    text-align: left !important;
}

.campaign-title-cell strong,
.campaign-title-cell span {
    display: block;
}

.campaign-title-cell strong {
    margin-bottom: 4px;
    line-height: 1.25;
}

.number-cell {
    color: #f2f4f8;
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

.campaign-actions-cell {
    position: relative;
    width: 1%;
    white-space: nowrap;
}

.campaign-edit-delete {
    display: flex;
    align-items: center;
    gap: 8px;
    width: auto;
}

.campaign-edit {
    flex: 0 0 auto;
    min-width: 0;
}

.campaign-edit summary {
    cursor: pointer;
    font-weight: 700;
    list-style: none;
}

.campaign-edit[open] summary {
    display: none;
}

.campaign-edit summary::-webkit-details-marker {
    display: none;
}

.campaign-edit-delete > form {
    flex: 0 0 auto;
}

.campaign-edit-delete:has(.campaign-edit[open]) > form {
    display: none;
}

.campaign-edit[open] {
    flex-basis: 100%;
}

.campaign-edit-form {
    border-radius: 8px;
    background: black;
    padding: .5rem .75rem 0;
    /* margin: 8px 0 4px; */
}

.campaigns-table .campaign-edit-form {
    min-width: 560px;
}

.campaign-subject-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: start;
}

.campaign-analysis-summary-button {
    margin-left: auto;
    display: none;
}

.campaign-edit[open] .campaign-analysis-summary-button {
    display: inline-flex;
}

.campaign-save-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.analysis-action-label {
    color: #c9d1dc;
    font-weight: 700;
    margin-right: auto;
}

.analysis-action-label strong {
    color: #f6c84c;
}

.analysis-modal-panel {
    width: min(760px, 100%);
}

.analysis-modal-content {
    margin: 0;
}

.template-analysis {
    border: 1px solid #2a303a;
    border-radius: 8px;
    background: #11151b;
    padding: 12px;
}

.template-analysis.is-empty {
    color: #9aa5b1;
}

.template-analysis.is-good {
    border-color: #2f8f4d;
}

.template-analysis.has-warning {
    border-color: #b78922;
}

.template-analysis.has-critical {
    border-color: #a0444f;
}

.template-analysis-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.template-analysis strong {
    color: #f2f4f8;
}

.template-analysis p {
    margin: 5px 0 0;
    color: #9aa5b1;
    font-weight: 400;
}

.analysis-score {
    flex: 0 0 auto;
    border: 1px solid #3a4352;
    border-radius: 999px;
    padding: 4px 8px;
    color: #f2f4f8;
    font-size: 12px;
    font-weight: 700;
}

.analysis-counts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.analysis-counts span {
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 700;
}

.analysis-counts .critical,
.template-analysis li.critical span {
    background: #3b1f23;
    color: #ffe0e4;
}

.analysis-counts .warning,
.template-analysis li.warning span {
    background: #3d3113;
    color: #ffe1a1;
}

.analysis-counts .info,
.template-analysis li.info span {
    background: #172739;
    color: #dcecff;
}

.template-analysis ul {
    display: grid;
    gap: 7px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.template-analysis li {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 8px;
    align-items: start;
    color: #c9d1dc;
    font-weight: 400;
    line-height: 1.35;
}

.template-analysis li span {
    display: inline-flex;
    justify-content: center;
    border-radius: 999px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 700;
}

.campaign-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.campaign-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.mini-metrics {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  margin: 0;
}

.mini-metrics span {
  background: #11151b;
  border: 1px solid #2a303a;
  border-radius: 6px;
  padding: 8px 10px;
  color: #9aa5b1;
}

.mini-metrics strong {
  color: #fff;
}

.action-row {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-start;
}

.action-row form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.action-row form.campaign-edit-form {
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
    gap: 12px;
}

.campaign-template-field {
    min-width: 0;
}

.campaign-save-actions {
    display: flex;
    justify-content: flex-end;
}

.campaign-analysis-actions {
    display: flex;
    justify-content: flex-end;
}

.action-row:has(.campaign-edit[open]) {
  flex-wrap: wrap;
}

.action-row:has(.campaign-edit[open]) > :not(.campaign-edit-delete) {
  display: none;
}

#campanhas:has(.campaign-edit[open]) .section-head > button {
  display: none;
}

.action-row input[type=email] {
  width: 230px;
}

.action-row input[type=number] {
  width: 88px;
}

.filter-bar {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.2fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}

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

.contact-segments {
    display: grid;
    grid-template-columns: repeat(2, minmax(90px, 1fr));
    gap: 6px;
    margin-bottom: 6px;
}

.lang-options {
    grid-template-columns: repeat(2, 52px);
    align-items: center;
    gap: 7px 10px;
    margin: 0;
}

.lang-options label {
    gap: 5px;
    line-height: 1.1;
}

.contact-segments label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    color: #c9d1dc;
}

.contact-segments input {
    width: auto;
    margin: 0;
}

.save-line {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.save-line form {
    display: inline-flex;
}

.inline-create {
    display: grid;
    grid-template-columns: 1fr 1.5fr auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 16px;
}

.segment-edit {
    display: grid;
    grid-template-columns: minmax(140px, .8fr) minmax(180px, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.pager {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 14px;
}

.pager span {
  color: #9aa5b1;
}

.footer-notice {
  margin-top: 18px;
}

@media (max-width: 900px) {
  .topbar {
    position: static;
    padding: 16px;
  }

  .topbar-inner {
    display: block;
  }

  .topbar-links {
    justify-content: flex-start;
    margin-top: 10px;
  }

  main {
    padding: 16px;
  }

    .metric-grid,
    .form-grid,
    .new-contact,
    .check-grid,
    .filter-bar,
    .inline-create,
    .login-row,
    .segment-edit {
        grid-template-columns: 1fr;
    }

  .split-line,
  .campaign-main {
    display: block;
  }

    .filter-actions,
    .pager,
    .head-pills,
    .head-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .contact-segments {
        grid-template-columns: 1fr;
    }

    .template-analysis-head,
    .template-analysis li {
        display: block;
    }

    .template-analysis li span {
        margin: 0 0 4px;
    }

  .campaign-controls,
  .action-row,
  .action-row form {
    display: block;
  }

    .action-row form.campaign-edit-form {
        display: block;
    }

  .mini-metrics {
    flex-wrap: wrap;
  }

  .action-row>* {
    margin-top: 8px;
  }

  .action-row input[type=email],
  .action-row input[type=number],
  .action-row button,
  .action-row .button {
    width: 100%;
    display: block;
  }

    .campaigns-table .action-row,
    .campaigns-table .action-row form,
    .campaigns-table .campaign-edit-delete {
        display: flex;
    }

    .campaigns-table .action-row button,
    .campaigns-table .action-row .button,
    .campaigns-table .action-row .icon-button {
        width: 38px;
        display: inline-flex;
    }

    .campaigns-table .action-row form.campaign-edit-form {
        display: block;
    }
}
