/* Design tokens loaded from ../styles/tokens.css */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--db-font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-app);
  transition: background 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

html {
  overflow-x: hidden;
}

.options {
  width: 90%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 32px 20px 60px;
  overflow-x: hidden;
}

/* ---- 3-Column Layout ---- */

.columns-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  align-items: start;
  min-width: 0;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.col-settings {
  position: sticky;
  top: 20px;
}

.col-library {
  position: sticky;
  top: 20px;
  align-self: start;
}

.col-library .cur-lib-grid-wrap {
  overflow-y: auto;
}

@media (max-width: 900px) {
  .columns-wrap {
    grid-template-columns: 1fr 1fr;
  }

  .col-settings {
    position: static;
  }

  .col-rates {
    order: 3;
  }

  .col-settings {
    order: 1;
  }

  .col-library {
    order: 2;
  }
}

@media (max-width: 780px) {
  .columns-wrap {
    grid-template-columns: 1fr;
  }

  .col-library {
    position: static;
  }

  .col-library .cur-lib-grid-wrap {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .options {
    padding: 20px 12px 40px;
  }

  .options-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
  }

  .options-header h1 {
    font-size: 18px;
  }

  .section {
    padding: 14px 14px;
  }

  .setting-row {
    flex-wrap: wrap;
    gap: 10px;
  }

  .setting-info {
    flex: 1 1 100%;
  }

  .theme-options,
  .time-options {
    flex-wrap: wrap;
    width: 100%;
  }

  .theme-opt {
    flex: 1;
    min-width: 70px;
  }

  .time-opt {
    flex: 1;
    min-width: 60px;
    text-align: center;
  }

  .add-row {
    flex-wrap: wrap;
  }

  .add-row .currency-picker {
    flex: 1 1 calc(50% - 16px);
    min-width: 120px;
  }

  .mr-add-row {
    flex-wrap: wrap;
    gap: 4px;
  }

  .mr-add-row .currency-picker {
    flex: 1 1 calc(50% - 40px);
    min-width: 100px;
  }

  .mr-add-row .mr-amount-input,
  .mr-add-row .mr-rate-input {
    flex: 0 0 auto;
  }

  .mr-add-row .mr-equals {
    padding-top: 6px;
  }

  .pair-arrow {
    padding-top: 6px;
  }

  .add-row .btn-primary {
    width: 100%;
  }

  .domain-add-row {
    flex-wrap: wrap;
  }

  .domain-add-row input {
    flex: 1 1 100%;
  }

  .domain-add-row .currency-picker {
    flex: 1;
  }

  .btn-small {
    flex: 0 0 auto;
  }

  .cur-lib-group-tiles {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  }

  .editor-row {
    flex-direction: column;
    gap: 6px;
  }

  .editor-row label {
    width: 100%;
  }

  .save-toast {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .fetch-status-row {
    flex-direction: column;
    gap: 1px;
  }

  .loaded-rates-header,
  .loaded-rates-row {
    grid-template-columns: 50px 1fr 36px;
  }
}

/* ---- Header ---- */

.options-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-default);
}

.options-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.options-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
}

.options-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0;
  letter-spacing: -0.02em;
}

.options-subtitle {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 1px;
}

/* ---- Sections ---- */

h1 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--accent);
}

h2 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}

h3 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.section {
  background: var(--bg-section);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 10px;
  border: 1px solid var(--border-default);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}

/* Section icons */
.section-icon {
  margin-right: 6px;
}

/* ---- Setting rows ---- */

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  gap: 12px;
  flex-wrap: wrap;
}

.setting-row + .setting-row {
  border-top: 1px solid var(--border-default);
}

.setting-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 0 1 auto;
}

.setting-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.setting-desc {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ---- Language picker — uses .currency-picker shared in components.css ---- */

/* Number format locale picker overrides */
.num-fmt-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.num-fmt-code {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}

.num-fmt-item.selected .num-fmt-code {
  color: var(--accent);
}

.num-fmt-sample {
  font-family: var(--db-mono);
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
}

.num-fmt-item.selected .num-fmt-sample {
  color: var(--accent);
}

/* ---- Toggle switch — shared in components.css ---- */

/* ---- Theme selector ---- */

.theme-options {
  display: flex;
  gap: 6px;
  flex-shrink: 1;
  flex-wrap: wrap;
}

.theme-opt {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border: 2px solid var(--border-default);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--db-font);
  flex: 1;
  min-width: 0;
}

.theme-opt:hover {
  border-color: var(--text-tertiary);
}

.theme-opt.active {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.theme-opt-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.theme-opt.active .theme-opt-label {
  color: var(--accent);
  font-weight: 600;
}

/* ---- Time format selector ---- */

.time-options {
  display: flex;
  gap: 6px;
  flex-shrink: 1;
  flex-wrap: wrap;
}

.time-opt {
  padding: 5px 12px;
  border: 2px solid var(--border-default);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-family: var(--db-font);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  flex: 1;
  min-width: 0;
  text-align: center;
  white-space: nowrap;
}

.time-opt:hover {
  border-color: var(--text-tertiary);
}

.time-opt.active {
  border-color: var(--accent);
  background: var(--accent-muted);
  color: var(--accent);
  font-weight: 600;
}

/* ---- Toggle group ---- */

.toggle-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Rate source search & scroll */

.rate-source-search-wrap {
  margin-bottom: 8px;
}

.rate-source-search {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-default);
  border-radius: var(--db-radius);
  font-size: 13px;
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}

.rate-source-search:focus {
  border-color: var(--accent);
}

.rate-source-search::placeholder {
  color: var(--text-tertiary);
}

.rate-source-scroll {
  max-height: 200px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--bg-card);
}

.rate-source-scroll .toggle-option {
  border-radius: 0;
}

.rate-source-scroll .toggle-option + .toggle-option {
  border-top: 1px solid var(--border-subtle);
}

.toggle-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.toggle-option:hover {
  background: var(--bg-card-hover);
}

.toggle-option input[type="radio"],
.toggle-option input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-default);
  border-radius: 50%;
  transition: all 0.2s;
  position: relative;
  flex-shrink: 0;
}

.toggle-option input[type="checkbox"] {
  border-radius: 4px;
}

.toggle-option input[type="radio"]:checked,
.toggle-option input[type="checkbox"]:checked {
  border-color: var(--accent);
}

.toggle-option input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.toggle-option input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 4px;
  width: 5px;
  height: 9px;
  border: solid var(--accent);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.toggle-option input[type="radio"]:checked ~ .toggle-option-label,
.toggle-option input[type="checkbox"]:checked ~ .toggle-option-label {
  color: var(--accent);
  font-weight: 500;
}

.toggle-option-label {
  font-size: 14px;
  transition: color 0.15s;
}

.source-error-indicator {
  margin-left: auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-error);
  color: var(--text-on-accent);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: help;
}

.source-error-text {
  color: var(--color-error);
  font-weight: 500;
}

.loaded-rates-meta-error {
  color: var(--color-error);
}


/* ---- Chips ---- */

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  min-height: 32px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--accent-muted);
  color: var(--accent);
  border-radius: var(--db-radius-pill);
  font-size: 13px;
  font-weight: 500;
  cursor: grab;
  user-select: none;
  transition: box-shadow 0.15s, transform 0.15s;
}

.chip:active {
  cursor: grabbing;
}

.chip.dragging {
  opacity: 0.5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transform: scale(1.05);
}

.chip.drag-over {
  border-left: 2px solid var(--accent);
}

.chip-remove {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

.chip-remove:hover {
  color: var(--color-error);
}

.add-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.pair-arrow {
  font-size: 18px;
  color: var(--text-secondary);
  padding-top: 8px;
  flex-shrink: 0;
}

/* --- Currency Picker — shared in components.css --- */

.add-pair-error {
  font-size: 12px;
  color: var(--color-error);
  padding-top: 6px;
  display: none;
}

.add-row .btn-primary {
  margin-top: 0;
  align-self: flex-start;
  white-space: nowrap;
}

.add-row select {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  font-size: 13px;
  background: var(--bg-input);
  color: var(--text-primary);
}

/* ---- Preview panel ---- */

.preview-section {
  border: 1px solid var(--border-subtle);
}

.preview-mock {
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: var(--bg-section);
}

.preview-site-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
}

.preview-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.preview-dot-red { background: #ff5f57; }
.preview-dot-yellow { background: #ffbd2e; }
.preview-dot-green { background: #28ca41; }

.preview-url {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-left: 4px;
  font-family: var(--db-mono);
}

.preview-content {
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-primary);
}

.preview-price {
  font-weight: 500;
}

.preview-content .db-pill {
  all: initial;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px 2px;
  margin: 0 2px;
  border-radius: 10px;
  background: var(--accent-muted);
  color: var(--accent);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.85em;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  vertical-align: baseline;
}

/* ---- Currency library ---- */

.cur-lib-search-wrap {
  margin-bottom: 10px;
}

.cur-lib-search {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-default);
  border-radius: var(--db-radius);
  font-size: 13px;
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}

.cur-lib-search:focus {
  border-color: var(--accent);
}

.cur-lib-search::placeholder {
  color: var(--text-tertiary);
}

.cur-lib-grid-wrap {
  max-height: 300px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Unified scrollbar for all scrollable areas */
.cur-lib-grid-wrap::-webkit-scrollbar,
.rate-source-scroll::-webkit-scrollbar,
.loaded-rates-grid::-webkit-scrollbar,
.currency-picker-list::-webkit-scrollbar {
  width: 4px;
}

.cur-lib-grid-wrap::-webkit-scrollbar-thumb,
.rate-source-scroll::-webkit-scrollbar-thumb,
.loaded-rates-grid::-webkit-scrollbar-thumb,
.currency-picker-list::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 4px;
}

.cur-lib-grid-wrap::-webkit-scrollbar-track,
.rate-source-scroll::-webkit-scrollbar-track,
.loaded-rates-grid::-webkit-scrollbar-track,
.currency-picker-list::-webkit-scrollbar-track {
  background: transparent;
}

.cur-lib-group-label {
  position: sticky;
  top: 0;
  padding: 6px 0 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  background: var(--bg-section);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 1;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cur-lib-group-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.cur-lib-group-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
  gap: 6px;
  margin-bottom: 6px;
}

.cur-lib-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cur-tile {
  position: relative;
  padding: 8px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--db-radius);
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.cur-tile:hover {
  border-color: var(--border-subtle);
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.cur-tile-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cur-tile-code {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.03em;
}

.cur-tile-symbol {
  color: var(--text-tertiary);
  font-size: 13px;
}

.cur-tile-actions {
  margin-left: auto;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.cur-tile:hover .cur-tile-actions {
  opacity: 1;
}

.cur-tile-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 14px;
  cursor: pointer;
  padding: 0 3px;
  line-height: 1;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
}

.cur-tile-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.cur-tile-btn-danger:hover {
  color: var(--color-error);
  background: var(--color-error-bg);
}

.cur-tile-name {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cur-tile-domains {
  font-size: 10px;
  color: var(--text-tertiary);
  font-family: var(--db-mono);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cur-tile-detail {
  display: none;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
}

.cur-tile-expanded .cur-tile-detail {
  display: block;
}

.cur-tile-ids {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.cur-tile-expanded .cur-tile-actions {
  opacity: 1;
}

.cur-tile-conflict {
  border-color: var(--color-warning-border);
}

.currency-symbol {
  color: var(--text-secondary);
  font-size: 13px;
}

.identifier-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  font-size: 12px;
  font-family: var(--db-mono);
  color: var(--text-secondary);
}

.identifier-chip-shared {
  border-color: var(--color-warning);
  background: var(--color-warning-bg);
}

.no-identifiers {
  font-size: 12px;
  color: var(--text-tertiary);
  font-style: italic;
}

.identifier-remove {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

.identifier-remove:hover {
  color: var(--color-error);
}

.identifier-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  margin-bottom: 6px;
  min-height: 28px;
}

.add-identifier-row {
  display: flex;
  gap: 6px;
}

.add-identifier-row input {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  font-size: 13px;
  background: var(--bg-input);
  color: var(--text-primary);
}

.long-input {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  font-size: 13px;
  background: var(--bg-input);
  color: var(--text-primary);
}

.currency-editor > label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

/* Conflict warnings */
.conflict-legend {
  margin-bottom: 8px;
  padding: 6px 10px;
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning-border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--color-warning-text);
}

.conflict-warnings {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning-border);
  border-radius: 6px;
}

.conflict-warnings h3 {
  color: var(--color-warning-text);
  margin-bottom: 6px;
}

.conflict-item {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  line-height: 1.5;
}

.conflict-identifier {
  font-family: var(--db-mono);
  font-weight: 600;
}

/* Collapsible "other conflicts" section */
.conflict-other-details {
  margin-top: 8px;
}

.conflict-other-summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 4px 0;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.conflict-other-summary::-webkit-details-marker {
  display: none;
}

.conflict-other-summary::before {
  content: '▸';
  font-size: 11px;
  transition: transform 0.15s ease;
}

.conflict-other-details[open] .conflict-other-summary::before {
  transform: rotate(90deg);
}

.conflict-other-details .conflict-warnings {
  margin-top: 6px;
}

.currency-card-actions {
  margin-top: 4px;
  display: flex;
  gap: 8px;
}

/* Currency editor */
.currency-editor {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg-card);
  border-radius: 6px;
}

.editor-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.editor-row label,
.currency-editor > label {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.block-label {
  display: block;
  margin-top: 8px;
  font-size: 13px;
}

.block-label textarea {
  margin-top: 4px;
}

.short-input {
  width: 60px;
  padding: 4px 8px;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  font-size: 13px;
  background: var(--bg-input);
  color: var(--text-primary);
}

.editor-row input[type="text"]:not(.short-input) {
  flex: 1;
  min-width: 100px;
  padding: 4px 8px;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  font-size: 13px;
  background: var(--bg-input);
  color: var(--text-primary);
}

.editor-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

/* Fetch status panel */
.fetch-status-panel {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: var(--db-radius);
  border: 1px solid var(--border-subtle);
}

.fetch-status-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.fetch-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.fetch-status-dot-ok { background: var(--accent); }
.fetch-status-dot-stale { background: var(--color-warning); }
.fetch-status-dot-error { background: var(--color-error); }

.fetch-status-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.fetch-status-title-error {
  color: var(--color-error);
}

.fetch-status-details {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.fetch-status-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
}

.fetch-status-label {
  color: var(--text-tertiary);
}

.fetch-status-value {
  color: var(--text-secondary);
  font-family: var(--db-mono);
  font-size: 11px;
}

/* Manual rate add row */
.mr-add-row {
  gap: 6px;
}

.mr-amount-input,
.mr-rate-input,
.custom-rate-amount-input {
  width: 64px;
  padding: 4px 8px;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--db-mono);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
  flex-shrink: 0;
}

.custom-rate-amount-input {
  width: 60px;
}

.mr-amount-input:focus,
.mr-rate-input:focus,
.custom-rate-amount-input:focus {
  border-color: var(--accent);
}

.mr-amount-input::placeholder,
.mr-rate-input::placeholder {
  color: var(--text-tertiary);
}

.mr-equals {
  color: var(--text-tertiary);
  font-size: 14px;
  font-weight: 500;
  flex-shrink: 0;
  padding-top: 6px;
}

/* Custom rates */
.custom-rates {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.custom-rates-search-wrap {
  margin-top: 8px;
  margin-bottom: 8px;
}

.custom-rates-search {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-default);
  border-radius: var(--db-radius);
  font-size: 13px;
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}

.custom-rates-search:focus {
  border-color: var(--accent);
}

.custom-rates-search::placeholder {
  color: var(--text-tertiary);
}

.custom-rates-scroll {
  max-height: 240px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--bg-card);
}

.custom-rates-scroll::-webkit-scrollbar {
  width: 4px;
}

.custom-rates-scroll::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 4px;
}

.custom-rates-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.custom-rates-list {
  display: flex;
  flex-direction: column;
}

.custom-rate-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  transition: background 0.1s;
}

.custom-rate-row:last-child {
  border-bottom: none;
}

.custom-rate-row:nth-child(even) {
  background: var(--bg-card-hover);
}

.custom-rate-row:hover {
  background: var(--bg-card-hover);
}

.custom-rate-pair {
  font-weight: 500;
  color: var(--text-primary);
  min-width: 100px;
  white-space: nowrap;
  font-family: var(--db-mono);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.custom-rate-arrow {
  color: var(--text-tertiary);
  font-size: 11px;
}

.custom-rate-equals {
  color: var(--text-tertiary);
  font-size: 12px;
  flex-shrink: 0;
}

.custom-rate-input {
  width: 90px;
  padding: 4px 8px;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--db-mono);
  background: var(--bg-input);
  color: var(--text-primary);
  text-align: right;
  outline: none;
  transition: border-color 0.15s;
}

.custom-rate-input:focus {
  border-color: var(--accent);
}

.custom-rate-input::placeholder {
  color: var(--text-tertiary);
  text-align: left;
}

.custom-rate-delete {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  margin-left: auto;
}

.custom-rate-delete:hover {
  color: var(--color-error);
}

.custom-rate-target {
  font-family: var(--db-mono);
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 36px;
}

.custom-rate-conflict {
  margin-left: auto;
  font-size: 11px;
  color: var(--color-warning);
  white-space: nowrap;
}

/* Rate source picker — options overrides (shared base in components.css) */
.rate-source-picker-dropdown {
  position: fixed;
  top: auto;
  left: auto;
  min-width: 200px;
  background: var(--bg-section);
  box-shadow: var(--shadow-dropdown-lg);
  z-index: var(--z-toast);
}

.rate-source-picker-search {
  padding: 6px 10px;
  background: var(--bg-section);
}

textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  font-size: 13px;
  font-family: monospace;
  resize: vertical;
  background: var(--bg-input);
  color: var(--text-primary);
}

.btn {
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  padding: 8px 20px;
  transition: background 0.2s;
}

.btn-sm {
  padding: 4px 12px;
  font-size: 13px;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-on-accent);
}

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

.btn-link {
  background: none;
  color: var(--accent);
  padding: 2px 8px;
  text-decoration: underline;
}

.btn-link:hover {
  color: var(--accent-light);
}

.btn-danger {
  color: var(--color-error);
}

.btn-danger:hover {
  color: var(--color-error-dark);
}

.domain-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.domain-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg-card);
  border-radius: 4px;
  font-size: 13px;
}

.domain-name {
  flex: 1;
  font-family: var(--db-mono);
}

.domain-cur {
  font-weight: 600;
  color: var(--accent);
  min-width: 32px;
}

.domain-remove {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.domain-remove:hover {
  color: var(--color-error);
}

.domain-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.domain-add-row input {
  flex: 1;
  padding: 4px 8px;
  font-family: var(--db-mono);
  font-size: 0.85rem;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  background: var(--bg-input);
  color: var(--text-primary);
}

.domain-add-row .currency-picker {
  flex: 1;
  min-width: 120px;
}

.btn-small {
  padding: 4px 14px;
  font-size: 0.85rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: var(--accent);
  color: var(--text-on-accent);
  font-weight: 600;
}

.btn-small:hover {
  opacity: 0.85;
}

/* ---- Advanced subsections ---- */

.advanced-subsection {
  padding-top: 12px;
}

.advanced-subsection + .advanced-subsection {
  border-top: 1px solid var(--border-subtle);
  margin-top: 12px;
}

/* ---- Whitelist chips ---- */

.whitelist-add-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.whitelist-add-row input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--db-mono);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}

.whitelist-add-row input:focus {
  border-color: var(--accent);
}

.whitelist-add-row input::placeholder {
  color: var(--text-tertiary);
  font-family: var(--db-font);
}

/* ---- Save toast ---- */

.save-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 8px 20px;
  background: var(--accent);
  color: var(--text-on-accent);
  border-radius: var(--db-radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-dropdown);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: var(--z-toast);
}

.save-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ---- Section header row ---- */

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-header-row h2 {
  margin-bottom: 0;
}

/* ---- Reload button ---- */

.btn-reload {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  font-family: var(--db-font);
  transition: all 0.2s;
}

.btn-reload:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-reload.loading .reload-icon {
  display: inline-block;
  animation: spin 0.8s linear infinite;
}

.btn-reload.loading {
  pointer-events: none;
  opacity: 0.6;
}

.reload-icon {
  font-size: 14px;
  line-height: 1;
}

/* @keyframes spin — shared in components.css */

/* ---- Loaded rates ---- */

.loaded-rates-section {
  margin-top: 10px;
}

.loaded-rates-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 0;
  background: none;
  border: none;
  border-top: 1px solid var(--border-subtle);
  cursor: pointer;
  font-family: var(--db-font);
  font-size: 12px;
  color: var(--text-secondary);
  transition: color 0.15s;
}

.loaded-rates-toggle:hover {
  color: var(--accent);
}

.loaded-rates-chevron {
  font-size: 10px;
  transition: transform 0.2s;
}

.loaded-rates-content {
  margin-top: 6px;
  padding: 8px 0;
}

.loaded-rates-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.loaded-rates-sources {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.loaded-rates-source-group {
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  overflow: hidden;
}

.loaded-rates-source-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg-card);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  transition: background 0.1s;
  user-select: none;
}

.loaded-rates-source-header:hover {
  background: var(--bg-card-hover);
}

.loaded-rates-source-header .loaded-rates-chevron {
  font-size: 10px;
  color: var(--text-tertiary);
  transition: transform 0.15s ease;
}

.loaded-rates-source-name {
  flex: 1;
}

.loaded-rates-source-count {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-tertiary);
}

.loaded-rates-source-body {
  display: none;
  border-top: 1px solid var(--border-subtle);
}

.loaded-rates-source-body.open {
  display: block;
}

.loaded-rates-grid {
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg-card);
}

.loaded-rates-header {
  display: grid;
  grid-template-columns: 60px 1fr 40px;
  gap: 8px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  background: var(--bg-card);
}

.loaded-rates-row {
  display: grid;
  grid-template-columns: 60px 1fr 40px;
  gap: 8px;
  padding: 4px 10px;
  font-size: 12px;
  transition: background 0.1s;
}

.loaded-rates-row:nth-child(even) {
  background: var(--bg-card-hover);
}

.loaded-rates-row:hover {
  background: var(--bg-card-hover);
}

.loaded-rates-code {
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--db-mono);
  font-size: 11px;
}

.loaded-rates-value {
  font-family: var(--db-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

.loaded-rates-type {
  font-size: 10px;
  color: var(--text-tertiary);
  font-family: var(--db-mono);
}

/* ---- Footer ---- */

.options-footer {
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border-default);
  text-align: left;
}

.footer-link {
  font-size: 12px;
  color: var(--text-tertiary);
  text-decoration: none;
  transition: color 0.15s;
}

.footer-link:hover {
  color: var(--accent);
}
