:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  --page-background: #f5f7fb;
  --card-background: #ffffff;
  --text-primary: #172033;
  --text-secondary: #4f5b70;
  --text-muted: #77839a;
  --text-light: #9aa3b5;
  --accent: #315efb;
  --border: #e9edf5;
  --input-background: #f7f9fc;
  --row-primary-height: 82px;
  --row-secondary-height: 104px;
  --row-tertiary-height: 82px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--page-background);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--text-primary);
  background: var(--page-background);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: min(100% - 24px, 520px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding-top: max(18px, env(safe-area-inset-top));
  padding-bottom: max(22px, env(safe-area-inset-bottom));
}

.calculator-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  padding: 5px;
  background: #e9edf5;
  border-radius: 14px;
}

.calculator-tab {
  min-width: 0;
  min-height: 44px;
  padding: 0 6px;
  color: #6f7a8e;
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 650;
  white-space: nowrap;
  transition: color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

.calculator-tab.is-active {
  color: var(--accent);
  background: #ffffff;
  box-shadow: 0 3px 10px rgba(38, 53, 82, 0.1);
}

.calculator-tab:focus-visible,
.refund-type-option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.calculator-stage {
  margin-top: 12px;
}

.calculator-panel {
  width: 100%;
}

.calculator-panel[hidden] {
  display: none !important;
}

.calculator-card {
  display: flex;
  flex-direction: column;
  height: 430px;
  padding: 18px 20px 20px;
  background: var(--card-background);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 8px 26px rgba(38, 53, 82, 0.06);
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  min-height: 64px;
}

.result-label {
  flex-shrink: 0;
  color: #69758a;
  font-size: 14px;
}

.result-value-wrap {
  display: flex;
  min-width: 0;
  max-width: 76%;
  align-items: baseline;
  justify-content: flex-end;
}

.result-value {
  min-width: 0;
  overflow: hidden;
  color: var(--accent);
  font-size: 28px;
  font-weight: 760;
  letter-spacing: -0.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-unit {
  flex-shrink: 0;
  margin-left: 7px;
  color: var(--text-muted);
  font-size: 12px;
}

.department-result-list {
  display: flex;
  min-width: 0;
  min-height: 64px;
  max-width: 78%;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
}

.department-result-item {
  display: flex;
  min-width: 0;
  max-width: 100%;
  align-items: baseline;
  justify-content: flex-end;
  line-height: 27px;
}

.department-result-kind {
  flex-shrink: 0;
  margin-right: 7px;
  color: #8a94a7;
  font-size: 11px;
}

.department-result-number {
  min-width: 0;
  overflow: hidden;
  color: var(--accent);
  font-size: 20px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.department-result-unit {
  flex-shrink: 0;
  margin-left: 5px;
  color: var(--text-muted);
  font-size: 11px;
}

.department-result-list.is-single .department-result-number {
  font-size: 28px;
  line-height: 64px;
}

.department-result-list.is-single .department-result-kind {
  font-size: 12px;
}

.department-result-list.is-empty {
  min-height: 0;
  flex-direction: row;
  align-items: baseline;
}

.department-result-list.is-empty .result-value-wrap {
  width: max-content;
  max-width: none;
  flex-shrink: 0;
}

.department-result-list.is-empty .result-value {
  flex-shrink: 0;
}

.card-divider {
  height: 1px;
  min-height: 1px;
  margin: 9px 0 18px;
  background: #edf0f5;
}

.calculator-fields {
  display: grid;
  min-height: 0;
  flex: 1;
  grid-template-rows: var(--row-primary-height) var(--row-secondary-height) var(--row-tertiary-height);
  align-content: space-between;
}

.field-pair {
  display: flex;
  min-width: 0;
  align-items: flex-start;
}

.calculator-row-primary,
.calculator-row-secondary,
.calculator-row-tertiary,
.form-row-spacer,
.tax-refund-field {
  min-height: 0;
}

.calculator-row-primary {
  height: var(--row-primary-height);
}

.calculator-row-secondary {
  height: var(--row-secondary-height);
}

.calculator-row-tertiary,
.form-row-spacer,
.tax-refund-field {
  height: var(--row-tertiary-height);
}

.form-row-spacer {
  pointer-events: none;
  visibility: hidden;
}

.field {
  display: block;
  min-width: 0;
}

.pair-field {
  flex: 1;
}

.pair-field + .pair-field {
  margin-left: 12px;
}

.field-label {
  display: flex;
  min-height: 20px;
  margin-bottom: 7px;
  align-items: center;
  justify-content: space-between;
  color: var(--text-secondary);
  font-size: 14px;
}

.field-hint {
  min-width: 0;
  color: var(--text-light);
  font-size: 11px;
  white-space: nowrap;
}

.compact-field-hint {
  margin-left: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.input-with-suffix {
  position: relative;
  display: block;
}

.text-input {
  width: 100%;
  height: 48px;
  min-height: 48px;
  padding: 0 13px;
  color: var(--text-primary);
  background: var(--input-background);
  border: 1px solid transparent;
  border-radius: 10px;
  outline: none;
  font-size: 17px;
  -webkit-appearance: none;
  appearance: none;
}

.text-input::placeholder {
  color: #a8b0bf;
}

.text-input:focus {
  background: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(49, 94, 251, 0.08);
}

.suffix-input {
  padding-right: 38px;
}

.unit-input {
  padding-right: 68px;
}

.input-suffix {
  position: absolute;
  top: 0;
  right: 12px;
  color: #69758a;
  font-size: 14px;
  line-height: 48px;
  pointer-events: none;
}

.input-suffix-long {
  font-size: 12px;
}

.rate-status,
.rate-status-placeholder {
  display: block;
  height: 17px;
  margin-top: 5px;
  overflow: hidden;
  color: #8b96aa;
  font-size: 11px;
  line-height: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rate-status.is-success {
  color: #3f8b68;
}

.rate-status.is-warning {
  color: #c17a2f;
}

.readonly-value {
  display: flex;
  width: 100%;
  height: 48px;
  min-height: 48px;
  padding: 0 13px;
  align-items: center;
  overflow: hidden;
  color: #7c8799;
  background: var(--input-background);
  border-radius: 10px;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.refund-type-switch {
  display: flex;
  padding: 2px;
  align-items: center;
  background: #f1f4f9;
  border-radius: 7px;
}

.refund-type-option {
  min-height: 26px;
  padding: 0 9px;
  color: #758096;
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.refund-type-option.is-active {
  color: var(--accent);
  background: #ffffff;
  box-shadow: 0 2px 7px rgba(38, 53, 82, 0.09);
}

@media (min-height: 700px) {
  .app-shell {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
}

@media (max-width: 359px) {
  .app-shell {
    width: min(100% - 16px, 520px);
  }

  .calculator-card {
    padding-right: 14px;
    padding-left: 14px;
  }

  .pair-field + .pair-field {
    margin-left: 8px;
  }

  .field-label,
  .input-suffix {
    font-size: 12px;
  }

  .field-hint,
  .rate-status {
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
