body {
  min-height: 100vh;
}

.container {
  width: calc(100% - 24px);
  max-width: 1700px;
  margin: 20px 12px 40px;
  display: grid;
  gap: 20px;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.tab-content {
  min-width: 0;
  display: grid;
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 2px 2px 0;
}

.page-head-copy h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2.2vw, 1.8rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.page-head-copy p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: min(360px, 100%);
  margin: 0;
  padding: 6px 11px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status::before {
  content: '';
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--positive);
}

.status.is-loading::before {
  background: var(--warning);
}

.status.is-error {
  border-color: rgba(220, 38, 38, 0.2);
  background: var(--negative-soft);
  color: var(--negative);
}

.status.is-error::before {
  background: var(--negative);
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px 14px;
  padding: 16px;
  align-items: end;
}

#mfmControls {
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}

.filter-group {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.controls select,
.controls input {
  width: 100%;
  min-width: 0;
}

.mfh-controls {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}

.mfh-controls .filter-group:first-child {
  flex: 1 1 auto;
  max-width: 320px;
}

.controls input[type='checkbox'] {
  width: auto;
  height: auto;
  padding: 0;
  justify-self: start;
}

.filter-group.inactive {
  opacity: 0.45;
}

.filter-group[hidden] {
  display: none;
}

.filter-group label {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.filter-group.action-group {
  align-self: end;
}

.filter-group.action-group .primary-btn {
  width: 100%;
}

.segmented {
  display: flex;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
}

.segmented .seg-btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 6px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.segmented .seg-btn + .seg-btn {
  border-left: 1px solid var(--border);
}

.segmented .seg-btn.active {
  background: var(--accent);
  color: #fff;
}

input,
select,
button {
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

select {
  padding-right: 30px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%2364748b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

input:hover,
select:hover,
button:hover {
  border-color: #b6c5d6;
}

input:focus,
select:focus,
button:focus-visible {
  border-color: var(--accent);
  outline: none;
  box-shadow: var(--ring);
}

.primary-btn {
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.primary-btn:hover {
  background: var(--accent-hover);
}

.primary-btn:disabled,
.ghost-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ghost-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
}

.ghost-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

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

.tabs {
  position: sticky;
  top: 12px;
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 24px);
  padding: 10px;
  overflow-y: auto;
}

.tab-btn {
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.tab-btn:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.tab-btn.active,
.tab-btn.group-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.tab-single {
  border: 0;
}

.tab-group {
  display: grid;
  gap: 2px;
}

.tab-parent {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tab-caret {
  font-size: 0.72rem;
  opacity: 0.55;
  transition: transform 0.2s ease;
}

.tab-group.open .tab-caret {
  transform: rotate(180deg);
}

.sub-tabs {
  display: none;
}

.tab-group.open .sub-tabs {
  display: grid;
  gap: 2px;
  margin-left: 6px;
  padding: 2px 0 2px 10px;
  border-left: 1px solid var(--border);
}

.sub-tab {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
}

.sub-tab:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.sub-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.mobile-tabs {
  display: none;
  padding: 10px;
  gap: 8px;
}

.mobile-tab-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.mobile-tab-row::-webkit-scrollbar {
  display: none;
}

.mobile-tab-btn {
  flex: 0 0 auto;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.mobile-tab-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.mobile-tab-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.mobile-tab-btn[data-group].active {
  border-color: rgba(4, 102, 200, 0.18);
  background: var(--accent-soft);
  color: var(--accent);
}

.mobile-sub-btn {
  font-weight: 600;
}

.coming-soon {
  padding: 44px 20px;
  color: var(--muted);
  text-align: center;
}

.coming-soon h3 {
  margin-bottom: 8px;
  color: var(--text);
}

.fund-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
}

.fund-chart-wrap {
  height: 420px;
}

.fund-sankey {
  width: 100%;
}

.fund-sankey svg {
  display: block;
}

.fund-sankey-tip {
  position: fixed;
  z-index: 60;
  display: none;
  width: max-content;
  max-width: min(320px, calc(100vw - 24px));
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.35;
  box-shadow: var(--shadow-pop);
  pointer-events: none;
}

.fund-sankey-tip-title {
  font-weight: 700;
}

.fund-sankey-tip-value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.fund-sankey-tip-list {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}

.fund-sankey-tip-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.fund-sankey-tip-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.fund-sankey-tip-row b {
  flex: 0 0 auto;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.fund-sankey-tip-more {
  color: var(--muted);
  font-size: 0.72rem;
}

.fund-sankey-tip-hint {
  margin-top: 6px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
}

.chart-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.agent-messages {
  min-height: 320px;
  max-height: 60vh;
  overflow-y: auto;
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 4px;
}

.agent-msg {
  display: flex;
}

.agent-user {
  justify-content: flex-end;
}

.agent-bubble {
  padding: 10px 12px;
  border-radius: 10px;
  max-width: 82%;
  white-space: normal;
  line-height: 1.45;
  background: var(--accent-soft);
  border: 1px solid rgba(4, 102, 200, 0.14);
  color: var(--text);
  overflow-wrap: anywhere;
}

.agent-user .agent-bubble {
  background: var(--positive-soft);
  border-color: rgba(22, 163, 74, 0.18);
  white-space: pre-wrap;
}

.agent-bubble p {
  margin: 0 0 8px;
}

.agent-bubble p:last-child,
.agent-bubble ul:last-child,
.agent-bubble ol:last-child {
  margin-bottom: 0;
}

.agent-bubble ul,
.agent-bubble ol {
  margin: 0 0 8px;
  padding-left: 20px;
}

.agent-bubble h1,
.agent-bubble h2,
.agent-bubble h3,
.agent-bubble h4 {
  margin: 6px 0;
  font-size: 1rem;
}

.agent-bubble code {
  background: var(--surface-muted);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.86em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.agent-bubble pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0 0 8px;
}

.agent-bubble pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.agent-bubble a {
  color: var(--accent);
  text-decoration: underline;
}

.agent-bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 0 0 8px;
  font-size: 0.85em;
}

.agent-bubble th,
.agent-bubble td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  text-align: left;
}

.agent-bubble th {
  background: var(--surface-muted);
}

.agent-bubble blockquote {
  border-left: 3px solid var(--border-strong);
  margin: 0 0 8px;
  padding-left: 10px;
  color: var(--muted);
}

.agent-bubble img {
  max-width: 100%;
}

.agent-tool {
  justify-content: flex-start;
}

.agent-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}

.agent-form input {
  flex: 1 1 auto;
  min-width: 0;
}

.agent-form button {
  flex: 0 0 auto;
}

.agent-chart {
  justify-content: flex-start;
}

.agent-chart-card {
  width: 100%;
  max-width: 560px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.agent-chart-title {
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.agent-chart-box {
  position: relative;
  height: 220px;
}

.fund-section h3 {
  margin-bottom: 10px;
}

.fund-section td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.fund-section tr.fund-header td {
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
}

.fund-ratio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  align-items: start;
}

.fund-ratio-card {
  min-width: 0;
  padding: 16px;
}

.fund-ratio-card h3 {
  margin: 0 0 10px;
  font-size: var(--text-base);
}

.fund-ratio-note {
  margin: -4px 0 10px;
  color: var(--muted);
  font-size: var(--text-xs);
}

.fund-ratio-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.fund-ratio-table td {
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}

.fund-ratio-table tr:last-child td {
  border-bottom: 0;
}

.fund-ratio-table td.num {
  padding-left: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.fund-side {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-content: start;
  padding: 16px;
  min-width: 0;
}

.fund-side-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 4px;
}

.fund-side-head h3 {
  margin: 0;
  font-size: var(--text-base);
}

.fund-side-head span {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
}

.fund-category {
  min-width: 0;
  border-top: 1px solid var(--border);
}

.fund-category:first-of-type {
  border-top: 0;
}

.fund-category summary {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 0;
  cursor: pointer;
  list-style: none;
}

.fund-category summary::-webkit-details-marker {
  display: none;
}

.fund-category summary::after {
  content: '+';
  margin-left: 2px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.fund-category[open] summary::after {
  content: '\2212';
  color: var(--accent);
}

.fund-category-swatch {
  flex: 0 0 auto;
  align-self: center;
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

.fund-category-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: var(--text-sm);
  font-weight: 700;
}

.fund-category summary:hover .fund-category-name {
  color: var(--accent);
}

.fund-category-meta {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.fund-category-table {
  max-height: 320px;
  margin: 2px 0 8px;
}

.fund-category-table table {
  table-layout: fixed;
  font-size: 0.82rem;
}

.fund-category-table td {
  padding: 7px 10px;
}

.fund-category-table td:first-child {
  overflow-wrap: anywhere;
  white-space: normal;
}

.fund-category-table td.num {
  width: 40%;
  white-space: nowrap;
}

.fund-sankey [data-node-id].fund-sankey-focus rect {
  stroke: var(--accent);
  stroke-width: 2;
}

.tab-panel {
  display: none;
  gap: 18px;
  min-width: 0;
}

.tab-panel.active {
  display: grid;
}

.tab-panel > * {
  min-width: 0;
  max-width: 100%;
}

#tab1 {
  width: 100%;
  max-width: 100%;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.kpis.kpis-5,
.kpis.kpis-6 {
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
}

.kpi {
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.kpi h3 {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.kpi p {
  margin: 8px 0 0;
  font-size: clamp(1.2rem, 1.7vw, 1.45rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.chart-card {
  padding: 18px;
  min-width: 0;
}

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

.chart-head h3 {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 800;
  letter-spacing: -0.01em;
}

.chart-head span {
  color: var(--muted);
  font-size: var(--text-xs);
}

canvas {
  max-height: 340px;
}

.lw-chart {
  width: 100%;
  height: 380px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  position: relative;
  overflow: hidden;
}

.tv-chart-full {
  width: 100%;
  height: 84vh;
  min-height: 680px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  position: relative;
}

.chart-inline-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.chart-legend {
  margin-top: 10px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--text);
  font-size: 0.82rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.legend-market {
  background: rgba(100, 116, 139, 0.72);
}

.legend-buy {
  background: rgba(34, 197, 94, 0.72);
}

.legend-sell {
  background: rgba(239, 68, 68, 0.72);
}

.legend-line {
  width: 14px;
  height: 0;
  border-top: 2px solid rgba(15, 23, 42, 0.92);
  display: inline-block;
}

.lw-tooltip {
  position: absolute;
  z-index: 12;
  display: none;
  min-width: 150px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.35;
  box-shadow: var(--shadow-pop);
  pointer-events: none;
}

.lw-tooltip-market {
  max-width: 250px;
}

.lw-tooltip-market .tip-head {
  margin-bottom: 4px;
}

.lw-tooltip-market .tip-grid {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  gap: 2px 10px;
}

.lw-tooltip-market .tip-grid span {
  color: var(--muted);
}

.lw-tooltip-market .tip-grid b {
  font-weight: 600;
  text-align: right;
}

.lw-tooltip-market .tip-line {
  margin-top: 3px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chips {
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 4px 10px;
  border: 1px solid rgba(4, 102, 200, 0.16);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
}

.chip-alert {
  border-color: rgba(220, 38, 38, 0.2);
  background: var(--negative-soft);
  color: var(--negative);
}

.chip-btn {
  cursor: pointer;
}

.chip-btn:hover {
  background: #d9edff;
}

.mfh-quick-label {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.chip-muted {
  border-color: var(--border);
  background: var(--surface-muted);
  color: var(--muted);
}

.mfm-table th:last-child,
.mfm-table td:last-child {
  width: 130px;
  min-width: 130px;
  text-align: right;
}

.mf-drill-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.mf-drill-bar .chips {
  margin-bottom: 0;
}

.mf-drill-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.mf-chart-wrap {
  position: relative;
  height: 340px;
}

.mf-chart-row {
  display: flex;
  gap: 16px;
  align-items: stretch;
}

.mf-chart-row .mf-chart-wrap {
  flex: 1 1 auto;
  min-width: 0;
}

.mf-legend {
  flex: 0 0 210px;
  max-height: 340px;
  overflow-y: auto;
  font-size: 0.8rem;
  padding-right: 4px;
}

.mf-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}

.mf-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: 0 0 auto;
}

.mf-legend-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mf-center-btn {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--accent);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.mf-center-btn[hidden] {
  display: none;
}

.mf-external-tip {
  position: absolute;
  z-index: 2000;
  pointer-events: none;
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.4;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.25);
  transform: translate(14px, 14px);
  max-width: 280px;
  opacity: 0;
}


.table-wrap {
  width: 100%;
  max-width: 100%;
  max-height: 65vh;
  margin-top: 14px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.table-wrap table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-sm);
}

.table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: right;
  text-transform: uppercase;
  white-space: nowrap;
}

.table-wrap tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.table-wrap tbody tr:last-child td {
  border-bottom: 0;
}

.table-wrap tbody tr:hover td {
  background: var(--surface-soft);
}

.table-wrap th:first-child,
.table-wrap td:first-child {
  text-align: left;
}

.table-wrap td[colspan] {
  padding: 24px 12px;
  color: var(--muted);
  text-align: center;
}

.rows-live tbody tr.dir-buy td {
  background: var(--positive-soft);
}

.rows-live tbody tr.dir-sell td {
  background: var(--negative-soft);
}

.rows-live tbody tr.dir-neutral td {
  background: var(--surface-muted);
}

.rows-live tbody tr.dir-buy td:first-child {
  border-left: 3px solid var(--positive);
}

.rows-live tbody tr.dir-sell td:first-child {
  border-left: 3px solid var(--negative);
}

.rows-live tbody tr.dir-neutral td:first-child {
  border-left: 3px solid var(--muted);
}

#stateTable th[data-sort] {
  cursor: pointer;
  user-select: none;
}

#stateTable th.sorted-asc::after {
  content: ' \25B2';
  font-size: 0.68rem;
  color: var(--accent);
}

#stateTable th.sorted-desc::after {
  content: ' \25BC';
  font-size: 0.68rem;
  color: var(--accent);
}

td.clickable {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
}

td.clickable:hover {
  text-decoration: underline;
}

.val-up {
  color: var(--positive);
  font-weight: 700;
}

.val-down {
  color: var(--negative);
  font-weight: 700;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.header-logo-link {
  display: inline-flex;
  flex-shrink: 0;
  border-radius: 16px;
  transition: transform 0.15s ease;
}

.header-logo-link:hover {
  transform: translateY(-1px);
}

.header-logo {
  display: block;
  width: 52px;
  height: 52px;
  filter: drop-shadow(0 6px 12px rgba(4, 102, 200, 0.18));
}

.header h1 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.header h1 b {
  color: var(--accent);
}

.auth-chip {
  position: relative;
  display: flex;
  align-items: center;
  margin-left: auto;
}

.auth-chip-loading {
  color: var(--muted);
  font-size: 13px;
}

.auth-chip-btn {
  padding: 7px 14px;
  font-size: 14px;
}

.auth-profile-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-profile-btn:hover,
.auth-profile-btn[aria-expanded='true'] {
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(4, 102, 200, 0.14);
}

.auth-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
}

.auth-avatar-fallback {
  background: linear-gradient(135deg, var(--accent), #3bb273);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.auth-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  width: 240px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
}

.auth-menu-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.auth-menu-identity {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.auth-menu-name {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-menu-email {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-menu-logout {
  width: 100%;
  margin-top: 4px;
  padding: 9px 8px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--negative);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.auth-menu-logout:hover {
  background: var(--negative-soft);
}

.auth-menu-logout:disabled {
  opacity: 0.6;
  cursor: default;
}

@media (max-width: 980px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .tabs {
    display: none;
  }

  .mobile-tabs {
    position: sticky;
    top: 8px;
    z-index: 20;
    display: grid;
  }

  .controls,
  .kpis {
    grid-template-columns: 1fr 1fr;
  }

  .filter-group.action-group {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .container {
    width: calc(100% - 16px);
    margin: 12px 8px 32px;
  }

  .header-logo {
    width: 42px;
    height: 42px;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .auth-menu {
    width: min(240px, calc(100vw - 32px));
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .filter-group.action-group {
    grid-column: auto;
  }

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

  .table-wrap {
    max-height: none;
  }

  .mfh-controls {
    flex-wrap: wrap;
  }

  .mfh-controls .filter-group:first-child {
    flex: 1 1 100%;
    max-width: none;
  }
}
