:root {
  color-scheme: dark;
  --background: #111318;
  --panel: #191c22;
  --field: #13161b;
  --border: #2c3038;
  --border-hover: #3a3f49;
  --text: #eef0f3;
  --muted: #9299a5;
  --subtle: #808792;
  --placeholder: #7d8490;
  --accent: #6d9eff;
  --accent-hover: #83adff;
  --purchase: #6d9eff;
  --transfer: #a78bfa;
  --danger: #ff7d87;
  --success: #75d38b;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--background);
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.rate-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.rate-status a,
.rate-card small a {
  color: var(--muted);
  text-underline-offset: 2px;
}

.rate-status a:hover,
.rate-card small a:hover {
  color: var(--text);
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--subtle);
}

.status-dot--online {
  background: var(--success);
}

.status-dot--offline {
  background: #e6ae62;
}

.status-dot--loading {
  animation: pulse 1.2s ease-in-out infinite;
}

.page-shell {
  width: min(820px, calc(100% - 32px));
  margin: 0 auto;
  padding: 44px 0 36px;
}

.page-intro {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 24px;
}

.page-intro h1 {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  margin: 0;
  font-size: clamp(30px, 5vw, 40px);
  line-height: 1.2;
  letter-spacing: -0.035em;
  font-weight: 650;
}

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

.calculator-grid {
  display: grid;
  gap: 16px;
}

.result-panel[hidden] {
  display: none;
}

.panel {
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
}

.text-button {
  padding: 5px 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
}

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

.field {
  display: block;
  min-width: 0;
  margin: 0 0 17px;
}

.field > span,
.field legend,
.field-label-row > span {
  display: block;
  margin: 0 0 8px;
  color: #c7cbd2;
  font-size: 14px;
  font-weight: 550;
}

.field small {
  color: var(--subtle);
  font-size: 12px;
  font-weight: 500;
}

.field input,
.field select {
  width: 100%;
  height: 48px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: var(--field);
  transition: border-color 0.15s;
}

.field > input {
  padding: 0 12px;
}

.field input:hover,
.field select:hover {
  border-color: var(--border-hover);
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  outline: none;
}

.field input::placeholder {
  color: var(--placeholder);
}

input[type="date"] {
  color-scheme: dark;
}

input[type="number"] {
  appearance: textfield;
}

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

.form-grid {
  display: grid;
  gap: 14px;
}

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

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

.field-label-row {
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.field-label-row > span {
  margin: 0;
}

.price-field--purchase .field-label-row > span,
.price-field--purchase .money-symbol {
  color: #91b4ff;
}

.price-field--transfer .field-label-row > span,
.price-field--transfer .money-symbol {
  color: #b8a2ff;
}

.price-field--purchase .money-input {
  border-color: rgba(109, 158, 255, 0.45);
}

.price-field--transfer .money-input {
  border-color: rgba(167, 139, 250, 0.45);
}

.price-field--purchase .money-input:focus-within {
  border-color: var(--purchase);
}

.price-field--transfer .money-input:focus-within {
  border-color: var(--transfer);
}

.money-input {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 156px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field);
}

.money-input:focus-within {
  border-color: var(--accent);
}

.money-symbol {
  display: grid;
  place-items: center;
  color: var(--muted);
  border-right: 1px solid var(--border);
  font-size: 14px;
  font-weight: 650;
}

.money-input input,
.money-input select {
  height: 48px;
  min-width: 0;
  border: 0;
  border-radius: 0;
  outline: 0;
}

.money-input input {
  padding: 0 12px;
  font-size: 16px;
}

.money-input select {
  padding: 0 10px;
  border-left: 1px solid var(--border);
  font-size: 14px;
}

.cycle-field {
  padding: 0;
  border: 0;
}

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

.segmented label,
.mode-switch label {
  position: relative;
}

.segmented input,
.mode-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.segmented span {
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  background: var(--field);
  font-size: 14px;
}

.segmented span:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.segmented input:checked + span {
  border-color: var(--accent);
  color: #dbe7ff;
  background: rgba(109, 158, 255, 0.12);
}

.segmented input:focus-visible + span,
.mode-switch input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mode-switch {
  display: flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--field);
}

.mode-switch span {
  display: block;
  padding: 5px 10px;
  border-radius: 5px;
  color: var(--muted);
  font-size: 13px;
}

.mode-switch input:checked + span {
  color: #e6ddff;
  background: rgba(167, 139, 250, 0.18);
}

.form-message {
  min-height: 18px;
  margin: -2px 0 8px;
  color: var(--danger);
  font-size: 13px;
}

.primary-button {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 15px;
  border: 0;
  border-radius: 8px;
  color: #0b1220;
  background: var(--accent);
  font-size: 16px;
  font-weight: 650;
}

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

.result-state {
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
}

.result-state--ready {
  border-color: rgba(117, 211, 139, 0.35);
  color: var(--success);
}

.result-state--stale {
  border-color: rgba(230, 174, 98, 0.35);
  color: #e6ae62;
}

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

.result-card,
.result-info-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--field);
}

.result-card {
  min-height: 125px;
  padding: 20px;
}

.result-card--value {
  border-color: rgba(117, 211, 139, 0.28);
  background: rgba(117, 211, 139, 0.055);
}

.result-card--days {
  border-color: rgba(109, 158, 255, 0.28);
  background: rgba(109, 158, 255, 0.055);
}

.result-kicker {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 550;
}

.result-card--value h3 {
  margin: 0;
  color: var(--success);
  font-size: clamp(34px, 7vw, 46px);
  line-height: 1;
  letter-spacing: -0.045em;
  font-weight: 700;
}

.sub-value {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.days-value {
  margin: 0;
  color: var(--accent);
  line-height: 1;
}

.days-value strong {
  font-size: clamp(34px, 7vw, 46px);
  letter-spacing: -0.04em;
}

.days-value span {
  font-size: 20px;
  font-weight: 650;
}

.period-progress {
  margin: 18px 2px 0;
}

.progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #2c3037;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.25s ease;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
  color: var(--subtle);
  font-size: 13px;
}

.progress-labels strong {
  color: var(--muted);
  font-weight: 500;
}

.result-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0 16px;
}

.result-info-card {
  min-height: 102px;
  display: block;
  padding: 17px 18px;
}

.result-info-card[hidden] {
  display: none;
}

.result-list dt {
  color: var(--muted);
  font-size: 14px;
  font-weight: 550;
}

.result-list dd {
  margin: 13px 0 0;
  color: var(--accent);
  font-size: 22px;
  line-height: 1.15;
  font-weight: 700;
}

.result-info-card--purchase {
  border-color: rgba(109, 158, 255, 0.25);
}

.result-info-card--period {
  border-color: rgba(109, 158, 255, 0.18);
}

.result-info-card--transfer {
  border-color: rgba(167, 139, 250, 0.3);
}

.result-info-card--transfer dd {
  color: var(--transfer);
}

.result-info-card--premium {
  border-color: rgba(117, 211, 139, 0.24);
}

.result-list dd.positive {
  color: var(--success);
}

.result-list dd.negative {
  color: var(--danger);
}

.rate-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--field);
}

.rate-card p,
.rate-card strong,
.rate-card small {
  display: block;
}

.rate-card p {
  margin: 0 0 4px;
  color: var(--subtle);
  font-size: 13px;
}

.rate-card strong {
  font-size: 16px;
  font-weight: 600;
}

.rate-card small {
  margin-top: 4px;
  color: var(--subtle);
  font-size: 13px;
}

.rate-card small a {
  margin-left: 8px;
}

.rate-card button {
  min-width: 64px;
  min-height: 40px;
  flex: 0 0 auto;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  background: #191d23;
  font-size: 14px;
}

.rate-card button:hover:not(:disabled) {
  border-color: var(--border-hover);
  color: var(--text);
}

.rate-card button:disabled {
  cursor: progress;
  opacity: 0.6;
}

.result-actions {
  margin-top: 10px;
}

.secondary-button {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  background: var(--field);
  font-size: 14px;
}

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

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: calc(100% - 36px);
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  background: #252932;
  font-size: 14px;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: 0.2s;
}

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

@keyframes pulse {
  50% { opacity: 0.35; }
}

@media (max-width: 620px) {
  .page-shell {
    width: min(100% - 32px, 820px);
    padding-top: 28px;
  }

  .page-intro h1 {
    gap: 10px;
    font-size: 26px;
  }

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

  .panel {
    padding: 18px;
  }

  .form-grid--two {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .price-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

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

  .money-input {
    grid-template-columns: 44px minmax(0, 1fr) 136px;
  }

  .result-highlight-grid,
  .result-list {
    grid-template-columns: 1fr;
  }

  .result-card {
    min-height: 112px;
    padding: 17px;
  }
}

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