:root {
  --table-accent: #2563eb;
  --table-accent-soft: #e8f0ff;
  --table-accent-strong: #0f766e;
  --table-surface: #fff;
  --table-surface-muted: #f7f9fc;
  --table-line: #d9e2ee;
  --table-ink: #24364b;
  --table-muted: #718197;
}

html[data-table-palette='colorful'] {
  --table-accent: #ef476f;
  --table-accent-soft: #fff0f3;
  --table-accent-strong: #06a77d;
}

html[data-table-palette='mono'] {
  --table-accent: #555;
  --table-accent-soft: #eee;
  --table-accent-strong: #333;
}

html[data-table-palette='ocean'] {
  --table-accent: #4361ee;
  --table-accent-soft: #edf2ff;
  --table-accent-strong: #118ab2;
}

html[data-table-palette='sunset'] {
  --table-accent: #f94144;
  --table-accent-soft: #fff2e8;
  --table-accent-strong: #f8961e;
}

html[data-table-theme='dark'] {
  --table-surface: #1c2735;
  --table-surface-muted: #243244;
  --table-line: #405065;
  --table-ink: #edf3fb;
  --table-muted: #aab8ca;
}

.table-style-settings-trigger {
  box-sizing: border-box;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 36px;
  height: 36px;
  padding: 0 9px;
  border: 1px solid rgba(137, 157, 175, .24);
  border-radius: 100px;
  background: rgba(255, 255, 255, .56);
  color: #40556c;
  font: 600 12px/1 inherit;
  letter-spacing: 0;
  cursor: pointer;
  transition: border-color .18s ease, background-color .18s ease, transform .18s ease;
}

.table-style-settings-trigger:hover,
.table-style-settings-trigger[aria-expanded='true'] {
  border-color: rgba(102, 130, 153, .38);
  background: rgba(255, 255, 255, .86);
  transform: translateY(-1px);
}

.table-style-settings-trigger > span:first-child {
  font-size: 18px;
  line-height: 1;
}

.table-style-settings-panel {
  position: fixed;
  z-index: 2600;
  display: none;
  box-sizing: border-box;
  max-width: calc(100vw - 20px);
  padding: 14px;
  border: 1px solid var(--table-line);
  border-radius: 12px;
  background: var(--table-surface);
  color: var(--table-ink);
  box-shadow: 0 16px 40px rgba(20, 35, 58, .2), 0 3px 10px rgba(20, 35, 58, .1);
}

.table-style-settings-panel.is-open { display: block; }

.table-style-settings-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 14px;
}

.table-style-settings-close {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--table-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.table-style-settings-close:hover { background: var(--table-accent-soft); color: var(--table-accent); }

.table-style-settings-group + .table-style-settings-group {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--table-line);
}

.table-style-settings-heading {
  margin: 0 0 7px;
  color: var(--table-muted);
  font-size: 11px;
  font-weight: 700;
}

.table-style-settings-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.table-style-settings-group:not(:first-of-type) .table-style-settings-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.table-style-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  min-height: 30px;
  padding: 4px 7px;
  overflow: hidden;
  border: 1px solid var(--table-line);
  border-radius: 6px;
  background: var(--table-surface-muted);
  color: var(--table-muted);
  font: 600 12px/1.1 inherit;
  letter-spacing: 0;
  white-space: nowrap;
  cursor: pointer;
}

.table-style-option:hover,
.table-style-option.is-active {
  border-color: var(--table-accent);
  background: var(--table-accent-soft);
  color: var(--table-accent);
}

.table-style-monochrome-option {
  justify-content: space-between;
  text-align: left;
}

.table-style-switch {
  position: relative;
  width: 30px;
  height: 16px;
  flex: 0 0 30px;
  border: 1px solid var(--table-line);
  border-radius: 999px;
  background: var(--table-line);
}

.table-style-switch > span {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--table-surface);
  box-shadow: 0 1px 2px rgba(20, 35, 58, .22);
  transition: transform .14s ease;
}

.table-style-monochrome-option.is-active .table-style-switch {
  border-color: var(--table-accent);
  background: var(--table-accent);
}

.table-style-monochrome-option.is-active .table-style-switch > span {
  transform: translateX(14px);
}

.table-style-swatch {
  width: 22px;
  height: 8px;
  flex: 0 0 22px;
  border-radius: 4px;
}

.table-style-settings-live {
  position: fixed;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Shared table surfaces consume the same tokens. Forest date grids keep their own detail-page style. */
html[data-table-theme] :is(.el-table, .sector-theme-table, table) {
  color: var(--table-ink);
}

html[data-table-theme] .el-table__inner-wrapper,
html[data-table-theme] .el-table__body-wrapper,
html[data-table-theme] .el-table__header-wrapper {
  background: var(--table-surface);
}

html[data-table-theme] :is(.el-table th.el-table__cell, .sector-theme-table th, table th) {
  background: var(--table-surface-muted);
  color: var(--table-muted);
  border-color: var(--table-line);
}

html[data-table-theme] :is(.el-table td.el-table__cell, .sector-theme-table td, table td) {
  border-color: var(--table-line);
}

html[data-table-theme] .el-table__body tr:hover > td.el-table__cell {
  background: var(--table-accent-soft);
}

html[data-table-theme] :is(.el-table, .sector-theme-table) {
  background: var(--table-surface);
}

/* List rows share the same ink and divider tokens, while retaining their own surfaces. */
html[data-table-theme] :is(
  .holdings-trade-record,
  .sector-theme-favorite-shortcut,
  .sector-theme-sector-list-row,
  .account-session-device,
  .detail-row,
  .backtest-search-suggestions button
) {
  border-color: var(--table-line);
  color: var(--table-ink);
}

/* GridBeam canvas is mounted once per table host and spans the complete grid. */
.table-style-beam-host {
  position: relative;
}

.table-style-beam-canvas {
  position: absolute;
  display: block;
  pointer-events: none;
  z-index: 5;
}

html[data-table-motion='breathing'] :is(
  .holdings-trade-record:not(:last-child),
  .sector-theme-favorite-shortcut:not(:last-child),
  .sector-theme-sector-list-row:not(:last-child),
  .account-session-device:not(:last-child),
  .detail-row:not(:last-child),
  .backtest-search-suggestions button:not(:last-child)
) {
  position: relative;
}

html[data-table-motion='breathing'] :is(
  .holdings-trade-record:not(:last-child),
  .sector-theme-favorite-shortcut:not(:last-child),
  .sector-theme-sector-list-row:not(:last-child),
  .account-session-device:not(:last-child),
  .detail-row:not(:last-child),
  .backtest-search-suggestions button:not(:last-child)
)::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  height: 1px;
  pointer-events: none;
  content: '';
  background-image: linear-gradient(
    90deg,
    transparent 0%,
    color-mix(in srgb, var(--table-accent) 14%, transparent) 38%,
    color-mix(in srgb, var(--table-accent-strong) 88%, transparent) 50%,
    color-mix(in srgb, var(--table-accent) 14%, transparent) 62%,
    transparent 100%
  );
  background-position: 0 0;
  background-repeat: no-repeat;
  background-size: 240% 100%;
  animation: table-divider-flow 10s linear infinite;
  mix-blend-mode: multiply;
}

html[data-table-theme='dark'][data-table-motion='breathing'] :is(
  .holdings-trade-record:not(:last-child),
  .sector-theme-favorite-shortcut:not(:last-child),
  .sector-theme-sector-list-row:not(:last-child),
  .account-session-device:not(:last-child),
  .detail-row:not(:last-child),
  .backtest-search-suggestions button:not(:last-child)
)::after {
  mix-blend-mode: screen;
}

html[data-table-motion='paused'] :is(
  .holdings-trade-record,
  .sector-theme-favorite-shortcut,
  .sector-theme-sector-list-row,
  .account-session-device,
  .detail-row,
  .backtest-search-suggestions button
)::before,
html[data-table-motion='paused'] :is(
  .holdings-trade-record,
  .sector-theme-favorite-shortcut,
  .sector-theme-sector-list-row,
  .account-session-device,
  .detail-row,
  .backtest-search-suggestions button
)::after {
  display: none;
  content: none;
  animation: none;
}

@keyframes table-divider-flow {
  from { background-position: 0 0; }
  to { background-position: 100% 0; }
}

@media (max-width: 640px) {
  .table-style-settings-trigger-label { display: none; }
  .table-style-settings-trigger { padding: 0 8px; }
}
