:root {
  color-scheme: dark;
  --bg: #111315;
  --surface: #181b1e;
  --surface-2: #202428;
  --surface-3: #252a2f;
  --line: #343a40;
  --line-soft: #2a2f34;
  --text: #f1f3f4;
  --muted: #9aa2a9;
  --subtle: #6f777e;
  --accent: #8fa3a2;
  --accent-strong: #b7c9c5;
  --peak: #c5a56b;
  --current: #8aa899;
  --danger: #b87b7b;
  --shadow: 0 12px 28px rgba(0, 0, 0, .32);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); color: var(--text); }
button, a, input { font: inherit; }
svg { display: block; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 96px 1fr 44px;
  background: radial-gradient(circle at 50% -10%, #272b2f 0, #111315 42%, #0d0f10 100%);
}

.topbar {
  display: grid;
  grid-template-columns: 300px minmax(220px, 1fr) auto;
  align-items: center;
  gap: 22px;
  padding: 0 24px 0 8px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(24, 27, 30, .96);
}

.brand { display: flex; align-items: center; text-decoration: none; min-width: 0; }
.brand img { width: 300px; max-height: 72px; object-fit: contain; filter: saturate(.25) contrast(1.08); }

.top-tabs { display: flex; align-items: center; gap: 6px; justify-self: center; padding: 4px; border: 1px solid var(--line-soft); border-radius: 7px; background: #131618; }
.top-tabs a { min-width: 92px; padding: 8px 12px; border-radius: 5px; color: var(--muted); text-align: center; text-decoration: none; font-size: 13px; font-weight: 600; }
.top-tabs a.active { color: var(--text); background: var(--surface-3); box-shadow: inset 0 0 0 1px #3d444a; }

.toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 12px; min-width: 0; }
.search-pill { width: 280px; height: 36px; padding: 0 12px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line-soft); border-radius: 6px; color: var(--muted); background: #111315; }
.search-pill svg, .icon-button svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.search-pill input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 13px; }
.search-pill input::placeholder { color: #737b82; }
.sync-status { display: grid; gap: 2px; color: var(--muted); text-align: right; font-size: 11px; white-space: nowrap; }
.sync-status strong { color: var(--text); font-size: 12px; font-weight: 600; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line-soft); border-radius: 6px; color: var(--muted); background: #15181a; cursor: pointer; }

.dashboard { padding: 24px 34px 28px; overflow: auto; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: stretch; margin-bottom: 14px; }
.hero-copy, .brief-panel, .kpi-strip article, .chart-panel, .insight-stack article, .table-panel, .feed-panel { border: 1px solid var(--line-soft); background: rgba(24, 27, 30, .92); box-shadow: var(--shadow); }
.hero-copy { padding: 18px 20px; }
.eyebrow { display: block; margin-bottom: 6px; color: var(--accent-strong); font-size: 11px; font-weight: 700; letter-spacing: 0; text-transform: uppercase; }
.hero-copy h1 { margin: 0; max-width: 760px; font-size: 24px; font-weight: 560; line-height: 1.22; }
.hero-copy p { margin: 8px 0 0; max-width: 780px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.brief-panel { padding: 16px; display: grid; align-content: center; gap: 6px; }
.brief-panel span, .kpi-strip span, .insight-stack span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.brief-panel strong { font-size: 17px; font-weight: 650; }
.brief-panel p, .insight-stack p { margin: 0; color: var(--subtle); font-size: 12px; line-height: 1.45; }

.kpi-strip { display: grid; grid-template-columns: repeat(6, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi-strip article { padding: 13px 14px; display: grid; gap: 5px; min-height: 82px; }
.kpi-strip strong { font-size: 19px; font-weight: 650; }
.kpi-strip small { color: var(--subtle); font-size: 11px; font-weight: 600; }

.analysis-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; }
.kpi-strip-three { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
.kpi-strip-four { grid-template-columns: repeat(4, minmax(160px, 1fr)); }
.overview-analysis { grid-template-columns: 1fr; }
.overview-chart { min-height: 300px; }
.page-heading { margin-bottom: 14px; padding: 18px 20px; border: 1px solid var(--line-soft); background: rgba(24, 27, 30, .92); box-shadow: var(--shadow); }
.page-heading h1 { margin: 0; font-size: 24px; font-weight: 560; line-height: 1.22; }
.page-heading p { margin: 8px 0 0; max-width: 760px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.single-column { grid-template-columns: 1fr; }
.transaction-layout { grid-template-columns: 300px minmax(0, 1fr); align-items: start; }

.chart-panel { padding: 18px 20px; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.panel-header h2 { margin: 0; font-size: 17px; font-weight: 650; }
.panel-header span { color: var(--muted); font-size: 12px; font-weight: 600; }
.panel-header.compact { margin-bottom: 10px; }
.panel-header.compact h2 { font-size: 16px; }
.legend { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.legend span { display: flex; align-items: center; gap: 7px; }
.legend i { width: 28px; height: 10px; border-radius: 3px; }
.volume-key { background: #757c82; }
.peak-key { background: var(--peak); }

.bar-chart { height: 230px; display: grid; grid-template-columns: repeat(12, minmax(44px, 1fr)); gap: 9px; align-items: end; overflow-x: auto; padding-top: 6px; }
.bar { height: 100%; min-width: 44px; display: grid; grid-template-rows: 20px 1fr 18px; gap: 5px; align-items: end; color: var(--muted); text-align: center; font-weight: 600; }
.bar span, .bar b { font-size: 11px; }
.bar i { width: 100%; height: calc(var(--value) * 1%); min-height: 5px; align-self: end; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, #8c9398, #565d62); }
.bar.peak i { background: linear-gradient(180deg, #d0b881, #8d7442); }
.bar.current i { background: linear-gradient(180deg, #9bb9a9, #657d71); }

.insight-stack { display: grid; gap: 10px; }
.insight-stack article { padding: 15px; display: grid; gap: 7px; }
.insight-stack strong { font-size: 16px; font-weight: 650; }
.meter { height: 20px; position: relative; overflow: hidden; border-radius: 4px; background: #111315; border: 1px solid var(--line-soft); }
.meter i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #65736d, #9bb9a9); }
.meter b { position: relative; z-index: 1; display: grid; place-items: center; height: 100%; color: var(--text); font-size: 11px; }

.data-grid { margin-top: 14px; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, .9fr); gap: 14px; }
.table-panel, .feed-panel { padding: 16px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 9px; border-bottom: 1px solid var(--line-soft); text-align: left; }
th { color: var(--subtle); font-size: 11px; text-transform: uppercase; letter-spacing: 0; }
td { color: var(--text); font-size: 12px; font-weight: 600; }
td:nth-child(2), td:nth-child(3) { white-space: nowrap; }
code { color: var(--accent-strong); font-family: "SFMono-Regular", Consolas, monospace; font-size: 11px; }
tr[hidden] { display: none; }

.tx-feed { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.tx-feed li { display: grid; grid-template-columns: 78px 1fr auto; gap: 8px; align-items: center; padding: 8px 10px; background: #141719; border: 1px solid var(--line-soft); }
.tx-feed time, .tx-feed span { color: var(--muted); font-size: 12px; font-weight: 600; }

.footer-bar { min-height: 44px; padding: 0 34px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; color: var(--muted); border-top: 1px solid var(--line-soft); background: #151719; font-size: 12px; font-weight: 600; }
.footer-bar > span:last-child { justify-self: end; }
.x-link { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line-soft); border-radius: 50%; color: #fff; background: #101214; text-decoration: none; transition: border-color .18s ease, color .18s ease, background .18s ease; }
.x-link:hover { color: #fff; border-color: #5c646a; background: #181b1e; }
.x-link img { width: 13px; height: 13px; object-fit: contain; }
.footer-bar b { color: var(--text); font-size: 13px; }
.footer-bar mark { margin-left: 6px; padding: 3px 8px; border-radius: 4px; color: #101211; background: var(--accent-strong); }

@media (max-width: 1260px) {
  .topbar { grid-template-columns: minmax(280px, 1fr); grid-template-areas: "brand" "toolbar" "tabs"; height: auto; min-height: 144px; padding: 12px 14px; }
  .brand { grid-area: brand; }
  .top-tabs { grid-area: tabs; justify-self: start; }
  .toolbar { grid-area: toolbar; }
  .sync-status { display: none; }
  .kpi-strip, .kpi-strip-three, .kpi-strip-four { grid-template-columns: repeat(3, 1fr); }
  .analysis-grid, .hero-grid, .data-grid, .transaction-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .topbar { display: flex; flex-direction: column; align-items: stretch; gap: 12px; padding: 14px; }
  .brand { justify-content: flex-start; }
  .brand img { width: min(300px, 90vw); max-height: 72px; }
  .top-tabs { justify-content: center; overflow-x: auto; }
  .top-tabs a { min-width: auto; flex: 1; }
  .toolbar { justify-content: center; flex-wrap: wrap; }
  .search-pill { width: 100%; }
  .dashboard { padding: 16px 12px 26px; }
  .hero-copy h1 { font-size: 21px; }
  .kpi-strip, .kpi-strip-three, .kpi-strip-four { grid-template-columns: 1fr 1fr; }
  .bar-chart { height: 190px; }
  .panel-header { flex-direction: column; }
  .legend { flex-wrap: wrap; }
  .tx-feed li { grid-template-columns: 1fr; }
  .footer-bar { padding: 14px; min-height: 76px; grid-template-columns: 1fr; justify-items: start; }
  .footer-bar > span:last-child { justify-self: start; }
  .x-link { justify-self: start; }
}
