:root {
  --ink: #1c2321;
  --ink-soft: #4d5955;
  --paper: #f5f6f4;
  --panel: #ffffff;
  --line: #dfe3e0;
  --teal: #2f6f5e;
  --teal-deep: #234f43;
  --amber: #c98a3d;
  --red: #b3452f;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

code {
  font-family: "IBM Plex Mono", monospace;
  background: #eceeec;
  padding: 0.1em 0.35em;
  border-radius: 3px;
  font-size: 0.9em;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.75rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-mark {
  font-size: 1.3rem;
  color: var(--teal);
}

.brand-name {
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: 0.01em;
}

.status-block {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.quota-readout {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.quota-readout #sentToday {
  color: var(--ink);
  font-weight: 500;
}

.quota-sep { margin: 0 0.15em; color: var(--line); }
.quota-label { margin-left: 0.4em; color: var(--ink-soft); }

.pill {
  padding: 0.3em 0.75em;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  background: #eceeec;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

.pill.running {
  background: #e6f0ec;
  color: var(--teal-deep);
  border-color: #bfd9cd;
}

/* ---------- Buttons ---------- */

.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 0.55em 1.1em;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.btn:hover { border-color: var(--ink-soft); }

.btn-primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
  font-weight: 500;
}

.btn-primary:hover { background: var(--teal-deep); border-color: var(--teal-deep); }

.btn-primary.pausing {
  background: var(--red);
  border-color: var(--red);
}

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0 1.75rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.tab {
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--ink-soft);
  padding: 0.85em 0.9em;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab.active {
  color: var(--ink);
  border-bottom-color: var(--teal);
  font-weight: 500;
}

/* ---------- Layout ---------- */

main {
  max-width: 920px;
  margin: 0 auto;
  padding: 2rem 1.75rem 4rem;
}

.panel { display: none; }
.panel.active { display: block; }

.panel-head { margin-bottom: 1.5rem; }
.panel-head h2 { margin: 0 0 0.3rem; font-size: 1.25rem; }
.hint { color: var(--ink-soft); font-size: 0.88rem; margin: 0; }

h3 { font-size: 0.95rem; margin: 0 0 0.6rem; }

/* ---------- Import cards ---------- */

.import-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.import-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
}

.import-card input[type="file"] {
  display: block;
  margin: 0.6rem 0;
  font-size: 0.85rem;
}

textarea, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="time"] {
  width: 100%;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.55em 0.7em;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

textarea { resize: vertical; font-family: "IBM Plex Mono", monospace; font-size: 0.85rem; }

.import-card textarea { margin-bottom: 0.6rem; }

/* ---------- Counts ---------- */

.counts-row {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.count-chip {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  padding: 0.3em 0.7em;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-soft);
}

/* ---------- Table ---------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.87rem;
}

.data-table th {
  text-align: left;
  font-weight: 500;
  color: var(--ink-soft);
  background: #f0f1ef;
  padding: 0.6em 0.8em;
  border-bottom: 1px solid var(--line);
  font-size: 0.8rem;
}

.data-table td {
  padding: 0.55em 0.8em;
  border-bottom: 1px solid var(--line);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.83rem;
}

.data-table tr:last-child td { border-bottom: none; }

.status-tag {
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.78rem;
  padding: 0.15em 0.55em;
  border-radius: 999px;
}

.status-pending { background: #eceeec; color: var(--ink-soft); }
.status-sent { background: #e6f0ec; color: var(--teal-deep); }
.status-failed { background: #f5e6e1; color: var(--red); }
.status-bounced { background: #f5e6e1; color: var(--red); }
.status-unsubscribed { background: #f0ece3; color: var(--amber); }

.row-action {
  background: none;
  border: none;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 0.8rem;
  text-decoration: underline;
}

/* ---------- Forms ---------- */

.field {
  display: block;
  margin-bottom: 1rem;
}

.field > span {
  display: block;
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-bottom: 0.3em;
}

.inline-fields {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.save-note {
  margin-left: 0.8rem;
  font-size: 0.85rem;
  color: var(--teal-deep);
}

.save-note.error { color: var(--red); }

/* ---------- Tracking block ---------- */

.tracking-block {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.tracking-block h3 { margin-bottom: 0.3rem; }
.tracking-block .hint { margin-bottom: 0.8rem; }

/* ---------- Analytics ---------- */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.9rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 0.8rem;
  text-align: center;
}

.metric-value {
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.6rem;
  font-weight: 500;
  color: var(--teal-deep);
}

.metric-label {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 0.3rem;
}

.tracking-notice {
  background: #fbf1e4;
  border: 1px solid #e8cfa0;
  color: #8a5a1f;
  padding: 0.7em 1em;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* ---------- Senders ---------- */

.sender-form { margin-bottom: 1.5rem; }

.optional {
  font-weight: 400;
  color: #9aa39f;
  font-size: 0.85em;
}

.senders-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.sender-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.sender-card.inactive { opacity: 0.55; }

.sender-info { display: flex; flex-direction: column; gap: 0.15rem; }

.sender-name {
  font-weight: 500;
  font-size: 0.92rem;
}

.sender-email {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.sender-quota {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.sender-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 21px;
  flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #d5d9d6;
  border-radius: 999px;
  transition: background 0.15s ease;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  height: 15px;
  width: 15px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s ease;
}

.toggle-switch input:checked + .toggle-slider { background: var(--teal); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(17px); }

.small-note {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: 0.4rem;
}

@media (max-width: 720px) {
  .import-row, .two-col { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 0.7rem; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .sender-card { flex-direction: column; align-items: flex-start; }
}
