:root {
  --bg: #f2f5f3;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --panel-subtle: #f5f8f6;
  --soft: #f5f8f6;
  --ink: #15201b;
  --muted: #65736c;
  --line: #dce4df;
  --line-strong: #c5d1ca;
  --accent: #0d806f;
  --accent-dark: #096557;
  --accent-soft: #e1f3ee;
  --good: #14754a;
  --bad: #b42318;
  --warn: #946000;
  --gold: #ad741c;
  --gold-soft: #fff4da;
  --code: #101a16;
  --code-text: #c9f0df;
  --shadow: 0 12px 32px rgba(24, 45, 35, .065);
}

* { box-sizing: border-box; }
html { min-width: 0; scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif;
  background-color: var(--bg);
  background-image: linear-gradient(180deg, #f8faf8 0, var(--bg) 480px);
  color: var(--ink);
  line-height: 1.48;
}
a { color: var(--accent-dark); text-decoration: none; }
a:hover { color: var(--accent); text-decoration: underline; }
img, svg, canvas { max-width: 100%; }
.wrap { width: min(100%, 1680px); max-width: 1680px; margin: 0 auto; padding: 20px; }
.main, .content, .checker-main, .page-main { min-width: 0; }
h1 { margin: 0 0 7px; font-size: clamp(28px, 3vw, 36px); font-weight: 850; letter-spacing: -.025em; line-height: 1.1; }
h2 { margin: 0; font-size: 17px; line-height: 1.25; letter-spacing: -.01em; }
.sub, .muted, .small { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: 'Cascadia Code', 'Consolas', monospace; overflow-wrap: anywhere; word-break: break-word; }

/* Shared application shell */
.app-shell, .market-shell, .wallet-shell, .wallet-detail-shell, .price-shell, .checker-shell, .shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.app-shell:has(> dashboard-sidebar),
.market-shell:has(> dashboard-sidebar),
.wallet-shell:has(> dashboard-sidebar),
.wallet-detail-shell:has(> dashboard-sidebar),
.price-shell:has(> dashboard-sidebar),
.checker-shell:has(> dashboard-sidebar),
.catalog-shell:has(> dashboard-sidebar),
.shell:has(> dashboard-sidebar) {
  grid-template-columns: 236px minmax(0, 1fr);
}
.side {
  position: sticky;
  top: 20px;
  min-height: calc(100vh - 40px);
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: #14211b;
  color: #edf6f1;
  border: 1px solid #24362e;
  border-radius: 18px;
  box-shadow: 0 18px 42px rgba(17, 32, 25, .14);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 3px 2px 15px; border-bottom: 1px solid rgba(255, 255, 255, .1); }
.brand-mark {
  width: 40px; height: 40px; flex: 0 0 auto; display: grid; place-items: center;
  border: 1px solid rgba(255, 255, 255, .16); border-radius: 12px;
  background: #1e8f7c; color: #fff; font-size: 13px; font-weight: 900;
}
.brand-copy { min-width: 0; flex: 1; }
.brand-name { color: #fff; font-size: 17px; font-weight: 850; line-height: 1.1; }
.brand-sub { margin-top: 4px; color: #93a89d; font-size: 11px; }
.side-menu { display: flex; flex: 1; min-height: 0; flex-direction: column; gap: 16px; }
.side-nav { display: grid; gap: 5px; }
.nav-link {
  min-height: 39px; padding: 9px 11px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid transparent; border-radius: 10px; background: transparent;
  color: #aebfb6; font-size: 13px; font-weight: 750;
}
.nav-link:hover { color: #fff; background: rgba(255, 255, 255, .06); text-decoration: none; }
.nav-link.active { color: #fff; background: #207d6e; border-color: #2f9381; text-decoration: none; }
.side > .side-menu .side-section { border-color: rgba(255, 255, 255, .1); }
.side > .side-menu .side-section-title { color: #93a89d; }
.side-foot {
  margin-top: auto; padding: 11px 12px; border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 11px; background: rgba(0, 0, 0, .14); color: #dfe8e2;
}
.side-toggle { display: none; }

/* Page headers */
.topbar:not(:has(.command-strip)), .page-head, .market-head > .market-hero, .wallet-head > .wallet-hero, .review-hero, .hero, .wrap > .top {
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
  padding: 20px 22px;
  border: 1px solid #25483c;
  border-radius: 18px;
  background: linear-gradient(135deg, #14231c 0, #1b3a30 100%);
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar:not(:has(.command-strip))::after, .page-head::after, .market-head > .market-hero::after, .wallet-head > .wallet-hero::after, .review-hero::after, .hero::after, .wrap > .top::after {
  content: '';
  position: absolute;
  width: 210px; height: 210px; right: -80px; top: -120px;
  border: 34px solid rgba(61, 188, 158, .09); border-radius: 50%; pointer-events: none;
}
.topbar:not(:has(.command-strip)) .sub, .page-head .sub, .market-head > .market-hero .sub, .wallet-head > .wallet-hero .sub, .review-hero .sub, .hero .sub, .wrap > .top .sub { color: #aac0b7; }
.topbar:not(:has(.command-strip)) a, .page-head a, .market-head > .market-hero a, .wallet-head > .wallet-hero a, .review-hero a, .hero a, .wrap > .top a {
  position: relative; z-index: 1; color: #d4eee6;
}
.topbar:not(:has(.command-strip)) a:hover, .page-head a:hover, .market-head > .market-hero a:hover, .wallet-head > .wallet-hero a:hover, .review-hero a:hover, .hero a:hover, .wrap > .top a:hover { color: #fff; }
.market-head > .market-hero, .wallet-head > .wallet-hero { margin-bottom: 0; }
.eyebrow, .page-kicker, .chart-kicker, .section-kicker { color: #6eb8a7; font-size: 11px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.topbar:has(.command-strip) { gap: 14px; }
.command-strip {
  position: relative; overflow: hidden; padding: 21px 23px; border: 1px solid #25483c;
  border-radius: 18px; background: linear-gradient(135deg, #14231c 0, #1b3a30 100%); color: #fff;
  box-shadow: var(--shadow);
}
.command-strip .sub { color: #aac0b7; }
.access-panel { border-radius: 16px; background: var(--panel); border-color: var(--line); box-shadow: var(--shadow); }
.workbench-head {
  padding: 17px 18px; border-radius: 14px; background: linear-gradient(135deg, #14231c 0, #1b3a30 100%); color: #fff;
}
.workbench-head .sub { color: #aac0b7; }

/* Surfaces and information hierarchy */
.panel, .card, .metric, .wallet-section, .market-section, .tool-card, .review-side-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.panel { padding: 16px; margin-bottom: 16px; }
.card, .metric { padding: 15px 16px; }
.section-head, .panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 13px; }
.cards, .stats, .metrics, .metric-grid, .mini-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}
.cards { margin-bottom: 16px; }
.metric { position: relative; min-height: 92px; overflow: hidden; }
.metric::before {
  content: ''; position: absolute; width: 58px; height: 58px; right: -24px; top: -24px;
  left: auto; bottom: auto; border-radius: 50%; background: var(--accent-soft); pointer-events: none;
}
.metric > * { position: relative; z-index: 1; }
.label { color: var(--muted); font-size: 11px; font-weight: 850; letter-spacing: .035em; text-transform: uppercase; }
.value { margin-top: 7px; font-size: 24px; line-height: 1.08; font-weight: 850; overflow-wrap: anywhere; }
.statusbar, .status {
  min-height: 40px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px;
  background: var(--panel-subtle); color: var(--muted); font-size: 13px; overflow-wrap: anywhere;
}
.topbar:not(:has(.command-strip)) + .statusbar { margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr); gap: 16px; }
.stack { display: grid; gap: 16px; }
.toolbar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin-bottom: 12px; }
.actions, .nav-actions, .review-nav, .chart-links, .source-actions, .filter-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nav-actions a, .review-nav a, .chart-links a, .wallet-quick a, .market-quick a {
  display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 6px 10px;
  border: 1px solid currentColor; border-radius: 9px; font-size: 12px; font-weight: 800;
}

/* Inputs and controls */
input, select, textarea {
  width: 100%; min-width: 0;
}
input, select, button, textarea {
  min-height: 38px; padding: 8px 10px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: #fff; color: var(--ink); font: inherit; font-size: 13px;
  box-shadow: 0 1px 0 rgba(16, 20, 18, .03);
}
input::placeholder, textarea::placeholder { color: #91a098; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(13, 128, 111, .18); border-color: var(--accent); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid rgba(13, 128, 111, .22); outline-offset: 2px; }
button {
  width: auto;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--accent); border-color: var(--accent); color: #fff; cursor: pointer; font-weight: 800;
}
button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button.ghost, .ghost { background: #fff; color: var(--ink); border-color: var(--line-strong); }
button.ghost:hover, .ghost:hover { background: var(--panel-subtle); color: var(--accent-dark); }
button.danger { background: var(--bad); border-color: var(--bad); }
button:disabled { opacity: .46; cursor: not-allowed; }
details > summary { cursor: pointer; }

/* Data and tables */
.table-wrap, .scroll, .latest-table-inner { max-width: 100%; overflow: auto; border-radius: 12px; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
th, td { padding: 10px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
th {
  position: sticky; top: 0; z-index: 1; background: var(--panel-subtle); color: var(--muted);
  font-size: 11px; font-weight: 800; letter-spacing: .025em; text-transform: uppercase;
}
tbody tr:hover { background: #f1f7f3; }
tr.clickable:hover { background: var(--accent-soft); cursor: pointer; }
.num { text-align: right; font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.pill, .tool-chip, .badge, .summary-chip, .status-token {
  display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px;
  border: 1px solid #c8e1d8; border-radius: 999px; background: var(--accent-soft);
  color: var(--accent-dark); font-size: 11px; font-weight: 750;
}
.footerbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.pager { display: flex; gap: 9px; align-items: center; }

/* Shared overlays */
.slug-picker { position: relative; }
.slug-options {
  position: absolute; left: 0; right: 0; top: calc(100% + 5px); z-index: 100; display: none;
  max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; box-shadow: 0 16px 34px rgba(24, 39, 31, .16);
}
.slug-option { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.slug-option:hover { background: var(--accent-soft); }
.slug-option .slug { font-family: 'Cascadia Code', 'Consolas', monospace; font-size: 12px; color: var(--ink); overflow-wrap: anywhere; }
.slug-option .name { margin-top: 3px; color: var(--muted); font-size: 12px; }
.market-row { cursor: default; }
.market-row:hover, .market-row:focus { background: var(--accent-soft); }
.market-trade-popover {
  position: fixed; z-index: 150; width: min(780px, calc(100vw - 24px)); max-height: min(520px, calc(100vh - 24px));
  overflow: hidden; border: 1px solid var(--line-strong); border-radius: 14px; background: #fff;
  box-shadow: 0 18px 42px rgba(24, 39, 31, .2); pointer-events: auto;
}
.market-trade-head { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--panel-subtle); }
.market-trade-title { font-weight: 800; }
.market-trade-body { max-height: 420px; overflow: auto; padding: 0 14px 12px; }
.market-trade-status { padding: 12px 14px; color: var(--muted); }
.market-trade-popover table { min-width: 720px; }
.market-trade-popover th, .market-trade-popover td { padding: 8px 7px; font-size: 12px; }

@media (max-width: 1200px) {
  .wrap { padding: 16px; }
  .app-shell, .market-shell, .wallet-shell, .wallet-detail-shell, .price-shell, .checker-shell, .shell { grid-template-columns: 1fr; }
  .app-shell:has(> dashboard-sidebar),
  .market-shell:has(> dashboard-sidebar),
  .wallet-shell:has(> dashboard-sidebar),
  .wallet-detail-shell:has(> dashboard-sidebar),
  .price-shell:has(> dashboard-sidebar),
  .checker-shell:has(> dashboard-sidebar),
  .catalog-shell:has(> dashboard-sidebar),
  .shell:has(> dashboard-sidebar) {
    grid-template-columns: 1fr;
  }
  .side { position: static; min-height: auto; }
  .side-nav { grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); }
  .topbar:has(.command-strip), .grid { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards, .stats, .metrics, .metric-grid, .mini-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  html { scroll-behavior: auto; }
  body { background-image: none; }
  .wrap { width: 100%; padding: 10px; }
  h1 { font-size: 26px; }
  h2 { font-size: 16px; }
  .main, .content, .checker-main { width: 100%; }
  .side { padding: 12px; border-radius: 15px; }
  .side-toggle {
    width: auto; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    flex: 0 0 auto; padding: 7px 10px; border: 1px solid rgba(255, 255, 255, .14); border-radius: 9px;
    background: rgba(255, 255, 255, .07); color: #e6f3ed; box-shadow: none; font-size: 12px; font-weight: 900;
  }
  .side-toggle:hover { background: rgba(255, 255, 255, .12); color: #fff; }
  .side-toggle-icon {
    width: 9px; height: 9px; flex: 0 0 auto; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
    transform: rotate(45deg); margin-top: -4px; transition: transform .16s ease, margin .16s ease;
  }
  .side:not(.is-collapsed) .side-toggle-icon { transform: rotate(225deg); margin-top: 4px; }
  .side.is-collapsed { gap: 0; }
  .side.is-collapsed .brand { padding-bottom: 0; border-bottom: 0; }
  .side.is-collapsed .side-menu { display: none; }
  .side-menu { gap: 10px; }
  .side-nav { grid-template-columns: 1fr; }
  .topbar:not(:has(.command-strip)), .page-head, .market-head > .market-hero, .wallet-head > .wallet-hero, .review-hero, .hero, .wrap > .top, .command-strip {
    padding: 16px; border-radius: 15px;
  }
  .topbar, .page-head, .review-hero, .wrap > .top, .section-head, .panel-head { align-items: flex-start; flex-direction: column; }
  .panel, .wallet-section, .market-section { padding: 13px; border-radius: 14px; }
  .cards, .stats, .metrics, .metric-grid, .mini-metrics, .toolbar, .grid, .query-grid, .scan-grid, .test-grid, .field-grid,
  .detail-toolbar, .source-row, .config-shell, .chart-grid, .tool-grid, .result-grid, .filter-grid { grid-template-columns: 1fr !important; }
  .metric { min-height: 82px; padding: 13px 14px; }
  .value { font-size: 21px; }
  input, select, button, textarea { min-height: 44px; font-size: 16px; }
  button, .nav-actions a, .review-nav a, .chart-links a, .wallet-quick a, .market-quick a { min-height: 44px; }
  .actions, .nav-actions, .review-nav, .chart-links, .source-actions, .filter-actions { width: 100%; }
  .actions > *, .source-actions > button, .filter-actions > button { flex: 1 1 140px; }
  .table-wrap, .scroll, .latest-table-inner { width: 100%; max-width: 100%; overflow-x: auto; }
  .panel:has(> table), .wallet-section:has(> table), .market-section:has(> table) { overflow-x: auto; }
  table:has(th:nth-child(4)) { min-width: 720px; }
  .footerbar { align-items: stretch; }
  .pager { width: 100%; }
  .market-trade-popover { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .sticky-actions, .run-panel, .config-sidebar, .result-panel, .chart-side {
    position: static !important; width: 100%; max-height: none !important;
  }
  .module-tabs {
    top: 0 !important; margin-inline: -3px; padding-inline: 3px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .module-tabs::-webkit-scrollbar { display: none; }
}

@media (max-width: 430px) {
  .cards, .stats, .metrics, .metric-grid, .mini-metrics { grid-template-columns: 1fr; }
  .wrap { padding: 8px; }
}
