/* Brand layer: one system across Home, Markets, Dashboard, Risks. Loaded last. No logic changes. */

html body {
  --sc-radius-panel: 8px;
  --sc-radius-control: 4px;
  --sc-rule: 1px solid var(--sc-border);
  --sc-space-section: 64px;
}

/* Header */
html body .site-header,
html body header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 64px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding: 12px 32px;
  background: var(--sc-canvas) !important;
  border-bottom: var(--sc-rule) !important;
}

html body .brand-link,
html body .site-brand {
  font-size: 18px !important;
  font-weight: 650 !important;
  letter-spacing: -0.01em !important;
  color: var(--sc-ink) !important;
  text-decoration: none;
}

html body .site-nav {
  display: flex;
  gap: 4px;
  align-items: center;
}

html body .site-nav a {
  padding: 8px 12px !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  color: var(--sc-ink-2) !important;
  text-decoration: none;
  border-radius: var(--sc-radius-control);
}

html body .site-nav a:hover {
  color: var(--sc-ink) !important;
  background: var(--sc-elevated);
}

html body .site-nav a.active {
  color: var(--sc-ink) !important;
  background: transparent;
  box-shadow: inset 0 -2px 0 var(--sc-accent);
  border-radius: 0;
}

html body button:active,
html body .home-primary:active {
  transform: translateY(1px) scale(0.99);
}

html body .home-primary,
html body .home-calculator-action,
html body .wallet,
html body .dashboard-connect button,
html body #dashboardConnectButton {
  background: var(--sc-accent) !important;
  color: var(--sc-canvas) !important;
  border: 1px solid transparent !important;
}

html body .home-primary:hover,
html body .home-calculator-action:hover,
html body .wallet:hover,
html body #dashboardConnectButton:hover {
  filter: brightness(1.06);
}

html body .home-secondary,
html body .home-borrow-link,
html body .back-markets,
html body .dashboard-connect-markets {
  color: var(--sc-accent) !important;
  font-weight: 600 !important;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

html body button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Page heads */
html body .dashboard-heading,
html body .app-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  padding-bottom: 24px;
  border-bottom: var(--sc-rule);
  margin-bottom: 32px;
  text-align: left;
}

html body .dashboard-heading > div:first-child,
html body .app-heading > div:first-child {
  text-align: left;
}

html body .dashboard-heading h1,
html body .app-heading h1 {
  margin: 0 0 8px !important;
}

html body .dashboard-heading p,
html body .app-heading p {
  margin: 0;
  font-size: 16px;
  color: var(--sc-ink-2);
  max-width: 60ch;
}

html body .section-label,
html body .home-kicker,
html body .feed-status {
  font-size: 12px !important;
  font-weight: 600 !important;
  letter-spacing: 0.06em !important;
  text-transform: uppercase;
  color: var(--sc-accent) !important;
}

/* Metric strip: rules, not boxes */
html body .market-metrics {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0 !important;
  border-top: var(--sc-rule);
  border-bottom: var(--sc-rule);
  border-radius: 0 !important;
  background: transparent !important;
  padding: 0 !important;
  margin-bottom: 40px;
}

html body .market-metrics > * {
  padding: 20px 20px 20px 0;
  border-left: none !important;
}

html body .market-metrics > * + * {
  padding-left: 20px;
  border-left: var(--sc-rule) !important;
}

html body .market-metrics strong,
html body .market-metrics b {
  font-size: 26px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--sc-ink);
}

html body .market-metrics span,
html body .market-metrics small,
html body .market-metrics p {
  font-size: 13px;
  color: var(--sc-ink-2);
}

/* Segmented control */
html body .segmented,
html body [role="tablist"] {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  background: var(--sc-elevated);
  border-radius: var(--sc-radius-panel);
}

html body .segmented button,
html body [role="tablist"] button {
  min-height: 36px;
  border-radius: var(--sc-radius-control) !important;
  background: transparent !important;
  color: var(--sc-ink-2) !important;
  border: none !important;
}

html body .segmented button[aria-pressed="true"],
html body .segmented button.on,
html body [role="tab"][aria-selected="true"] {
  background: var(--sc-surface) !important;
  color: var(--sc-ink) !important;
  box-shadow: 0 0 0 1px var(--sc-border);
}

/* Inputs */
html body input[type="search"],
html body input[type="text"],
html body input[type="number"],
html body select {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--sc-border) !important;
  border-radius: var(--sc-radius-control) !important;
  background: var(--sc-surface) !important;
  color: var(--sc-ink) !important;
  font-size: 14px;
}

html body input:focus-visible,
html body select:focus-visible {
  border-color: var(--sc-accent) !important;
}

/* Tables */
html body table thead th {
  position: sticky;
  top: 0;
  background: var(--sc-canvas);
  z-index: 1;
}

html body .home-market-table td,
html body .dashboard-table td {
  vertical-align: middle;
}

html body td:not(:first-child),
html body th:not(:first-child) {
  text-align: right;
}

/* Empty and connect states: a flat diagram, not a box */
html body .dashboard-connect {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 40px;
  align-items: center;
  padding: 40px 0;
  border-top: var(--sc-rule);
  border-bottom: var(--sc-rule);
}

html body .dashboard-connect h2 {
  margin: 0 0 12px !important;
}

html body .dashboard-connect p {
  margin: 0 0 24px;
  max-width: 56ch;
}

html body .dashboard-connect::after {
  content: "";
  display: block;
  height: 180px;
  width: 100%;
  max-width: 280px;
  border-radius: var(--sc-radius-panel);
  background-color: var(--sc-elevated);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 280 180'><rect x='24' y='28' width='232' height='124' rx='8' fill='none' stroke='%23394247' stroke-width='1.5'/><line x1='24' y1='60' x2='256' y2='60' stroke='%23394247' stroke-width='1.5'/><circle cx='52' cy='44' r='4' fill='%23bfd0dd'/><rect x='52' y='88' width='64' height='8' rx='4' fill='%23394247'/><rect x='52' y='104' width='112' height='8' rx='4' fill='%23394247'/><path d='M150 124 L184 96 L216 112 L244 84' fill='none' stroke='%23bfd0dd' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  grid-column: 2;
  grid-row: 1;
}

/* Footer */
html body .stox-footer {
  margin-top: var(--sc-space-section);
  padding: 32px;
  border-top: var(--sc-rule);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--sc-ink-2);
}

html body .stox-footer a {
  color: var(--sc-ink-2);
  text-decoration: none;
  margin-left: 20px;
}

html body .stox-footer a:hover {
  color: var(--sc-ink);
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 960px) {
  html body .dashboard-connect {
    grid-template-columns: minmax(0, 1fr);
  }

  html body .dashboard-connect::after {
    grid-column: 1;
    grid-row: auto;
    width: 100%;
    max-width: 280px;
  }
}

@media (max-width: 640px) {
  html body header,
  html body .site-header {
    padding: 0 16px;
    gap: 12px;
  }

  html body .dashboard-heading,
  html body .app-heading {
    flex-direction: column;
    align-items: start;
  }

  html body .market-metrics > * + * {
    border-left: none !important;
    padding-left: 0;
  }
}
