:root {
  --bg: #070908;
  --sidebar-bg: #0b0e0d;
  --drawer-bg: #0c100e;
  --input-bg: #0b0f0d;
  --table-head: #111613;
  --row-hover: #141a17;
  --viewed-bg: rgba(246, 187, 92, 0.08);
  --viewed-hover: rgba(246, 187, 92, 0.13);
  --track-bg: #0a0d0c;
  --insight-bg: #0d1210;
  --chart-bg: #090d0b;
  --chart-grid: #24302b;
  --axis-line: #52615a;
  --tooltip-bg: rgba(12, 16, 14, 0.96);
  --tooltip-shadow: 0 12px 36px rgba(0, 0, 0, 0.32);
  --backdrop-bg: rgba(0, 0, 0, 0.54);
  --marker-label-bg: rgba(7, 9, 8, 0.86);
  --empty-overlay-bg: rgba(9, 13, 11, 0.86);
  --kline-up: #6bd5b0;
  --kline-down: #ff6f78;
  --volume-up: rgba(107, 213, 176, 0.42);
  --volume-down: rgba(255, 111, 120, 0.42);
  --surface: #101413;
  --surface-2: #171c1a;
  --surface-3: #202724;
  --line: #2b3430;
  --text: #f0f6f2;
  --muted: #9aa8a0;
  --soft: #cad8d0;
  --accent: #8dc7ff;
  --accent-2: #73d39a;
  --danger: #ff6767;
  --warn: #f6bb5c;
  --shadow: 0 18px 70px rgba(0, 0, 0, 0.38);
  color-scheme: dark;
}

body[data-theme="light"] {
  --bg: #f5f7f4;
  --sidebar-bg: #eef3ee;
  --drawer-bg: #fbfdfb;
  --input-bg: #ffffff;
  --table-head: #eef4ef;
  --row-hover: #edf5ef;
  --viewed-bg: rgba(184, 121, 24, 0.1);
  --viewed-hover: rgba(184, 121, 24, 0.17);
  --track-bg: #dfe8e0;
  --insight-bg: #f0f6f2;
  --chart-bg: #ffffff;
  --chart-grid: #dce6df;
  --axis-line: #8da096;
  --tooltip-bg: rgba(255, 255, 255, 0.98);
  --tooltip-shadow: 0 12px 34px rgba(45, 61, 51, 0.18);
  --backdrop-bg: rgba(21, 31, 25, 0.32);
  --marker-label-bg: rgba(255, 255, 255, 0.9);
  --kline-up: #15956a;
  --kline-down: #e24858;
  --volume-up: rgba(21, 149, 106, 0.28);
  --volume-down: rgba(226, 72, 88, 0.28);
  --surface: #ffffff;
  --surface-2: #f2f6f2;
  --surface-3: #e6eee7;
  --line: #cbd8d0;
  --text: #152019;
  --muted: #607167;
  --soft: #33483b;
  --accent: #2d8ee6;
  --accent-2: #16865a;
  --danger: #d8404d;
  --warn: #b9781a;
  --shadow: 0 18px 50px rgba(50, 66, 56, 0.12);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.account-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.account-name {
  max-width: 180px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-dialog {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  place-items: center;
  padding: 20px;
  background: var(--backdrop-bg);
  backdrop-filter: blur(8px);
}

.auth-dialog.active {
  display: grid;
}

.auth-card {
  width: min(430px, 100%);
  display: grid;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--drawer-bg);
  box-shadow: var(--shadow);
}

.auth-card-head strong,
.auth-card-head span {
  display: block;
}

.auth-card-head strong {
  font-size: 24px;
}

.auth-card-head span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.auth-tabs button,
.google-button {
  border: 0;
  border-radius: 7px;
  color: var(--soft);
  background: transparent;
  padding: 10px 12px;
}

.auth-tabs button.active {
  color: var(--text);
  background: var(--surface-3);
}

.google-button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

.auth-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  padding: 12px;
  outline: none;
}

.auth-form input:focus {
  border-color: var(--accent);
}

.auth-message {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.auth-dialog {
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(6, 10, 8, 0.72), rgba(6, 10, 8, 0.92)),
    radial-gradient(circle at 50% 0, rgba(141, 199, 255, 0.12), transparent 42%),
    var(--bg);
}

body[data-theme="light"] .auth-dialog {
  background:
    linear-gradient(180deg, rgba(242, 247, 243, 0.74), rgba(242, 247, 243, 0.94)),
    radial-gradient(circle at 50% 0, rgba(45, 142, 230, 0.1), transparent 42%),
    var(--bg);
}

.auth-shell {
  width: min(1040px, 100%);
  max-width: calc(100vw - 56px);
  min-height: 620px;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--drawer-bg);
  box-shadow: var(--shadow);
}

.auth-showcase {
  display: grid;
  align-content: space-between;
  gap: 28px;
  padding: 38px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(141, 199, 255, 0.08), rgba(115, 211, 154, 0.06)),
    var(--surface);
}

.auth-brandline {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-logo {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: #06100b;
  font-size: 18px;
  line-height: 1;
  font-weight: 900;
}

.auth-brandline strong,
.auth-brandline span {
  display: block;
}

.auth-brandline .auth-logo {
  display: grid;
}

.auth-brandline span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.auth-copy {
  max-width: 560px;
}

.auth-copy h1 {
  margin: 10px 0 14px;
  font-size: clamp(34px, 4vw, 52px);
  line-height: 1.08;
  letter-spacing: 0;
}

.auth-copy p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.8;
}

.auth-preview {
  display: grid;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--chart-bg);
}

.auth-preview-head,
.auth-preview-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.auth-preview-head strong {
  color: var(--accent-2);
}

.auth-chart-bars {
  height: 150px;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  align-items: end;
  gap: 9px;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.auth-chart-bars i {
  display: block;
  min-height: 18px;
  border-radius: 4px 4px 0 0;
  background: var(--accent-2);
  opacity: 0.78;
}

.auth-chart-bars i:nth-child(3n),
.auth-chart-bars i:nth-child(5n) {
  background: var(--danger);
  opacity: 0.72;
}

.auth-card {
  width: 100%;
  min-width: 0;
  align-self: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 42px;
}

.auth-card-head strong {
  font-size: 30px;
}

.auth-tabs {
  margin-top: 4px;
  border-radius: 10px;
}

.auth-tabs button {
  min-height: 46px;
  font-weight: 800;
}

.google-button {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 10px;
  font-weight: 800;
}

.google-button:not(.disabled):hover {
  border-color: var(--accent);
}

.google-button.disabled {
  cursor: help;
  color: var(--muted);
  opacity: 0.82;
}

.google-mark {
  width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: #1a73e8;
  font-weight: 900;
  font-family: Arial, sans-serif;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.email-option-button {
  min-height: 48px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 74%, transparent);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 800;
  cursor: pointer;
}

.email-option-button:hover,
.email-option-button.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--panel));
}

.email-mark {
  width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 22%, var(--panel));
  color: var(--accent);
}

.email-mark svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth-form {
  gap: 14px;
}

.auth-form label {
  font-weight: 700;
}

.auth-form input {
  min-height: 48px;
  min-width: 0;
  border-radius: 10px;
}

.auth-email-form {
  padding-top: 2px;
  animation: authReveal 160ms ease-out;
}

.auth-code-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 10px;
  align-items: end;
}

.auth-code-button {
  min-height: 48px;
  border-radius: 10px;
}

.auth-submit {
  min-height: 52px;
  margin-top: 4px;
  border-radius: 10px;
  font-weight: 900;
}

.auth-footnote {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

@keyframes authReveal {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 860px) {
  .auth-dialog {
    padding: 14px;
  }

  .auth-shell {
    max-width: calc(100vw - 28px);
    min-height: auto;
    grid-template-columns: 1fr;
  }

  .auth-showcase {
    display: none;
  }

  .auth-card {
    padding: 28px;
  }

  .auth-code-field {
    grid-template-columns: 1fr;
  }
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px 14px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #70c2ff, #72d592);
  color: #06100b;
  font-weight: 900;
  border-radius: 8px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--soft);
  text-align: left;
  padding: 11px 12px;
}

.nav-item:hover,
.nav-item.active {
  color: var(--text);
  background: var(--surface-3);
}

.source-card {
  margin-top: auto;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
}

.source-card span,
.source-card small,
.eyebrow,
.panel-head span {
  color: var(--muted);
  font-size: 12px;
}

.source-card strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.main {
  min-width: 0;
  padding: 22px 24px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 750;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

.top-actions,
.table-tools,
.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.theme-switch button {
  min-height: 28px;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.theme-switch button.active {
  background: var(--accent);
  color: #071015;
}

.primary-button,
.ghost-button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 36px;
  padding: 0 13px;
  color: var(--text);
}

.primary-button {
  background: var(--accent);
  border-color: var(--accent);
  color: #071015;
  font-weight: 700;
}

.ghost-button,
.icon-button {
  background: var(--surface-2);
}

.ghost-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #071015;
}

.ghost-button.compact {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.primary-button.compact {
  min-height: 30px;
  padding: 0 12px;
  font-size: 12px;
}

.icon-button {
  width: 34px;
  padding: 0;
  font-size: 22px;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.table-settings-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #071015;
}

.filter-panel {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) repeat(6, minmax(120px, 1fr));
  gap: 10px;
  padding: 14px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  padding: 0 10px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kpi {
  min-height: 112px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi span {
  color: var(--muted);
  font-size: 12px;
}

.kpi strong {
  font-size: 24px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.kpi small {
  color: var(--soft);
}

.content-grid {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

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

.content-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel,
.report-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head.compact {
  align-items: center;
}

.chart {
  min-height: 260px;
  position: relative;
}

.chart.large {
  min-height: 340px;
}

.chart svg {
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: block;
}

.chart-tooltip {
  position: absolute;
  z-index: 4;
  min-width: 172px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tooltip-bg);
  color: var(--text);
  box-shadow: var(--tooltip-shadow);
  pointer-events: none;
  font-size: 12px;
  line-height: 1.55;
}

.chart-tooltip strong,
.chart-tooltip span {
  display: block;
}

.chart-tooltip span {
  color: var(--soft);
}

.chart-hover-line {
  stroke: var(--accent);
  stroke-dasharray: 4 4;
  stroke-width: 1;
}

.chart-hover-dot {
  fill: var(--accent);
  stroke: var(--chart-bg);
  stroke-width: 2;
}

.axis text,
.chart-label {
  fill: var(--muted);
  font-size: 11px;
}

.split-card {
  display: grid;
  gap: 12px;
}

.split-row {
  display: grid;
  gap: 7px;
}

.split-row header {
  display: flex;
  justify-content: space-between;
  color: var(--soft);
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--track-bg);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
}

.mini-table th,
.mini-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 6px;
  font-size: 13px;
}

.mini-table th {
  color: var(--muted);
  text-align: left;
  font-weight: 600;
}

.mini-table td:last-child,
.mini-table th:last-child {
  text-align: right;
}

.table-panel {
  padding: 0;
  overflow: hidden;
  position: relative;
}

.table-panel .panel-head {
  padding: 16px 16px 10px;
  margin-bottom: 0;
}

.table-panel-head {
  align-items: center;
}

.panel-title-actions {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.panel-title-actions h2 {
  margin: 0;
  line-height: 1.1;
}

.table-tools {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.table-settings-button {
  width: 38px;
  height: 38px;
  min-height: 38px;
  color: var(--muted);
  background: var(--surface);
}

.table-settings-button:hover,
.table-settings-button.active {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  border-color: var(--accent);
  color: var(--text);
}

.column-settings-panel {
  position: absolute;
  left: 16px;
  top: 68px;
  z-index: 20;
  width: min(920px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 94%, #000);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  overflow: hidden;
}

.column-settings-panel[hidden] {
  display: none;
}

.column-settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px 13px;
  border-bottom: 1px solid var(--line);
}

.column-settings-head strong {
  display: block;
  font-size: 16px;
  line-height: 1.25;
}

.column-settings-head span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.column-settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(260px, 0.95fr);
  gap: 0;
  max-height: min(580px, calc(100vh - 210px));
}

.column-settings-section {
  min-width: 0;
  padding: 15px 16px 16px;
}

.column-settings-section + .column-settings-section {
  border-left: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-2) 78%, transparent);
}

.column-settings-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.column-settings-section-head strong {
  font-size: 13px;
}

.column-settings-section-head small {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.column-field-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 410px;
  overflow: auto;
  padding: 1px 4px 1px 1px;
}

.column-field-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.column-field-toggle:hover {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--line));
}

.column-field-toggle.is-on {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface-2));
  border-color: color-mix(in srgb, var(--accent) 62%, var(--line));
}

.column-field-toggle input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.column-toggle-mark {
  display: none;
}

.column-field-toggle span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.column-order-list {
  display: grid;
  gap: 8px;
  max-height: 410px;
  overflow: auto;
  padding: 1px 4px 1px 1px;
}

.column-order-empty {
  display: grid;
  place-items: center;
  min-height: 96px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  text-align: center;
  padding: 12px;
}

.column-order-row {
  display: grid;
  grid-template-columns: 28px 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.column-order-index {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 700;
}

.column-order-row.dragging {
  opacity: 0.42;
}

.column-drag-handle {
  color: var(--muted);
  cursor: grab;
  font-weight: 900;
  text-align: center;
  user-select: none;
}

.column-order-name {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.column-move {
  display: inline-flex;
  gap: 4px;
}

.column-move button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
}

.column-settings-error {
  margin: 0 16px 12px;
  color: var(--danger);
  font-size: 12px;
}

.column-settings-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 13px 16px 16px;
  border-top: 1px solid var(--line);
}

@media (max-width: 900px) {
  .column-settings-panel {
    top: 64px;
  }

  .column-settings-layout {
    grid-template-columns: 1fr;
  }

  .column-settings-section + .column-settings-section {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .column-field-list {
    grid-template-columns: 1fr;
  }
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 280px);
}

.trade-table {
  width: 100%;
  min-width: 1480px;
  border-collapse: collapse;
}

.trade-table th,
.trade-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  white-space: nowrap;
  font-size: 13px;
}

.trade-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--table-head);
  color: var(--muted);
  text-align: left;
  font-weight: 650;
  user-select: none;
}

.trade-table th.sortable {
  cursor: pointer;
}

.trade-table tr:hover td {
  background: var(--row-hover);
}

.trade-table tr.viewed-trade td {
  background: var(--viewed-bg);
}

.trade-table tr.viewed-trade:hover td {
  background: var(--viewed-hover);
}

.trade-table tr.preview-lock-row td {
  padding: 14px 20px;
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}

.trade-table tr.preview-lock-row:hover td {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}

.preview-lock-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: center;
  cursor: pointer;
  display: block;
  text-decoration: none;
}

.preview-lock-button strong {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
}

.preview-lock-button span {
  color: var(--muted);
  font-size: 13px;
}

.trade-table td.number,
.trade-table th.number {
  text-align: right;
}

.seq-cell {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  min-width: 42px;
}

.viewed-star {
  display: inline-block;
  width: 9px;
  color: var(--warn);
  font-weight: 900;
}

.viewed-star.empty {
  opacity: 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 6px;
  padding: 0 8px;
  background: var(--surface-3);
  color: var(--soft);
  font-weight: 650;
  font-size: 12px;
}

.tag.long {
  background: rgba(115, 211, 154, 0.16);
  color: #86e4a9;
}

.tag.short {
  background: rgba(255, 103, 103, 0.16);
  color: #ff8585;
}

.positive {
  color: var(--accent-2);
}

.negative {
  color: var(--danger);
}

.neutral {
  color: var(--soft);
}

.pagination {
  justify-content: flex-end;
  padding: 12px 16px 16px;
}

.report-panel {
  padding: 26px;
}

.report-title {
  margin-bottom: 20px;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.report-metric {
  padding: 14px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.report-metric span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.report-metric strong {
  font-size: 20px;
}

.insights {
  display: grid;
  gap: 10px;
}

.insight {
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  background: var(--insight-bg);
  color: var(--soft);
  line-height: 1.7;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 10;
  width: min(1280px, calc(100vw - 48px));
  height: 100vh;
  background: var(--drawer-bg);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateX(104%);
  transition: transform 180ms ease;
  overflow: auto;
  padding: 18px;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: none;
  background: var(--backdrop-bg);
}

.drawer-backdrop.open {
  display: block;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.detail-pill {
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
}

.detail-pill span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 7px;
}

.detail-pill strong {
  overflow-wrap: anywhere;
}

.detail-pill strong .positive,
.field strong .positive,
.trade-table td .positive {
  color: var(--accent-2);
}

.detail-pill strong .negative,
.field strong .negative,
.trade-table td .negative {
  color: var(--danger);
}

.detail-pill strong .neutral,
.field strong .neutral,
.trade-table td .neutral {
  color: var(--soft);
}

.drawer-section {
  margin-top: 14px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 10px;
}

.bar-tabs,
.chart-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bar-tabs button {
  min-width: 44px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--soft);
  font-weight: 700;
}

.bar-tabs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #061014;
}

.trade-chart-shell {
  position: relative;
  width: 100%;
  height: clamp(460px, 58vh, 680px);
  background: var(--chart-bg);
  border-radius: 8px;
  overflow: hidden;
}

.drawing-toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 7;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border: 1px solid color-mix(in srgb, var(--line) 76%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--chart-bg) 88%, transparent);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(10px);
}

.drawing-toolbar button,
.drawing-object-toolbar button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: color-mix(in srgb, var(--text) 74%, transparent);
  padding: 0;
}

.drawing-toolbar button:hover,
.drawing-toolbar button.active,
.drawing-object-toolbar button:hover {
  border-color: color-mix(in srgb, var(--accent) 48%, transparent);
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: var(--text);
}

.tv-icon,
.drawing-object-toolbar svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.drawing-object-toolbar button[data-object-action="style"] {
  width: 48px;
  font-size: 12px;
  font-weight: 800;
}

.drawing-width-readout {
  min-width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
}

.tv-icon circle,
.tv-icon rect,
.drawing-object-toolbar rect {
  fill: color-mix(in srgb, var(--chart-bg) 70%, transparent);
}

.drawing-object-toolbar {
  position: absolute;
  z-index: 9;
  display: flex;
  gap: 4px;
  padding: 5px;
  border: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  border-radius: 9px;
  background: color-mix(in srgb, var(--chart-bg) 90%, transparent);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(10px);
}

.drawing-object-toolbar[hidden] {
  display: none;
}
#tradeChart {
  position: absolute;
  inset: 0;
  transition:
    opacity 180ms ease,
    filter 180ms ease;
}

.trade-chart-shell.is-loading #tradeChart {
  opacity: 0.42;
  filter: blur(1px);
}

.trade-chart-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.chart-drawing-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.trade-chart-shell.draw-tool-active .chart-drawing-layer,
.chart-drawing-layer.is-dragging {
  cursor: crosshair;
  pointer-events: auto;
}

.drawing-item {
  pointer-events: none;
}

.drawing-hit {
  stroke: transparent;
  stroke-width: 16;
  fill: none;
  pointer-events: stroke;
  cursor: move;
}

.drawing-zone-hit {
  fill: transparent;
  stroke: transparent;
  pointer-events: fill;
  cursor: move;
}

.drawing-line {
  stroke: #8dc7ff;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.45));
}

.drawing-line.extended {
  stroke-dasharray: none;
}

.drawing-line.horizontal {
  stroke: #f6bb5c;
  stroke-dasharray: 7 5;
}

.drawing-preview-line {
  stroke: #f6bb5c;
  stroke-width: 1.6;
  stroke-dasharray: 4 5;
  vector-effect: non-scaling-stroke;
  opacity: 0.92;
  filter: drop-shadow(0 0 3px rgba(246, 187, 92, 0.36));
}

.drawing-preview-label {
  fill: #f6bb5c;
  font-size: 12px;
}

.drawing-line.measure {
  stroke: #8dc7ff;
}

.drawing-item.selected .drawing-line,
.drawing-item.selected .drawing-position-line {
  stroke-width: 2.4;
  filter: drop-shadow(0 0 3px rgba(141, 199, 255, 0.42));
}

.drawing-handle {
  fill: var(--chart-bg);
  stroke: #f5f7fa;
  stroke-width: 2.4;
  vector-effect: non-scaling-stroke;
  pointer-events: all;
  cursor: grab;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.65));
}

.drawing-handle:hover {
  fill: #8dc7ff;
  stroke: #ffffff;
}

.chart-drawing-layer.is-dragging .drawing-handle {
  cursor: grabbing;
}

.drawing-measure-rect {
  fill: color-mix(in srgb, #8dc7ff 13%, transparent);
  stroke: #8dc7ff;
  stroke-width: 1;
  stroke-dasharray: 5 4;
  vector-effect: non-scaling-stroke;
}

.drawing-price-label,
.drawing-measure-text,
.drawing-position-text {
  fill: var(--text);
  font-size: 12px;
  font-weight: 800;
  paint-order: stroke;
  stroke: var(--chart-bg);
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
}

.drawing-position-profit {
  fill: rgba(50, 168, 116, 0.22);
  stroke: rgba(80, 210, 150, 0.72);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.drawing-position-risk {
  fill: rgba(223, 78, 78, 0.20);
  stroke: rgba(255, 118, 118, 0.72);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.drawing-position-line {
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.drawing-position-line.entry {
  stroke: #f6bb5c;
  stroke-dasharray: 7 5;
}

.drawing-position-line.target {
  stroke: #55d89c;
}

.drawing-position-line.stop {
  stroke: #ff7373;
}

.chart-drawing-hud {
  position: absolute;
  z-index: 8;
  left: 58px;
  top: 12px;
  max-width: min(480px, calc(100% - 90px));
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--soft);
  font-size: 12px;
  line-height: 1.4;
  pointer-events: none;
}

.trade-marker-line {
  position: absolute;
  top: 0;
  bottom: 24px;
  width: 0;
  border-left: 1px dashed currentColor;
}

.trade-marker-line.open {
  color: var(--accent);
}

.trade-marker-line.close {
  color: var(--warn);
}

.trade-marker-label {
  position: absolute;
  top: 8px;
  left: 5px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--marker-label-bg);
  color: currentColor;
  font-size: 12px;
  font-weight: 800;
}

.trade-range-fill {
  position: absolute;
  top: 0;
  bottom: 24px;
  background: rgba(141, 199, 255, 0.09);
  border-left: 1px solid rgba(141, 199, 255, 0.28);
  border-right: 1px solid rgba(246, 187, 92, 0.28);
}

.chart-empty-state {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  z-index: 3;
  background: var(--empty-overlay-bg);
  color: var(--muted);
  text-align: center;
  white-space: pre-line;
  line-height: 1.8;
  padding: 24px;
}

.chart-empty-state.loading {
  background: color-mix(in srgb, var(--chart-bg) 72%, transparent);
  color: var(--soft);
}

.chart-empty-state.show {
  display: grid;
}

.chart-attribution {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.chart-attribution a {
  color: var(--accent);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.field {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.field span {
  color: var(--muted);
}

.field strong {
  text-align: right;
}

@media (max-width: 1180px) {
  #app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
  }

  .source-card {
    min-width: 220px;
    margin-top: 0;
  }

  .filter-panel,
  .kpi-grid,
  .content-grid.two,
  .content-grid.three,
  .report-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .main {
    padding: 16px 12px 28px;
  }

  .topbar,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .theme-switch {
    justify-content: center;
  }

  .filter-panel,
  .kpi-grid,
  .content-grid.two,
  .content-grid.three,
  .report-grid,
  .detail-meta,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .drawer {
    width: 100vw;
    padding: 14px;
  }

  .chart-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .trade-chart-shell {
    height: 420px;
  }
}
