:root {
  --ink: #1d2433;
  --muted: #667085;
  --line: #e4e7ec;
  --bg: #f6f5f2;
  --card: #ffffff;
  --brand: #7a5c3e;
  --brand-ink: #ffffff;
  --brand-soft: #f3ece4;
  --ok: #157347;
  --ok-soft: #e7f5ee;
  --warn: #9a6700;
  --warn-soft: #fff6dd;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --info-soft: #eef4ff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
h1 { font-size: 1.55rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: .5rem 0; }
p { margin: .25rem 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.big { font-size: 1.15rem; letter-spacing: .04em; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; }
.flag { color: var(--bad); font-weight: 600; }

.banner { padding: .4rem 1rem; text-align: center; font-size: .85rem; font-weight: 600; }
.banner-test { background: #fff1c2; color: #6b4e00; }

.topbar { display: flex; align-items: center; gap: 1.25rem; padding: .7rem 1.5rem; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; text-decoration: none; color: var(--ink); }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.brand-mark.lg { width: 48px; height: 48px; font-size: 1.4rem; border-radius: 12px; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.nav a { padding: .4rem .7rem; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.on { background: var(--brand-soft); color: var(--brand); }
.who { display: flex; align-items: center; gap: .75rem; font-size: .85rem; color: var(--muted); }

.page { max-width: 1180px; margin: 0 auto; padding: 1.5rem; }
.page.narrow { max-width: 480px; padding-top: 8vh; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 1rem; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card.auth { padding: 2rem; }
.narrow-card { max-width: 560px; }
.auth-brand { text-align: center; margin-bottom: 1.25rem; }
.auth-brand h1 { margin-top: .6rem; }

label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; font-weight: 600; color: #344054; margin-bottom: .75rem; }
input, select, textarea { font: inherit; color: var(--ink); padding: .55rem .7rem; border: 1px solid #d0d5dd; border-radius: 8px; background: #fff; width: 100%; font-weight: 400; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
input:disabled, textarea:disabled { background: #f9fafb; color: var(--muted); }
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-grid .span2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; margin: 0 0 1rem; }
legend { font-weight: 700; padding: 0 .35rem; }
.choice .radio { flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5rem; font-weight: 500; }
.choice .radio input[type=radio] { width: auto; }
.choice .radio select { width: auto; min-width: 260px; }
.filters { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
.filters label { margin: 0; min-width: 150px; }
.search { display: flex; gap: .5rem; }
.inline, .inline-form { display: inline-flex; gap: .5rem; align-items: flex-end; margin: 0; }
.inline-form label { margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .55rem 1rem; border-radius: 8px; border: 1px solid #d0d5dd; background: #fff; color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f9fafb; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); border-color: #f4c7c3; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.small { padding: .3rem .65rem; font-size: .85rem; }
.btn.wide { width: 100%; margin-top: .5rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; text-decoration: underline; }
.link.danger { color: var(--bad); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.table.dense td { padding: .35rem .5rem; font-size: .85rem; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.dim td { color: var(--muted); }
.table tr.flag-row td { background: var(--bad-soft); }
.card > .table { margin: 0 -.25rem; width: calc(100% + .5rem); }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0 0 .75rem; }
.dl dt { color: var(--muted); font-size: .85rem; }
.dl dd { margin: 0; }
.inline-dl { grid-template-columns: repeat(auto-fill, minmax(90px, max-content) minmax(120px, 1fr)); }

.pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #f2f4f7; color: #344054; text-transform: capitalize; }
.pill.succeeded, .pill.paid, .pill.active, .pill.signed, .pill.completed, .pill.imported { background: var(--ok-soft); color: var(--ok); }
.pill.failed, .pill.past_due, .pill.disputed, .pill.disabled, .pill.rejected, .pill.no_show { background: var(--bad-soft); color: var(--bad); }
.pill.retry, .pill.requires_action, .pill.processing, .pill.pending, .pill.draft, .pill.warn, .pill.scheduled { background: var(--warn-soft); color: var(--warn); }
.pill.refunded, .pill.partially_refunded, .pill.cancelled, .pill.canceled, .pill.inactive, .pill.archived, .pill.muted, .pill.void, .pill.skipped { background: #f2f4f7; color: var(--muted); }
.pill.open, .pill.rescheduled { background: var(--warn-soft); color: var(--warn); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.empty { padding: 1rem 0; }
.count { background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: 0 .5rem; font-size: .85rem; }

.alert { padding: .75rem 1rem; border-radius: var(--radius); background: var(--bad-soft); color: #7a271a; margin-bottom: 1rem; border: 1px solid #f9d0cb; }
.alert.warn { background: var(--warn-soft); color: #6b4e00; border-color: #f5e2a8; }
.alert.info { background: var(--info-soft); color: #1d3a7a; border-color: #d1e0ff; }
.notice { padding: .6rem 1rem; border-radius: var(--radius); background: var(--ok-soft); color: var(--ok); margin-bottom: 1rem; font-weight: 600; }

.list { list-style: none; padding: 0; margin: 0 0 .75rem; }
.list li { padding: .4rem 0; border-bottom: 1px solid var(--line); display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.steps { padding-left: 1.2rem; color: #344054; }
.qr { display: grid; place-items: center; margin: .5rem 0; }
.codes { columns: 2; padding-left: 1.2rem; font-size: 1.05rem; }
.stepper { display: flex; gap: .5rem; list-style: none; padding: 0; margin: 0 0 1rem; flex-wrap: wrap; }
.stepper li { padding: .35rem .8rem; border-radius: 999px; background: #f2f4f7; color: var(--muted); font-size: .85rem; font-weight: 600; }
.stepper li.on { background: var(--brand); color: #fff; }
.stepper li.done { background: var(--ok-soft); color: var(--ok); }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.tabs a { padding: .3rem .7rem; border-radius: 999px; text-decoration: none; color: var(--muted); font-size: .85rem; text-transform: capitalize; }
.tabs a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.stat span { display: block; color: var(--muted); font-size: .8rem; }
.stat strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }

.note, .consent-text { white-space: pre-wrap; font: inherit; background: #fbfaf8; border: 1px solid var(--line); border-radius: 8px; padding: .75rem .9rem; margin: .5rem 0; }
.note.original { max-height: 70vh; overflow: auto; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }
.consent-text { font-size: .9rem; }
.note-block { border-top: 1px solid var(--line); padding: .75rem 0; }
.note-block:first-of-type { border-top: 0; }
.note-block.addendum { margin-left: 1.25rem; }
.note-head { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
details summary { cursor: pointer; color: var(--brand); font-size: .9rem; margin: .25rem 0; }

.sig-pad { width: 100%; max-width: 600px; height: 160px; border: 1px dashed #98a2b3; border-radius: 8px; background: #fff; touch-action: none; display: block; margin-bottom: .5rem; }
.sig-block .label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .3rem; }
.sig-img { max-width: 360px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.stripe-field { padding: .75rem; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 1rem; min-height: 120px; }
.import-item { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; margin: .5rem 0; }
.import-item pre { max-height: 180px; overflow: auto; margin: .4rem 0 0; font-size: .8rem; }

.idle-warning { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .7rem 1.1rem; border-radius: 10px; z-index: 20; box-shadow: var(--shadow); }
.foot { text-align: center; color: var(--muted); font-size: .75rem; padding: 1.5rem; }

@media (max-width: 700px) {
  .page { padding: 1rem .75rem; }
  .nav a { padding: .35rem .45rem; font-size: .9rem; }
  .page-head { align-items: stretch; }
  .actions .btn { flex: 1 1 auto; }
}
@media print {
  .topbar, .foot, .banner, .notice, .idle-warning { display: none; }
  body { background: #fff; }
  .page { padding: 0; max-width: none; }
}
