:root {
  color-scheme: light;
  --bg: #f4f8f9;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-hover: #e9e9ee;
  --surface-soft: #fafafa;
  --surface-strong: #f0f0f3;
  --border: #d5e1e5;
  --border-soft: #e7e7eb;
  --text: #102d40;
  --text-strong: #102d40;
  --muted: #57707d;
  --muted-strong: #505058;
  --accent: #147d78;
  --accent-hover: #106560;
  --accent-soft: rgba(20, 125, 120, 0.1);
  --accent-border: rgba(20, 125, 120, 0.42);
  --focus-ring: #106560;
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.1);
  --warning: #825500;
  --warning-soft: rgba(234, 179, 8, 0.12);
  --danger: #dc2626;
  --danger-soft: rgba(239, 68, 68, 0.1);
  --shadow-sm: 0 1px 2px rgba(19, 19, 24, 0.04), 0 5px 14px rgba(19, 19, 24, 0.035);
  --shadow-md: 0 16px 42px rgba(25, 25, 30, 0.08), 0 2px 8px rgba(25, 25, 30, 0.04);
  --radius-control: 5px;
  --radius-card: 8px;
  --radius-large: 8px;
  --font-sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #102d40;
  --surface: #222227;
  --surface-raised: #26262c;
  --surface-hover: #303038;
  --surface-soft: #17171a;
  --surface-strong: #2b2b31;
  --border: #34343c;
  --border-soft: #2b2b31;
  --text: #e8e8ec;
  --text-strong: #fafafa;
  --muted: #9999a3;
  --muted-strong: #b3b3bb;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --accent-border: rgba(96, 165, 250, 0.5);
  --focus-ring: #93c5fd;
  --success: #4ade80;
  --success-soft: rgba(34, 197, 94, 0.12);
  --warning: #facc15;
  --warning-soft: rgba(250, 204, 21, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.16), 0 6px 16px rgba(0, 0, 0, 0.12);
  --shadow-md: 0 18px 46px rgba(0, 0, 0, 0.28), 0 2px 8px rgba(0, 0, 0, 0.2);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

svg {
  display: block;
}

.is-hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 9px 12px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text-strong);
  box-shadow: var(--shadow-md);
  font-weight: 650;
  text-decoration: none;
  transform: translateY(calc(-100% - 20px));
  transition: transform 120ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 80px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(18px);
}

.product-identity {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  width: fit-content;
  color: inherit;
  text-decoration: none;
}

.product-mark {
  width: 39px;
  height: 39px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.product-mark svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--text-strong);
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.product-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.product-name {
  color: var(--text-strong);
  font-size: 15px;
  font-weight: 710;
  letter-spacing: -0.015em;
}

.workspace-name {
  max-width: 210px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-tabs {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--surface-strong);
}

.stage-tab {
  position: relative;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted-strong);
  cursor: pointer;
  font-size: 13px;
  font-weight: 570;
  white-space: nowrap;
  transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.stage-tab:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--surface-hover) 72%, transparent);
}

.stage-tab.is-active {
  color: var(--text-strong);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.stage-index {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1;
}

.stage-tab.is-active .stage-index {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.stage-alert {
  position: absolute;
  top: 6px;
  right: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 2px var(--surface-strong);
}

.header-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.privacy-pill,
.heading-badge,
.mini-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 560;
  white-space: nowrap;
}

.privacy-pill {
  height: 36px;
  padding: 0 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--border) 45%, var(--text));
  background: var(--surface-hover);
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.new-button {
  background: var(--text-strong);
  color: var(--bg);
  border-color: var(--text-strong);
}

.new-button:hover {
  background: var(--text);
  border-color: var(--text);
}

.theme-icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-icon-moon {
  display: block;
}

.workspace {
  min-width: 0;
}

.app-view {
  display: none;
  width: min(100%, 1480px);
  min-height: calc(100vh - 131px);
  min-height: calc(100dvh - 131px);
  margin: 0 auto;
  padding: 38px clamp(22px, 3.5vw, 56px) 48px;
  animation: view-in 190ms ease-out;
}

.app-view.is-active {
  display: block;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 32px;
  margin-bottom: 26px;
}

.view-heading > div:first-child {
  max-width: 760px;
}

.view-heading h1 {
  margin: 4px 0 8px;
  color: var(--text-strong);
  font-size: clamp(27px, 3vw, 40px);
  font-weight: 710;
  letter-spacing: -0.042em;
  line-height: 1.08;
  text-wrap: balance;
}

.view-heading p {
  max-width: 710px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.compact-heading h1 {
  font-size: clamp(26px, 2.7vw, 36px);
}

.eyebrow,
.panel-kicker {
  display: block;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.09em;
  line-height: 1.4;
  text-transform: uppercase;
}

.heading-badge {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 8px 13px;
}

.verified-badge {
  color: color-mix(in srgb, var(--success) 70%, var(--text));
}

.warning-badge {
  border-color: color-mix(in srgb, var(--warning) 38%, var(--border));
  background: var(--warning-soft);
  color: color-mix(in srgb, var(--warning) 63%, var(--text));
}

.warning-badge > span {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--warning);
  color: #171717;
  font-size: 11px;
  font-weight: 800;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.panel h2 {
  margin: 4px 0 8px;
  color: var(--text-strong);
  font-size: 19px;
  font-weight: 680;
  letter-spacing: -0.025em;
  line-height: 1.22;
}

.panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.input-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.7fr);
  align-items: stretch;
  gap: 18px;
}

.intake-panel {
  min-height: 540px;
  display: grid;
  grid-template-columns: minmax(300px, 0.78fr) minmax(360px, 1.22fr);
  overflow: hidden;
}

.intake-copy {
  position: relative;
  z-index: 3;
  padding: 30px;
  border-right: 1px solid var(--border-soft);
}

.intake-copy > h2 {
  margin-top: 7px;
  font-size: clamp(22px, 2vw, 29px);
}

.intake-copy > p {
  max-width: 430px;
  font-size: 14px;
  line-height: 1.6;
}

.drop-zone {
  min-height: 172px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 28px;
  padding: 23px;
  border: 1px dashed color-mix(in srgb, var(--border) 72%, var(--accent));
  border-radius: 14px;
  background: var(--surface-soft);
  cursor: pointer;
  text-align: center;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  margin-bottom: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.drop-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.drop-title {
  color: var(--text-strong);
  font-size: 14px;
  font-weight: 650;
}

.drop-help {
  color: var(--muted);
  font-size: 11px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  cursor: pointer;
  font-size: 12px;
  font-weight: 640;
  line-height: 1;
  text-decoration: none;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease, opacity 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.43;
}

.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button-primary:hover:not(:disabled) {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.button-secondary {
  border-color: var(--border);
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.button-secondary:hover:not(:disabled),
.button-ghost:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--border) 50%, var(--text));
  background: var(--surface-hover);
}

.button-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted-strong);
}

.button-full {
  width: 100%;
}

.inline-message {
  margin-top: 13px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--warning) 35%, var(--border));
  border-radius: var(--radius-control);
  background: var(--warning-soft);
  color: var(--text);
  font-size: 11px;
}

.document-canvas {
  position: relative;
  min-height: 540px;
  overflow: hidden;
  background:
    radial-gradient(circle at 72% 36%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 37%),
    linear-gradient(145deg, var(--surface-soft), color-mix(in srgb, var(--surface-strong) 78%, var(--surface)));
}

.document-canvas::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.38;
  background-image: radial-gradient(var(--border) 0.75px, transparent 0.75px);
  background-size: 18px 18px;
  mask-image: linear-gradient(90deg, transparent, black 30%, black 100%);
}

.canvas-chip {
  position: absolute;
  z-index: 3;
  left: 7%;
  width: 150px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: color-mix(in srgb, var(--surface-raised) 92%, transparent);
  color: var(--muted-strong);
  box-shadow: var(--shadow-sm);
  font-size: 11px;
  font-weight: 600;
  backdrop-filter: blur(8px);
}

.canvas-chip span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
}

.chip-source { top: 15%; }
.chip-rule { top: 42%; }
.chip-review { top: 69%; }

.canvas-lines {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: var(--border);
  stroke-width: 1.25;
}

.tax-sheet {
  position: absolute;
  z-index: 2;
  top: 10%;
  right: 6.5%;
  width: min(56%, 350px);
  min-height: 430px;
  padding: 28px 26px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
  transform: rotate(1.2deg);
}

.tax-sheet::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 12px -12px -12px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  background: color-mix(in srgb, var(--surface) 86%, var(--bg));
}

.sheet-header,
.sheet-row,
.sheet-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.sheet-header {
  color: var(--text-strong);
  font-size: 12px;
  font-weight: 780;
  letter-spacing: 0.05em;
}

.sheet-header > span > span {
  color: var(--accent);
}

.sheet-header small {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
}

.sheet-title {
  margin-top: 31px;
  color: var(--text-strong);
  font-size: 20px;
  font-weight: 690;
  letter-spacing: -0.03em;
}

.sheet-rule {
  height: 1px;
  margin: 17px 0;
  background: var(--border);
}

.sheet-row {
  padding: 9px 0;
  color: var(--text);
  font-size: 11px;
}

.sheet-row strong {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
}

.sheet-row.muted {
  color: var(--muted);
}

.sheet-row.total {
  color: var(--text-strong);
  font-size: 12px;
  font-weight: 700;
}

.sheet-row.total strong {
  color: var(--accent);
  font-size: 12px;
}

.sheet-foot {
  position: absolute;
  right: 26px;
  bottom: 24px;
  left: 26px;
  justify-content: flex-start;
  color: var(--muted);
  font-size: 9px;
}

.sheet-foot .status-dot {
  width: 6px;
  height: 6px;
}

.input-sidebar {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.typed-panel,
.scope-panel {
  padding: 23px;
}

.panel-heading-row,
.panel-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.mini-badge {
  padding: 5px 9px;
  background: var(--surface-soft);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.03em;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0 17px;
}

.field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted-strong);
  font-size: 11px;
  font-weight: 580;
}

.field-wide {
  grid-column: 1 / -1;
}

.money-input {
  min-height: 39px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface-soft);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.money-input:focus-within {
  border-color: var(--accent);
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: none;
}

.money-input > span {
  padding-left: 10px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
}

.money-input input {
  min-width: 0;
  width: 100%;
  padding: 9px 10px 9px 5px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: right;
}

.scope-panel {
  flex: 1;
  background: var(--surface-soft);
}

.scope-list {
  display: grid;
  gap: 15px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.scope-list li {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: flex-start;
  gap: 9px;
  color: var(--muted);
  font-size: 11px;
}

.scope-list strong {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
  font-size: 12px;
}

.check-icon,
.stop-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 800;
}

.check-icon {
  background: var(--success-soft);
  color: var(--success);
}

.stop-icon {
  background: var(--warning-soft);
  color: var(--warning);
}

.loaded-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-top: 18px;
  padding: 18px 20px;
  border-color: var(--accent-border);
  background: linear-gradient(120deg, var(--accent-soft), var(--surface) 42%);
}

.loaded-summary {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 13px;
}

.loaded-summary h2 {
  margin: 2px 0;
  font-size: 15px;
}

.loaded-icon {
  width: 39px;
  height: 39px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent-border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--accent);
}

.loaded-icon svg,
.empty-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trust-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 28px;
}

.trust-grid article {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 4px 8px;
}

.trust-icon {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
}

.trust-grid strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text);
  font-size: 12px;
}

.trust-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.review-metrics {
  flex: 0 0 auto;
  display: flex;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.review-metrics > span {
  min-width: 92px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 9px 13px;
  border-right: 1px solid var(--border-soft);
}

.review-metrics > span:last-child {
  border-right: 0;
}

.review-metrics small {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.review-metrics strong {
  color: var(--text-strong);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 620;
}

.empty-state {
  min-height: 430px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 45px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-card);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  text-align: center;
}

.empty-icon {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  margin-bottom: 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted-strong);
  box-shadow: var(--shadow-sm);
}

.empty-state h2 {
  margin: 0 0 5px;
  color: var(--text-strong);
  font-size: 18px;
}

.empty-state p {
  margin: 0 0 17px;
  color: var(--muted);
  font-size: 13px;
}

.review-layout {
  height: min(690px, calc(100vh - 250px));
  min-height: 510px;
  display: grid;
  grid-template-columns: minmax(310px, 0.72fr) minmax(500px, 1.28fr);
  gap: 18px;
}

.transaction-panel,
.treatment-panel {
  min-height: 0;
  overflow: hidden;
}

.transaction-panel {
  display: flex;
  flex-direction: column;
}

.panel-toolbar {
  flex: 0 0 auto;
  align-items: center;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-soft);
}

.panel-toolbar h2 {
  margin-bottom: 0;
  font-size: 16px;
}

.transaction-list {
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  scrollbar-color: var(--border) transparent;
  scrollbar-width: thin;
}

.transaction-item {
  width: 100%;
  display: grid;
  grid-template-columns: 31px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: border-color 130ms ease, background 130ms ease;
}

.transaction-item:hover {
  background: var(--surface-hover);
}

.transaction-item.is-selected {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.transaction-item.is-unset:not(.is-selected) {
  background: var(--warning-soft);
}

.transaction-number {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
}

.transaction-copy {
  min-width: 0;
}

.transaction-copy strong,
.transaction-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.transaction-copy strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.transaction-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.transaction-amount {
  color: var(--text-strong);
  font-family: var(--font-mono);
  font-size: 10px;
  white-space: nowrap;
}

.treatment-panel {
  display: flex;
  flex-direction: column;
}

#treatmentInspector {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: clamp(22px, 3vw, 36px);
}

.inspector-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border-soft);
}

.inspector-heading h2 {
  max-width: 650px;
  margin: 5px 0 7px;
  font-size: clamp(22px, 2.5vw, 30px);
}

.inspector-heading p {
  font-family: var(--font-mono);
  font-size: 10px;
}

.amount-card {
  flex: 0 0 auto;
  min-width: 135px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  text-align: right;
}

.amount-card small {
  display: block;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  text-transform: uppercase;
}

.amount-card strong {
  color: var(--text-strong);
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 620;
}

.treatment-control {
  margin-top: 25px;
}

.treatment-control > label {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 630;
}

.select-wrap {
  position: relative;
}

.select-wrap::after {
  content: "⌄";
  position: absolute;
  top: 50%;
  right: 14px;
  color: var(--muted);
  pointer-events: none;
  transform: translateY(-55%);
}

.treatment-select {
  width: 100%;
  min-height: 46px;
  padding: 10px 40px 10px 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  appearance: none;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
}

.treatment-select:focus {
  border-color: var(--accent);
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: none;
}

.treatment-explanation {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 19px;
}

.explanation-card {
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--surface-soft);
}

.explanation-card small,
.summary-card small,
.filing-card small {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.explanation-card strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 11px;
}

.explanation-card p {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.treatment-tip {
  display: flex;
  gap: 10px;
  margin-top: 19px;
  padding: 13px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
}

.treatment-tip > span {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
}

.review-footer {
  flex: 0 0 auto;
  min-height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-soft);
}

.gate-message {
  color: var(--muted);
  font-size: 11px;
}

.gate-message strong {
  color: var(--warning);
}

.compute-button {
  min-width: 145px;
}

.result-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.55fr);
  align-items: start;
  gap: 18px;
}

.schedule-panel {
  overflow: hidden;
}

.schedule-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 26px 28px 20px;
  border-bottom: 1px solid var(--border-soft);
}

.schedule-header h2 {
  margin: 5px 0 4px;
  font-size: 22px;
}

.schedule-header p {
  font-family: var(--font-mono);
  font-size: 9px;
}

.draft-stamp {
  padding: 6px 9px;
  border: 1px solid color-mix(in srgb, var(--warning) 45%, var(--border));
  border-radius: 8px;
  background: var(--warning-soft);
  color: color-mix(in srgb, var(--warning) 66%, var(--text));
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.tax-table-wrap {
  padding: 15px 28px 25px;
}

.tax-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.tax-table th,
.tax-table td {
  padding: 8px 0;
  vertical-align: top;
}

.tax-table th {
  font-weight: inherit;
  text-align: left;
}

.tax-table th:first-child {
  padding-right: 14px;
  color: var(--text);
}

.tax-table .tax-number {
  width: 150px;
  color: var(--text-strong);
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: right;
  white-space: nowrap;
}

.tax-table .tax-ref {
  width: 90px;
  padding-left: 14px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  text-align: right;
}

.tax-table tr.tax-section th {
  padding-top: 21px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 680;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tax-table tr.tax-total th,
.tax-table tr.tax-total td {
  padding-top: 11px;
  border-top: 1px solid var(--border);
  color: var(--text-strong);
  font-weight: 700;
}

.tax-table tr.tax-payable th,
.tax-table tr.tax-payable td {
  padding-top: 13px;
  border-top: 2px solid var(--text-strong);
  color: var(--text-strong);
  font-size: 14px;
  font-weight: 760;
}

.tax-table tr.tax-payable .tax-number {
  color: var(--accent);
  font-size: 15px;
}

.schedule-proof {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 28px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-soft);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
}

.schedule-proof .status-dot {
  width: 6px;
  height: 6px;
}

.result-sidebar {
  display: grid;
  gap: 13px;
}

.summary-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.summary-card.hero-summary {
  min-height: 148px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-color: var(--accent-border);
  background: linear-gradient(145deg, var(--accent-soft), var(--surface) 58%);
}

.summary-card .summary-value {
  display: block;
  color: var(--text-strong);
  font-family: var(--font-mono);
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 650;
  letter-spacing: -0.045em;
}

.summary-card .summary-note {
  color: var(--muted);
  font-size: 10px;
}

.abstain-detail {
  margin-top: 12px;
}

.summary-card .abstain-value {
  font-size: 23px;
}

.summary-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.summary-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 10px;
}

.summary-list strong {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-align: right;
}

.abstain-card {
  padding: 28px;
  border-color: color-mix(in srgb, var(--warning) 48%, var(--border));
  background: linear-gradient(145deg, var(--warning-soft), var(--surface) 60%);
}

.abstain-card h2 {
  margin-top: 8px;
  font-size: 24px;
}

.abstain-code {
  display: inline-flex;
  padding: 5px 8px;
  border-radius: 7px;
  background: var(--warning-soft);
  color: color-mix(in srgb, var(--warning) 68%, var(--text));
  font-family: var(--font-mono);
  font-size: 9px;
}

.result-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-top: 18px;
  padding: 15px 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
}

.result-actions > div {
  display: flex;
  gap: 8px;
}

.filing-content {
  display: grid;
  gap: 18px;
}

.filing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.filing-card {
  min-height: 190px;
  display: flex;
  flex-direction: column;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.filing-card-header {
  display: flex;
  justify-content: space-between;
  gap: 15px;
}

.filing-card h2 {
  margin: 4px 0;
  color: var(--text-strong);
  font-size: 17px;
  letter-spacing: -0.02em;
}

.filing-box {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
}

.filing-value {
  margin-top: auto;
  padding-top: 22px;
  color: var(--text-strong);
  font-family: var(--font-mono);
  font-size: 27px;
  font-weight: 640;
  letter-spacing: -0.045em;
}

.filing-source {
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
}

.filing-note {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px;
  background: var(--surface-soft);
}

.filing-note h2 {
  font-size: 15px;
}

.filing-note-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
}

.status-bar {
  min-height: 50px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  padding: 10px 28px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 10px;
}

.status-bar > div,
.status-meta {
  display: flex;
  align-items: center;
  gap: 9px;
}

.status-state {
  justify-self: start;
}

.maker-signature {
  justify-self: center;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.035em;
}

.maker-signature strong {
  color: var(--text-strong);
  font-weight: 700;
}

.status-bar .status-dot {
  width: 7px;
  height: 7px;
}

.status-meta {
  justify-self: end;
  gap: 0;
}

.status-meta span {
  padding: 0 10px;
  border-right: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.02em;
}

.status-meta span:last-child {
  padding-right: 0;
  border-right: 0;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 24px;
  bottom: 68px;
  max-width: min(360px, calc(100vw - 48px));
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--text-strong);
  color: var(--bg);
  box-shadow: var(--shadow-md);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .app-header {
    grid-template-columns: auto 1fr auto;
  }

  .stage-tabs {
    justify-self: center;
  }

  .stage-tab {
    padding-inline: 10px;
  }

  .stage-index {
    display: none;
  }

  .privacy-label {
    display: none;
  }

  .privacy-pill {
    width: 38px;
    justify-content: center;
    padding: 0;
  }

  .input-layout {
    grid-template-columns: 1fr;
  }

  .input-sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .result-layout {
    grid-template-columns: minmax(0, 1.3fr) minmax(260px, 0.7fr);
  }
}

@media (max-width: 920px) {
  .app-header {
    position: static;
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding: 12px 18px 0;
  }

  .stage-tabs {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    justify-content: stretch;
    overflow-x: auto;
  }

  .stage-tab {
    flex: 1 0 auto;
    justify-content: center;
  }

  .app-view {
    min-height: calc(100vh - 165px);
    padding: 28px 20px 38px;
  }

  .view-heading {
    align-items: flex-start;
  }

  .intake-panel {
    grid-template-columns: 1fr;
  }

  .intake-copy {
    border-right: 0;
    border-bottom: 1px solid var(--border-soft);
  }

  .document-canvas {
    min-height: 470px;
  }

  .review-layout {
    height: auto;
    grid-template-columns: 1fr;
  }

  .transaction-panel {
    max-height: 430px;
  }

  .treatment-panel {
    min-height: 520px;
  }

  .result-layout {
    grid-template-columns: 1fr;
  }

  .result-sidebar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-card.hero-summary {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .app-header {
    padding-inline: 12px;
  }

  .product-mark {
    width: 36px;
    height: 36px;
  }

  .workspace-name,
  .source-button,
  .privacy-pill {
    display: none;
  }

  .header-actions {
    gap: 6px;
  }

  .icon-button {
    width: 36px;
    height: 36px;
  }

  .stage-tabs {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .stage-tab {
    padding-inline: 11px;
    font-size: 11px;
  }

  .app-view {
    padding: 24px 13px 34px;
  }

  .view-heading {
    display: block;
  }

  .view-heading h1 {
    font-size: 27px;
  }

  .heading-badge,
  .review-metrics {
    margin-top: 16px;
  }

  .review-metrics {
    width: 100%;
  }

  .review-metrics > span {
    min-width: 0;
    flex: 1;
  }

  .intake-copy,
  .typed-panel,
  .scope-panel {
    padding: 20px;
  }

  .document-canvas {
    min-height: 410px;
  }

  .canvas-chip {
    left: 4%;
    width: 122px;
    padding: 8px 9px;
    font-size: 9px;
  }

  .tax-sheet {
    right: 4%;
    width: 62%;
    min-height: 360px;
    padding: 21px 18px;
  }

  .sheet-title {
    margin-top: 22px;
    font-size: 16px;
  }

  .sheet-row {
    font-size: 9px;
  }

  .sheet-foot {
    right: 18px;
    bottom: 18px;
    left: 18px;
  }

  .input-sidebar,
  .trust-grid,
  .field-grid,
  .treatment-explanation,
  .result-sidebar,
  .filing-grid {
    grid-template-columns: 1fr;
  }

  .field-wide,
  .summary-card.hero-summary {
    grid-column: auto;
  }

  .loaded-panel,
  .result-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .loaded-panel .button,
  .result-actions .button {
    width: 100%;
  }

  .result-actions > div {
    flex-direction: column;
  }

  .review-layout {
    gap: 12px;
  }

  .transaction-panel {
    max-height: 370px;
  }

  #treatmentInspector {
    padding: 20px;
  }

  .inspector-heading {
    display: block;
  }

  .amount-card {
    margin-top: 14px;
    text-align: left;
  }

  .review-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .compute-button {
    width: 100%;
  }

  .schedule-header,
  .tax-table-wrap {
    padding-right: 18px;
    padding-left: 18px;
  }

  .tax-table .tax-number {
    width: 82px;
  }

  .tax-table .tax-ref {
    width: 62px;
    padding-left: 7px;
    font-size: 9px;
  }

  .status-bar {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 5px;
    padding-inline: 12px;
  }

  .status-state,
  .maker-signature {
    justify-self: center;
  }

  .status-meta {
    display: none;
  }
}

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

@media print {
  :root,
  :root[data-theme="dark"] {
    color-scheme: light;
    --bg: #fff;
    --surface: #fff;
    --surface-soft: #fff;
    --border: #c8c8c8;
    --border-soft: #e2e2e2;
    --text: #111;
    --text-strong: #000;
    --muted: #555;
    --accent: #111;
    --shadow-sm: none;
  }

  body {
    background: #fff;
  }

  .app-header,
  .status-bar,
  .view-heading,
  .result-actions,
  #view-input,
  #view-review,
  #computationEmpty,
  #filingEmpty,
  .toast {
    display: none !important;
  }

  .app-shell,
  .workspace,
  #view-computation,
  #computationContent,
  #view-filing,
  #filingContent {
    display: block !important;
    min-height: 0;
  }

  #view-computation {
    width: 100%;
    padding: 0;
  }

  #view-filing {
    width: 100%;
    padding: 24px 0 0;
    break-before: page;
  }

  .schedule-panel {
    border: 0;
    box-shadow: none;
  }

  .result-sidebar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 14px;
  }

  .summary-card,
  .filing-card,
  .filing-note {
    break-inside: avoid;
    box-shadow: none;
  }

  .filing-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .schedule-header,
  .tax-table-wrap {
    padding-right: 0;
    padding-left: 0;
  }

  .schedule-proof {
    padding-right: 0;
    padding-left: 0;
  }
}

.maker-signature a{font-weight:600;color:var(--text);text-decoration:none}
