:root {
  color-scheme: light;
  --bg: #f5f1e8;
  --bg-2: #ede6d6;
  --panel: #fffdf8;
  --ink: #1c1813;
  --muted: #6e665a;
  --line: #e3dac8;
  --accent: #1e5a45;
  --accent-strong: #164634;
  --accent-soft: #e7efea;
  --accent-bright: #7fd9b4;
  --ink-bg: #14201a;
  --on-ink: #ede7d8;
  --muted-ink: #93a093;
  --line-ink: #2c3a31;
  --warning: #b45309;
  --danger: #a13628;
  --danger-soft: #f9e7e1;
  --shadow: 0 18px 44px rgba(45, 37, 25, 0.09);
  --display: "Newsreader", Georgia, serif;
  --mono: "Spline Sans Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --body: "Hanken Grotesk", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 0;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
select,
textarea {
  font: inherit;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3,
.eyebrow,
label,
legend,
.section-number,
th,
.app-footer,
.state-pill {
  letter-spacing: 0;
}

.topbar {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 7px clamp(18px, 3vw, 34px);
  border-bottom: 1px solid var(--line);
  background: rgba(245, 241, 232, 0.9);
  position: sticky;
  top: 0;
  z-index: 8;
  backdrop-filter: blur(14px);
}

.brand,
.brand-main,
.topbar-actions,
.panel-tools {
  display: flex;
  align-items: center;
}

.brand {
  gap: 16px;
  min-width: 0;
}

.brand-main {
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand-main h1 {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: inline-flex;
  flex: 0 0 auto;
}

.brand-mark svg,
.brand-mark img {
  width: 32px;
  height: 32px;
  display: block;
}

.brand-mark rect:first-child {
  fill: var(--accent);
}

.brand-mark rect:not(:first-child),
.brand-mark circle {
  fill: #fbf7ee;
}

.brand-mark rect:nth-child(2) {
  opacity: 0.5;
}

.brand-mark rect:nth-child(3) {
  opacity: 0.78;
}

.brand-mark path {
  fill: none;
  stroke: #fbf7ee;
  stroke-width: 1.9;
  stroke-linecap: round;
}

.network-pill,
.state-pill {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.topbar-actions {
  gap: 10px;
}

.app-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.62);
}

.app-nav a {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.app-nav a:hover,
.app-nav a.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.home-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 2px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

main {
  width: min(1160px, calc(100% - 64px));
  margin: 0 auto;
  padding: 30px 0 54px;
}

.dashboard-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  margin-bottom: 22px;
}

.dashboard-head h2 {
  font-family: var(--display);
  font-size: clamp(32px, 3.5vw, 40px);
  font-weight: 600;
  line-height: 1.05;
}

.dashboard-head p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 15.5px;
  font-weight: 500;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 415px;
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.form-panel,
.activity-panel,
.tax-panel {
  padding: 26px;
}

.activity-panel {
  margin-top: 20px;
}

.tax-panel {
  margin-top: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.panel-head h2,
.panel-head h3 {
  font-family: var(--display);
  font-weight: 600;
  line-height: 1.1;
}

.panel-head h2 {
  font-size: 23px;
}

.panel-head h3 {
  font-size: 19px;
}

.section-number {
  margin-left: auto;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
}

.state-pill.pending {
  background: #fff7ed;
  color: #c2410c;
}

.state-pill.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.grid {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

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

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

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

.hidden {
  display: none !important;
}

label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  padding: 0 12px;
  border: 1px solid #d8ccb7;
  border-radius: 9px;
  background: var(--bg);
  color: var(--ink);
  outline: none;
  font-size: 16px;
  font-weight: 700;
}

textarea {
  min-height: 156px;
  padding: 12px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
  text-transform: none;
}

input::placeholder {
  color: #878075;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30, 90, 69, 0.14);
}

input:disabled {
  color: var(--muted);
  background: #ebe5d9;
}

.route-grid {
  margin-bottom: 7px;
}

.route-note,
.section-note,
.field-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
}

.route-note {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 22px;
}

.field-note {
  margin: -6px 0 16px;
  color: var(--warning);
  font-weight: 700;
}

fieldset {
  margin: 0;
  padding: 20px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
}

fieldset + fieldset {
  margin-top: 22px;
}

legend {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 0 14px;
}

legend > span:first-child {
  color: var(--ink);
  font-family: var(--display);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.1;
  text-transform: none;
}

.info-button {
  width: 22px;
  height: 22px;
  min-height: 22px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.info-popover {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 10;
  width: min(320px, calc(100vw - 40px));
  display: none;
  padding: 12px 13px;
  border: 1px solid var(--line-ink);
  border-radius: 9px;
  background: var(--ink-bg);
  color: var(--on-ink);
  box-shadow: 0 20px 42px rgba(28, 24, 19, 0.22);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.38;
}

.info-popover.open {
  display: block;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 15px;
}

.segmented label {
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 8px 12px;
  border: 1px solid #d8ccb7;
  border-radius: 9px;
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: none;
}

.segmented label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.segmented input {
  display: none;
}

.section-note {
  margin-top: -4px;
}

.actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  border-radius: 9px;
  background: var(--ink);
  color: #fffaf0;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

#connectButton,
#createButton {
  border-color: var(--accent);
  background: var(--accent);
  color: #fbf7ee;
}

button.secondary,
#approveButton,
#clearActivity,
#refreshDcas,
.table-action {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.form-error {
  min-height: 20px;
  margin-top: 12px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
}

.pause-notice {
  margin: -8px 0 16px;
  padding: 11px 12px;
  border: 1px solid #e5b7aa;
  border-radius: 9px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
}

.preview-panel {
  position: sticky;
  top: 82px;
  padding: 24px;
  border: 0;
  border-radius: 20px;
  background: var(--ink-bg);
  color: var(--on-ink);
  box-shadow: 0 24px 50px rgba(20, 32, 26, 0.18);
}

.preview-panel .panel-head {
  margin-bottom: 20px;
}

.preview-panel h2 {
  color: var(--on-ink);
  font-size: 20px;
}

.preview-panel .state-pill {
  min-height: 29px;
  padding: 5px 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-family: var(--body);
  font-size: 12px;
  font-weight: 800;
}

.preview-panel .state-pill.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.preview-list {
  display: flex;
  flex-direction: column;
  margin: 0;
}

.preview-list div {
  min-height: 44px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-ink);
}

.preview-list div:last-child {
  border-bottom: 0;
}

dt {
  color: var(--muted-ink);
  font-size: 13px;
  font-weight: 500;
}

dd {
  min-width: 0;
  margin: 0;
  color: var(--on-ink);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  text-align: right;
  overflow-wrap: anywhere;
}

.preview-list .required dt {
  color: var(--on-ink);
  font-weight: 800;
}

.preview-list .required dd {
  color: var(--accent-bright);
  font-size: 15px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

td {
  font-weight: 700;
}

td[colspan] {
  color: var(--muted);
}

td a {
  color: var(--accent-strong);
  font-weight: 800;
}

.row-actions,
.compact-actions,
.panel-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.panel-tools {
  justify-content: flex-end;
}

.compact-label {
  min-width: 155px;
}

.compact-label select {
  min-height: 36px;
  margin-top: 4px;
  font-size: 14px;
}

.table-action,
.compact-actions button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.editor-panel {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbf6ec;
}

.editor-panel .panel-head {
  margin-bottom: 16px;
}

.tax-disclaimer {
  margin: -8px 0 22px;
  padding: 12px 13px;
  border: 1px solid #e7c987;
  border-radius: 10px;
  background: #fff7df;
  color: #7c4a03;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.tax-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 355px;
  gap: 18px;
  align-items: start;
}

.tax-controls label {
  display: block;
}

.tax-source-card,
.manual-tax-import {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbf6ec;
}

.tax-source-card h3 {
  margin-bottom: 7px;
  font-family: var(--display);
  font-size: 20px;
  font-weight: 600;
}

.tax-source-card p,
.manual-tax-import p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.tax-source-card .grid {
  margin-top: 15px;
}

.tax-history-source {
  min-height: 53px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  margin-top: 20px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
}

.tax-history-source span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.tax-history-source strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.25;
}

.tax-advanced-source {
  margin-top: 12px;
}

.tax-advanced-source summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tax-advanced-source p {
  margin: 10px 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.manual-tax-import summary {
  cursor: pointer;
  color: var(--ink);
  font-family: var(--display);
  font-size: 18px;
  font-weight: 600;
}

.manual-tax-import p {
  margin: 10px 0 14px;
}

.tax-field-note,
.tax-inline-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
}

.tax-field-note {
  margin: -6px 0 15px;
}

.tax-value-actions {
  align-items: center;
  margin: -2px 0 18px;
}

.tax-inline-status {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
}

.tax-actions {
  flex-wrap: wrap;
  justify-content: flex-start;
  margin-top: 16px;
}

.tax-actions button {
  min-height: 38px;
}

.tax-summary {
  padding: 18px;
  border-radius: 16px;
  background: var(--ink-bg);
  color: var(--on-ink);
}

.tax-summary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  overflow: hidden;
  margin: 0;
  border: 1px solid var(--line-ink);
  border-radius: 11px;
  background: var(--line-ink);
}

.tax-summary-grid div {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 13px;
  background: var(--ink-bg);
}

.tax-summary-grid dt {
  color: var(--muted-ink);
}

.tax-summary-grid dd {
  color: var(--on-ink);
}

.tax-note-card {
  margin-top: 14px;
  padding: 15px;
  border: 1px solid var(--line-ink);
  border-radius: 11px;
  background: var(--panel-ink);
}

.tax-note-card h3 {
  margin-bottom: 8px;
  color: var(--on-ink);
  font-family: var(--display);
  font-size: 19px;
  font-weight: 600;
}

.tax-note-card p {
  color: var(--muted-ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.tax-table-wrap {
  margin-top: 20px;
}

.app-footer {
  width: min(1160px, calc(100% - 64px));
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  justify-content: space-between;
  margin: 0 auto;
  padding: 0 0 32px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

@media (max-width: 980px) {
  main,
  .app-footer {
    width: min(100% - 32px, 1160px);
  }

  .workspace {
    grid-template-columns: 1fr;
  }

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

  .preview-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .topbar,
  .dashboard-head {
    align-items: flex-start;
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .app-nav,
  .topbar-actions,
  .home-link,
  #connectButton {
    width: 100%;
  }

  .app-nav {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .home-link,
  #connectButton {
    justify-content: center;
  }

  .grid.two,
  .grid.three,
  .segmented {
    grid-template-columns: 1fr;
  }

  .panel-head {
    align-items: flex-start;
  }

  .actions {
    flex-direction: column;
  }

  .actions button,
  .compact-actions button {
    width: 100%;
  }
}

@media (max-width: 460px) {
  .brand {
    flex-wrap: wrap;
  }

  .form-panel,
  .activity-panel,
  .tax-panel,
  .preview-panel {
    padding: 18px;
  }
}
