:root {
  --bg: #141414;
  --bg-elevated: #1c1c1c;
  --surface: #262626;
  --surface-hover: #323232;
  --text: #ffffff;
  --text-secondary: #ececec;
  --muted: #b4b8c0;
  --accent: #f0f0f0;
  --accent-hover: #ffffff;
  --accent-soft: rgba(255, 255, 255, 0.1);
  --border: #404040;
  --border-light: #4d4d4d;
  --success: #4ade80;
  --danger: #f87171;
  --china: #de2910;
  --china-gold: #ffde00;
  --korea-red: #cd2e3a;
  --korea-blue: #0047a0;
  --radius: 12px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body[data-region='china'] {
  --accent: var(--china);
  --accent-hover: #ff4a3d;
  --accent-soft: rgba(222, 41, 16, 0.18);
}

body[data-region='korea'] {
  --accent: var(--korea-blue);
  --accent-hover: #1a5fd4;
  --accent-soft: rgba(0, 71, 160, 0.22);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app-header {
  background: var(--bg-elevated);
  color: var(--text);
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.app-header::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--china) 0%,
    var(--china) 38%,
    var(--china-gold) 38%,
    var(--china-gold) 42%,
    var(--korea-blue) 42%,
    var(--korea-blue) 88%,
    var(--korea-red) 88%,
    var(--korea-red) 100%
  );
}

.header-flags {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.header-flags .flag {
  display: inline-block;
  height: 4px;
  border-radius: 2px;
}

.flag--cn {
  width: 48px;
  background: linear-gradient(90deg, var(--china) 70%, var(--china-gold) 70%);
}

.flag--kr {
  width: 48px;
  background: linear-gradient(90deg, var(--korea-blue) 50%, var(--korea-red) 50%);
}

.app-header__inner {
  max-width: 1100px;
  margin: 0 auto;
}

.app-header h1 {
  margin: 0 0 8px;
  font-size: clamp(1.4rem, 3vw, 1.85rem);
  font-weight: 700;
}

.app-header p {
  margin: 0;
  opacity: 0.88;
  font-size: 0.95rem;
  max-width: 52ch;
}

.header-link {
  color: var(--text-secondary);
  text-decoration: none;
}

.header-link:hover {
  color: var(--accent);
}

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
  width: 100%;
}

@media (max-width: 640px) {
  .layout {
    padding: 12px;
  }

  .card {
    padding: 16px;
  }

  .summary-total {
    font-size: 1.55rem;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .field-row--rates {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .actions .btn {
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
  }
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 20px;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.tabs .tab {
  flex-shrink: 0;
}

.tab {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}

.tab:hover {
  border-color: var(--accent);
}

.tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

body[data-region='china'] .tab.is-active,
body[data-region='korea'] .tab.is-active {
  color: #fff;
}

.panel {
  display: none;
}

.panel.is-active {
  display: block;
}

.grid {
  display: grid;
  gap: 20px;
}

@media (min-width: 900px) {
  .grid--calc {
    grid-template-columns: minmax(280px, 1fr) minmax(280px, 400px);
    align-items: start;
  }
}

.results-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* overflow на форме ломает позицию нативных <select> в Chrome/Edge */
.form-scroll,
.card,
.panel,
.layout,
.field,
.field-row {
  overflow: visible;
}

.form-scroll {
  max-height: none;
}

/* select без .c-select__native — fallback */
.field select:not(.c-select__native) {
  display: block;
  width: 100%;
  background-color: var(--surface);
}

.field input[type='date'] {
  display: block;
  width: 100%;
}

.rates-heading {
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.rates-note {
  margin: 0 0 8px;
  font-size: 0.82rem;
  line-height: 1.4;
}

.field-row--rates {
  grid-template-columns: repeat(3, 1fr);
}

@media (min-width: 700px) {
  .field-row--rates {
    grid-template-columns: repeat(4, 1fr);
  }
}

.field-row--3 {
  grid-template-columns: 1fr;
}

@media (min-width: 700px) {
  .field-row--3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.region-hint {
  margin: 0 0 12px;
  padding: 10px 14px;
  background: var(--accent-soft);
  border-radius: 10px;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.region-hint:empty {
  display: none;
}

.field-hint.ok {
  color: var(--success);
}

.field-hint.warn {
  color: var(--danger);
}

.rates-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.field-inline {
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-sm {
  width: 64px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.scenario-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.scenario-tab {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
}

.scenario-tab.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.scenario-range {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.scenario-pill {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: var(--bg-elevated);
  color: var(--muted);
}

.scenario-pill.is-active {
  border-style: solid;
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.summary-sub {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 8px;
}

.profit-box {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.profit-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  padding: 4px 0;
}

.profit-accent {
  color: var(--success);
}

.compare-table tr.row-highlight td {
  background: var(--accent-soft);
  font-weight: 700;
}

.risks-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.risks-list--ok {
  color: var(--success);
}

.risks-list--warn {
  color: var(--danger);
}

.early-row {
  align-items: end;
  margin-bottom: 8px;
  grid-template-columns: 1fr 1fr 1fr auto;
}

@media (max-width: 700px) {
  .early-row {
    grid-template-columns: 1fr 1fr;
  }
}

.early-row .btn {
  margin-bottom: 14px;
}

.early-list {
  margin-bottom: 10px;
}

.compare-table-wrap {
  overflow-x: auto;
  overflow-y: visible;
}

.credit-table td:first-child,
.credit-table th:first-child {
  white-space: nowrap;
}

.credit-summary {
  margin-top: 16px;
  padding: 12px;
  background: var(--accent-soft);
  border-radius: 10px;
  font-size: 0.92rem;
}

.credit-total-box {
  margin-top: 12px;
  padding: 14px;
  border: 2px solid var(--accent);
  border-radius: 12px;
  background: var(--surface);
}

.credit-total-box .label {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0 0 4px;
}

.credit-total-box .value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  margin: 0;
}

.pay-diff {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px;
  text-align: right;
  justify-content: flex-end;
}

.pay-was {
  color: var(--muted);
  text-decoration: line-through;
  font-weight: 500;
}

.pay-now {
  color: var(--success);
}

.pay-extra {
  display: block;
  width: 100%;
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 600;
}

.credit-table tr.row-changed td {
  background: rgba(45, 106, 79, 0.06);
}

.saved-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  margin-left: 6px;
}

.grid--credit {
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .grid--credit {
    grid-template-columns: 360px 1fr;
  }
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card h2 {
  color: var(--text);
}

.card h2 {
  margin: 0 0 16px;
  font-size: 1.1rem;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  background: var(--bg-elevated);
  color: var(--text);
}

.field input:focus,
.field select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.field-row {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.field-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

.summary-rows .muted {
  color: var(--muted);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

.checkbox input {
  width: auto;
}

.section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  font-weight: 700;
  margin: 20px 0 12px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.section-title:first-child {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

.summary {
  position: static;
}

.summary-total {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
  margin: 8px 0 4px;
}

.summary-rows {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
}

.summary-rows li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.88rem;
}

.summary-rows li:last-child {
  border-bottom: none;
}

.summary-rows .muted {
  color: var(--muted);
}

.summary-rows .val {
  font-weight: 600;
  white-space: nowrap;
}

.summary-rows .val.is-discount {
  color: var(--success);
}

.badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  margin-left: 6px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.btn {
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  border-radius: 999px;
  padding: 11px 20px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn:hover {
  background: var(--accent-soft);
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn--danger {
  border-color: var(--danger);
  color: var(--danger);
}

.btn--danger:hover {
  background: rgba(179, 58, 58, 0.08);
}

.btn--sm {
  padding: 7px 14px;
  font-size: 0.8rem;
}

.disclaimer {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 14px;
  line-height: 1.45;
}

.saved-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.saved-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.saved-item__main {
  flex: 1;
  min-width: 200px;
}

.saved-item__title {
  font-weight: 700;
  margin: 0 0 4px;
}

.saved-item__meta {
  font-size: 0.82rem;
  color: var(--muted);
}

.saved-item__total {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent);
}

.saved-item__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compare-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  padding: 14px;
  background: var(--accent-soft);
  border-radius: 12px;
}

.compare-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 0;
}

.compare-table.cities-table {
  font-size: 0.82rem;
  table-layout: fixed;
}

.compare-table.cities-table th,
.compare-table.cities-table td {
  padding: 8px 6px;
  word-break: break-word;
}

.compare-table.cities-table th:nth-child(2),
.compare-table.cities-table td:nth-child(2),
.compare-table.cities-table th:nth-child(3),
.compare-table.cities-table td:nth-child(3) {
  width: 28%;
}

.compare-table.cities-table th:nth-child(4),
.compare-table.cities-table td:nth-child(4) {
  width: 12%;
}

.compare-table.credit-table {
  font-size: 0.78rem;
  min-width: 520px;
}

.compare-table.credit-table th,
.compare-table.credit-table td {
  padding: 6px 8px;
}

.compare-table th,
.compare-table td {
  padding: 10px 12px;
  border: 1px solid var(--border);
  text-align: right;
}

.compare-table th:first-child,
.compare-table td:first-child {
  text-align: left;
  font-weight: 600;
  background: var(--surface);
  color: var(--text-secondary);
  position: sticky;
  left: 0;
}

.compare-table td {
  color: var(--text);
}

.compare-table thead th {
  background: var(--surface-hover);
  color: var(--text);
  font-weight: 600;
  border-color: var(--border);
}

.compare-table tr.total td {
  font-weight: 800;
  background: var(--accent-soft);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 100;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.hint-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  margin-left: 6px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: help;
  vertical-align: middle;
}

.extra-list .extra-row {
  margin-bottom: 8px;
}

.print-only {
  display: none;
}

.print-params {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.print-params th,
.print-params td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.print-params th {
  width: 38%;
  color: var(--muted);
  font-weight: 600;
}

.app-header__row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.auth-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.auth-bar__email {
  opacity: 0.9;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn--header {
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
  padding: 8px 14px;
  font-size: 0.82rem;
}

.btn--header:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.btn--credit-cta {
  width: 100%;
  margin-top: 12px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 36, 29, 0.45);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.is-open {
  display: flex;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow);
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 {
  margin: 0 0 16px;
}

.modal-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.modal-tab {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
}

.modal-tab.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.faq-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.faq-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
  overflow: hidden;
}

.faq-item summary {
  padding: 14px 16px;
  font-weight: 700;
  cursor: pointer;
  background: var(--surface-hover);
}

.faq-item__body {
  padding: 0 16px 14px;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.55;
}

.faq-item__body p {
  margin: 0 0 10px;
}

.faq-item__body ul {
  margin: 0;
  padding-left: 18px;
}

.site-footer {
  max-width: 1100px;
  margin: 24px auto 32px;
  padding: 0 20px;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

.site-footer a {
  color: var(--text-secondary);
}

.site-footer a:hover {
  color: var(--accent);
}

.region-hint {
  background: var(--accent-soft);
  color: var(--text-secondary);
}

@media print {
  .no-print,
  .print-summary {
    display: none !important;
  }

  .print-only {
    display: block !important;
  }
  body {
    background: var(--surface);
  }
  .layout {
    display: block;
  }
  .grid--calc {
    display: block;
  }
  .results-col {
    width: 100%;
  }
  .card {
    box-shadow: none;
    break-inside: avoid;
  }
}
