:root {
  color-scheme: light;
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Noto Sans CJK SC",
    system-ui,
    sans-serif;
  color: #17223b;
  background: #f3f5f2;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #17223b;
  --ink-soft: #536077;
  --navy: #10223e;
  --navy-soft: #183251;
  --green: #087a5b;
  --green-dark: #065d47;
  --green-pale: #e7f4ef;
  --paper: #ffffff;
  --surface: #f8faf8;
  --line: #d8ded9;
  --line-strong: #bcc7bf;
  --danger: #a62935;
  --focus: #1666d8;
  --shadow: 0 18px 54px rgb(16 34 62 / 14%);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: #f3f5f2;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: #f3f5f2;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 100;
  inset-block-start: 12px;
  inset-inline-start: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--navy);
  font-weight: 700;
  transform: translateY(-160%);
}

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

.app-shell {
  min-height: 100vh;
}

.auth-view,
.state-view {
  width: calc(100% - 32px);
  margin-inline: auto;
}

.auth-view {
  display: grid;
  max-width: 920px;
  min-height: 530px;
  margin-block: max(28px, calc((100vh - 530px) / 2));
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.95fr);
  overflow: hidden;
  border-radius: 16px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.auth-copy {
  display: flex;
  min-width: 0;
  padding: clamp(42px, 7vw, 72px);
  flex-direction: column;
  justify-content: flex-end;
  color: #ffffff;
  background: var(--navy);
}

.auth-copy h1 {
  max-width: 8ch;
  margin: 12px 0 20px;
  font-size: 4.8rem;
  line-height: 0.98;
  letter-spacing: 0;
  text-wrap: balance;
}

.auth-intro {
  max-width: 34ch;
  margin: 0;
  color: #d5e0ed;
  font-size: 1rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.auth-form {
  display: flex;
  min-width: 0;
  padding: clamp(36px, 6vw, 64px);
  flex-direction: column;
  justify-content: center;
  background: var(--paper);
}

.field-group {
  min-width: 0;
}

.field-group label {
  display: block;
  margin-block-end: 10px;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 700;
}

.field-group input {
  width: 100%;
  min-height: 50px;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink);
  background: #ffffff;
  transition: border-color 160ms ease-out, box-shadow 160ms ease-out;
}

.field-group input:hover:not(:disabled) {
  border-color: #819087;
}

.field-group input[aria-invalid="true"] {
  border-color: var(--danger);
}

.field-group input:disabled {
  cursor: wait;
  color: #6a7485;
  background: #edf0ed;
}

.field-hint,
.form-status {
  margin: 9px 0 0;
  color: var(--ink-soft);
  font-size: 0.875rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.form-status {
  min-height: 1.4em;
  color: var(--danger);
}

.button {
  display: inline-flex;
  min-height: 44px;
  padding: 10px 17px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 160ms ease-out, color 160ms ease-out, transform 160ms ease-out, box-shadow 160ms ease-out;
}

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

.button:active:not(:disabled) {
  transform: translateY(0);
}

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

.button-primary {
  color: #ffffff;
  background: var(--green);
  box-shadow: 0 8px 20px rgb(8 122 91 / 22%);
}

.button-primary:hover:not(:disabled) {
  background: var(--green-dark);
}

.auth-form .button-primary {
  width: 100%;
  margin-block-start: 24px;
}

.button-quiet {
  color: #e8eef5;
  background: transparent;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 28%);
}

.button-quiet:hover:not(:disabled) {
  color: #ffffff;
  background: rgb(255 255 255 / 10%);
}

.state-view {
  display: flex;
  max-width: 560px;
  min-height: 100vh;
  padding: 72px 24px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
}

.state-view h1 {
  max-width: 14ch;
  margin: 14px 0 12px;
  font-size: 3.2rem;
  line-height: 1.08;
  letter-spacing: 0;
  text-wrap: balance;
}

.state-view p:not(.kicker) {
  max-width: 48ch;
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.7;
}

.state-view .button {
  margin-block-start: 24px;
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.error-actions .button {
  margin-block-start: 24px;
}

.button-secondary {
  color: var(--green-dark);
  background: #ffffff;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.button-secondary:hover:not(:disabled) {
  background: var(--green-pale);
  box-shadow: inset 0 0 0 1px var(--green);
}

.file-button {
  user-select: none;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #c9d7d0;
  border-block-start-color: var(--green);
  border-radius: 50%;
  animation: spin 750ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.kicker {
  margin: 0;
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1.4;
}

.auth-copy .kicker {
  color: #74d7b2;
}

#app-view {
  width: 100%;
  min-height: 100vh;
}

.app-header {
  display: flex;
  min-height: 76px;
  padding: 14px max(24px, calc((100vw - 1240px) / 2));
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: #ffffff;
  background: var(--navy);
}

.brand-lockup,
.header-actions {
  display: flex;
  min-width: 0;
  align-items: center;
}

.brand-lockup {
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 12px;
  color: #ffffff;
  background: var(--green);
  font-size: 1.25rem;
  font-weight: 900;
  place-items: center;
  box-shadow: 0 7px 16px rgb(0 0 0 / 18%);
}

.brand-name {
  margin: 2px 0 0;
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.2;
}

.app-header .kicker {
  color: #9ab1c9;
  font-size: 0.65rem;
}

.header-actions {
  justify-content: flex-end;
  gap: 14px;
}

.sync-status {
  max-width: 30ch;
  color: #c9d7e5;
  font-size: 0.82rem;
  line-height: 1.4;
  text-align: end;
  overflow-wrap: anywhere;
}

.sync-status.is-error {
  color: #ffd0d4;
}

.primary-nav {
  display: flex;
  min-height: 58px;
  padding-inline: max(24px, calc((100vw - 1240px) / 2));
  align-items: stretch;
  gap: 4px;
  overflow-x: auto;
  border-block-end: 1px solid var(--line);
  background: #ffffff;
  scrollbar-width: thin;
}

.nav-tab {
  position: relative;
  min-width: max-content;
  min-height: 52px;
  padding: 12px 18px;
  border: 0;
  color: #5a6577;
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}

.nav-tab::after {
  position: absolute;
  inset-inline: 18px;
  inset-block-end: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: transparent;
  content: "";
}

.nav-tab:hover {
  color: var(--ink);
  background: #f5f8f6;
}

.nav-tab.is-active {
  color: var(--green-dark);
}

.nav-tab.is-active::after {
  background: var(--green);
}

.content-wrap {
  width: min(100%, 1288px);
  margin-inline: auto;
  padding: clamp(28px, 4vw, 52px) 24px 72px;
}

.app-view {
  min-width: 0;
}

.view-heading {
  display: flex;
  min-width: 0;
  margin-block-end: 34px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
}

.view-heading h1 {
  max-width: 20ch;
  margin: 8px 0 10px;
  font-size: 3.6rem;
  line-height: 1.06;
  letter-spacing: 0;
  text-wrap: balance;
}

.view-description {
  max-width: 62ch;
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.catalog-notice {
  display: flex;
  min-width: 0;
  margin-block: -10px 24px;
  padding: 12px 14px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid #b7d7c9;
  border-radius: 12px;
  color: #174f3f;
  background: #edf8f2;
}

.catalog-notice p {
  min-width: 0;
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.catalog-notice .button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 12px;
  color: #174f3f;
  border-color: #8ebaa8;
}

.catalog-counts {
  display: flex;
  flex: 0 0 auto;
  padding-block-end: 7px;
  gap: 18px;
  color: var(--ink-soft);
  font-size: 0.88rem;
  white-space: nowrap;
}

.catalog-counts strong {
  color: var(--ink);
  font-size: 1.2rem;
}

.empty-workspace {
  display: flex;
  min-height: 250px;
  padding: clamp(28px, 5vw, 54px);
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  background: rgb(255 255 255 / 62%);
}

.empty-workspace p {
  max-width: 58ch;
  margin: 8px 0 0;
  color: var(--ink-soft);
  line-height: 1.7;
}

.empty-workspace .empty-title {
  margin: 0;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 800;
}

.sr-only {
  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;
}

.calculator-grid {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.58fr);
  gap: 20px 24px;
  align-items: start;
}

.work-section,
.inventory-section,
.custom-accessory-section {
  min-width: 0;
  padding: clamp(22px, 3vw, 30px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
}

.model-section,
.price-section,
.adjustments-section,
.calculator-actions {
  grid-column: 1;
}

.margin-summary {
  position: sticky;
  inset-block-start: 24px;
  grid-column: 2;
  grid-row: 1 / span 3;
  min-width: 0;
  padding: clamp(24px, 3vw, 34px);
  border-radius: 14px;
  color: #ffffff;
  background: var(--navy);
  box-shadow: 0 16px 38px rgb(16 34 62 / 18%);
}

.margin-summary:not(.is-ready) .summary-breakdown {
  display: none;
}

.margin-summary.is-empty {
  padding-block: clamp(20px, 2.5vw, 28px);
}

.margin-summary.is-empty .margin-profit {
  margin-block: 22px 0;
  font-size: 1.8rem;
  line-height: 1.25;
  letter-spacing: 0;
}

.margin-summary.is-empty .margin-rate,
.margin-summary.is-empty .summary-status {
  display: none;
}

.section-heading,
.summary-head,
.adjustment-heading {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  gap: 15px;
}

.section-heading {
  margin-block-end: 22px;
}

.section-heading.compact {
  margin-block-end: 18px;
}

.section-heading h2,
.summary-head h2,
.adjustment-heading h3 {
  margin: 0;
  color: inherit;
  line-height: 1.2;
  letter-spacing: 0;
}

.section-heading h2,
.summary-head h2 {
  font-size: 1.3rem;
}

.section-heading p:not(.section-index),
.adjustment-heading span {
  margin: 5px 0 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.section-index {
  flex: 0 0 auto;
  margin: 2px 0 0;
  color: var(--green);
  font-size: 0.73rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.4;
}

.search-input,
.custom-accessory-form input {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink);
  background: #ffffff;
}

.search-input::placeholder,
.custom-accessory-form input::placeholder,
.money-input input::placeholder {
  color: #748092;
}

.recent-models {
  margin-block-start: 14px;
}

.recent-models-heading {
  display: flex;
  margin-block-end: 7px;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-soft);
  font-size: 0.76rem;
}

.recent-models-heading strong {
  color: var(--ink);
  font-size: 0.82rem;
}

.recent-model-list {
  display: flex;
  min-width: 0;
  gap: 8px;
  overflow-x: auto;
  padding-block-end: 2px;
  scrollbar-width: thin;
}

.recent-model-chip {
  display: inline-flex;
  min-width: 0;
  min-height: 44px;
  max-width: min(46%, 240px);
  padding: 7px 11px;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  border: 1px solid #b7d7c9;
  border-radius: 10px;
  color: var(--ink);
  background: #f4fbf7;
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.recent-model-chip:hover:not(:disabled) {
  border-color: var(--green);
  background: var(--green-pale);
}

.recent-model-chip:disabled {
  color: #687582;
  background: #eef1ef;
  border-color: #c6d0ca;
  cursor: not-allowed;
}

.recent-model-code,
.recent-model-meta {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-model-code {
  font-size: 0.8rem;
}

.recent-model-meta {
  margin-block-start: 2px;
  color: var(--ink-soft);
  font-size: 0.72rem;
}

.model-list {
  display: grid;
  max-height: 520px;
  margin-block-start: 14px;
  padding-inline-end: 4px;
  gap: 9px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.model-option {
  display: grid;
  min-width: 0;
  max-height: 300px;
  padding: 14px;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  cursor: pointer;
  transition: border-color 150ms ease-out, background-color 150ms ease-out, transform 150ms ease-out;
}

.model-option:hover:has(input:not(:disabled)) {
  border-color: #82978b;
  background: #fbfdfc;
  transform: translateY(-1px);
}

.model-option:has(input:checked) {
  border-color: var(--green);
  background: var(--green-pale);
  box-shadow: inset 0 0 0 1px var(--green);
}

.model-option:has(input:disabled) {
  cursor: not-allowed;
  background: #eef1ef;
  border-color: #c6d0ca;
}

.model-option:has(input:disabled) .model-name {
  color: #4d5a68;
}

.model-option:has(input:disabled) .spec-row,
.model-option:has(input:disabled) .spec-label {
  color: #5a6877;
}

.model-option > input {
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  accent-color: var(--green);
}

.model-option-body,
.model-option-top {
  display: flex;
  min-width: 0;
}

.model-option-body {
  flex-direction: column;
  gap: 5px;
}

.model-option-top {
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.model-name {
  min-width: 0;
  display: -webkit-box;
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.52;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.stock-badge,
.summary-badge,
.local-only-label {
  display: inline-flex;
  min-height: 25px;
  padding: 4px 9px;
  align-items: center;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.stock-badge {
  flex: 0 0 auto;
  color: var(--green-dark);
  background: var(--green-pale);
}

.stock-badge.is-sold-out {
  color: #7b3440;
  background: #f8e7e9;
}

.spec-row {
  display: grid;
  min-width: 0;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 8px;
  color: #596678;
  font-size: 0.78rem;
  line-height: 1.45;
}

.spec-label {
  color: #536173;
}

.spec-value {
  min-width: 0;
  color: #445064;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.inline-status,
.field-error,
.summary-status {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.inline-status.is-error,
.field-error {
  color: var(--danger);
}

.field-label {
  display: block;
  margin-block-end: 9px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
}

.money-input {
  display: flex;
  min-width: 0;
  min-height: 60px;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #ffffff;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
}

.money-input:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgb(22 102 216 / 16%);
}

.money-input > span {
  padding-inline-start: 16px;
  color: #5e6a7b;
  font-size: 1.2rem;
  font-weight: 800;
}

.money-input input {
  width: 100%;
  min-width: 0;
  height: 58px;
  padding: 8px 16px 8px 8px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0;
}

.money-input:has(input:disabled) {
  background: #edf0ed;
  opacity: 0.72;
}

.check-row {
  display: flex;
  min-height: 44px;
  margin-block-start: 8px;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 0.88rem;
  cursor: pointer;
}

.check-row input,
.choice-option input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  accent-color: var(--green);
}

.subsidy-result {
  margin: 0;
  padding: 10px 12px;
  border-radius: 9px;
  color: #674d09;
  background: #fff3c8;
  font-size: 0.84rem;
  line-height: 1.55;
}

.summary-head {
  justify-content: space-between;
}

.summary-head .section-index {
  color: #7ed8b6;
}

.summary-badge {
  color: #dce7f2;
  background: rgb(255 255 255 / 10%);
}

.margin-profit {
  margin: 34px 0 0;
  color: #ffffff;
  font-size: 4rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.margin-rate {
  margin: 10px 0 28px;
  color: #a8bdcf;
  font-weight: 700;
}

.summary-breakdown {
  display: grid;
  margin: 0;
  gap: 0;
}

.summary-breakdown > div {
  display: flex;
  min-width: 0;
  padding-block: 12px;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  border-block-start: 1px solid rgb(255 255 255 / 13%);
}

.summary-breakdown dt {
  min-width: 0;
  color: #acbdd0;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.summary-breakdown dd {
  margin: 0;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
}

.summary-status {
  color: #b9c9d8;
}

.calculation-help {
  margin-block-start: 14px;
  border-block-start: 1px solid rgb(255 255 255 / 13%);
}

.calculation-help summary {
  min-height: 44px;
  padding-block: 12px 8px;
  color: #dce7f2;
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
}

.calculation-help ul {
  margin: 0;
  padding: 0 0 8px 18px;
  color: #b9c9d8;
  font-size: 0.78rem;
  line-height: 1.55;
}

.calculation-help li + li {
  margin-block-start: 5px;
}

.margin-summary.is-ready:not(.is-warning, .is-loss) .summary-badge {
  color: #d7ffef;
  background: rgb(35 168 115 / 24%);
}

.margin-summary.is-warning {
  background: #4d3e17;
}

.margin-summary.is-warning .summary-badge {
  color: #fff2b8;
  background: rgb(255 211 68 / 16%);
}

.margin-summary.is-loss {
  background: #491f28;
}

.margin-summary.is-loss .summary-badge {
  color: #ffdce0;
  background: rgb(255 126 143 / 16%);
}

.adjustments-section {
  padding: 0;
  overflow: clip;
}

.adjustments-section > summary {
  display: flex;
  min-height: 60px;
  padding: 16px 22px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
}

.adjustments-section > summary::-webkit-details-marker {
  display: none;
}

.adjustments-section > summary::after {
  width: 9px;
  height: 9px;
  margin-inline-start: 4px;
  flex: 0 0 auto;
  border-inline-end: 2px solid var(--green);
  border-block-end: 2px solid var(--green);
  content: "";
  transform: rotate(45deg) translateY(-2px);
  transition: transform 160ms ease-out;
}

.adjustments-section[open] > summary::after {
  transform: rotate(225deg) translate(-2px, -2px);
}

.adjustments-section > summary > span:first-child {
  display: flex;
  align-items: center;
  gap: 12px;
}

.adjustments-section > summary strong {
  color: var(--green);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

.adjustments-section > summary > span:nth-child(2) {
  margin-inline-start: auto;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.adjustments-body {
  display: grid;
  padding: 0 22px 24px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  border-block-start: 1px solid var(--line);
}

.adjustment-column {
  min-width: 0;
  padding-block-start: 22px;
}

.adjustment-heading {
  margin-block-end: 14px;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.adjustment-heading h3 {
  font-size: 1rem;
}

.adjustment-heading span {
  margin: 0;
  font-size: 0.76rem;
}

.choice-list {
  display: grid;
  max-height: 340px;
  margin-block-start: 10px;
  gap: 7px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.choice-option {
  display: flex;
  min-width: 0;
  min-height: 52px;
  padding: 9px 10px;
  align-items: flex-start;
  gap: 9px;
  border-radius: 9px;
  background: var(--surface);
  cursor: pointer;
}

.choice-option:has(input:checked) {
  background: var(--green-pale);
}

.choice-option.is-disabled {
  cursor: not-allowed;
  opacity: 0.63;
}

.choice-option-text {
  display: grid;
  min-width: 0;
  flex: 1;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 10px;
}

.choice-name {
  grid-column: 1 / -1;
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.choice-meta,
.choice-cost,
.choice-empty {
  color: var(--ink-soft);
  font-size: 0.74rem;
  line-height: 1.4;
}

.choice-cost {
  text-align: end;
}

.choice-empty {
  margin: 12px 0;
}

.calculator-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 16px;
}

.calculator-actions .button {
  min-width: 160px;
}

.calculator-actions .inline-status {
  margin: 0;
}

.local-only-label {
  flex: 0 0 auto;
  color: var(--green-dark);
  background: var(--green-pale);
}

.inventory-toolbar {
  display: grid;
  min-width: 0;
  margin-block-end: 20px;
  grid-template-columns: minmax(0, 520px);
  gap: 8px;
}

.inventory-toolbar .search-input {
  max-width: 520px;
}

.inventory-toolbar .inline-status {
  margin: 0;
}

.inventory-status-row {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.inventory-status-row .button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 9px 14px;
}

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

.inventory-section.is-empty {
  align-self: start;
}

.inventory-section.is-empty .inventory-list {
  max-height: none;
}

.inventory-list {
  display: grid;
  max-height: 620px;
  gap: 1px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.inventory-row {
  display: flex;
  min-width: 0;
  min-height: 64px;
  padding: 10px 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-block-end: 1px solid #e6eae7;
}

.inventory-detail {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 3px;
}

.inventory-name {
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.inventory-meta,
.custom-accessory-meta {
  color: var(--ink-soft);
  font-size: 0.73rem;
  line-height: 1.4;
}

.inventory-controls {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: 44px 58px 44px;
  align-items: center;
}

.inventory-step,
.inventory-input {
  min-height: 44px;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: #ffffff;
}

.inventory-step {
  padding: 0;
  font-size: 1.15rem;
  font-weight: 900;
  cursor: pointer;
}

.inventory-step:first-child {
  border-radius: 9px 0 0 9px;
}

.inventory-step:last-child {
  border-radius: 0 9px 9px 0;
}

.inventory-input {
  width: 58px;
  padding: 5px;
  border-inline: 0;
  border-radius: 0;
  text-align: center;
  appearance: textfield;
}

.inventory-input::-webkit-inner-spin-button,
.inventory-input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.custom-accessory-section {
  margin-block-start: 20px;
}

.custom-accessory-header {
  display: flex;
  margin-block-end: 18px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.custom-accessory-header .section-heading {
  margin: 0;
}

.custom-accessory-toggle {
  flex: 0 0 auto;
}

.custom-accessory-editor {
  margin-block-end: 12px;
}

.custom-accessory-form {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) repeat(3, minmax(110px, 0.65fr)) minmax(150px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.custom-accessory-form label {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.custom-accessory-form label > span {
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
}

.custom-accessory-list {
  display: grid;
  margin-block-start: 12px;
  gap: 1px;
}

.custom-accessory-actions {
  display: flex;
  min-width: max-content;
  gap: 8px;
  align-items: center;
}

.custom-accessory-row {
  display: grid;
  min-width: 0;
  min-height: 54px;
  padding-block: 8px;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  border-block-end: 1px solid #e6eae7;
}

.custom-accessory-row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.custom-accessory-name {
  min-width: 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.danger-button {
  min-height: 44px;
  color: var(--danger);
  background: #ffffff;
  box-shadow: inset 0 0 0 1px #dfb9be;
}

.danger-button:hover:not(:disabled) {
  color: #7f1f2a;
  background: #fff5f6;
}

.stats-strip {
  display: grid;
  margin-block-end: 20px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-block: 1px solid var(--line);
  background: #ffffff;
}

.stats-strip > div {
  display: flex;
  min-width: 0;
  min-height: 92px;
  padding: 16px 20px;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  border-inline-end: 1px solid var(--line);
}

.stats-strip > div:last-child {
  border-inline-end: 0;
}

.stats-strip strong {
  min-width: 0;
  color: var(--ink);
  font-size: 1.7rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.stats-strip span {
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.records-settings-layout {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  gap: 20px;
  align-items: start;
}

.records-section,
.settings-section,
.backup-section {
  min-width: 0;
  padding: clamp(22px, 3vw, 30px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
}

.settings-column {
  display: grid;
  min-width: 0;
  gap: 20px;
}

.sales-record-list {
  display: grid;
  gap: 10px;
}

.records-empty {
  margin: 28px 0 0;
  padding: 22px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--ink-soft);
  text-align: center;
}

.sale-record {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #ffffff;
}

.sale-record-header,
.sale-record-actions {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.sale-record-title {
  min-width: 0;
  color: var(--ink);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.sale-record-profit {
  flex: 0 0 auto;
  color: var(--green-dark);
  white-space: nowrap;
}

.sale-record-profit.is-loss {
  color: var(--danger);
}

.sale-record-time,
.sale-record-detail,
.sale-record-names {
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.sale-record-actions {
  margin-block-start: 10px;
  justify-content: flex-end;
}

.sale-record-actions .button {
  min-height: 44px;
  padding-inline: 12px;
}

.settings-form {
  display: grid;
  gap: 13px;
}

.settings-form label {
  display: grid;
  gap: 7px;
}

.settings-form label > span {
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 800;
}

.settings-form input {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink);
  background: #ffffff;
}

.settings-form .button {
  width: 100%;
  margin-block-start: 4px;
}

.backup-section .section-heading {
  margin-block-end: 16px;
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.backup-actions .button {
  flex: 1 1 150px;
  min-height: 44px;
}

dialog {
  width: min(calc(100% - 32px), 440px);
  padding: 0;
  border: 0;
  border-radius: 14px;
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 24px 80px rgb(16 34 62 / 28%);
}

dialog::backdrop {
  background: rgb(16 34 62 / 48%);
}

.confirm-dialog-form {
  padding: 26px;
}

.confirm-dialog-form h2 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.25;
}

.confirm-dialog-form p {
  margin: 12px 0 0;
  color: var(--ink-soft);
  line-height: 1.65;
}

.confirm-dialog-actions {
  display: flex;
  margin-block-start: 24px;
  justify-content: flex-end;
  gap: 10px;
}

:where(a, button, input):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

h1[tabindex="-1"]:focus {
  outline: none;
}

@media (max-width: 1040px) {
  .view-heading h1 {
    font-size: 2.5rem;
  }

  .margin-summary.is-empty .margin-profit {
    font-size: 1.35rem;
  }

  .margin-profit {
    font-size: 2.5rem;
  }

  .stats-strip strong {
    font-size: 1.35rem;
  }

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

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

  .custom-accessory-form .custom-accessory-actions {
    grid-column: 1 / -1;
  }

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

@media (min-width: 761px) and (max-width: 1040px) {
  .calculator-grid {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 0.68fr);
  }

  .margin-summary {
    position: sticky;
    grid-column: 2;
    grid-row: 1 / span 3;
    inset-block-start: 24px;
  }

  .calculator-actions {
    flex-wrap: wrap;
  }

  .calculator-actions .inline-status {
    flex: 1 0 100%;
  }

  .calculator-actions .button {
    min-width: 0;
    flex: 1 1 0;
  }
}

@media (max-width: 760px) {
  body {
    background: #f3f5f2;
  }

  .auth-view {
    max-width: 560px;
    min-height: 0;
    margin-block: 16px;
    grid-template-columns: 1fr;
  }

  .auth-copy {
    min-height: 270px;
    padding: 34px 28px;
  }

  .auth-copy h1 {
    max-width: none;
    font-size: 3.2rem;
  }

  .state-view h1 {
    font-size: 2.5rem;
  }

  .view-heading h1 {
    font-size: 2rem;
  }

  .money-input input {
    font-size: 1.5rem;
  }

  .margin-profit {
    font-size: 2.25rem;
  }

  .stats-strip strong {
    font-size: 1.2rem;
  }

  .auth-form {
    padding: 34px 28px 38px;
  }

  .app-header {
    padding-inline: 18px;
  }

  .sync-status {
    display: inline-flex;
    max-width: 38vw;
    overflow: hidden;
    font-size: 0.7rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .primary-nav {
    padding-inline: 8px;
  }

  .content-wrap {
    padding-inline: 18px;
  }

  .view-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 16px;
  }

  .catalog-counts {
    padding-block-end: 0;
  }

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

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

  .model-section,
  .price-section,
  .margin-summary,
  .adjustments-section,
  .calculator-actions {
    grid-column: 1;
  }

  .margin-summary {
    position: static;
    grid-row: auto;
  }

  .inventory-toolbar {
    gap: 8px;
  }

  .inventory-toolbar .search-input {
    max-width: none;
  }

  .inventory-status-row {
    align-items: stretch;
    flex-direction: column;
  }

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

  .custom-accessory-header {
    align-items: stretch;
    flex-direction: column;
  }

  .custom-accessory-toggle {
    width: 100%;
  }

  .custom-accessory-form .button {
    width: 100%;
  }

  .model-list {
    max-height: min(66vh, 560px);
    overflow-y: auto;
    scroll-padding-block: 4px;
  }

  .model-option {
    max-height: none;
  }

  .model-option .spec-secondary {
    display: grid;
  }

  .model-name {
    -webkit-line-clamp: 3;
  }

  .margin-summary {
    padding: 18px 16px;
  }

  .margin-summary:not(.is-ready) .margin-rate {
    margin-block-end: 0;
  }

  .calculator-grid:has(.margin-summary.is-ready) .calculator-actions {
    position: static;
    margin-inline: 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 8px 22px rgb(16 34 62 / 10%);
  }

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

  .stats-strip > div:nth-child(2) {
    border-inline-end: 0;
  }

  .stats-strip > div:nth-child(-n + 2) {
    border-block-end: 1px solid var(--line);
  }
}

@media (max-width: 430px) {
  .auth-copy h1 {
    font-size: 2.75rem;
  }

  .state-view h1 {
    font-size: 2.2rem;
  }

  .auth-view,
  .state-view {
    width: calc(100% - 24px);
  }

  .auth-copy {
    min-height: 240px;
    padding: 28px 22px;
  }

  .auth-form {
    padding: 30px 22px 34px;
  }

  .app-header {
    min-height: 70px;
    padding: 12px;
    gap: 12px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .brand-lockup .kicker {
    display: none;
  }

  .header-actions {
    gap: 8px;
  }

  .button-quiet {
    padding-inline: 13px;
  }

  .nav-tab {
    padding-inline: 15px;
  }

  .content-wrap {
    padding: 30px 14px 56px;
  }

  .catalog-counts {
    width: 100%;
    justify-content: space-between;
    gap: 10px;
  }

  .empty-workspace {
    min-height: 220px;
    padding: 26px 22px;
  }

  .work-section,
  .inventory-section,
  .custom-accessory-section {
    padding: 20px 16px;
    border-radius: 12px;
  }

  .margin-summary {
    padding: 24px 20px;
    border-radius: 12px;
  }

  .catalog-notice {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .catalog-notice .button {
    width: 100%;
  }

  .model-option {
    padding: 12px 10px;
  }

  .model-option-top {
    flex-direction: column;
    gap: 7px;
  }

  .spec-row {
    grid-template-columns: 70px minmax(0, 1fr);
  }

  .adjustments-section {
    padding: 0;
  }

  .adjustments-section > summary {
    padding-inline: 16px;
  }

  .adjustments-body {
    padding-inline: 16px;
  }

  .calculator-actions {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .calculator-actions .button {
    width: 100%;
  }

  .inventory-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .inventory-controls {
    width: 146px;
  }

  .custom-accessory-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .custom-accessory-meta {
    grid-column: 1;
    grid-row: 2;
  }

  .custom-accessory-row-actions {
    grid-column: 2;
    grid-row: 1 / span 2;
    flex-direction: column;
  }

  .records-section,
  .settings-section,
  .backup-section {
    padding: 20px 16px;
    border-radius: 12px;
  }

  .stats-strip > div {
    min-height: 78px;
    padding-inline: 14px;
  }

  .sale-record-header {
    flex-direction: column;
    gap: 5px;
  }

  .error-actions {
    width: 100%;
    flex-direction: column;
  }

  .error-actions .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }

  .spinner {
    animation: none;
    border-color: var(--green) var(--line) var(--line) var(--line);
  }

  .button,
  .model-option,
  .money-input,
  .adjustments-section > summary::after {
    transition: none;
  }

  .button:hover:not(:disabled),
  .model-option:hover {
    transform: none;
  }
}
