:root {
  color-scheme: light;
  --page: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f3f5f8;
  --surface-3: #eaeef3;
  --border: #e3e8ee;
  --border-strong: #d3dae2;
  --text: #1f2933;
  --text-2: #52606d;
  --muted: #8794a2;
  --accent: #3b9eea;
  --accent-hover: #2b8ad6;
  --accent-soft: #e8f3fd;
  --accent-ink: #ffffff;
  --sidebar: #ffffff;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;

  --ok: #12a150;
  --ok-soft: #e4f6ec;
  --warn: #f2b632;
  --warn-ink: #5c4200;
  --warn-soft: #fdf3dc;
  --bad: #e5484d;
  --bad-soft: #fde8e8;
  --orange: #ec835a;
  --orange-soft: #fdeee7;
  --info: #3b9eea;
  --neutral: #c3c9d1;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); color: var(--text); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 500; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
svg.i { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
.shell > div { min-width: 0; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--border); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 16px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.brand .logo svg { width: 17px; height: 17px; }
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: .02em; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent-hover); }
.sidebar .account { margin-top: auto; border-top: 1px solid var(--border); padding: 14px 10px 0; display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); display: grid; place-items: center; font-weight: 600; font-size: 12px; flex-shrink: 0; }
.account .who { min-width: 0; flex: 1; }
.account .who div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; }
.account button:hover { background: var(--surface-2); color: var(--text); }
.content { padding: 28px 28px 48px; min-width: 0; }
.mobilebar { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; color: var(--text-2); font-size: 15px; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 8px; display: flex; gap: 6px; align-items: center; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; }
.card + .card, .stack-16 > * + * { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.card-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.card.flush { padding: 0; }
.card.flush .card-head { padding: 18px 24px 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3-1 { grid-template-columns: 2fr 1fr; }
.section-gap { margin-top: 16px; }

/* ---------- Buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); padding: 9px 16px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; line-height: 1.2; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.icon { padding: 7px 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

label, .label { display: block; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 7px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; min-height: 42px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--accent); }
.field { margin-bottom: 16px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 16px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--text); text-transform: none; letter-spacing: 0; font-weight: 500; margin: 0; cursor: pointer; }
.input-pair { display: flex; gap: 8px; }
.input-pair > :first-child { flex: 1.6; }
.input-pair > :last-child { flex: 1; }
.form-error { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 8px; }

.pills { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pill { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 99px; padding: 6px 16px; font: inherit; font-weight: 500; cursor: pointer; }
.pill:hover { border-color: var(--border-strong); }
.pill.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-hover); }
.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.link-btn { background: none; border: none; color: var(--accent); font: inherit; font-weight: 500; cursor: pointer; padding: 0; display: inline-flex; align-items: center; gap: 6px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; cursor: pointer; color: var(--text-2); }
.chip:hover { border-color: var(--accent); color: var(--accent-hover); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); font-weight: 600; padding: 12px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 13px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfc; }
td .sub { display: block; font-size: 12px; color: var(--muted); }
td.id { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--text-2); white-space: nowrap; }
td.wrap { word-break: break-word; min-width: 130px; max-width: 180px; }
td.subject { min-width: 190px; }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty svg { width: 28px; height: 28px; margin-bottom: 8px; stroke-width: 1.5; }

.pager-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 24px; flex-wrap: wrap; color: var(--text-2); }
.pager { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.pager button { border: none; border-right: 1px solid var(--border); background: var(--surface); padding: 7px 12px; font: inherit; font-size: 13px; color: var(--text-2); cursor: pointer; min-width: 34px; }
.pager button:last-child { border-right: none; }
.pager button:hover:not(:disabled) { background: var(--surface-2); }
.pager button.active { background: var(--accent); color: #fff; }
.pager button:disabled { cursor: default; color: var(--muted); }

/* ---------- Status ---------- */
.status { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 4px 12px; border-radius: 5px; white-space: nowrap; min-width: 116px; }
.status svg { width: 13px; height: 13px; }
.status.delivered { background: var(--ok); color: #fff; }
.status.hard_bounce { background: var(--bad); color: #fff; }
.status.soft_bounce { background: var(--warn); color: var(--warn-ink); }
.status.deferred { background: var(--warn-soft); color: var(--warn-ink); }
.status.complaint { background: var(--orange); color: #fff; }
.status.queued, .status.cancelled { background: var(--surface-3); color: var(--text-2); }
.status.in_transit { background: var(--accent-soft); color: var(--accent-hover); }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; border: 1px solid var(--border); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--neutral); }
.badge.sending::before { background: var(--accent); animation: pulse 1.2s infinite; }
.badge.scheduled::before { background: var(--warn); }
.badge.completed::before { background: var(--ok); }
.badge.cancelled::before { background: var(--bad); }
.badge.on::before { background: var(--ok); }
@keyframes pulse { 50% { opacity: .25; } }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 4px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }

.progress { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; min-width: 90px; }
.progress > div { height: 100%; background: var(--accent); border-radius: 99px; transition: width .8s ease; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .k { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 7px; font-weight: 500; }
.kpi .k i { width: 8px; height: 8px; border-radius: 2px; }
.kpi .v { font-size: 26px; font-weight: 600; margin-top: 6px; letter-spacing: -.02em; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }

.bar-stack { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; margin: 4px 0 18px; background: var(--surface-3); }
.bar-stack > div { height: 100%; transition: flex-grow .8s ease; min-width: 0; }
.legend-list { display: grid; gap: 10px; }
.legend-list .row { display: grid; grid-template-columns: 12px 1fr auto 58px; gap: 10px; align-items: center; }
.legend-list .sw { width: 12px; height: 12px; border-radius: 3px; }
.legend-list .v { font-variant-numeric: tabular-nums; font-weight: 600; }
.legend-list .p { font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; }
.chart-box { position: relative; height: 290px; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px 24px; }
.meta-grid .label { margin-bottom: 3px; }
.meta-grid div div { word-break: break-word; }

/* ---------- Modal / drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 50; display: flex; justify-content: center; align-items: flex-start; padding: 48px 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 640px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal.wide { max-width: 980px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px 24px; border-bottom: 1px solid var(--border); gap: 12px; }
.modal-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.modal-body { padding: 22px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 12px 12px; }

.log { background: #0f172a; color: #d6deeb; border-radius: 8px; padding: 14px 16px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; line-height: 1.6; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.log .t { color: #7f8ea3; }
.log .q { color: #82aaff; }
.log .ok { color: #7fdbca; }
.log .err { color: #ff7b72; }
.log .def { color: #ffcb6b; }
.response { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; word-break: break-word; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 20px 1fr auto; gap: 10px; padding: 8px 0; align-items: center; position: relative; }
.timeline li::before { content: ""; position: absolute; left: 9px; top: 26px; bottom: -10px; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .dot { width: 12px; height: 12px; border-radius: 50%; margin-left: 4px; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); position: relative; z-index: 1; }

.notice { display: flex; gap: 10px; align-items: flex-start; border-radius: 8px; padding: 12px 14px; font-size: 13px; background: var(--accent-soft); color: #134e7a; }
.notice.warn { background: var(--warn-soft); color: var(--warn-ink); }
.toast-host { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: 100; }
.toast { background: #1f2933; color: #fff; padding: 11px 16px; border-radius: 8px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 380px; }
.toast.error { background: var(--bad); }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-side { background: linear-gradient(150deg, #1f6fb5, #3b9eea 60%, #63b8f2); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-side h2 { font-size: 30px; font-weight: 600; line-height: 1.25; max-width: 420px; }
.login-side p { opacity: .85; max-width: 420px; font-size: 15px; }
.login-side .brand { color: #fff; padding: 0; }
.login-side .brand .logo { background: rgba(255,255,255,.2); }
.login-form { display: grid; place-items: center; padding: 32px 16px; background: var(--surface); }
.login-form form { width: 100%; max-width: 360px; }
.login-form h1 { font-size: 24px; font-weight: 600; margin-bottom: 6px; }
.login-form .btn { width: 100%; padding: 12px; margin-top: 4px; }

@media (max-width: 1100px) {
  .grid.cols-3-1, .grid.cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.15); }
  .shell.nav-open .sidebar { transform: none; }
  .mobilebar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
  .content { padding: 20px 16px 40px; }
  .card { padding: 18px 16px; }
  .login-page { grid-template-columns: 1fr; }
  .login-side { display: none; }
  h1 { font-size: 22px; }
}

/* Barra de filtros do relatório */
.filter-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.filter-row > .f-date { flex: 1 1 260px; max-width: 320px; }
.filter-row > .f-select { flex: 1 1 170px; max-width: 280px; }
.filter-row > .f-actions { display: flex; gap: 8px; margin-left: auto; }
.grid > .card { margin-top: 0; }
.card.flush th:first-child, .card.flush td:first-child { padding-left: 24px; }
.card.flush th:last-child, .card.flush td:last-child { padding-right: 24px; }
