:root {
  --bg: #f3efe6;
  --ink: #1c1915;
  --muted: #5c574e;
  --line: #d9d2c5;
  --paper: #fffcf6;
  --paper-2: #f7f2e8;
  --accent: #143d32;
  --accent-2: #1f6b56;
  --gold: #c4a35a;
  --danger: #9b2c2c;
  --warn: #8a4b12;
  --ok: #1b5e3b;
  --shadow: 0 1px 2px rgba(28, 25, 21, 0.06), 0 8px 24px rgba(28, 25, 21, 0.06);
  --radius: 12px;
  --font: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background:
    radial-gradient(900px 400px at 10% -10%, #efe6d0 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  line-height: 1.45;
  min-height: 100vh;
}

button, input, select, textarea { font: inherit; color: inherit; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 20px 80px; }

header.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}
.brand .logo {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-size: 1.85rem;
  margin: 0 0 4px;
}
.brand p { margin: 0; color: var(--muted); max-width: 42ch; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.counter {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.9rem;
}
.counter.at-limit { border-color: #e2b4b4; background: #fbf3f3; color: var(--danger); }

button {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: #bfb6a6; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--accent); color: #f7f3ea; border-color: var(--accent); }
button.primary:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }
button.ghost { background: transparent; }
button.danger { color: var(--danger); border-color: #e2b4b4; background: #fbf6f4; }

#upgradeBtn {
  background: #143d32;
  color: #f8f1d8;
  border: 1px dashed #c4a35a;
  font-weight: 600;
  position: relative;
}
#upgradeBtn small {
  display: block;
  font-weight: 500;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #e6d7a8;
}

.banner {
  background: #f7efe0;
  border: 1px solid #e4d3a8;
  color: #5a4716;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  display: none;
}
.banner.show { display: block; }

section { margin-bottom: 22px; }
section h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 10px;
  font-weight: 700;
}

.chase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.card, .panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card {
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  display: block;
}
.card:hover, .card.selected { border-color: var(--accent-2); }
.card .who { font-weight: 700; font-size: 1.05rem; }
.card .meta { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }
.card .amt { margin-top: 8px; font-variant-numeric: tabular-nums; font-weight: 650; }
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  margin-top: 8px;
}
.badge.b-current { background: #e6f4ec; color: var(--ok); }
.badge.b-1-7 { background: #f8edd9; color: var(--warn); }
.badge.b-8-14 { background: #f6e2c8; color: #7a3d0f; }
.badge.b-15-29 { background: #f8e0d8; color: #8a2f1d; }
.badge.b-30-plus, .badge.b-30\\+ { background: #f6d6d6; color: var(--danger); }
.empty { color: var(--muted); padding: 8px 0 4px; }

.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
  align-items: start;
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  header.top { flex-direction: column; }
}

.panel { padding: 16px 16px 18px; }
.panel h3 { margin: 0 0 12px; font-size: 1.05rem; }

.form-grid { display: grid; gap: 8px; }
.form-grid.two { grid-template-columns: 1fr 1fr; gap: 8px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--muted); font-weight: 650; }
input, select, textarea {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 7px 9px;
  width: 100%;
}
textarea { min-height: 88px; resize: vertical; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
tr[data-id] { cursor: pointer; }
tr[data-id]:hover { background: var(--paper-2); }
tr.selected { background: #eef5f1; }
tr.paid td { color: var(--muted); }
.table-wrap { overflow-x: auto; }

.aging-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  background: #fff;
  font-size: 0.82rem;
}

.draft { margin-top: 18px; }
.draft-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: end; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #f7f3ea; border-color: var(--accent); }

.message-box {
  white-space: pre-wrap;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  min-height: 140px;
  font-size: 0.95rem;
  margin: 10px 0;
}
.subject { font-weight: 700; margin-bottom: 8px; }

.fee-box { background: var(--paper-2); border-radius: 10px; padding: 12px; margin: 10px 0; border: 1px solid var(--line); }
.disclaimer {
  font-size: 0.8rem;
  color: var(--muted);
  border-left: 3px solid var(--gold);
  padding: 6px 0 6px 10px;
  margin: 10px 0 0;
}

.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: var(--ink);
  color: #f7f3ea;
  padding: 10px 14px;
  border-radius: 8px;
  display: none;
  z-index: 20;
}
.toast.show { display: block; }

dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
  max-width: 440px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(28, 25, 21, 0.45); }
dialog .inner { padding: 20px 22px 22px; }
dialog h2 { text-transform: none; letter-spacing: 0; font-size: 1.2rem; color: var(--ink); margin: 0 0 8px; }
.placeholder-tag {
  display: inline-block;
  background: #f3e6b5;
  color: #5a4716;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.hint { font-size: 0.8rem; color: var(--muted); margin: 6px 0 0; }
.hidden { display: none !important; }

.fee-include {
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-weight: 650;
}
.fee-include input { width: auto; }

input::placeholder, textarea::placeholder {
  color: #9a9488;
  opacity: 1;
}

.hero {
  background: var(--ink);
  color: var(--paper);
  padding: 28px 28px 26px;
  margin-bottom: 18px;
  border-radius: 4px 4px 18px 18px;
}
.hero .eyebrow {
  margin: 0 0 10px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}
.hero h1 {
  font-family: "IBM Plex Serif", "Palatino Linotype", Palatino, serif;
  font-size: clamp(1.6rem, 3vw, 2.15rem);
  line-height: 1.2;
  margin: 0 0 16px;
  font-weight: 600;
  color: var(--paper);
}
.hero .benefits {
  margin: 0 0 14px;
  padding-left: 1.15rem;
  max-width: 42rem;
}
.hero .benefits li {
  margin: 0 0 6px;
  color: #e6e1d6;
}
.hero .who {
  margin: 0;
  color: #c9c3b6;
  font-size: 0.95rem;
  max-width: 42rem;
}

.brand .logo {
  margin: 0 0 4px;
  font-family: "IBM Plex Serif", "Palatino Linotype", Palatino, serif;
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

#upgradeBtn.licensed {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
#upgradeBtn.licensed small { color: #c9c3b6; }

.site-foot {
  margin: 22px 0 8px;
  padding: 14px 4px 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
}
.site-foot strong { color: var(--ink); }

dialog label { display: block; margin: 12px 0 8px; font-size: 0.85rem; font-weight: 650; }
dialog input { width: 100%; margin-top: 4px; }

@media (max-width: 720px) {
  .hero { padding: 22px 18px 20px; }
}
