:root {
  color-scheme: light;
  --ink: #17201e;
  --muted: #66716e;
  --line: #dce2df;
  --soft-line: #edf0ee;
  --surface: #ffffff;
  --canvas: #f5f7f6;
  --accent: #176b55;
  --accent-hover: #105541;
  --accent-soft: #e8f4ef;
  --warning: #9a5d0b;
  --warning-soft: #fff7e8;
  --danger: #a33b36;
  --danger-soft: #fff0ef;
  --radius: 6px;
  --shadow: 0 8px 26px rgba(23, 32, 30, 0.06);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); font-size: 14px; line-height: 1.45; }
button, input, select, textarea { color: inherit; font: inherit; letter-spacing: 0; }
button, label[for] { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-header { height: 60px; background: #173f36; color: #fff; }
.header-inner, main, footer { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.header-inner { height: 100%; display: flex; align-items: center; justify-content: space-between; }
.brand { color: inherit; display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border: 1px solid rgba(255,255,255,.48); display: grid; place-items: center; font-weight: 700; }
.brand strong, .brand small { display: block; letter-spacing: 0; }
.brand strong { font-size: 14px; line-height: 1.2; }
.brand small { margin-top: 2px; color: rgba(255,255,255,.7); font-size: 11px; }
.header-meta { display: flex; align-items: center; gap: 20px; color: rgba(255,255,255,.72); font-size: 12px; }
.environment { display: inline-flex; align-items: center; gap: 7px; color: #fff; }
.environment > span { width: 7px; height: 7px; border-radius: 50%; background: #6fe0b8; box-shadow: 0 0 0 3px rgba(111,224,184,.14); }

main { padding: 30px 0 54px; min-height: calc(100dvh - 112px); }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 28px; margin-bottom: 24px; }
.page-heading h1 { margin: 0; font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: 0; }
.page-heading p { margin: 7px 0 0; color: var(--muted); max-width: 650px; }
.privacy-note { display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; }
.privacy-note strong { font-size: 12px; }
.privacy-note small { margin-top: 2px; color: var(--muted); }

.tabs { display: flex; align-items: center; gap: 26px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tab { position: relative; border: 0; background: transparent; padding: 0 0 11px; color: var(--muted); font-weight: 650; }
.tab::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: transparent; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); }
.tab.active::after { background: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.demo-tools { margin: 0 0 14px; color: var(--muted); }
.demo-tools > summary { width: max-content; cursor: pointer; font-size: 12px; font-weight: 650; list-style-position: inside; }
.segmented { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.segmented button { border: 1px solid var(--line); border-radius: 4px; background: var(--surface); padding: 7px 10px; color: var(--muted); font-size: 12px; }
.segmented button:hover { border-color: #aeb9b5; color: var(--ink); }
.segmented button.selected { border-color: #a9cfc1; background: var(--accent-soft); color: var(--accent); }

.workspace-grid { display: grid; grid-template-columns: minmax(360px, .78fr) minmax(520px, 1.22fr); gap: 16px; align-items: start; }
.input-panel, .result-panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.result-panel { position: sticky; top: 16px; }
.panel-heading { min-height: 68px; display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--soft-line); }
.panel-heading h2 { margin: 0; font-size: 16px; line-height: 1.3; }
.panel-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.step-number { flex: 0 0 auto; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 750; }
.result-heading { justify-content: flex-start; }
.result-heading div { flex: 1; }

.source-list { padding: 4px 20px 0; }
.source-row { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; min-height: 78px; border-bottom: 1px solid var(--soft-line); }
.source-copy { min-width: 0; }
.source-copy strong { display: block; font-size: 13px; }
.file-status { margin: 4px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.upload-button { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; border: 1px solid var(--accent); border-radius: 4px; background: var(--accent); color: #fff; padding: 0 12px; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.upload-button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.upload-button.secondary { background: var(--surface); color: var(--accent); }
.upload-button.secondary:hover { background: var(--accent-soft); }

.primary-action { width: calc(100% - 40px); min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 10px; margin: 18px 20px; border: 1px solid var(--accent); border-radius: 4px; background: var(--accent); color: #fff; font-weight: 750; }
.primary-action:hover { background: var(--accent-hover); }
.primary-action:active, .upload-button:active, .decision-actions button:active { transform: translateY(1px); }
.primary-action:disabled { cursor: wait; opacity: .64; }
.button-arrow { font-size: 18px; line-height: 1; }
.input-error { margin: -8px 20px 16px; border-left: 3px solid var(--danger); background: var(--danger-soft); padding: 9px 11px; color: var(--danger); font-size: 12px; }

.data-details, .result-details { border-top: 1px solid var(--soft-line); }
.data-details > summary, .result-details > summary { min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 20px; cursor: pointer; font-weight: 650; list-style: none; }
.data-details > summary::-webkit-details-marker, .result-details > summary::-webkit-details-marker { display: none; }
.data-details > summary::after, .result-details > summary::after { content: "+"; color: var(--muted); font-size: 18px; font-weight: 400; }
.data-details[open] > summary::after, .result-details[open] > summary::after { content: "−"; }
.result-details > summary > small { margin-left: auto; color: var(--muted); font-weight: 500; }
.details-body { padding: 0 20px 20px; }
.field-label, .form-grid label > span { display: block; margin-bottom: 6px; color: #43504d; font-size: 11px; font-weight: 700; }
textarea, input, select { width: 100%; border: 1px solid #cdd5d2; border-radius: 3px; background: #fff; }
input, select { height: 38px; padding: 0 10px; }
textarea { min-height: 176px; padding: 10px; resize: vertical; font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(23,107,85,.18); border-color: var(--accent); }
.field-help { margin: 7px 0 0; color: var(--muted); font-size: 11px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; }
.form-grid-wide { grid-column: 1 / -1; }
.compact-textarea { min-height: 92px; }
.subsection-title { margin: 20px 0 12px; padding-top: 16px; border-top: 1px solid var(--soft-line); font-size: 12px; }

.empty-state { min-height: 360px; display: grid; place-content: center; text-align: center; padding: 30px; }
.empty-state h3 { margin: 0; font-size: 17px; }
.empty-state p { margin: 6px 0 0; color: var(--muted); }
.processing-state { min-height: 360px; padding: 46px 36px; }
.progress-line { height: 3px; overflow: hidden; background: var(--soft-line); }
.progress-line span { display: block; width: 38%; height: 100%; background: var(--accent); animation: progress 1.1s ease-in-out infinite; }
.processing-state ol { margin: 28px 0 0; padding: 0; list-style: none; }
.processing-state li { display: flex; align-items: center; gap: 10px; padding: 8px 0; color: #9aa29f; }
.processing-state li > span { width: 8px; height: 8px; border-radius: 50%; border: 1px solid currentColor; }
.processing-state li.current { color: var(--accent); }
.processing-state li.complete { color: var(--ink); }
.processing-state li.complete > span { border-color: var(--accent); background: var(--accent); }
@keyframes progress { 0% { transform: translateX(-110%); } 100% { transform: translateX(310%); } }

.decision-banner { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 18px 20px 0; border-left: 4px solid var(--warning); background: var(--warning-soft); padding: 16px; }
.decision-banner.success { border-left-color: var(--accent); background: var(--accent-soft); }
.decision-banner.danger { border-left-color: var(--danger); background: var(--danger-soft); }
.decision-banner span:first-child { display: block; color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.decision-banner strong { display: block; margin-top: 4px; font-size: 21px; line-height: 1.2; }
.decision-code { flex: 0 0 auto; border: 1px solid currentColor; padding: 4px 6px; color: var(--muted); font-family: "SFMono-Regular", Consolas, monospace; font-size: 9px; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 20px; border: 1px solid var(--soft-line); border-top: 0; }
.metrics > div { min-width: 0; padding: 14px; }
.metrics > div + div { border-left: 1px solid var(--soft-line); }
.metrics span, .metrics strong { display: block; }
.metrics span { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.metrics strong { margin-top: 5px; font-size: 16px; overflow-wrap: anywhere; }
.action-block { padding: 20px; }
.action-block h3 { margin: 0 0 8px; font-size: 13px; }
.review-note { margin: 0; border-left: 2px solid #bcc7c3; padding-left: 10px; color: #46514e; }
.decision-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.decision-actions button, .output-actions button, #clear-audit { min-height: 34px; border: 1px solid #bcc7c3; border-radius: 4px; background: #fff; padding: 0 11px; font-size: 12px; font-weight: 700; }
.decision-actions button:hover, .output-actions button:hover, #clear-audit:hover { border-color: var(--accent); color: var(--accent); }
#approve-review, #create-payment { border-color: var(--accent); background: var(--accent); color: #fff; }
#approve-review:hover, #create-payment:hover { background: var(--accent-hover); color: #fff; }
#reject-review { border-color: #d7aaa7; color: var(--danger); }
.action-status { margin: 12px 0 0; background: var(--accent-soft); padding: 9px 10px; color: var(--accent); font-size: 12px; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th, td { padding: 10px 12px; border-top: 1px solid var(--soft-line); text-align: left; vertical-align: top; }
th { background: #fafbfa; color: var(--muted); font-size: 10px; font-weight: 700; }
td:first-child { color: var(--ink); font-weight: 650; }
.check-badge { display: inline-block; min-width: 54px; padding: 2px 5px; text-align: center; font-size: 9px; font-weight: 800; }
.check-badge.pass { background: var(--accent-soft); color: var(--accent); }
.check-badge.fail { background: var(--danger-soft); color: var(--danger); }
.check-badge.unknown { background: var(--warning-soft); color: var(--warning); }
.output-actions { display: flex; gap: 6px; padding: 0 20px 10px; }
pre { max-height: 320px; overflow: auto; margin: 0 20px 20px; background: #182320; color: #e7efec; padding: 14px; font: 11px/1.55 "SFMono-Regular", Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.audit-footer { display: flex; align-items: center; gap: 8px; min-height: 42px; margin: 0 20px; border-top: 1px solid var(--soft-line); color: var(--muted); font-size: 10px; }
.audit-footer strong { color: var(--ink); font-family: "SFMono-Regular", Consolas, monospace; }

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-heading h2 { margin: 0; font-size: 22px; }
.section-heading p { margin: 5px 0 0; color: var(--muted); }
.audit-panel, .workflow-panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 22px; box-shadow: var(--shadow); }
.audit-table-wrap { border: 1px solid var(--soft-line); }
.audit-empty { padding: 70px 20px; border: 1px dashed #cdd5d2; color: var(--muted); text-align: center; }
.flow-list { display: grid; grid-template-columns: repeat(5, 1fr); margin: 24px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.flow-list li { display: flex; gap: 10px; padding: 18px 12px; }
.flow-list li + li { border-left: 1px solid var(--soft-line); }
.flow-list li > span { flex: 0 0 auto; color: var(--accent); font-weight: 800; }
.flow-list strong { display: block; font-size: 12px; }
.flow-list p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.policy-grid { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 22px; border: 1px solid var(--line); }
.policy-grid section { padding: 18px; }
.policy-grid section + section { border-left: 1px solid var(--line); }
.policy-grid h3 { margin: 0; font-size: 13px; }
.policy-grid p { margin: 6px 0 0; color: var(--muted); }
.prototype-scope { max-width: 820px; margin: 18px 0 0; color: var(--muted); font-size: 12px; }
.prototype-scope strong { color: var(--ink); }

footer { min-height: 52px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }

@media (max-width: 960px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .result-panel { position: static; }
  .flow-list { grid-template-columns: 1fr; }
  .flow-list li + li { border-left: 0; border-top: 1px solid var(--soft-line); }
}

@media (max-width: 640px) {
  .header-inner, main, footer { width: min(100% - 24px, 1180px); }
  .app-header { height: 56px; }
  .policy-version { display: none; }
  main { padding-top: 22px; }
  .page-heading { align-items: flex-start; margin-bottom: 20px; }
  .page-heading h1 { font-size: 24px; }
  .privacy-note { display: none; }
  .tabs { gap: 22px; overflow-x: auto; }
  .demo-tools > summary { width: auto; }
  .segmented { display: grid; grid-template-columns: 1fr 1fr; }
  .workspace-grid { display: block; }
  .result-panel { margin-top: 14px; }
  .panel-heading { padding: 16px; }
  .source-list { padding: 2px 16px 0; }
  .source-row { grid-template-columns: 1fr; gap: 10px; padding: 14px 0; }
  .upload-button { width: 100%; }
  .primary-action { width: calc(100% - 32px); margin: 16px; }
  .data-details > summary, .result-details > summary { padding: 0 16px; }
  .details-body { padding: 0 16px 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid-wide { grid-column: auto; }
  .decision-banner { margin: 16px 16px 0; }
  .decision-code { display: none; }
  .metrics { margin: 0 16px; }
  .metrics > div { padding: 12px 9px; }
  .metrics strong { font-size: 13px; }
  .action-block { padding: 18px 16px; }
  .decision-actions { display: grid; }
  .decision-actions button { width: 100%; }
  .table-wrap { margin: 0; }
  th, td { min-width: 90px; padding: 9px; }
  td:last-child { min-width: 230px; }
  pre { margin: 0 16px 16px; }
  .output-actions { padding: 0 16px 10px; }
  .audit-footer { margin: 0 16px; flex-wrap: wrap; }
  .audit-panel, .workflow-panel { padding: 16px; }
  .section-heading { align-items: flex-start; }
  .policy-grid { grid-template-columns: 1fr; }
  .policy-grid section + section { border-left: 0; border-top: 1px solid var(--line); }
  footer { flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
