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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #0d1117;
  color: #c9d1d9;
  min-height: 100vh;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  position: relative;
}

/* ── Theme toggle (sliding pill) ── */

.theme-pill {
  position: absolute;
  top: 2.5rem;
  left: 1.5rem;
  cursor: pointer;
}

.theme-pill input {
  display: none;
}

.theme-pill__track {
  display: block;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: #21262d;
  position: relative;
  transition: background 0.3s;
}

.theme-pill__knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #c9d1d9;
  transition: transform 0.3s, background 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-pill__knob::before {
  content: "\1F319";
  font-size: 10px;
  line-height: 1;
}

/* Checked = light mode: knob slides right, show sun */
.theme-pill input:checked + .theme-pill__track {
  background: #d0d7de;
}

.theme-pill input:checked + .theme-pill__track .theme-pill__knob {
  transform: translateX(18px);
  background: #f7931a;
}

.theme-pill input:checked + .theme-pill__track .theme-pill__knob::before {
  content: "\2600\FE0F";
}

/* ── Heading ── */

h1 {
  text-align: center;
  font-size: 2rem;
  font-weight: 700;
  color: #f7931a;
  margin-bottom: 0.25rem;
}

h1 .accent {
  color: #e8e6e3;
}

/* ── Updated-at ── */

#updatedAt {
  text-align: center;
  font-size: 0.85rem;
  color: #6e7681;
  margin-bottom: 1.5rem;
}

/* ── Table wrapper (responsive scroll) ── */

.table-wrap {
  overflow-x: auto;
  border-radius: 10px;
  background: #161b22;
}

/* ── Table ── */

#priceTable {
  width: 100%;
  border-collapse: collapse;
}

#priceTable th,
#priceTable td {
  padding: 0.8rem 1rem;
  text-align: center;
  border: none;
  white-space: nowrap;
}

/* faint row separators */
#priceTable tbody tr + tr {
  border-top: 1px solid #21262d;
}

/* ── Header cells ── */

#priceTable th {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6e7681;
  padding-top: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #21262d;
}

/* ── Row hover ── */

#priceTable tbody tr:hover {
  background: #1c2128;
}

/* ── Sort header ── */

.sort-header {
  cursor: pointer;
  user-select: none;
}

.sort-header:hover {
  color: #c9d1d9;
}

body.light .sort-header:hover {
  color: #1f2328;
}

/* ── Updated-at wrapper ── */

.updated-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.updated-wrap #updatedAt {
  margin-bottom: 0;
}

/* ── Refresh button ── */

.refresh-btn {
  background: none;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #6e7681;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0.2rem 0.45rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.refresh-btn:hover {
  color: #f7931a;
  border-color: #f7931a;
}

body.light .refresh-btn {
  border-color: #d0d7de;
  color: #656d76;
}

body.light .refresh-btn:hover {
  color: #f7931a;
  border-color: #f7931a;
}

/* ── Average row ── */

.average-row {
  background: rgba(247, 147, 26, 0.08) !important;
  font-weight: 600;
  border-top: 1px solid rgba(247, 147, 26, 0.25) !important;
}

/* ── Note spans ── */

.note {
  font-size: 0.7em;
  color: #8b949e;
  font-weight: 400;
}

/* ── USDT Premium card ── */

.usdt-card {
  margin-top: 1rem;
  padding: 0.9rem 1.25rem;
  border-radius: 10px;
  background: #161b22;
  cursor: pointer;
  user-select: none;
}

.usdt-card h2 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6e7681;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.5em;
}

.usdt-card h2::after {
  content: "";
  display: inline-block;
  width: 0.45em;
  height: 0.45em;
  border-right: 1.5px solid #6e7681;
  border-bottom: 1.5px solid #6e7681;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.usdt-card.expanded h2::after {
  transform: rotate(45deg);
}

.usdt-rate {
  font-size: 1.3rem;
  font-weight: 700;
  color: #c9d1d9;
}

.usdt-offers {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease;
}

.usdt-card.expanded .usdt-offers {
  max-height: 20rem;
}

.usdt-offer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
  font-size: 0.8rem;
  color: #8b949e;
  border-top: 1px solid #21262d;
  gap: 0.75rem;
}

.usdt-offer:first-child {
  margin-top: 0.6rem;
}

.usdt-offer__merchant {
  flex: 1;
  font-family: monospace;
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.usdt-offer__price {
  font-weight: 600;
  color: #c9d1d9;
  white-space: nowrap;
}

.usdt-offer__methods {
  font-size: 0.7rem;
  white-space: nowrap;
}

.usdt-offer__limits {
  font-size: 0.7rem;
  white-space: nowrap;
}

/* ── Converter card ── */

.converter-card {
  margin-top: 1.5rem;
  padding: 1.25rem 1.5rem;
  border-radius: 10px;
  background: #161b22;
}

.converter-card h2 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6e7681;
  margin-bottom: 1rem;
}

.converter-fields {
  display: flex;
  gap: 1rem;
}

.converter-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.converter-field--premium {
  flex: 0 0 6.5rem;
}

.converter-field label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6e7681;
}

.converter-field input {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  color: #c9d1d9;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s;
}

.converter-field input:focus {
  border-color: #f7931a;
}

.converter-field input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Hide number spin buttons */
.converter-field input::-webkit-outer-spin-button,
.converter-field input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.converter-field input[type="number"] {
  -moz-appearance: textfield;
}

#converterRate {
  font-size: 0.85rem;
  color: #6e7681;
  margin-top: 0.75rem;
}

/* ── Disclaimer ── */

.disclaimer {
  text-align: center;
  font-size: 0.75rem;
  color: #6e7681;
  margin-top: 1.5rem;
}

/* ── Light mode ── */

body.light {
  background: #f6f8fa;
  color: #1f2328;
}

body.light .table-wrap,
body.light .converter-card,
body.light .usdt-card {
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

body.light .usdt-rate {
  color: #1f2328;
}

body.light .usdt-card h2 {
  color: #656d76;
}

body.light .usdt-offer {
  color: #656d76;
  border-top-color: #d0d7de;
}

body.light .usdt-offer__price {
  color: #1f2328;
}

body.light h1 .accent {
  color: #1f2328;
}

body.light #updatedAt,
body.light #converterRate,
body.light #priceTable th,
body.light .converter-card h2,
body.light .converter-field label {
  color: #656d76;
}

body.light #priceTable tbody tr + tr {
  border-top-color: #d0d7de;
}

body.light #priceTable th {
  border-bottom-color: #d0d7de;
}

body.light #priceTable tbody tr:hover {
  background: #f3f4f6;
}

body.light .average-row {
  background: rgba(247, 147, 26, 0.06) !important;
  border-top-color: rgba(247, 147, 26, 0.3) !important;
}

body.light .note {
  color: #656d76;
}

body.light .converter-field input {
  background: #f6f8fa;
  border-color: #d0d7de;
  color: #1f2328;
}

body.light .converter-field input:focus {
  border-color: #f7931a;
}

body.light .converter-field input:disabled {
  opacity: 0.5;
}

body.light .theme-pill__track {
  background: #d0d7de;
}

@media (max-width: 500px) {
  .container {
    padding: 1.5rem 0.75rem;
  }

  #priceTable th,
  #priceTable td {
    padding: 0.6rem 0.5rem;
    font-size: 0.85rem;
    white-space: normal;
  }

  #priceTable th {
    font-size: 0.6rem;
  }

  .converter-fields {
    flex-direction: column;
  }

  .converter-field--premium {
    flex: auto;
  }

  .usdt-offer {
    flex-wrap: wrap;
  }

  .usdt-offer__merchant {
    flex-basis: 50%;
  }
}
