:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0d1010;
  color: #f2f6f3;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --panel: #151a18;
  --panel-2: #1b211e;
  --panel-3: #202823;
  --line: #2a332f;
  --line-strong: #39453f;
  --text: #f2f6f3;
  --muted: #9ba9a1;
  --accent: #8ee6a8;
  --positive: #8ee6a8;
  --warning: #ffd48a;
  --info: #9fc8ff;
  --danger: #ff9f9f;
  --focus: #d8ffe3;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #0d1010; }
body { min-height: 100vh; color: var(--text); }
button, input, select, textarea, a { font: inherit; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { min-height: 42px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.exchange-layout { min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.sidebar { border-right: 1px solid var(--line); background: #101412; padding: var(--space-6) 18px; display: flex; flex-direction: column; gap: 28px; }
.brand { display: flex; align-items: center; gap: var(--space-3); }
.brand-mark { display: grid; place-items: center; width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 14px; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); margin-top: 2px; }
nav { display: grid; gap: var(--space-2); }
.nav-item { padding: 11px 12px; border-radius: 10px; color: var(--muted); border: 1px solid transparent; }
.nav-item:hover, .nav-item.active { color: #fff; background: var(--panel); border-color: var(--line); }
.nav-item.unavailable::after { content: " · later"; font-size: 11px; }
.sidebar-note { margin-top: auto; color: var(--muted); font-size: 12px; display: flex; gap: var(--space-2); align-items: center; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

.shell { padding: var(--space-8); min-width: 0; }
.topbar { display: flex; justify-content: space-between; gap: var(--space-6); align-items: flex-start; margin-bottom: 28px; }
.topbar h1, .hero-card h2, .section-heading h2, .component-card h3 { margin: 0; }
.eyebrow { margin: 0 0 var(--space-2); text-transform: uppercase; letter-spacing: .12em; font-size: 11px; color: var(--accent); }
.subtitle, .muted, .empty-state p, .error-state p { color: var(--muted); }
.topbar-actions, .button-row, .status-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

button, .button {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  color: #fff;
  background: var(--panel-2);
  cursor: pointer;
}
button:hover:not(:disabled), .button:hover { border-color: var(--line-strong); background: var(--panel-3); }
button:disabled { opacity: .55; cursor: not-allowed; }
.button-primary { background: #d8ffe3; color: #0d1710; border-color: #d8ffe3; font-weight: 700; }
.button-danger { color: var(--danger); }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #101412;
  color: var(--text);
  padding: 10px 12px;
}
label { display: grid; gap: 7px; }
.label { color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }

.status-pill, .exchange-status {
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 7px 10px;
  font-size: 12px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.status-pill[data-state="error"], .exchange-status[data-tone="danger"] { color: var(--danger); border-color: #644141; }
.exchange-status[data-tone="positive"] { color: var(--positive); border-color: #355744; }
.exchange-status[data-tone="warning"] { color: var(--warning); border-color: #655534; }
.exchange-status[data-tone="info"] { color: var(--info); border-color: #38536e; }
.exchange-status__symbol { font-weight: 800; }

.hero-card, .panel, .component-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}
.hero-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, .7fr); gap: 28px; margin-bottom: var(--space-5); }
.runtime-grid { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.runtime-grid div { background: var(--panel-2); padding: 14px; border-radius: var(--radius-md); }
.runtime-grid dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.runtime-grid dd { margin: 6px 0 0; overflow-wrap: anywhere; }

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: var(--space-4); }
.section-kicker { color: var(--muted); font-size: 12px; }
.empty-state, .error-state { border: 1px dashed var(--line); border-radius: 14px; padding: 28px; margin-top: var(--space-5); }

.component-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); margin-top: var(--space-5); }
.component-card { background: var(--panel-2); }
.component-card > * + * { margin-top: var(--space-3); }
.component-card p { margin-bottom: 0; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-md); }
.exchange-table { width: 100%; border-collapse: collapse; min-width: 620px; }
.exchange-table th, .exchange-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.exchange-table th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.exchange-table tr:last-child td { border-bottom: 0; }

.hash, .numeric { font-variant-numeric: tabular-nums; }
.hash { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }

.skeleton {
  min-height: 16px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--panel-3), #2a332f, var(--panel-3));
  background-size: 200% 100%;
  animation: pulse 1.6s linear infinite;
}
@keyframes pulse { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

.dialog-card { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-5); background: #101412; }
.dialog-card header { display: flex; justify-content: space-between; gap: var(--space-4); align-items: start; }

@media (max-width: 820px) {
  .exchange-layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: var(--space-4); }
  .sidebar nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sidebar-note { display: none; }
  .shell { padding: var(--space-5) var(--space-4) var(--space-8); }
  .topbar, .hero-card { grid-template-columns: 1fr; display: grid; }
  .topbar-actions { align-items: stretch; }
  .component-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .runtime-grid, .form-grid { grid-template-columns: 1fr; }
  button, .button { min-height: 44px; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.market-toolbar { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(220px, .6fr) auto; gap: var(--space-4); align-items: end; margin: var(--space-5) 0 var(--space-4); }
.watch-toggle { display: flex; align-items: center; gap: var(--space-2); min-height: 42px; }
.watch-toggle input { width: auto; min-height: 0; }
.market-summary { color: var(--muted); font-size: 13px; margin-bottom: var(--space-3); }
.market-table { min-width: 1120px; }
.market-table td:first-child, .market-table th:first-child { width: 56px; text-align: center; }
.market-id { display: block; margin-top: 4px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.watch-button { min-height: 36px; min-width: 36px; padding: 6px; border-radius: var(--radius-pill); }
.numeric[data-direction="up"] { color: var(--positive); }
.numeric[data-direction="down"] { color: var(--danger); }
@media (max-width: 820px) {
  .market-toolbar { grid-template-columns: 1fr 1fr; }
  .watch-toggle { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .market-toolbar { grid-template-columns: 1fr; }
  .watch-toggle { grid-column: auto; }
  .market-table th:nth-child(6), .market-table td:nth-child(6),
  .market-table th:nth-child(7), .market-table td:nth-child(7) { display: none; }
  .market-table { min-width: 860px; }
}

.market-link { background: transparent; border: 0; padding: 0; min-height: 0; text-align: left; color: inherit; }
.market-link:hover { background: transparent; border-color: transparent; }
.detail-header { display:flex; align-items:flex-start; justify-content:space-between; gap:var(--space-4); margin-bottom:var(--space-5); }
.detail-header h2 { margin:0; }
.detail-stats { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:var(--space-3); margin-bottom:var(--space-5); }
.detail-stats > div { background:var(--panel-2); border:1px solid var(--line); border-radius:var(--radius-md); padding:var(--space-4); display:grid; gap:6px; }
.detail-toolbar { display:flex; align-items:end; justify-content:space-between; gap:var(--space-4); margin-bottom:var(--space-3); }
.chart-panel { border:1px solid var(--line); border-radius:var(--radius-md); background:#101412; padding:var(--space-3); margin-bottom:var(--space-5); }
.ohlcv-chart { width:100%; min-height:280px; display:block; }
.candle-wick, .candle-body { stroke-width:2; }
.candle-wick.up, .candle-body.up { stroke:var(--positive); fill:var(--positive); }
.candle-wick.down, .candle-body.down { stroke:var(--danger); fill:var(--danger); }
.detail-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:var(--space-4); margin-bottom:var(--space-5); }
.trade-tape { margin:0; padding-left:20px; display:grid; gap:8px; }
@media (max-width:820px) {
  .detail-header { display:grid; }
  .detail-stats { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .detail-grid { grid-template-columns:1fr; }
}
@media (max-width:520px) {
  .detail-stats { grid-template-columns:1fr; }
  .detail-toolbar { display:grid; }
}

.swap-grid { display:grid; grid-template-columns:minmax(0,1.35fr) minmax(320px,.65fr); gap:var(--space-4); margin-top:var(--space-5); }
.swap-health { margin:var(--space-4) 0; }
.route-list { display:grid; gap:var(--space-2); padding-left:22px; color:var(--muted); }
.review-grid { margin:0; display:grid; gap:var(--space-3); }
.review-grid div { background:var(--panel-3); border-radius:var(--radius-sm); padding:var(--space-3); }
.review-grid dt { color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.08em; }
.review-grid dd { margin:5px 0 0; overflow-wrap:anywhere; }
@media (max-width:900px) { .swap-grid { grid-template-columns:1fr; } }

.orders-grid { display:grid; grid-template-columns:minmax(0,1.2fr) minmax(320px,.8fr); gap:var(--space-4); margin-top:var(--space-5); margin-bottom:var(--space-5); }
.orders-table-wrap { margin-top:var(--space-4); }
@media (max-width:900px) { .orders-grid { grid-template-columns:1fr; } }

.bridge-grid { display:grid; grid-template-columns:minmax(0,1.2fr) minmax(320px,.8fr); gap:var(--space-4); margin-top:var(--space-5); margin-bottom:var(--space-5); }
.bridge-health { margin:var(--space-4) 0; }
.bridge-table-wrap { margin-top:var(--space-4); }
@media (max-width:900px) { .bridge-grid { grid-template-columns:1fr; } }

.balance-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:var(--space-4); }
.balance-card strong { font-size:24px; }
.portfolio-section { margin-top:var(--space-6); }
@media (max-width:900px) { .balance-grid { grid-template-columns:1fr; } }

#connect { min-width:150px; }
.wallet-status-panel { margin-top:var(--space-3); }

.sr-only{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}
.table-wrap:focus-visible{outline:2px solid currentColor;outline-offset:2px}
@media (max-width:700px){
  .exchange-table thead{display:none}
  .exchange-table,.exchange-table tbody,.exchange-table tr,.exchange-table td{display:block;width:100%}
  .exchange-table tr{padding:var(--space-3) 0;border-bottom:1px solid var(--border)}
  .exchange-table td{display:grid;grid-template-columns:minmax(110px,38%) 1fr;gap:var(--space-3);align-items:start}
  .exchange-table td::before{content:attr(data-label);font-weight:600;color:var(--text-muted)}
}
