:root {
  --bg: #f5f6f4;
  --ink: #1a2421;
  --muted: #5c6b66;
  --line: #e1e5e0;
  --card: #ffffff;
  --coral: #e45b3c;
  --coral-dark: #b8422b;
  --teal: #0f6b68;
  --teal-dark: #0b4f4d;
  --cream: #fff8f4;
  --amber-bg: #fff4e0;
  --amber: #8a5a12;
  --good-bg: #e6f4f3;
  --bad-bg: #fdecea;
  --shadow: 0 1px 2px rgba(26, 36, 33, 0.05), 0 12px 32px rgba(26, 36, 33, 0.05);
  --radius: 16px;
  --font: "Outfit", "Avenir Next", "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
}
a { color: var(--teal); }
img { max-width: 100%; }

.top {
  background: var(--teal);
  color: #f4f7f6;
  position: sticky;
  top: 0;
  z-index: 10;
}
.top-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.85rem 1.1rem 0.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.top-tools { display: flex; align-items: center; gap: 0.55rem; }
.top button.ghost {
  background: transparent;
  color: #f4f7f6;
  border: 1.5px solid rgba(244, 247, 246, 0.75);
  min-height: 36px;
  padding: 0.3rem 0.8rem;
  font-size: 0.88rem;
}
.top button.ghost:hover { background: rgba(255, 255, 255, 0.14); }
.brand {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  text-decoration: none;
  color: inherit;
  flex: 0 0 auto;
  white-space: nowrap;
}
.brand strong {
  font-family: var(--display);
  font-weight: 560;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}
.brand span {
  background: var(--coral);
  color: white;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}
.pill {
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.pill.dry { background: var(--amber-bg); color: var(--amber); }
.pill.live { background: #d8f3e4; color: #0d6b3a; }
.pill.warn { background: var(--bad-bg); color: var(--coral-dark); }
nav.main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.35rem 1.1rem 0.75rem;
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
}
nav.main a {
  color: #e7f3f2;
  text-decoration: none;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  font-size: 0.92rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
nav.main a:hover, nav.main a.active { background: rgba(255, 255, 255, 0.12); }
.top button.secondary,
.top button.secondary:hover {
  color: #f4f7f6;
  border-color: rgba(244, 247, 246, 0.75);
  background: transparent;
}
.top button.secondary:hover { background: rgba(255, 255, 255, 0.14); }
.stripe { height: 4px; background: linear-gradient(90deg, var(--coral), var(--coral-dark)); }

.wrap { max-width: 1080px; margin: 0 auto; padding: 1.25rem 1.1rem 3rem; }
h1, h2, h3 { font-family: var(--display); font-weight: 560; letter-spacing: -0.03em; margin: 0 0 0.4rem; }
h1 { font-size: 2rem; line-height: 1.15; }
h2 { font-size: 1.35rem; }
.lede { color: var(--muted); margin: 0 0 1.1rem; max-width: 42rem; }
.flash {
  background: var(--cream);
  border: 1px solid #f0d2c8;
  color: var(--coral-dark);
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  margin-bottom: 1rem;
}
.errors { background: var(--bad-bg); border-radius: 12px; padding: 0.7rem 0.9rem; color: var(--coral-dark); }
.errors ul { margin: 0.2rem 0 0; padding-left: 1.1rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.stat, .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat { padding: 0.9rem 1rem; }
.stat .label { color: var(--muted); font-size: 0.8rem; }
.stat .value {
  font-family: var(--display);
  font-size: 1.7rem;
  margin-top: 0.15rem;
}
.card { padding: 1rem 1.05rem; margin-bottom: 0.9rem; }
.card h2 { margin-bottom: 0.6rem; }
.grid-2 { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 0.9rem; }
.callout {
  background: var(--cream);
  border: 1px solid #f3ddd6;
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 0.9rem;
}
.callout strong { color: var(--coral-dark); }
.url {
  width: 100%;
  font: 0.85rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 0.7rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fbfcfb;
  color: var(--ink);
}

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); font-weight: 650; }
td, th { padding: 0.65rem 0.4rem; vertical-align: top; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--teal); }
.neg { color: var(--coral-dark); }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 650;
  background: #eef1ee;
  color: var(--ink);
}
.badge.completed, .badge.credited, .badge.active, .badge.sent { background: var(--good-bg); color: var(--teal-dark); }
.badge.cancelled, .badge.refunded, .badge.reversed, .badge.blocked, .badge.failed, .badge.error { background: var(--bad-bg); color: var(--coral-dark); }
.badge.pending, .badge.recorded, .badge.dry_run, .badge.paused, .badge.accepted, .badge.ready, .badge.collected, .badge.manual { background: var(--amber-bg); color: var(--amber); }
.badge.synced { background: var(--good-bg); color: var(--teal-dark); }

.btn, button, .btn-link {
  font: inherit;
  background: var(--coral-dark);
  color: white;
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1rem;
  min-height: 44px;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn:hover, button:hover { background: var(--coral); }
.btn.secondary, button.secondary {
  background: transparent;
  color: var(--teal);
  border: 1.5px solid var(--teal);
}
.btn.secondary:hover { background: var(--good-bg); }
.btn.small, button.small { min-height: 36px; padding: 0.35rem 0.75rem; font-size: 0.88rem; }
.row-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

label { display: block; font-size: 0.82rem; font-weight: 650; margin-bottom: 0.25rem; }
input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: white;
  border: 1px solid #cfd6d2;
  border-radius: 10px;
  padding: 0.65rem 0.7rem;
  min-height: 44px;
}
textarea { min-height: 88px; }
input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(15, 107, 104, 0.25);
  border-color: var(--teal);
}
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.fields .wide { grid-column: 1 / -1; }
.help { color: var(--muted); font-size: 0.82rem; margin-top: 0.25rem; }
.coupon-sync h2 { margin-bottom: 0; }
.sync-actions { margin: 0.7rem 0 0.2rem; }
.checklist {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 0.35rem 0.75rem;
  margin: 0.6rem 0 0;
}
.checklist dt { color: var(--muted); font-size: 0.82rem; }
.checklist dd { margin: 0; overflow-wrap: anywhere; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(900px 400px at 10% -10%, rgba(228, 91, 60, 0.18), transparent 50%),
    radial-gradient(700px 400px at 100% 0%, rgba(15, 107, 104, 0.18), transparent 45%),
    var(--bg);
}
.login-card { width: min(440px, 100%); padding: 1.4rem; }
.steps { margin: 0; padding-left: 1.1rem; }
.steps li { margin: 0.35rem 0; }
.message {
  white-space: pre-wrap;
  background: #f7f8f6;
  border-radius: 10px;
  padding: 0.7rem;
  font-size: 0.92rem;
}
pre.json {
  overflow: auto;
  background: #14221f;
  color: #e7f3f0;
  border-radius: 12px;
  padding: 0.9rem;
  font-size: 0.78rem;
  line-height: 1.45;
  max-height: 32rem;
}
.week-nav { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-bottom: 0.8rem; }
.payout {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 0.8rem;
  align-items: start;
}
.payout + .payout { margin-top: 0.75rem; }
dl.kv { display: grid; grid-template-columns: 9rem 1fr; gap: 0.35rem 0.6rem; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
footer.note { color: var(--muted); font-size: 0.85rem; margin-top: 1.5rem; }

@media (max-width: 860px) {
  .stats, .grid-2, .fields, .payout, .checklist { grid-template-columns: 1fr; }
  h1 { font-size: 1.7rem; }
  .top-inner { align-items: center; flex-wrap: wrap; row-gap: 0.45rem; }
  .brand { flex-basis: 100%; }
  .top-tools { flex-wrap: wrap; }
  .brand strong { font-size: 1.2rem; }
  .checklist dt { margin-top: 0.35rem; }
  .card form > button,
  .sync-actions button,
  .row-actions .btn { width: 100%; }
  .row-actions { align-items: stretch; }
  table.stack td { overflow-wrap: anywhere; }
  table.stack thead { display: none; }
  table.stack tr { display: block; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 0.7rem; padding: 0.35rem 0.6rem; background: white; }
  table.stack td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: 0.4rem 0; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-size: 0.78rem; font-weight: 650; }
}
