:root {
  --background: #f6ead8;
  --paper: #f6ead8;
  --field: #fff8ee;
  --foreground: #152028;
  --ink: #152028;
  --ink-muted: #5a6b76;
  --accent: #0f4c5c;
  --accent-hover: #0c3d4a;
  --line: #d8c4aa;
  --surface: rgba(246, 234, 216, 0.92);
  --header-bg: rgba(246, 234, 216, 0.88);
  --danger: #9b2c2c;
  --danger-soft: #f8e8e8;
  --success: #1f6b4a;
  --success-soft: #e5f4ec;
  --warn: #8a5a12;
  --warn-soft: #f7efd9;
  --font-display: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", serif;
  --font-sans: "Source Sans 3", "Source Sans Pro", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 0.75rem;
  --shadow: 0 18px 50px -36px rgba(15, 40, 50, 0.55);
  --wrap: 74rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-color: var(--background);
  background-image:
    linear-gradient(
      180deg,
      rgba(246, 234, 216, 0.72) 0%,
      rgba(246, 234, 216, 0.64) 45%,
      rgba(236, 220, 196, 0.76) 100%
    ),
    url("/static/images/espp-office-bg.png");
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

@media (max-width: 640px) {
  body {
    background-attachment: scroll;
  }
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: var(--accent);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

p {
  margin: 0 0 0.85rem;
}

p:last-child {
  margin-bottom: 0;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  background: var(--header-bg);
  backdrop-filter: blur(12px);
}

.app-header-inner,
.app-main,
.app-footer {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

@media (min-width: 640px) {
  .app-header-inner,
  .app-main,
  .app-footer {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.app-brand img {
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
}

.app-brand-name {
  display: block;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.app-brand-tag {
  display: none;
  margin-top: 0.15rem;
  font-size: 0.6875rem;
  line-height: 1.3;
  color: var(--ink-muted);
}

@media (min-width: 640px) {
  .app-brand img {
    width: 2.25rem;
    height: 2.25rem;
  }

  .app-brand-name {
    font-size: 1.5rem;
  }

  .app-brand-tag {
    display: block;
  }
}

.app-header-nav {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.app-header-aside {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.header-link {
  color: var(--ink-muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}

.header-link:hover,
.header-link.is-active {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.release-notes {
  position: relative;
}

.release-version {
  list-style: none;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  background: var(--paper);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
}

.release-version::-webkit-details-marker {
  display: none;
}

.release-notes[open] .release-version {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--paper));
}

.release-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 50;
  width: min(22rem, calc(100vw - 2rem));
  max-height: min(24rem, 70vh);
  overflow: auto;
  padding: 0.9rem 1rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.release-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.release-panel-title {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.release-close {
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.release-close:hover {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.release-entry + .release-entry {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.release-entry h3 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  letter-spacing: 0;
}

.release-entry h3 span {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-muted);
}

.release-entry ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.8125rem;
}

.release-entry li + li {
  margin-top: 0.3rem;
}

.app-header-meta {
  font-size: 0.8125rem;
  color: var(--ink-muted);
  text-align: right;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-top: 2rem;
  padding-bottom: 2.5rem;
}

.app-footer {
  padding-bottom: 1.75rem;
  color: var(--ink-muted);
  font-size: 0.8125rem;
}

.page-intro h1 {
  font-size: clamp(1.85rem, 3vw, 2.35rem);
}

.lede {
  max-width: 40rem;
  margin-top: 0.5rem;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.layout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 960px) {
  .layout-grid {
    grid-template-columns: 1fr;
  }
}

.workspace-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(4px);
  padding: 1.25rem;
}

@media (min-width: 640px) {
  .workspace-panel {
    padding: 1.75rem;
  }
}

.panel-title {
  margin-bottom: 0.35rem;
  font-size: 1.5rem;
}

.panel-lede {
  margin-bottom: 1.5rem;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.form-section {
  margin: 0;
  padding: 0 0 1.75rem;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  min-width: 0;
}

.form-section:last-of-type {
  border-bottom: 0;
  padding-bottom: 0;
}

.step-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
  padding: 0;
  float: none;
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink);
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

@media (max-width: 560px) {
  .field-grid {
    grid-template-columns: 1fr;
  }
}

label {
  display: block;
  margin-bottom: 0.85rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
}

label:last-child {
  margin-bottom: 0;
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--field);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.4;
  outline: none;
}

input[type="number"] {
  font-variant-numeric: tabular-nums;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent);
}

input[readonly] {
  background: color-mix(in srgb, var(--line) 22%, var(--field));
  color: var(--ink);
}

input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  margin: 0 0.5rem 0 0;
  accent-color: var(--accent);
  vertical-align: middle;
}

label:has(input[type="checkbox"]) {
  display: flex;
  align-items: flex-start;
  gap: 0.15rem;
  font-weight: 500;
}

label:has(input[type="checkbox"]) input {
  margin-top: 0.15rem;
  flex-shrink: 0;
}

.field-hint {
  display: block;
  margin-top: 0.3rem;
  color: var(--ink-muted);
  font-size: 0.8rem;
  font-weight: 400;
}

.quick-picks {
  margin: 0.35rem 0 1rem;
  padding: 0.8rem 1rem;
  border: 1px dashed var(--line);
  border-radius: 0.65rem;
  background: color-mix(in srgb, var(--line) 14%, transparent);
  font-size: 0.85rem;
}

.quick-picks-heading {
  margin: 0 0 0.35rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.quick-picks-detail {
  margin: 0 0 0.65rem;
  color: var(--ink-muted);
  font-size: 0.8rem;
}

.quick-picks-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  padding: 0.7rem 1.15rem;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-block {
  width: 100%;
}

@media (min-width: 640px) {
  .btn-block {
    width: auto;
    min-width: 12rem;
  }
}

.btn-secondary {
  border-color: var(--line);
  background: var(--paper);
  color: var(--ink);
}

.btn-secondary:hover {
  background: color-mix(in srgb, var(--line) 28%, var(--paper));
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ghost {
  padding: 0.4rem 0.7rem;
  border-color: var(--line);
  background: var(--paper);
  color: var(--ink);
  font-weight: 500;
  font-size: 0.8rem;
  text-align: left;
  white-space: normal;
}

.btn-ghost:hover {
  background: color-mix(in srgb, var(--line) 28%, var(--paper));
  border-color: var(--accent);
  color: var(--accent);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.htmx-indicator {
  display: none;
  color: var(--ink-muted);
  font-size: 0.875rem;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline;
}

.report-panel {
  position: sticky;
  top: 4.5rem;
}

.empty-report {
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.tax-report {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.report-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.eyebrow {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.hero-figure {
  margin: 0.15rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 4vw, 3.25rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.hero-meta {
  margin-top: 0.45rem;
  color: var(--ink-muted);
  font-size: 0.8rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 0.4rem;
  padding: 0.4rem 0.7rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
}

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

.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.report-section {
  padding-top: 1.5rem;
  border-top: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
}

.report-section h4 {
  margin-bottom: 0.55rem;
  font-size: 1.15rem;
}

.report-section > p {
  color: var(--ink);
  font-size: 0.925rem;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.report-table th,
.report-table td {
  padding: 0.45rem 0.35rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  text-align: left;
  vertical-align: top;
}

.report-table th {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.report-table td:first-child {
  width: 48%;
  color: var(--ink-muted);
}

.report-table td:last-child {
  font-variant-numeric: tabular-nums;
}

.report-table.highlight td:last-child {
  font-weight: 600;
  color: var(--ink);
}

.report-table .total-row td {
  border-bottom: 0;
  border-top: 2px solid var(--accent);
  padding-top: 0.7rem;
  color: var(--ink);
}

.stat-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.stat-list li {
  margin: 0 0 0.65rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--accent);
  font-size: 0.9rem;
}

.narrative p {
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
  line-height: 1.6;
}

.muted {
  color: var(--ink-muted);
}

.error-report {
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line));
  border-radius: var(--radius);
  background: var(--danger-soft);
  padding: 1.1rem 1.2rem;
  color: var(--danger);
}

.error-report h3 {
  margin-bottom: 0.5rem;
  font-size: 1.15rem;
  color: var(--danger);
}

.error-report ul {
  margin: 0;
  padding-left: 1.1rem;
}

#stcg-rate-wrap.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.vision-page,
.architecture-page {
  max-width: 42rem;
  margin: 0 auto;
}

.architecture-page {
  max-width: 54rem;
}

.vision-page h1,
.architecture-page h1 {
  font-size: clamp(1.85rem, 3vw, 2.35rem);
}

.vision-page .lede,
.architecture-page .lede {
  margin-top: 0.5rem;
}

.github-doc-link {
  font-size: 0.9rem;
  font-weight: 600;
}

.vision-section {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
}

.vision-section h2 {
  margin-bottom: 0.55rem;
  font-size: 1.25rem;
}

.vision-section ol,
.vision-section ul:not(.stat-list) {
  margin: 0;
  padding-left: 1.2rem;
}

.vision-section li + li {
  margin-top: 0.35rem;
}

.diagram-frame {
  margin: 1.1rem 0 1.25rem;
  padding: 1.15rem 1rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: color-mix(in srgb, var(--paper) 88%, #fff);
}

.diagram-frame .mermaid {
  margin: 0;
  text-align: center;
}

.diagram-frame .mermaid svg {
  overflow: visible;
  max-width: 100%;
}

.diagram-frame .mermaid .nodeLabel,
.diagram-frame .mermaid .cluster-label,
.diagram-frame .mermaid .edgeLabel {
  overflow: visible;
}

.diagram-frame .mermaid foreignObject {
  overflow: visible;
}

.app-sim-page {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.app-sim-intro .lede {
  margin-bottom: 0.85rem;
}

.device-toggle {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.device-toggle .btn.is-selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--paper));
  color: var(--accent);
}

.device-stage {
  display: flex;
  justify-content: center;
  padding: 0.25rem 0 1rem;
}

.device-frame {
  width: min(100%, 24.5rem);
}

.device-bezel {
  position: relative;
  padding: 0.7rem;
  border-radius: 2.85rem;
  background: #11181d;
  box-shadow:
    var(--shadow),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset,
    0 28px 48px -28px rgba(15, 40, 50, 0.7);
}

.device-frame.is-android .device-bezel {
  border-radius: 2.1rem;
  padding: 0.55rem;
  background: #1a2228;
}

.device-screen {
  display: flex;
  flex-direction: column;
  height: min(46.5rem, calc(100vh - 12rem));
  min-height: 36rem;
  overflow: hidden;
  border-radius: 2.2rem;
  background: var(--paper);
}

.device-frame.is-android .device-screen {
  border-radius: 1.65rem;
}

.device-status {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 2.35rem;
  padding: 0.45rem 1.15rem 0.15rem;
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.device-time {
  justify-self: start;
}

.device-notch {
  justify-self: center;
  width: 5.6rem;
  height: 1.35rem;
  border-radius: 999px;
  background: #11181d;
}

.device-frame.is-android .device-notch {
  position: absolute;
  top: 0.45rem;
  left: 50%;
  width: 0.72rem;
  height: 0.72rem;
  margin: 0;
  transform: translateX(-50%);
  border-radius: 999px;
  background: #11181d;
  box-shadow: 0 0 0 2px color-mix(in srgb, #11181d 35%, transparent);
}

.device-icons {
  justify-self: end;
  width: 3.4rem;
  height: 0.7rem;
  border-radius: 0.15rem;
  background:
    linear-gradient(90deg, currentColor 0 22%, transparent 22% 30%, currentColor 30% 58%, transparent 58% 66%, currentColor 66% 100%);
  opacity: 0.72;
}

.device-appbar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 1rem 0.7rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
}

.device-appbar img {
  width: 1.4rem;
  height: 1.4rem;
  flex-shrink: 0;
}

.device-appbar-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.device-appbar-meta {
  margin: 0.1rem 0 0;
  color: var(--ink-muted);
  font-size: 0.6875rem;
  line-height: 1.3;
}

.device-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.9rem 0.95rem 1rem;
}

.device-pane-lede {
  margin: 0 0 0.9rem;
  color: var(--ink-muted);
  font-size: 0.8125rem;
}

.device-frame .field-grid {
  grid-template-columns: 1fr;
}

.device-frame .report-panel,
.device-frame .device-body .tax-report {
  position: static;
}

.device-frame .form-actions {
  position: sticky;
  bottom: 0;
  margin-top: 1.1rem;
  padding-top: 0.75rem;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--paper) 0%, transparent) 0%,
    var(--paper) 28%
  );
}

.device-frame .form-actions .btn {
  width: 100%;
}

.device-frame .hero-figure {
  font-size: clamp(1.85rem, 8vw, 2.4rem);
}

.device-frame .report-table {
  font-size: 0.8125rem;
}

.device-tabbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem 0.2rem;
  border-top: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  background: color-mix(in srgb, var(--header-bg) 88%, var(--paper));
}

.device-tab {
  border: 0;
  border-radius: 0.65rem;
  padding: 0.55rem 0.4rem 0.5rem;
  background: transparent;
  color: var(--ink-muted);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}

.device-tab.is-active {
  background: color-mix(in srgb, var(--accent) 10%, var(--paper));
  color: var(--accent);
}

.device-homebar {
  height: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.device-homebar::after {
  content: "";
  width: 7.25rem;
  height: 0.28rem;
  border-radius: 999px;
  background: #11181d;
}

.device-frame.is-android .device-homebar::after {
  width: 6.1rem;
  height: 0.22rem;
  background: color-mix(in srgb, var(--ink) 55%, transparent);
}

@media (max-width: 720px) {
  .device-stage {
    padding: 0;
  }

  .device-frame {
    width: 100%;
  }

  .device-bezel {
    padding: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .device-screen {
    height: auto;
    min-height: 32rem;
    max-height: none;
    border-radius: 0.9rem;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
  }

  .device-frame.is-android .device-screen {
    border-radius: 0.9rem;
  }

  .device-body {
    max-height: none;
  }
}
