:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #090b10;
  color: #eef2f7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #090b10;
}

button,
input {
  font: inherit;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar,
.status,
.links,
.admin-form {
  display: flex;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #8a94a6;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.1;
}

.button {
  border: 1px solid #263041;
  background: #172033;
  color: #eef2f7;
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
}

.button.secondary {
  background: #121722;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  border-radius: 50%;
}
.icon-button:hover {
  background: #1d2738;
}

/* Quicknav: brand on the left (Anvil + X), collection icons on the right with count. */
.quicknav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding: 10px 12px;
  border: 1px solid #1a2030;
  border-radius: 10px;
  background: #0b0f18;
}
.qn-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.qn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  height: 32px;
  font-size: 13px;
  font-weight: 600;
  color: #eef2f7;
  text-decoration: none;
  border: 1px solid #1f2a3e;
  border-radius: 8px;
  background: #121722;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.qn-link:hover {
  background: #1d2738;
  border-color: #2a3852;
  color: #fff;
}
.qn-anvil {
  background: linear-gradient(180deg, #1c2840 0%, #14203a 100%);
  border-color: #2a3852;
}
.qn-x {
  width: 32px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}
.qn-collections {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
  justify-content: flex-end;
}
.qn-count {
  font-size: 12px;
  color: #8a94a6;
  white-space: nowrap;
}
.qn-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.qn-item {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid #1f2a3e;
  border-radius: 50%;
  background: #121722;
  cursor: pointer;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, transform 0.15s;
}
.qn-item:hover {
  border-color: #6dd49b;
  transform: scale(1.08);
}
.qn-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.qn-placeholder {
  font-size: 10px;
  font-weight: 700;
  color: #8a94a6;
}

/* Site footer */
.site-footer {
  margin-top: 36px;
  padding: 18px 0 8px;
  border-top: 1px solid #1a2030;
  text-align: center;
  color: #6d7791;
  font-size: 12px;
}
.site-footer p { margin: 2px 0; }
.site-footer a {
  color: #9bb6da;
  text-decoration: none;
  font-weight: 600;
}
.site-footer a:hover { color: #c4d4ea; text-decoration: underline; }
.footer-tagline {
  font-style: italic;
  color: #4a5468;
  letter-spacing: 0.02em;
}

/* Card highlight on quicknav jump */
.card.highlight {
  border-color: #6dd49b;
  box-shadow: 0 0 0 2px rgba(109, 212, 155, 0.55), 0 0 24px rgba(109, 212, 155, 0.25);
  transition: border-color 0.3s, box-shadow 0.3s;
}

.status {
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  color: #8a94a6;
  font-size: 14px;
}

.admin {
  margin-top: 18px;
}

.admin-form {
  width: 100%;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid #202838;
  border-radius: 8px;
  background: #0d111a;
}

.hidden {
  display: none;
}

.admin-form input {
  min-width: 180px;
  flex: 1;
  border: 1px solid #263041;
  border-radius: 8px;
  background: #090b10;
  color: #eef2f7;
  padding: 9px 10px;
}

.admin-form p {
  width: 100%;
  color: #8a94a6;
  font-size: 13px;
}

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

.card {
  position: relative;
  min-width: 0;
  border: 1px solid #202838;
  border-radius: 8px;
  background: #0d111a;
  /* overflow visible so tooltips inside the card can escape its bounds */
  overflow: visible;
}

/* Trash button — always visible, neutral idle, danger on hover. */
.card-trash {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid #202838;
  background: #121722;
  color: #8a94a6;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.card-trash:hover {
  background: #2a1a22;
  border-color: #3a2530;
  color: #ef6d8c;
}

/* Inline disable confirm panel */
.disable-panel {
  margin: 10px 14px;
  padding: 12px;
  border: 1px solid #3a2530;
  border-radius: 8px;
  background: #1a1015;
}
.disable-panel.hidden { display: none; }
.disable-warn { margin: 0 0 10px; font-size: 13px; color: #ffb38a; }
.disable-token {
  width: 100%;
  border: 1px solid #3a2530;
  border-radius: 6px;
  background: #090b10;
  color: #eef2f7;
  padding: 8px 10px;
  font: inherit;
  margin-bottom: 10px;
}
.disable-actions { display: flex; gap: 8px; }
.button.danger { background: #2a1a22; border-color: #3a2530; color: #ef6d8c; }
.button.danger:hover { background: #3a2530; }
.disable-msg { margin: 8px 0 0; font-size: 12px; color: #ef6d8c; }

/* Card sections */
.sec {
  padding: 14px 16px;
  border-top: 1px solid #1a2030;
}
.sec:first-of-type { border-top: none; }
.sec header {
  margin-bottom: 10px;
}
.sec header h3 {
  margin: 0 0 2px;
  font-size: 13px;
  color: #aab4c8;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
}
.sec .caption {
  margin: 0;
  font-size: 12px;
  color: #6d7791;
  line-height: 1.45;
}

.sec-market header h3 { color: #6dd49b; }
.sec-amm    header h3 { color: #e0c374; }
.sec-route  header h3 { color: #9bb6da; }
.sec-pool   header h3 { color: #c89bd6; }

/* Key-value layout used across sections */
dl.kv {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 16px;
  margin: 0;
  font-size: 14px;
}
dl.kv dt {
  color: #8a94a6;
  font-size: 13px;
}
dl.kv dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
dl.kv dd.good { color: #6dd49b; }
dl.kv dd.bad  { color: #ef6d8c; }

.pool-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted #4a5468;
}
.pool-link:hover { color: #9bb6da; border-bottom-color: #9bb6da; }

/* Best route panel */
.routes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.route {
  display: flex;
  flex-direction: column;
  border: 1px solid #1f2a3e;
  border-radius: 8px;
  background: #0e1623;
  /* overflow visible so [data-tooltip] children (e.g. .route-diff) can escape */
}
.route-you-are {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  color: #8a94a6;
  text-transform: uppercase;
  letter-spacing: .12em;
}
.route-header {
  position: relative;
  padding: 8px 12px;
  text-align: center;
  background: #131c2d;
  border-bottom: 1px solid #1f2a3e;
  border-top-left-radius: 7px;
  border-top-right-radius: 7px;
}
.route-title {
  font-size: 16px;
  font-weight: 700;
  color: #eef2f7;
  letter-spacing: 0.02em;
}
.route-badge {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  font-size: 10px;
  color: #6dd49b;
  background: #122a1d;
  padding: 2px 6px;
  border-radius: 4px;
}
.route-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
}
.route-action {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  color: #eef2f7;
  letter-spacing: -0.01em;
}
.route-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.route-price {
  font-size: 15px;
  color: #aab4c8;
  font-variant-numeric: tabular-nums;
}
.route-diff {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}
.route-diff.good { color: #6dd49b; background: rgba(109, 212, 155, 0.1); }
.route-diff.bad  { color: #ef6d8c; background: rgba(239, 109, 140, 0.1); }
.route-note, .route-hint {
  font-size: 12px;
  color: #8a94a6;
}
.route-hint { color: #6d7791; font-size: 11px; }
.route-note { color: #ffb38a; }
.route-empty {
  color: #6d7791;
  font-size: 13px;
}

/* Liquidity bar */
.bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
}
.bar-track {
  width: 70px;
  height: 6px;
  background: #1a2030;
  border-radius: 3px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  transition: width 0.3s;
}
.bar-fill.good { background: #6dd49b; }
.bar-fill.ok   { background: #c8d46d; }
.bar-fill.warn { background: #e0c374; }
.bar-fill.bad  { background: #ef6d8c; }
.bar-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.bar-label.good { color: #6dd49b; }
.bar-label.ok   { color: #c8d46d; }
.bar-label.warn { color: #e0c374; }
.bar-label.bad  { color: #ef6d8c; }

/* Impact bar in simulator */
.impact-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 110px;
}
.impact-track {
  flex: 1;
  height: 6px;
  background: #1a2030;
  border-radius: 3px;
  overflow: hidden;
  min-width: 50px;
}
.impact-fill {
  height: 100%;
  transition: width 0.3s;
}
.impact-fill.good { background: #6dd49b; }
.impact-fill.ok   { background: #c8d46d; }
.impact-fill.warn { background: #e0c374; }
.impact-fill.bad  { background: #ef6d8c; }
.impact-val {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  min-width: 52px;
  text-align: right;
}
.impact-val.good { color: #6dd49b; }
.impact-val.ok   { color: #c8d46d; }
.impact-val.warn { color: #e0c374; }
.impact-val.bad  { color: #ef6d8c; }

/* Nested simulator details */
.nested-sim {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #1a2030;
  border-radius: 8px;
  background: #0a0e17;
}
.nested-sim > summary {
  cursor: pointer;
  font-size: 12px;
  color: #aab4c8;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.nested-sim h4 {
  margin: 12px 0 6px;
  font-size: 12px;
  color: #8a94a6;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* Small helpers */
.small { font-size: 12px; }
.age   { color: #6d7791; }

table.sim {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.sim th, table.sim td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid #1a2030;
}
table.sim th {
  color: #8a94a6;
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
table.sim td.good { color: #6dd49b; }
table.sim td.bad  { color: #ef6d8c; }

.warnings {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #2a1a22;
  border: 1px solid #3a2530;
}
.warnings .warn {
  margin: 0 0 4px;
  font-size: 13px;
  color: #ffb38a;
}
.warnings .warn:last-child { margin-bottom: 0; }

/* Custom tooltip — Tailwind-inspired: dark slate bg, rounded, shadow, fade-in, arrow.
   `:where()` zeros specificity so already-positioned elements (e.g. .card-trash absolute)
   keep their own positioning. */
:where([data-tooltip]) {
  position: relative;
}
[data-tooltip]::after,
[data-tooltip]::before {
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease-out, transform 0.15s ease-out;
  position: absolute;
  z-index: 50;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translate(-50%, 4px);
  max-width: 260px;
  width: max-content;
  padding: 8px 10px;
  border-radius: 6px;
  background: #0f172a; /* slate-900 */
  color: #f8fafc;       /* slate-50 */
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: none;
  text-align: left;
  white-space: normal;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  border: 1px solid #1e293b; /* slate-800 */
}
[data-tooltip]::before {
  content: '';
  left: 50%;
  bottom: calc(100% + 3px);
  transform: translate(-50%, 4px);
  border: 5px solid transparent;
  border-top-color: #0f172a;
}
[data-tooltip]:hover::after,
[data-tooltip]:hover::before,
[data-tooltip]:focus-visible::after,
[data-tooltip]:focus-visible::before {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.tip {
  cursor: help;
  border-bottom: 1px dotted #4a5468;
}
.tip-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  line-height: 14px;
  text-align: center;
  border-radius: 50%;
  background: #2a3245;
  color: #aab4c8;
  font-size: 10px;
  font-weight: 700;
  margin-left: 4px;
  vertical-align: 1px;
}

.hero {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 14px;
  padding: 14px;
  align-items: center;
}

.hero img,
.placeholder {
  width: 84px;
  height: 84px;
  border-radius: 8px;
  object-fit: cover;
  background: #151b28;
}

.placeholder {
  display: grid;
  place-items: center;
  color: #8a94a6;
  font-weight: 700;
}

.title {
  min-width: 0;
}

.title h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 20px;
}

.title p,
.muted,
.details {
  color: #8a94a6;
}

.title p {
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.links {
  border-top: 1px solid #202838;
  border-bottom: 1px solid #202838;
}

.links a {
  flex: 1;
  padding: 9px;
  color: #b9c2d2;
  text-align: center;
  text-decoration: none;
  font-size: 13px;
}

.links a + a {
  border-left: 1px solid #202838;
}

.good {
  color: #40d98a;
}

.bad,
.error {
  color: #ff7a64;
}

.details {
  border-top: 1px solid #202838;
  padding: 12px 14px 14px;
  font-size: 13px;
}

.details summary {
  cursor: pointer;
  color: #b9c2d2;
}

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

.fee-grid h3 {
  margin-bottom: 6px;
  color: #eef2f7;
  font-size: 13px;
}

.fee-grid p,
.details > p {
  margin-top: 4px;
}

@media (max-width: 760px) {
  main {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  h1 { font-size: 22px; }

  .grid {
    display: block;
  }

  .card + .card {
    margin-top: 14px;
  }

  /* Quicknav: stack brand row above the collections row on small screens */
  .quicknav {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .qn-brand { justify-content: flex-start; }
  .qn-collections {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .qn-icons {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
    flex: 1 1 100%;
  }
  .qn-item { flex: 0 0 auto; }

  /* Best routes: stack Buyer / Seller vertically so the action text stays large */
  .routes {
    grid-template-columns: 1fr;
  }

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