@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  --paper: #f5f7fa;
  --surface: #ffffff;
  --ink: #001c64;
  --ink-2: #334a6f;
  --ink-3: #60738f;
  --rule: #d7e0eb;
  --held: #0070e0;
  --held-strong: #003087;
  --held-soft: #e8f3ff;
  --released: #087f5b;
  --released-soft: #e7f6f0;
  --returned: #687b96;
  --alert: #b3261e;
  --alert-soft: #fff0ef;
  --focus: #0070e0;
  --shadow: 0 2px 10px rgba(0, 28, 100, 0.07), 0 1px 2px rgba(0, 28, 100, 0.05);
  --shadow-hover: 0 8px 24px rgba(0, 48, 135, 0.11);
  --radius-lg: 18px;
  --radius-sm: 10px;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-size: 16px;
  line-height: 1.5;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: linear-gradient(180deg, #fff 0, var(--paper) 260px); }
a { color: #005ea6; text-underline-offset: 2px; }
:focus-visible { outline: 3px solid rgba(0, 112, 224, 0.3); outline-offset: 2px; }
.num { font-variant-numeric: lining-nums; }
.ag-theme-quartz .num, .countdown { font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 72px; padding: 14px 28px; background: rgba(255,255,255,.96); border-bottom: 1px solid #e4eaf2;
  box-shadow: 0 1px 5px rgba(0,48,135,.05); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 800; font-size: 1.2rem; color: var(--ink); text-decoration: none; letter-spacing: -0.025em; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px 10px 10px 4px; background: linear-gradient(145deg, #00a8ea, #0070e0 55%, #003087); box-shadow: 0 4px 10px rgba(0,112,224,.23); position: relative; }
.brand-mark::after { content: "\2713"; position: absolute; inset: 0; display: grid; place-items: center; color: white; font-size: 18px; font-weight: 800; transform: translateY(-1px); }
.topbar nav { display: flex; gap: 18px; align-items: center; font-size: 0.95rem; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 700px) {
  .topbar { padding: 12px 16px; }
  .topbar nav { gap: 12px; font-size: 0.9rem; }
  .topbar nav .optional, .mode-pill { display: none; }
  main { padding: 24px 16px 48px; }
}
.topbar nav a { color: var(--ink-2); text-decoration: none; font-weight: 550; padding: 8px 2px; border-bottom: 2px solid transparent; }
.topbar nav a:hover { color: var(--held); }
.topbar nav a[aria-current="page"] { color: var(--held-strong); font-weight: 700; border-bottom-color: var(--held); }
.mode-pill { font-size: 0.78rem; font-weight: 600; color: var(--held-strong); background: var(--held-soft); border: 1px solid #c6e1fb; border-radius: 999px; padding: 5px 11px; white-space: nowrap; }

main { max-width: 1180px; margin: 0 auto; padding: 42px 24px 72px; }
main.narrow { max-width: 760px; }

h1 { font-size: clamp(1.8rem, 3vw, 2.45rem); line-height: 1.12; letter-spacing: -0.035em; margin: 0 0 9px; font-weight: 750; color: var(--ink); }
h2 { font-size: 1.25rem; letter-spacing: -0.01em; margin: 0 0 12px; font-weight: 700; }
h3 { font-size: 1rem; margin: 0 0 8px; font-weight: 700; }
.lede { color: var(--ink-2); max-width: 62ch; margin: 0 0 24px; }
.muted { color: var(--ink-3); }
.small { font-size: 0.875rem; }
.eyebrow { margin: 0 0 8px; color: var(--held); font-size: .78rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.trust-strip { display: flex; align-items: flex-start; gap: 12px; background: #f3f8fd; border: 1px solid #d4e6f7; border-radius: 14px; padding: 14px 16px; margin-bottom: 18px; color: var(--ink-2); }
.trust-strip::before { content: "\2713"; flex: 0 0 26px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--held); color: #fff; font-weight: 800; }
.trust-strip strong { display: block; color: var(--ink); font-size: .92rem; }
.trust-strip span { display: block; font-size: .82rem; margin-top: 1px; }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid #e1e7ef; border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 18px; }
.split > .panel + .panel { margin-top: 0; }
.stack > * + * { margin-top: 18px; }
.split { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 24px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

/* ---------- buttons + forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; font: inherit; font-weight: 700; font-size: 0.94rem; padding: 10px 20px; border-radius: 999px;
  border: 1px solid var(--held); background: var(--held); color: #fff; cursor: pointer; text-decoration: none;
  box-shadow: 0 2px 4px rgba(0,112,224,.16); transition: background .16s ease, border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.btn:hover { background: #005ea6; border-color: #005ea6; box-shadow: 0 4px 10px rgba(0,94,166,.2); transform: translateY(-1px); }
.btn.secondary { background: var(--surface); color: var(--held-strong); border-color: #8bbbea; box-shadow: none; }
.btn.secondary:hover { background: #f3f8fd; border-color: var(--held); }
.btn.release { background: var(--released); border-color: var(--released); }
.btn.alert { background: var(--surface); color: var(--alert); border-color: #e8aaa6; box-shadow: none; }
.btn.paypal-sim { background: #ffc439; border-color: #ffc439; color: #001c64; box-shadow: none; }
.btn.paypal-sim:hover { background: #f2ba36; border-color: #f2ba36; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

label.field { display: grid; gap: 6px; font-weight: 600; font-size: 0.9rem; }
label.field .hint { font-weight: 400; color: var(--ink-3); font-size: 0.85rem; }
input, textarea, select {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--surface);
  border: 1px solid #aebdce; border-radius: 9px; padding: 11px 13px; width: 100%; min-height: 44px;
}
input:hover, textarea:hover, select:hover { border-color: #7f94aa; }
input:focus, textarea:focus, select:focus { border-color: var(--held); box-shadow: 0 0 0 3px rgba(0,112,224,.13); outline: 0; }
textarea { resize: vertical; min-height: 90px; }
::placeholder { color: #a9b0c0; opacity: 1; }
.form-grid { display: grid; gap: 16px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-amount { display: grid; grid-template-columns: 1fr 110px; gap: 10px; }
@media (max-width: 560px) { .row-2 { grid-template-columns: 1fr; } }

.error { color: var(--alert); background: var(--alert-soft); border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 12px; }
.notice { background: var(--held-soft); border: 1px solid #c6e1fb; border-radius: var(--radius-sm); padding: 13px 15px; color: var(--held-strong); }

/* ---------- the hold meter ---------- */
.amount { font-size: clamp(2rem, 5vw, 2.8rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.amount .cur { font-size: 0.5em; font-weight: 600; color: var(--ink-3); margin-right: 6px; letter-spacing: 0; }
.meter { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: #edf0f5; margin: 16px 0 9px; }
.meter.small { height: 8px; margin: 0; width: 100%; }
.meter span { display: block; height: 100%; }
.meter .held { background: linear-gradient(90deg, var(--held-strong), var(--held), #00a8ea); }
.meter .released { background: var(--released); }
.meter .returned { background: repeating-linear-gradient(90deg, var(--returned) 0 3px, #a3acbd 3px 6px); }
.meter .pending { background: #edf0f5; }
.meter-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 0.85rem; color: var(--ink-2); }
.meter-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.meter-legend .held i { background: var(--held); }
.meter-legend .released i { background: var(--released); }
.meter-legend .returned i { background: var(--returned); }

/* ---------- status ---------- */
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 0.85rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: #edf0f5; color: var(--ink-2); white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.held { background: var(--held-soft); color: var(--held); }
.status.released { background: var(--released-soft); color: var(--released); }
.status.alert { background: var(--alert-soft); color: var(--alert); }
.status.working { background: #fff5d8; color: #7a5200; }

.next-step { background: var(--held-soft); border: 1px solid #c6e1fb; border-left: 4px solid var(--held); border-radius: 10px; padding: 13px 15px; margin: 20px 0 0; }
.next-step.alert { border-color: var(--alert); }
.next-step.released { border-color: var(--released); }
.next-step strong { display: block; }
.next-step span { display: block; margin-top: 2px; }

/* ---------- criteria + results ---------- */
.criteria { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.criteria li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; padding: 12px 14px; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--surface); }
.criteria .mark { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; font-weight: 800; font-size: 0.85rem; background: #edf0f5; color: var(--ink-3); }
.criteria .pass .mark, .criteria li.pass .mark { background: var(--released-soft); color: var(--released); }
.criteria li.fail .mark { background: var(--alert-soft); color: var(--alert); }
.criteria li.unsure .mark { background: #fff6dc; color: #8a5a00; }
.criteria .evidence { color: var(--ink-2); font-size: 0.9rem; margin-top: 3px; }
.criteria .meta { color: var(--ink-3); font-size: 0.8rem; margin-top: 4px; }
.criteria-edit li { grid-template-columns: 28px 1fr 32px; }
.criteria-edit input { border: 0; padding: 2px 0; }
.icon-btn { border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: 1.1rem; border-radius: 6px; }
.icon-btn:hover { color: var(--alert); }

.shots { display: grid; grid-template-columns: 3fr 1fr; gap: 12px; margin-top: 14px; }
.shots figure { margin: 0; }
.shots img { width: 100%; max-height: 360px; object-fit: cover; object-position: top; border: 1px solid var(--rule); border-radius: var(--radius-sm); display: block; background: #fff; }
.shots figcaption { font-size: 0.8rem; color: var(--ink-3); margin-top: 4px; }

.score { display: flex; align-items: baseline; gap: 10px; }
.score b { font-size: 1.6rem; font-weight: 800; }

/* ---------- trace ---------- */
.trace { list-style: none; margin: 0; padding: 0; position: relative; }
.trace::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--rule); }
.trace li { position: relative; padding: 0 0 14px 26px; }
.trace li::before { content: ""; position: absolute; left: 2px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--ink-3); }
.trace li.t-paypal::before { border-color: #1c6dd0; background: #e6effc; }
.trace li.t-ai::before { border-color: var(--held); background: var(--held-soft); }
.trace li.t-policy::before { border-color: var(--ink); background: var(--ink); }
.trace li.t-security::before, .trace li.t-error::before { border-color: var(--alert); background: var(--alert-soft); }
.trace li.t-human::before { border-color: var(--released); background: var(--released-soft); }
.trace .who { font-size: 0.78rem; color: var(--ink-3); }
.trace .what { font-size: 0.92rem; overflow-wrap: anywhere; }
.trace details { margin-top: 4px; }
.trace summary { cursor: pointer; font-size: 0.8rem; color: var(--ink-3); }
.trace pre { font-size: 0.75rem; background: #f7f8fb; border: 1px solid var(--rule); border-radius: 6px; padding: 8px; overflow: auto; max-height: 240px; white-space: pre-wrap; word-break: break-word; }
.trace-filter { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.trace-filter button { font: inherit; font-size: 0.8rem; border: 1px solid var(--rule); background: var(--surface); border-radius: 999px; padding: 3px 10px; cursor: pointer; color: var(--ink-2); }
.trace-filter button[aria-pressed="true"] { background: var(--held-strong); color: #fff; border-color: var(--held-strong); }

/* ---------- dashboard ---------- */
.totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 22px 0; color: var(--ink-2); }
.totals > span { display: grid; gap: 2px; background: #fff; border: 1px solid #e1e7ef; border-radius: 14px; padding: 17px 18px; box-shadow: var(--shadow); }
.totals b { color: var(--ink); font-size: 1.24rem; }
@media (max-width: 700px) { .totals { grid-template-columns: 1fr; } }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; }
#grid { width: 100%; }
.ag-theme-quartz .ag-cell { display: flex; align-items: center; }
.ag-theme-quartz .ag-cell .status { line-height: 1.3; }
.ag-theme-quartz .ag-cell-value { overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; min-width: 0; }
.cell-meter { width: 100%; }
.ag-theme-quartz {
  --ag-font-family: "Inter", system-ui, sans-serif;
  --ag-font-size: 14px;
  --ag-foreground-color: var(--ink);
  --ag-header-foreground-color: var(--ink-2);
  --ag-border-color: var(--rule);
  --ag-header-background-color: #f7f9fc;
  --ag-row-hover-color: #edf6ff;
  --ag-selected-row-background-color: var(--held-soft);
  --ag-wrapper-border-radius: 16px;
}
.ag-theme-quartz { box-shadow: var(--shadow); }
.ag-theme-quartz .ag-row { cursor: pointer; }
.cell-meter { display: flex; align-items: center; height: 100%; }

.copy-link { display: flex; gap: 8px; flex-wrap: wrap; }
.copy-link input { flex: 1 1 260px; }
.copy-link .btn { white-space: nowrap; }
.copy-link input { font-size: 0.85rem; color: var(--ink-2); }

.countdown { font-variant-numeric: tabular-nums; font-weight: 700; }
.foot { text-align: center; color: var(--ink-3); font-size: 0.8rem; padding: 24px; }

@media (prefers-reduced-motion: no-preference) {
  .meter span { transition: width 600ms ease; }
}

/* ---------- assistant ---------- */
.chat { display: grid; gap: 10px; margin: 12px 0; max-height: 420px; overflow: auto; }
.chat:empty { display: none; }
.msg { padding: 10px 14px; border-radius: 12px; max-width: 80ch; line-height: 1.45; }
.msg.user { background: var(--held-strong); color: #fff; justify-self: end; border-radius: 16px 16px 4px 16px; }
.msg.assistant { background: #f5f8fc; border: 1px solid var(--rule); border-radius: 16px 16px 16px 4px; }
.msg a { word-break: break-all; }
.tool-calls { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 4px; font-size: 0.82rem; color: var(--ink-2); }
.tool-src { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; margin-right: 4px; }
.tool-src.proofpay { background: var(--held-soft); color: var(--held-strong); }
.tool-src.paypal-agent-toolkit { background: #e6effc; color: #1c5cb0; }
.ask { display: flex; gap: 8px; }
