/*
 * st-trade 2026 visual system
 * A build-free design layer for the server-rendered trading operations console.
 */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #f7f8fb;
  --panel-strong: #edf0f5;
  --text: #18202f;
  --muted: #6b7280;
  --muted-strong: #465064;
  --line: #e1e5ec;
  --line-strong: #cbd2dc;
  --border: var(--line);
  --accent: #3155d6;
  --accent-strong: #2445bb;
  --accent-soft: #eef2ff;
  --accent-muted: #8aa0f2;
  --good: #087a55;
  --good-soft: #e9f8f1;
  --warn: #956000;
  --warn-soft: #fff7db;
  --bad: #bd2c2c;
  --bad-soft: #fff0f0;
  --purple: #6d4ed4;
  --purple-soft: #f2efff;
  --teal: #087f8c;
  --teal-soft: #e9f8fa;
  --nav-bg: #ffffff;
  --nav-bg-strong: #ffffff;
  --nav-panel: #f3f5f9;
  --nav-line: #e6e9ef;
  --nav-text: #18202f;
  --nav-muted: #697386;
  --shadow: 0 12px 32px rgba(28, 39, 60, 0.07);
  --shadow-soft: 0 5px 16px rgba(28, 39, 60, 0.055);
  --shadow-tight: 0 1px 2px rgba(28, 39, 60, 0.05);
  --radius: 12px;
  --radius-lg: 12px;
  --radius-sm: 8px;
}

html {
  background: var(--bg);
  color-scheme: light;
  scroll-padding-top: 92px;
}

body {
  background: var(--bg);
  background-image: none;
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: -0.005em;
  line-height: 1.55;
  min-width: 320px;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.svg-sprite {
  height: 0;
  overflow: hidden;
  position: absolute;
  width: 0;
}

.skip-link {
  background: var(--accent);
  border-radius: 0 0 var(--radius-sm) 0;
  color: #fff;
  font-weight: 750;
  left: 0;
  padding: 10px 14px;
  position: fixed;
  top: 0;
  transform: translateY(-120%);
  transition: transform 140ms ease;
  z-index: 1000;
}

.skip-link:focus {
  transform: translateY(0);
}

.route-progress {
  height: 3px;
  inset: 0 0 auto;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  position: fixed;
  transition: opacity 140ms ease;
  z-index: 1001;
}

.route-progress span {
  animation: route-progress 1.1s cubic-bezier(.4, 0, .2, 1) infinite;
  background: linear-gradient(90deg, #5c7cff, #35b6c8);
  display: block;
  height: 100%;
  transform-origin: left;
  width: 45%;
}

body[data-navigation-pending="true"] .route-progress {
  opacity: 1;
}

@keyframes route-progress {
  0% { transform: translateX(-110%) scaleX(.45); }
  55% { transform: translateX(115%) scaleX(1); }
  100% { transform: translateX(245%) scaleX(.35); }
}

.app-shell {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--nav-bg);
  border-right: 1px solid var(--nav-line);
  box-shadow: none;
  height: 100vh;
  overflow-y: auto;
  padding: 18px 14px;
  position: sticky;
  scrollbar-color: var(--line-strong) transparent;
  top: 0;
  z-index: 30;
}

.sidebar-inner {
  gap: 18px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: calc(100vh - 36px);
}

.sidebar-brand-row {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.brand {
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  background: var(--accent);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 11px;
  box-shadow: none;
  font-size: 12px;
  height: 38px;
  letter-spacing: .04em;
  width: 38px;
}

.brand-copy {
  font-size: 17px;
  letter-spacing: -.02em;
}

.brand-copy span {
  color: var(--nav-muted);
  font-size: 10px;
  letter-spacing: .02em;
}

.global-plugin-status {
  background: var(--panel-soft);
  border-color: var(--nav-line);
  color: var(--text);
  border-radius: 10px;
  min-height: 46px;
  padding: 8px 10px;
}

.global-plugin-status:hover {
  background: var(--accent-soft);
  border-color: var(--line-strong);
  color: var(--text);
}

.global-plugin-status .plugin-status-copy strong { color: var(--text); }
.global-plugin-status[data-connection] .plugin-status-copy > span { color: var(--muted); }

.plugin-light {
  height: 9px;
  width: 9px;
}

.side-nav {
  gap: 3px;
}

.nav-section {
  color: #748096;
  font-size: 10px;
  letter-spacing: .09em;
  margin: 16px 11px 5px;
  text-transform: uppercase;
}

.side-nav a {
  border: 0;
  border-radius: 9px;
  color: var(--muted-strong);
  font-weight: 640;
  gap: 11px;
  min-height: 39px;
  padding: 8px 10px;
  transform: none;
}

.side-nav a:hover {
  background: var(--panel-soft);
  border-color: transparent;
  color: var(--text);
  transform: none;
}

.side-nav a.active {
  background: var(--accent-soft);
  border: 0;
  box-shadow: inset 3px 0 var(--accent);
  color: var(--accent-strong);
}

.side-nav a.active::before {
  display: none;
}

.nav-icon {
  fill: none;
  flex: 0 0 auto;
  height: 17px;
  opacity: .84;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
  width: 17px;
}

.side-nav a.active .nav-icon {
  color: var(--accent);
  opacity: 1;
}

.nav-key {
  display: none;
}

.sidebar-footer {
  border-color: var(--nav-line);
  padding-top: 12px;
}

.nav-logout button {
  background: var(--panel-soft);
  border-color: var(--nav-line);
}

.shell-icon-button {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  color: currentColor;
  display: inline-flex;
  height: 38px;
  justify-content: center;
  min-height: 38px;
  padding: 0;
  width: 38px;
}

.shell-icon-button:hover {
  background: var(--panel-soft);
  border-color: var(--line);
  box-shadow: none;
  color: var(--text);
  transform: none;
}

.shell-icon-button svg {
  fill: none;
  height: 19px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
  width: 19px;
}

.sidebar-close,
.mobile-appbar,
.sidebar-backdrop {
  display: none;
}

.app-main {
  min-width: 0;
}

.topbar,
.auth-header {
  backdrop-filter: none;
  background: var(--panel);
  border-bottom-color: rgba(225, 229, 236, .88);
  box-shadow: 0 1px rgba(28, 39, 60, .025);
}

.topbar-inner,
.auth-header-inner {
  gap: 24px;
  min-height: 48px;
  padding: 8px clamp(20px, 2.4vw, 32px);
}

.topbar-title {
  gap: 0;
}

.topbar-title .topbar-eyebrow {
  color: #7c8698;
  font-size: 12px;
  font-weight: 740;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.topbar-eyebrow i {
  color: #bcc3cf;
  font-style: normal;
  margin: 0 3px;
}

.topbar-badge {
  background: #fff;
  border-color: var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-tight);
  color: var(--muted-strong);
  font-weight: 690;
}

.topbar-badge--safe {
  background: var(--good-soft);
  border-color: #c8eadc;
  color: var(--good);
  gap: 6px;
}

.status-dot {
  background: #16a875;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(22, 168, 117, .12);
  height: 7px;
  width: 7px;
}

.app-main main,
.auth-main,
.page-container {
  margin: 0 auto;
  max-width: 1800px;
  padding: 24px clamp(20px, 2.4vw, 32px) 40px;
}

h1 {
  font-size: clamp(23px, 2vw, 28px);
  font-weight: 790;
  letter-spacing: -.035em;
}

h2 {
  font-size: 17px;
  font-weight: 760;
  letter-spacing: -.015em;
}

.page-head {
  align-items: center;
  margin-bottom: 20px;
}

.page-head > div:first-child {
  gap: 3px;
}

.page-head .muted {
  font-size: 13px;
}

.panel,
.summary-tile,
.quote-section,
.opportunity-card,
.automation-queue-card,
.buy-request-task,
.buy-request-strategy,
.automation-tab-summary {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-tight);
}

.panel {
  background: var(--panel);
  box-shadow: none;
  padding: 20px;
}

.panel::before,
.summary-tile::before {
  display: none;
}

.panel > h2 {
  border-bottom-color: var(--line);
  min-height: 38px;
}

.panel > h2::before {
  background: var(--accent);
  border-radius: 999px;
  height: 15px;
  width: 3px;
}

.summary-grid {
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-bottom: 20px;
}

.summary-tile {
  background: var(--panel);
  min-height: 80px;
  padding: 14px 16px;
}

.summary-value {
  color: var(--text);
  font-size: 25px;
  font-weight: 790;
  letter-spacing: -.035em;
}

.summary-label {
  color: #737e90;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .02em;
}

table {
  background: #fff;
  border-color: var(--line);
  border-radius: var(--radius);
  box-shadow: none;
}

th,
td {
  border-bottom-color: #eaedf2;
  padding: 10px 12px;
}

th {
  background: #f7f8fa;
  color: #586276;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .02em;
}

tbody tr {
  transition: background-color 100ms ease;
}

tbody tr:hover {
  background: #f8faff;
}

.quote-table-wrap {
  border-radius: var(--radius);
  min-width: 0;
  scrollbar-color: #c8cfda transparent;
}

.automation-queue-card,
.automation-queue-grid {
  min-width: 0;
}

.automation-queue-head {
  flex-wrap: wrap;
}

.buy-listing-recovery {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
  padding: 18px;
  border: 1px solid #e6c786;
  border-left: 4px solid #bd862d;
  border-radius: var(--radius);
  background: #fffaf0;
  overflow-wrap: anywhere;
  scroll-margin-top: 24px;
}

.buy-listing-recovery p {
  margin: 0;
}

.buy-listing-recovery > .button {
  justify-self: start;
}

.buy-listing-recovery-scope [data-buy-listing-deal-saved-scope] {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  font-size: 13px;
}

input,
select,
textarea {
  background: #fff;
  border-color: var(--line-strong);
  border-radius: 9px;
  box-shadow: 0 1px 1px rgba(28, 39, 60, .025);
  min-height: 40px;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #aeb8c8;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #7189e8;
  box-shadow: 0 0 0 3px rgba(49, 85, 214, .11);
}

button,
.button,
a.button,
.quote-link {
  align-items: center;
  border: 1px solid var(--accent);
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 700;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  text-decoration: none;
  transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease, color 120ms ease, transform 120ms ease;
}

button,
.button,
a.button {
  background: var(--accent);
  box-shadow: none;
  color: #fff;
}

button:hover,
.button:hover,
a.button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  box-shadow: none;
  transform: none;
}

button.secondary,
.button.secondary,
a.button.secondary,
.quote-link {
  background: #fff;
  border-color: var(--line-strong);
  box-shadow: var(--shadow-tight);
  color: var(--muted-strong);
}

button.secondary:hover,
.button.secondary:hover,
a.button.secondary:hover,
.quote-link:hover {
  background: var(--accent-soft);
  border-color: #aab8ee;
  box-shadow: none;
  color: var(--accent-strong);
}

button:disabled,
button:disabled:hover {
  background: #edf0f4;
  border-color: #dfe3e9;
  color: #959dad;
}

.chip,
.quote-pill,
.sort-chip {
  border-radius: 999px;
  font-weight: 690;
}

.chip {
  background: var(--accent-soft);
  border-color: #d4dcfb;
  color: #3652b8;
}

.chip.good,
.quote-pill {
  background: var(--good-soft);
  border-color: #c8eadc;
  color: var(--good);
}

.chip.warn,
.quote-pill.warn {
  background: var(--warn-soft);
  border-color: #eedca4;
  color: var(--warn);
}

.opportunity-card {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-tight);
  padding: 17px;
}

.opportunity-card::before {
  background: var(--good);
  opacity: .8;
  width: 3px;
}

.opportunity-card:hover {
  border-color: #c9d0db;
  box-shadow: var(--shadow);
}

.item-thumb,
.item-thumb-fallback {
  background: linear-gradient(145deg, #263044, #111827);
  border-color: rgba(255, 255, 255, .12);
  border-radius: 11px;
  box-shadow: 0 6px 16px rgba(17, 24, 39, .13);
}

.price-node,
.quote-summary-item {
  background: #f8f9fb;
  border-color: var(--line);
}

.route-arrow {
  background: var(--accent);
}

.empty,
.automation-empty {
  background: #fafbfc;
  border-color: #cfd5df;
  box-shadow: none;
}

.opportunity-pagination,
.list-toolbar,
.list-filter-option,
.scan-progress {
  background: #fff;
  border-color: var(--line);
  box-shadow: none;
}

.scan-progress-bar,
.scan-step-progress-bar {
  background: linear-gradient(90deg, var(--accent), #2b9faf);
}

.status {
  border-radius: 8px;
  color: var(--muted-strong);
}

.metric,
.risk-low {
  color: var(--good);
}

.risk-medium {
  color: var(--warn);
}

.trend-modal {
  backdrop-filter: blur(5px);
  background: rgba(10, 17, 30, .62);
}

.trend-dialog,
.buff-year-trend-dialog {
  border-radius: var(--radius-lg);
  box-shadow: 0 28px 80px rgba(10, 17, 30, .3);
}

.opportunity-card,
.quote-section,
.automation-queue-card,
.buy-request-item,
.scan-step {
  content-visibility: auto;
  contain-intrinsic-size: auto 180px;
}

[aria-busy="true"] {
  cursor: progress;
  opacity: .68;
  pointer-events: none;
  position: relative;
}

.loading-skeleton,
.partial-loading-placeholder {
  animation: skeleton-pulse 1.35s ease-in-out infinite;
  background: linear-gradient(90deg, #edf0f4 20%, #f8f9fb 42%, #edf0f4 64%);
  background-size: 300% 100%;
  border-radius: var(--radius);
}

.automation-shell-tile {
  display: grid;
  gap: 12px;
}

.automation-shell-line {
  height: 12px;
  width: 54%;
}

.automation-shell-value {
  height: 27px;
  width: 36%;
}

.automation-shell-workbench {
  display: grid;
  gap: 18px;
  min-height: 440px;
}

.automation-shell-heading {
  display: grid;
  gap: 8px;
}

.automation-shell-heading span:first-child {
  height: 22px;
  width: 160px;
}

.automation-shell-heading span:last-child {
  height: 12px;
  width: min(420px, 70%);
}

.automation-shell-tabs {
  display: grid;
  gap: 9px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.automation-shell-tabs span {
  height: 54px;
}

.automation-shell-body {
  min-height: 250px;
}

@keyframes skeleton-pulse {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

.toast-region {
  bottom: 20px;
  display: grid;
  gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
  pointer-events: none;
  position: fixed;
  right: 20px;
  z-index: 500;
}

.app-toast {
  animation: toast-in 180ms ease-out;
  background: #151d2b;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 11px;
  box-shadow: 0 18px 45px rgba(10, 17, 30, .22);
  color: #f8fafc;
  font-size: 13px;
  font-weight: 620;
  padding: 11px 13px;
  pointer-events: auto;
}

.app-toast[data-kind="error"] {
  background: #8f2528;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-header .brand,
.auth-header .brand-copy,
.auth-header .brand-copy span {
  color: var(--text);
}

.auth-main {
  min-height: calc(100vh - 48px);
}

.auth-card {
  border-radius: var(--radius-lg);
}

.topbar-help { color: var(--muted-strong); text-decoration: none; }
.topbar-help:hover { color: var(--accent); }
.nav-user { color: var(--muted-strong); }
.status:empty { display: none; }
.price-value, .metric, .summary-value, td { font-variant-numeric: tabular-nums; }

.page-read-error {
  align-items: center;
  background: var(--warn-soft);
  border: 1px solid #eedca4;
  border-radius: var(--radius-sm);
  color: var(--warn);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 12px 16px;
}

.page-loading-rows { display: grid; gap: 14px; margin-top: 16px; }
.page-loading-rows > div { height: 52px; }
.page-loading { min-height: 300px; }
.list-context { align-items: center; display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 16px; }

details.disclosure > summary {
  align-items: center;
  color: var(--muted-strong);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  padding: 6px 0;
}
details.disclosure[open] > summary { margin-bottom: 12px; }
details.disclosure.panel:not([open]) { padding-block: 12px; }
details.disclosure > .muted { margin-top: 8px; }
.opportunity-market.disclosure { grid-column: 1 / -1; }
.opportunity-market.disclosure > summary { border-top: 1px solid var(--line); padding-top: 12px; }
.holding-cost-manual-help.disclosure { display: block; }

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 208px minmax(0, 1fr);
  }

  .sidebar {
    padding-inline: 11px;
  }

  .topbar-meta .topbar-badge:last-child {
    display: none;
  }
}

@media (max-width: 980px) {
  body {
    padding-top: 60px;
  }

  body.auth-page {
    padding-top: 0;
  }

  .app-shell {
    display: block;
  }

  .mobile-appbar {
    align-items: center;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 10px;
    grid-template-columns: auto auto minmax(0, 1fr);
    inset: 0 0 auto;
    min-height: 60px;
    padding: 8px 14px;
    position: fixed;
    z-index: 50;
  }

  .brand--compact {
    color: var(--text);
    font-size: 14px;
    text-decoration: none;
  }

  .brand--compact .brand-mark {
    border-radius: 9px;
    height: 32px;
    width: 32px;
  }

  .mobile-page-title {
    color: var(--muted-strong);
    font-size: 12px;
    font-weight: 700;
    overflow: hidden;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar {
    border-right: 1px solid var(--nav-line);
    bottom: 0;
    display: block;
    height: 100dvh;
    left: 0;
    max-width: calc(100vw - 52px);
    overflow-y: auto;
    padding: 17px 13px;
    position: fixed;
    top: 0;
    transform: translateX(-104%);
    transition: transform 190ms cubic-bezier(.2, .8, .2, 1);
    width: 286px;
    z-index: 80;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    background: rgba(7, 12, 22, .55);
    border: 0;
    border-radius: 0;
    display: block;
    inset: 0;
    min-height: 0;
    opacity: 0;
    padding: 0;
    pointer-events: none;
    position: fixed;
    transition: opacity 180ms ease;
    width: 100%;
    z-index: 70;
  }

  .sidebar-backdrop:hover {
    background: rgba(7, 12, 22, .55);
    border: 0;
    box-shadow: none;
    transform: none;
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-close {
    color: var(--muted-strong);
    display: inline-flex;
  }

  .sidebar-close:hover {
    background: var(--panel-soft);
    border-color: var(--nav-line);
    color: var(--text);
  }

  .sidebar-inner {
    display: grid;
    gap: 18px;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-height: calc(100dvh - 34px);
  }

  .side-nav {
    display: grid;
    gap: 3px;
    overflow: visible;
    padding: 0;
  }

  .side-nav a {
    justify-content: flex-start;
  }

  .nav-section {
    display: block;
  }

  .topbar {
    display: none;
  }

  .app-main main,
  .page-container {
    padding: 22px 18px 40px;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

@media (max-width: 700px) {
  .page-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .page-head > .actions {
    width: 100%;
  }

  .summary-tile {
    min-height: 92px;
    padding: 14px;
  }

  .summary-value {
    font-size: 22px;
  }

  .panel {
    padding: 16px;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 13px;
  }

  .app-main main,
  .auth-main,
  .page-container {
    padding: 18px 12px 34px;
  }

  h1 {
    font-size: 24px;
  }

  .summary-grid {
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-label {
    line-height: 1.35;
  }

  .actions {
    gap: 7px;
  }

  .actions > a,
  .actions > button,
  .list-search > button,
  .list-search > a {
    width: auto;
  }

  .list-toolbar .actions > a,
  .list-toolbar .actions > button,
  .page-head > .actions > a,
  .page-head > .actions > button {
    flex: 1 1 auto;
  }

  .quote-table .quote-link,
  td .quote-link {
    width: auto;
  }

  th,
  td {
    padding: 10px;
  }

  .quote-table-wrap > table.automation-mini-table {
    min-width: 100%;
  }

  .quote-table-wrap > table.automation-mini-table.buy-request-wide-table {
    min-width: 1420px;
  }

  .quote-table-wrap > table.automation-mini-table th {
    white-space: normal;
  }

  .toast-region {
    bottom: 12px;
    right: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
