:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #17212b;
  --muted: #61707d;
  --line: #d9e0e5;
  --primary: #1668b3;
  --primary-dark: #10558f;
  --accent: #0f8f7d;
  --danger: #c0392b;
  --focus: #94b8d8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.shell {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
}

.site-header {
  background: #12313f;
  color: #fff;
  border-bottom: 1px solid #0c2531;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 68px;
}

.brand {
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.brand::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 18px;
  margin-right: 10px;
  border-radius: 2px;
  background: #6fd5c2;
}

.site-nav {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.site-nav a {
  color: #c8d6df;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 6px;
  font-weight: 600;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: #fff;
  background: #1d4253;
}

.site-nav a.active {
  color: #fff;
  background: #26596d;
}

.main-layout {
  padding: 32px 0 56px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 1px 2px rgba(23, 33, 43, 0.04);
}

.panel-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: end;
}

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

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

input,
select,
output {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

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

.readonly-output {
  display: flex;
  flex-wrap: wrap;
  gap: 0 4px;
  align-items: center;
  min-height: 40px;
  background: #eef2f4;
  border-color: #ccd5da;
  font-weight: 700;
}

.calculate-button {
  width: 100%;
}

.form-action {
  width: 100%;
  align-self: end;
}

.btn {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.secondary {
  background: #e7eef3;
  color: #234b5f;
  border-color: #c9d5dd;
}

.btn.secondary:hover {
  background: #d8e4ea;
}

.btn.ghost {
  background: transparent;
  color: #fff;
  border-color: #497184;
}

.btn.ghost:hover {
  background: #1d4253;
}

.btn.danger {
  background: #f7e8e5;
  color: var(--danger);
  border-color: #e4b8b0;
}

.btn.danger:hover {
  background: #f1d6d1;
}

.result-region {
  margin-top: 28px;
  border-top: 1px solid var(--line);
  padding-top: 24px;
}

.empty-state,
.notice {
  color: var(--muted);
  background: #f3f6f7;
  border: 1px dashed #c6d0d6;
  border-radius: 8px;
  padding: 18px;
}

.notice.error {
  color: var(--danger);
  background: #f9ecea;
  border-color: #e7bdb6;
}

.best-card {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(180px, 1fr) minmax(220px, 1fr);
  gap: 18px;
  border: 1px solid #bfd6e5;
  background: #f2f8fc;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 22px;
}

.best-card .label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}

.best-card .value {
  font-size: 24px;
  font-weight: 800;
  color: #144b63;
}

.money-reference {
  display: inline;
  margin-left: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
}

.readonly-output > span:first-child {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.readonly-output .money-reference {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.path-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  color: #144b63;
}

.path-flow .arrow {
  color: var(--accent);
}

.section-title {
  margin: 26px 0 12px;
  font-size: 17px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  background: #eef2f4;
  color: #43535f;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tr:last-child td {
  border-bottom: none;
}

.mono {
  font-family: Consolas, "Courier New", monospace;
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e6f3f0;
  color: #14705f;
  font-size: 13px;
  font-weight: 800;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(230px, 1fr));
  gap: 16px;
}

.option-card {
  border: 1px solid #cfd9de;
  border-radius: 8px;
  padding: 18px;
  background: #fff;
}

.option-card h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.option-card.selected {
  border-color: var(--accent);
  background: #edf7f5;
}

.option-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 14px;
}

.option-card dt {
  color: var(--muted);
  font-weight: 700;
}

.option-card dd {
  margin: 0;
  font-weight: 800;
}

.option-card .btn {
  margin-top: 14px;
  width: 100%;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 32, 40, 0.56);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.modal {
  width: min(1080px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  padding: 26px;
  box-shadow: 0 18px 40px rgba(12, 24, 31, 0.24);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.modal-header h2 {
  margin: 0;
  font-size: 22px;
}

.settings-section {
  margin-bottom: 0;
}

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

.settings-section > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.settings-section h3 {
  margin: 0;
  font-size: 18px;
}

.settings-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.settings-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.settings-tab {
  border: 1px solid #c9d5dd;
  border-radius: 6px;
  background: #eef2f4;
  color: #43535f;
  padding: 8px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.settings-tab:hover,
.settings-tab:focus-visible {
  background: #dce6ea;
}

.settings-tab.active {
  background: #d8ecf7;
  border-color: #8fb9d3;
  color: #174f68;
}

.currency-cell {
  min-width: 0;
}

.currency-combined {
  font-weight: 700;
}

.currency-cell .currency-entry {
  width: 100%;
}

.denomination-cell {
  min-width: 0;
}

.denomination-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  width: 100%;
  max-width: 480px;
}

.settings-table.editing .denomination-list {
  gap: 2px;
}

.denomination-item {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.denomination-item .btn {
  width: 20px;
  min-height: 22px;
  padding: 0;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

.denomination-item input {
  width: 9ch;
  min-width: 68px;
  padding: 4px 5px;
  font-size: 13px;
  text-align: center;
}

.denomination-item input[type="number"]::-webkit-outer-spin-button,
.denomination-item input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

.denomination-item input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.denomination-add {
  margin-top: 6px;
  width: fit-content;
}

.muted-value {
  color: var(--muted);
  font-weight: 600;
}

.btn.confirm {
  background: #ffe8c2;
  border-color: #e7b65c;
  color: #8a5a10;
}

.btn.confirm:hover {
  background: #ffdca4;
}

.settings-table input,
.settings-table select {
  min-height: 36px;
  padding: 6px 8px;
  width: 100%;
  min-width: 0;
  display: block;
  margin-inline: auto;
  text-align: center;
}

.settings-table .denomination-item input {
  width: 9ch;
  min-width: 68px;
  padding: 4px 5px;
  font-size: 13px;
}

.settings-table {
  table-layout: fixed;
}

.settings-table th,
.settings-table td {
  text-align: center;
  vertical-align: middle;
  border-bottom: none;
}

.settings-table th:not(:last-child),
.settings-table td:not(:last-child) {
  border-right: 1px solid var(--line);
}

.settings-table thead th {
  border-bottom: 1px solid var(--line);
}

.settings-table tbody tr {
  border-bottom: 1px solid var(--line);
}

.settings-table tbody tr:last-child {
  border-bottom: none;
}

.rates-table th:nth-child(1),
.rates-table th:nth-child(2) {
  width: 30%;
}

.rates-table th:nth-child(3) {
  width: 24%;
}

.rates-table input[data-field="rate"] {
  width: 110px;
}

.rates-table select {
  max-width: 160px;
}

.currencies-table th:nth-child(1) {
  width: 30%;
}

.currencies-table th:nth-child(2) {
  width: 55%;
}

.settings-table select:disabled {
  -webkit-appearance: none;
  appearance: none;
  background-color: #fff;
  color: var(--text);
}

.settings-table .actions {
  display: flex;
  justify-content: center;
}

.settings-table .btn {
  min-height: 34px;
  padding: 5px 10px;
  font-size: 13px;
}

.settings-table .denomination-item .btn {
  width: 20px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  font-size: 11px;
  line-height: 1;
}

.form-message {
  margin: 14px 0 0;
  color: var(--danger);
  font-weight: 700;
}

.form-message.success {
  color: #16734a;
}

.modal-note {
  color: var(--muted);
  margin: 10px 0 0;
  font-size: 13px;
}

@media (max-width: 900px) {
  .modal-backdrop {
    align-items: flex-start;
    padding: 12px;
  }

  .modal {
    padding: 18px 16px;
  }

  .modal-header h2 {
    font-size: 19px;
  }

  .settings-table th,
  .settings-table td {
    padding: 10px;
  }

  .settings-table .btn {
    font-size: 12px;
    padding: 5px 7px;
  }

  .denomination-item .btn {
    width: 20px;
    min-height: 24px;
    height: 24px;
    padding: 0;
    font-size: 11px;
    line-height: 1;
  }

  .settings-table .denomination-item input {
    width: 9ch;
    min-width: 68px;
  }

  .header-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "brand"
      "nav";
    align-items: center;
    gap: 12px;
    min-height: 0;
    padding: 14px 0;
  }

  .brand {
    grid-area: brand;
    display: inline-flex;
    align-items: center;
    font-size: 15px;
  }

  .site-nav {
    grid-area: nav;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-left: 0;
  }

  .site-nav a {
    text-align: center;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.25;
    border: 1px solid #315d6d;
    background: #163b4b;
  }

  .site-nav a.active {
    background: #226275;
    border-color: #3d7f92;
  }

  .panel {
    padding: 20px;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-grid,
  .denomination-grid {
    grid-template-columns: 1fr;
  }

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

  .best-card,
  .option-grid {
    grid-template-columns: 1fr;
  }

  .settings-section > header {
    flex-direction: column;
    align-items: flex-start;
  }
}
