:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  --page: #f6f4f0;
  --surface: #fffefd;
  --ink: #1e1c1b;
  --muted: #6d6863;
  --line: #eae5df;
  --accent: #b82e2d;
  --accent-light: #fff0ec;
  --green: #18734f;
  --green-light: #e7f5ed;
  --gold: #88601d;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; background: var(--page); color: var(--ink); }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.shell {
  width: min(100% - 72px, 1512px);
  min-height: 100vh;
  min-height: 100dvh;
  margin-inline: auto;
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr) 38px;
}
.topbar, .top-status, .wordmark, .feed-label, .paper-label {
  display: flex;
  align-items: center;
}
.topbar { justify-content: space-between; gap: 12px; }
.wordmark {
  color: var(--ink);
  text-decoration: none;
  gap: 10px;
  font-size: 20px;
  font-weight: 850;
  letter-spacing: -.055em;
}
.brand-logo { width: 36px; height: 32px; object-fit: contain; }
.top-status { gap: 9px; flex-shrink: 0; }
.feed-label, .paper-label {
  min-height: 31px;
  padding: 0 11px;
  border-radius: 100px;
  gap: 7px;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 680;
  white-space: nowrap;
}
.paper-label { border: 1px solid #e2d9cf; color: #625650; }
.feed-label { background: #ece9e4; color: #625b54; }
.feed-label[data-state="live"] { background: var(--green-light); color: var(--green); }
.feed-label[data-state="stale"], .feed-label[data-state="offline"] { background: #f9efdc; color: var(--gold); }
.status-dot { width: 6px; height: 6px; background: currentColor; border-radius: 50%; }
.feed-label[data-state="live"] .status-dot { animation: pulse 2.9s ease-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 #18734f32; } 60% { box-shadow: 0 0 0 5px #18734f00; } }
main {
  min-height: 0;
  display: grid;
  grid-template-rows: clamp(178px, 23vh, 210px) auto minmax(0, 1fr);
  gap: 14px;
}
.lead { display: grid; grid-template-columns: minmax(0, 1.62fr) minmax(305px, 1fr); gap: 14px; min-height: 0; }
.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  align-items: center;
  background: #821d22;
  border-radius: 22px;
  color: #fff9f4;
}
.hero img, .hero-overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero img { z-index: -2; width: 65%; left: auto; object-fit: cover; object-position: 62% 44%; mask-image: linear-gradient(to right, transparent, black 24%); }
.hero-overlay {
  z-index: -1;
  background: linear-gradient(92deg, #55151bf5 0%, #7e2126c9 28%, #8a232350 51%, transparent 70%), linear-gradient(0deg, #44201e55, transparent 65%);
}
.hero-content {
  margin-left: clamp(20px, 3.1vw, 50px);
  padding-block: 12px;
}
.hero h1 {
  margin: 0;
  max-width: min(25ch, calc(100% - 14px));
  font-size: clamp(24px, 3.05vw, 42px);
  letter-spacing: .016em;
  line-height: 1.12;
  font-weight: 850;
  text-wrap: balance;
  text-shadow: 0 4px 24px #3e0d154d;
}
.market-panel.panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: clamp(11px, 1.45vw, 20px);
  gap: 10px;
  font-variant-numeric: tabular-nums;
}
.market-head, .market-symbol, .market-meta, .quote-levels {
  display: flex;
  align-items: center;
}
.market-head { justify-content: space-between; gap: 8px; min-height: 30px; }
.market-symbol { gap: 8px; }
.market-coin {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #934e16;
  background: #f2e7d1;
  font-size: 19px;
}
.market-frame {
  border-radius: 6px;
  background: #f2efe9;
  color: #675a53;
  padding: 3px 6px;
  font-size: 11px;
  font-weight: 700;
}
.market-timer { display: grid; gap: 3px; }
.market-timer time {
  font-size: clamp(19px, 2.1vw, 30px);
  font-weight: 770;
  letter-spacing: -.05em;
  line-height: 1;
}
.round-track { display: block; height: 3px; border-radius: 9px; background: #f0e8e2; overflow: hidden; }
.round-track i { display: block; width: 100%; height: 100%; background: var(--accent); transform-origin: left center; transform: scaleX(0); transition: transform .32s linear; }
.quote-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.quote { min-width: 0; padding: 7px 9px; border-radius: 9px; align-content: center; }
.quote-up { background: #edf5ef; color: #1e6c4c; }
.quote-down { background: #fbefec; color: #a8433b; }
.quote-side { font-size: 10px; font-weight: 740; }
.quote-levels { gap: 5px; flex-wrap: wrap; align-items: baseline; }
.quote-levels strong { font-size: clamp(18px, 2vw, 28px); letter-spacing: -.04em; line-height: 1.18; }
.quote-levels > span, .quote-age { opacity: .88; font-size: 11px; }
.quote-age { margin-top: 2px; }
.market-meta {
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 3px 7px;
  padding-top: 5px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}
#market-status { font-weight: 660; }
#market-freshness { margin-left: auto; }
.market-meta [data-state="live"] { color: var(--green); }
.market-meta [data-state="partial"], .market-meta [data-state="stale"], .quote-age[data-state="stale"] { color: var(--gold); }
.quote-age[data-state="unavailable"] { color: var(--muted); }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 2px 10px #30231303;
}
.metric {
  min-width: 0;
  border-radius: 15px;
  padding: 14px 19px 13px;
  font-variant-numeric: tabular-nums;
}
.metric h2 { color: var(--muted); font-size: 12px; margin: 0 0 4px; font-weight: 650; }
.metric-value {
  font-size: clamp(23px, 3vw, 40px);
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -.058em;
  overflow-wrap: anywhere;
}
.metric-note { color: var(--muted); margin-top: 5px; font-size: 11px; line-height: 1.25; }
.result-note { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 8px; }
.positive { color: var(--green); }
.negative { color: var(--accent); }
.workspace { display: grid; grid-template-columns: minmax(0, 1.24fr) minmax(0, 1fr); gap: 14px; min-height: 0; }
.panel {
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.panel-head {
  min-height: 63px;
  padding: 15px 17px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  flex-shrink: 0;
}
.panel h2 {
  display: flex;
  gap: 7px;
  align-items: center;
  font-size: 20px;
  letter-spacing: -.047em;
  margin: 0;
  line-height: 1.08;
  font-weight: 780;
}
.chart-value { font-size: 13px; color: var(--muted); font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.chart-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px; min-width: 0; }
.segments { display: flex; flex: none; padding: 2px; border-radius: 8px; background: #f2efeb; gap: 2px; }
.segments.periods { max-width: 100%; flex-wrap: wrap; }
.segments button {
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  padding: 5px 8px;
  min-height: 28px;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 680;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.segments button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 4px #2920161a; }
.segments button:hover[aria-pressed="false"] { background: #ebe5de; color: var(--ink); }
.period-strip {
  padding: 0 16px 7px;
  flex-shrink: 0;
}
.period-form, .period-date-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
}
.period-form { column-gap: 10px; }
.period-date-fields { min-width: 0; }
.period-month-nav {
  display: flex;
  flex: none;
  align-items: center;
  gap: 4px;
}
.period-month-label {
  min-width: 88px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  text-align: center;
}
.period-month-label::first-letter { text-transform: uppercase; }
.period-form label {
  display: flex;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
}
.period-form input, .period-form button {
  min-height: 27px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  font: 600 11px Inter, "Segoe UI", Arial, sans-serif;
}
.period-form input { width: clamp(103px, 9vw, 124px); padding: 3px 4px; }
.period-form button { cursor: pointer; padding: 4px 6px; }
.period-form button:hover:not(:disabled) { border-color: #c7b5a9; }
.period-form button:disabled { opacity: .45; cursor: default; }
.period-month-nav button { min-width: 27px; font-size: 18px; line-height: 1; padding-block: 2px; }
#period-reset { padding-inline: 6px; font-size: 13px; }
.tip-result { display: flex; gap: 6px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tip-result:not(:has(> :not([hidden]))) { display: none; }
.chart-area {
  position: relative;
  flex: 1;
  min-height: 77px;
  margin: 0 12px 10px;
  overflow: hidden;
}
.chart-area canvas { display: block; width: 100%; height: 100%; touch-action: pan-y; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; pointer-events: none; }
.chart-tip {
  position: absolute;
  top: 6px;
  left: 0;
  padding: 6px 9px;
  pointer-events: none;
  color: var(--ink);
  background: #fffefd;
  border: 1px solid var(--line);
  box-shadow: 0 4px 15px #2e20131a;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
}
.chart-tip strong { display: block; font-size: 13px; margin-top: 2px; }
.count-pill {
  display: inline-block;
  border-radius: 8px;
  background: #f4f0ea;
  color: #645951;
  padding: 4px 6px;
  font-size: 10px;
  letter-spacing: normal;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.deals-panel .panel-head { padding-inline: 16px; }
.deals-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  flex-shrink: 0;
  gap: 5px 10px;
  padding: 0 16px 8px;
}
.deals-filter, .deals-outcomes, .deals-totals { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; }
.deals-filter select {
  min-height: 27px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 4px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 650;
}
.deals-outcomes, .deals-totals { flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.deals-outcomes { column-gap: 10px; }
.deals-outcomes > span { white-space: nowrap; }
.deals-outcomes[hidden] { display: none; }
.deals-totals strong { font-size: 12px; white-space: nowrap; }
.deals-scroll {
  min-height: 0;
  flex: 1;
  overflow: auto;
  scrollbar-color: #d6cec4 transparent;
  scrollbar-width: thin;
}
.deals-scroll:focus-visible { outline-offset: -4px; }
.deals-table { width: 100%; border-spacing: 0; font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.deals-table th, .deals-table td { text-align: left; padding: 8px 9px; }
.deals-table th:first-child, .deals-table td:first-child { padding-left: 16px; }
.deals-table th:last-child, .deals-table td:last-child { text-align: right; padding-right: 17px; }
.deals-table th {
  background: #f9f7f4;
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 2;
  font-weight: 640;
  font-size: 11px;
  border-block: 1px solid #f0ece8;
}
.deals-table th button {
  border: 0;
  border-radius: 4px;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
}
.deals-table th button:hover, .deals-table th[aria-sort] button { color: var(--ink); }
.deals-table th[aria-sort="ascending"] button::after { content: " ↑"; }
.deals-table th[aria-sort="descending"] button::after { content: " ↓"; }
.deals-table td { border-bottom: 1px solid #f0ece8; }
.deals-table tr:last-child td { border-bottom: 0; }
.deals-date { color: var(--muted); font-size: 11px; }
.deal-signal { font-weight: 700; font-size: 11px; }
.direction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 6px;
  background: var(--green-light);
  color: var(--green);
  padding: 3px 6px;
  font-size: 10px;
  font-weight: 740;
}
.direction.down { background: var(--accent-light); color: var(--accent); }
.deal-pnl { font-weight: 730; }
.deals-table td.deals-empty { text-align: center; padding: 34px 9px; color: var(--muted); }
.deal-open { color: var(--gold); font-size: 11px; font-weight: 650; }
.bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
@media (min-width: 970px) and (min-height: 700px) {
  .shell { height: 100vh; height: 100dvh; }
}
@media (min-width: 970px) and (max-height: 760px) {
  .shell { grid-template-rows: 56px minmax(0, 1fr) 30px; }
  main { grid-template-rows: 158px auto minmax(0, 1fr); gap: 10px; }
  .lead, .metrics, .workspace { gap: 10px; }
  .metric { padding-block: 10px; }
  .hero h1 { font-size: clamp(25px, 2.75vw, 38px); }
  .market-panel { padding: 10px 13px; gap: 6px; }
  .panel-head { min-height: 52px; padding-block: 8px; }
  .period-strip { padding-bottom: 5px; }
}
@media (max-width: 969px) {
  .shell { width: calc(100% - 36px); grid-template-rows: 58px 1fr auto; }
  main { grid-template-rows: minmax(175px, auto) auto auto; gap: 12px; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .chart-panel { min-height: 310px; }
  .deals-panel { max-height: 380px; min-height: 250px; }
  .bottom { padding-block: 12px; }
}
@media (max-width: 580px) {
  .shell { width: calc(100% - 22px); grid-template-rows: 54px 1fr auto; }
  .wordmark { font-size: 18px; gap: 7px; }
  .brand-logo { width: 29px; height: 26px; }
  .top-status { gap: 5px; }
  .paper-label, .feed-label { padding-inline: 7px; font-size: 9.5px; min-height: 27px; }
  main { grid-template-rows: auto auto auto; }
  .hero { border-radius: 15px; }
  .hero img { width: 100%; object-position: 61% 48%; mask-image: none; }
  .hero-overlay { background: linear-gradient(90deg, #55151bf2 1%, #7e21268c 55%, #8a232302 100%); }
  .hero-content { margin-left: 15px; }
  .period-strip { padding-inline: 9px; }
  .market-panel { gap: 7px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .metric { border-radius: 10px; padding: 10px 11px; }
  .metric-value { font-size: 25px; }
  .metric-note { font-size: 10px; }
  .panel { border-radius: 12px; }
  .panel-head, .deals-panel .panel-head { padding: 10px 9px; min-height: 49px; }
  .deals-toolbar { padding-inline: 9px; }
  .panel h2 { font-size: 17px; }
  .segments button { padding: 4px 5px; min-height: 25px; font-size: 10px; }
  .chart-controls { gap: 4px; }
  .chart-area { margin-inline: 7px; }
  .chart-panel { min-height: 260px; }
  .deals-table th, .deals-table td { padding-inline: 6px; }
  .deals-table th:first-child, .deals-table td:first-child { padding-left: 10px; }
  .deals-table th:last-child, .deals-table td:last-child { padding-right: 10px; }
  .bottom { font-size: 10px; gap: 5px; }
}
@media (max-width: 460px) {
  .chart-panel .panel-head { flex-wrap: wrap; }
  .chart-controls { justify-content: flex-start; }
}
@media (max-width: 360px) {
  .feed-label { max-width: 78px; white-space: normal; }
  .status-dot { flex: 0 0 6px; }
  .deals-table th, .deals-table td { padding-inline: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.brand-accent { color: var(--accent); }
.history-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 8px;
}
.history-gap {
  border: 1px solid #e8ddcb;
  border-radius: 4px;
  color: #7e581c;
  line-height: 1.1;
  padding: 2px 4px;
}
@media (min-width: 970px) and (max-height: 699px) {
  .shell {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    grid-template-rows: 50px minmax(0, 1fr) 27px;
  }
  main { grid-template-rows: clamp(145px, 24vh, 158px) auto minmax(0, 1fr); gap: 8px; }
  .hero h1 { font-size: clamp(23px, 4.4vh, 31px); }
  .chart-area { min-height: 0; }
}
@media (max-width: 580px) {
  .bottom { align-items: flex-start; }
  .bottom > #last-update { text-align: right; }
}

@media (max-width: 699px) {
  .lead { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(142px, auto) auto; gap: 9px; }
  .hero h1 { font-size: clamp(14px, 5vw, 28px); }
  .hero h1 span { display: block; white-space: nowrap; }
}
