@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600;700;800&family=Playfair+Display:ital,wght@0,600;0,700;1,600&display=swap');

:root {
  --ink: #12182c;
  --muted: #5d6a82;
  --line: #dfe4ed;
  --paper: #f7f7f4;
  --card: #ffffff;
  --mint: #8cf0c7;
  --mint-ink: #0c6b4b;
  --mint-bg: #e3f9f0;
  --blue: #4668ff;
  --blue-bg: #e9eeff;
  --amber: #8a5a00;
  --amber-bg: #fdf0d0;
  --red: #b3261e;
  --red-bg: #fde7e5;
  --grey-bg: #eceff4;
  --display: 'Playfair Display', Georgia, serif;
  --sans: Manrope, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'DM Mono', ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.55 var(--sans); }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }

.shell { max-width: 1120px; margin: 0 auto; padding: 0 20px 72px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 14px 0; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 20px; letter-spacing: -0.8px; }
.mark { background: var(--ink); color: var(--mint); border-radius: 8px; width: 28px; height: 28px; display: grid; place-items: center; font: 700 14px var(--mono); letter-spacing: 0; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { text-decoration: none; padding: 8px 12px; border-radius: 8px; color: #465066; font-weight: 700; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.tabs a:hover { color: var(--ink); background: #ecece6; }
.tabs a[aria-current="page"] { background: var(--ink); color: #fff; }
.who { display: flex; gap: 12px; align-items: center; font-size: 14px; color: var(--muted); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--blue); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.badge { background: var(--amber-bg); color: var(--amber); font: 500 11px var(--mono); padding: 1px 7px; border-radius: 99px; }
.tabs a[aria-current="page"] .badge { background: var(--mint); color: var(--ink); }

.page { padding-top: 28px; display: flex; flex-direction: column; gap: 22px; }
.page h1 { font: 700 clamp(30px, 4.5vw, 44px)/1.05 var(--display); letter-spacing: -1.4px; margin: 0; }
.page h2 { font-size: 18px; margin: 0; letter-spacing: -0.2px; }
.lede { color: var(--muted); max-width: 62ch; margin: 8px 0 0; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.eyebrow { font: 500 12px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: #516077; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.mono { font-family: var(--mono); font-size: 12.5px; }

.btn { border: 0; background: var(--ink); color: #fff; padding: 11px 17px; border-radius: 9px; font-weight: 700; font-size: 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { background: #2c3755; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid #c9d0de; }
.btn.ghost:hover { background: #ecece6; }
.btn.mint { background: var(--mint); color: var(--ink); }
.btn.mint:hover { background: #75e3b8; }
.btn.danger { background: var(--red); }
.btn.danger.ghost { background: transparent; color: var(--red); border: 1px solid #e6b9b5; }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 13px; font-weight: 700; color: #3a4560; }
.field .hint { font-size: 12.5px; color: var(--muted); }
.field input, .field select, .field textarea { padding: 10px 12px; border: 1px solid #c9d0de; border-radius: 9px; background: #fff; width: 100%; min-width: 0; }
.field textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.check input { width: 18px; height: 18px; }

.pill { font: 500 11.5px var(--mono); padding: 3px 9px; border-radius: 99px; white-space: nowrap; letter-spacing: .02em; display: inline-block; }
.pill.allowed, .pill.approved { background: var(--mint-bg); color: var(--mint-ink); }
.pill.approval_required, .pill.pending { background: var(--amber-bg); color: var(--amber); }
.pill.not_allowed, .pill.denied { background: var(--red-bg); color: var(--red); }
.pill.no_rule, .pill.idle { background: var(--grey-bg); color: #4a5568; }
.pill.needs_info { background: var(--blue-bg); color: var(--blue); }

.alert { border-radius: 9px; padding: 10px 14px; font-size: 14px; }
.alert.err { background: var(--red-bg); color: var(--red); }
.alert.ok { background: var(--mint-bg); color: var(--mint-ink); }
.alert.info { background: var(--blue-bg); color: #2a43c4; }
.empty { border: 1px dashed #c9d0de; border-radius: 12px; padding: 28px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* Ask */
.askbox { display: flex; gap: 10px; flex-wrap: wrap; }
.askbox input { flex: 1 1 320px; min-width: 0; font-size: 17px; padding: 14px 16px; border: 1.5px solid #b7c0d3; border-radius: 12px; background: #fff; }
.askbox .btn { padding: 14px 24px; font-size: 15px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid #c9d0de; background: #fff; border-radius: 99px; padding: 6px 12px; font-size: 13px; cursor: pointer; color: #3a4560; }
.chip:hover { border-color: var(--ink); color: var(--ink); }

.answer { border-radius: 14px; border: 1px solid var(--line); background: #fff; overflow: hidden; }
.answer-head { padding: 22px 24px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); }
.answer.allowed .answer-head { background: var(--mint-bg); }
.answer.approval_required .answer-head { background: var(--amber-bg); }
.answer.not_allowed .answer-head { background: var(--red-bg); }
.answer.no_rule .answer-head { background: var(--grey-bg); }
.answer.needs_info .answer-head { background: var(--blue-bg); }
.answer-q { font-size: 14px; color: var(--muted); }
.answer-headline { font: 700 clamp(22px, 3vw, 30px)/1.2 var(--display); letter-spacing: -0.8px; margin: 0; }
.answer-body { padding: 20px 24px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.answer-body section { min-width: 0; }
.answer-body h3 { font: 500 11.5px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: #516077; margin: 0 0 8px; }
.answer-body ul { margin: 0; padding-left: 18px; }
.answer-body li { margin-bottom: 4px; }
.full { grid-column: 1 / -1; }
.approver-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.approver { background: var(--ink); color: #fff; border-radius: 8px; padding: 6px 12px; font-weight: 700; font-size: 14px; }
.approver small { display: block; font-weight: 500; font-size: 11.5px; color: #b8c1d3; }
.quote { margin: 8px 0 0; border-left: 3px solid var(--mint); padding: 4px 0 4px 12px; color: #364058; font-size: 14.5px; }
.src { background: #fafaf7; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.src + .src { margin-top: 10px; }
.src b { font-size: 14px; }
.answer-foot { padding: 14px 24px; border-top: 1px solid var(--line); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; background: #fcfcfa; }

/* Tables */
.tablewrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font: 500 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #f4f5f9; }
table.t tr.group td { background: #f1f2ee; font-weight: 800; font-size: 13px; letter-spacing: .02em; }

.steps { display: flex; flex-direction: column; gap: 8px; }
.step { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fcfcfa; }
.step .grow { flex: 1 1 200px; min-width: 0; }
.step input { padding: 7px 10px; border: 1px solid #c9d0de; border-radius: 8px; min-width: 0; flex: 1 1 160px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.stat b { display: block; font: 700 30px/1.1 var(--display); letter-spacing: -1px; }
.stat span { font-size: 13px; color: var(--muted); }

.authwrap { max-width: 440px; margin: 56px auto 0; display: flex; flex-direction: column; gap: 18px; }
.authwrap h1 { font: 700 38px/1.05 var(--display); letter-spacing: -1.4px; margin: 0; }
.authwrap form { display: flex; flex-direction: column; gap: 14px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(22px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 14px; z-index: 20; max-width: calc(100vw - 32px); box-shadow: 0 10px 30px rgba(18, 24, 44, .25); }
.modal { position: fixed; inset: 0; background: rgba(18, 24, 44, .45); display: grid; place-items: center; padding: 16px; z-index: 15; }
.modal .box { background: #fff; border-radius: 14px; padding: 22px; width: min(720px, 100%); max-height: 86vh; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.modal pre { white-space: pre-wrap; background: #f4f5f9; border-radius: 10px; padding: 14px; font: 13px/1.6 var(--mono); margin: 0; max-height: 52vh; overflow: auto; }
.linkbox { background: #f4f5f9; border-radius: 9px; padding: 10px 12px; font: 13px var(--mono); overflow-wrap: anywhere; user-select: all; }

@media (max-width: 820px) {
  .grid2, .grid3, .answer-body, .stats { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .answer-head, .answer-body, .answer-foot { padding-left: 16px; padding-right: 16px; }
  .authwrap { margin-top: 28px; }
}
