.btn {
  border: 1px solid var(--border-strong);
  background: var(--bg-soft);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
}

.btn:hover {
  border-color: var(--accent);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.btn-cta {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 10px 16px;
}

.btn-cta:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 86%, #fff 14%);
}

.topbar-actions .btn-cta {
  margin-right: 6px;
}

.btn-ghost {
  background: transparent;
}

.btn-danger {
  border-color: var(--danger);
  color: #e8b4b4;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 12px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-primary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.kpi-diag {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat-card.is-diag {
  padding: 10px 12px;
  border-color: transparent;
  background: var(--bg-soft);
}

.stat-card.is-diag .value {
  font-size: 16px;
  font-weight: 500;
}

.stat-card.is-diag .label {
  font-size: 11px;
  margin-bottom: 4px;
}

.kpi-delta {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: flex-end;
  margin-bottom: 12px;
}

.filter-bar .field {
  margin: 0;
  min-width: 118px;
  flex: 1 1 118px;
}

.filter-bar .field label {
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.filter-bar .select {
  padding: 6px 8px;
  font-size: 13px;
}

.filter-bar-end {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
  flex: 0 0 auto;
}

.format-drawer {
  margin: 0 0 12px;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-head .panel-title {
  margin: 0;
}

.section-head-start {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.panel.is-quiet {
  border-color: transparent;
  background: transparent;
  padding: 0;
}

.trend-chart {
  width: 100%;
  height: 200px;
  margin-bottom: 10px;
  color: var(--text);
}

.trend-chart svg {
  width: 100%;
  height: 100%;
  display: block;
}

.matrix-wrap {
  overflow: auto;
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.matrix-table th,
.matrix-table td {
  padding: 8px 10px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.matrix-table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.matrix-table th:first-child,
.matrix-table td:first-child {
  text-align: left;
  font-weight: 600;
}

.matrix-table td.is-empty {
  color: var(--text-faint);
}

.matrix-table td.is-live-col {
  background: var(--accent-soft);
}

.list-metric {
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .kpi-primary,
  .kpi-diag {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
}

.stat-card .label {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.stat-card .value {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.stat-card .hint {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-faint);
}

.stat-card.is-live {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.stat-card.is-frozen {
  opacity: 0.78;
}

.basis-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--accent);
  color: #fff;
  vertical-align: middle;
}

.basis-tag.is-frozen {
  background: var(--bg-soft);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.data-table th.is-live-col,
.data-table td.is-live-col {
  background: var(--accent-soft);
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.panel-title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field label {
  font-size: 12px;
  color: var(--text-muted);
}

.input,
.select,
.textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  outline: none;
  width: 100%;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
}

.textarea {
  min-height: 120px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
}

.input-inline {
  width: auto;
  min-width: 160px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1120px;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}

.data-table th {
  position: sticky;
  top: 0;
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  z-index: 1;
  cursor: pointer;
  user-select: none;
}

.data-table th.col-check,
.data-table td.col-check {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 40px;
  min-width: 40px;
  max-width: 40px;
  padding-left: 10px;
  padding-right: 6px;
  text-align: center;
  background: var(--bg-elevated);
  cursor: default;
}

.data-table th.col-check {
  background: var(--bg-soft);
  z-index: 5;
}

.data-table tr:hover td.col-check {
  background: color-mix(in srgb, var(--bg-elevated) 88%, #fff 8%);
}

.data-table th.col-deal,
.data-table td.col-deal {
  min-width: 260px;
}

.data-table th.col-account,
.data-table td.col-account {
  position: sticky;
  left: 40px;
  z-index: 2;
  min-width: 140px;
  background: var(--bg-elevated);
  box-shadow: 6px 0 10px -6px rgba(0, 0, 0, 0.55);
}

.data-table th.col-account {
  background: var(--bg-soft);
  z-index: 4;
}

.data-table tr:hover td.col-account {
  background: color-mix(in srgb, var(--bg-elevated) 88%, #fff 8%);
}

.data-table-deals th.col-deal,
.data-table-deals td.col-deal {
  position: sticky;
  left: 40px;
  z-index: 2;
  background: var(--bg-elevated);
  box-shadow: 6px 0 10px -6px rgba(0, 0, 0, 0.55);
}

.data-table-deals th.col-deal {
  background: var(--bg-soft);
  z-index: 4;
}

.data-table-deals tr:hover td.col-deal {
  background: color-mix(in srgb, var(--bg-elevated) 88%, #fff 8%);
}

.data-table td.col-deal .select-deal {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.combo-trigger {
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.combo-panel {
  position: fixed;
  z-index: 80;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  font-size: 12px;
}

.combo-search {
  margin: 8px;
  width: calc(100% - 16px);
  font-size: 12px;
  padding: 6px 8px;
}

.combo-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-bottom: 6px;
  overscroll-behavior: contain;
}

.combo-option {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 6px 10px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.combo-option:hover,
.combo-option.is-active {
  background: var(--accent-soft);
}

.combo-option.is-current {
  font-weight: 600;
}

.toolbar .combo-trigger {
  max-width: 280px;
}

.combo-filter {
  display: inline-flex;
  align-items: stretch;
  max-width: 320px;
  min-width: 160px;
}

.combo-filter .combo-trigger {
  max-width: none;
  flex: 1;
  min-width: 0;
}

.combo-filter:has(.combo-clear) .combo-trigger {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.combo-clear {
  flex: 0 0 auto;
  width: 28px;
  border: 1px solid var(--border);
  border-left: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.combo-clear:hover {
  color: var(--text);
  background: var(--bg-soft);
}

.combo-option.is-sticky {
  position: sticky;
  z-index: 2;
  background: var(--bg-elevated);
  box-shadow: 0 1px 0 var(--border);
}

.combo-option.is-sticky:nth-child(1) {
  top: 0;
}

.combo-option.is-sticky:nth-child(2) {
  top: 28px;
}

.combo-empty {
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 13px;
}

.col-resizer {
  position: absolute;
  top: 0;
  right: -4px;
  width: 10px;
  height: 100%;
  cursor: col-resize;
  z-index: 3;
}

.col-resizer:hover,
body.col-resizing .col-resizer {
  background: linear-gradient(
    to right,
    transparent 4px,
    var(--accent) 4px,
    var(--accent) 6px,
    transparent 6px
  );
}

body.col-resizing,
body.col-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

.data-table th:hover {
  color: var(--text);
}

.data-table td {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.data-table tr.is-total-row td {
  font-weight: 600;
}

.data-table tr.is-active-row td {
  background: var(--accent-soft);
}

.data-table tr.is-active-row td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

.data-table tr.is-active-row td.is-live-col {
  background: color-mix(in srgb, var(--accent-soft) 70%, var(--accent) 16%);
}

.data-table tr.is-active-row:hover td {
  background: var(--accent-soft);
}

.data-table tr.is-active-row:hover td.is-live-col {
  background: color-mix(in srgb, var(--accent-soft) 70%, var(--accent) 16%);
}

.data-table .num {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--bg);
}

.badge-short { border-color: #4a6a7a; color: #9fc0d0; }
.badge-long { border-color: #5a6a4a; color: #b0c49a; }
.badge-social { border-color: #6a5a7a; color: #c4b0d8; }

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}

.tab-row {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.tab {
  background: transparent;
  border: 1px solid transparent;
  padding: 10px 22px;
  min-width: 148px;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.02em;
  border-radius: var(--radius-sm);
  line-height: 1.2;
}

.tab:hover {
  color: var(--text);
  background: var(--bg-soft);
}

.tab.active {
  color: var(--text);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.tab .count {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  vertical-align: 1px;
}

.tab.active .count {
  background: rgba(107, 140, 174, 0.28);
  color: var(--text);
}

.data-table .num-up {
  color: #8fbf8f;
}

.data-table .num-down {
  color: #d08a8a;
}

.data-table-compact {
  min-width: 1240px;
}

.split-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.split-watchlists {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
}

.dq-wrap {
  margin: 0 0 12px;
}

.dq-chip {
  border: 1px solid var(--border-strong);
  background: var(--bg-soft);
  color: var(--text);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
}

.dq-chip:hover {
  border-color: var(--accent);
}

.dq-chip.is-ready {
  border-color: var(--success);
}

.dq-chip.is-issues {
  border-color: var(--warning);
}

.dq-panel {
  margin-top: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.dq-counts {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.dq-count.is-error { color: var(--danger); }
.dq-count.is-warning { color: var(--warning); }
.dq-count.is-info { color: var(--text-muted); }

.dq-ready-note {
  margin: 0 0 8px;
}

.dq-group {
  margin-top: 10px;
}

.dq-group-title {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.dq-group-title.is-error { color: var(--danger); }
.dq-group-title.is-warning { color: var(--warning); }
.dq-group-title.is-info { color: var(--text-muted); }

.dq-code {
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 0;
}

.dq-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dq-issue {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 4px 0;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
}

.dq-issue:hover {
  color: var(--accent);
}

.notice {
  border: 1px solid var(--border-strong);
  background: var(--accent-soft);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  line-height: 1.5;
}

.notice strong {
  display: block;
  margin-bottom: 4px;
}

@media (max-width: 900px) {
  .split-2,
  .split-watchlists {
    grid-template-columns: 1fr;
  }
}

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.list-row:last-child {
  border-bottom: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 20px;
}

.modal {
  width: min(720px, 100%);
  max-height: min(90vh, 900px);
  overflow: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.modal h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 0 8px;
  cursor: pointer;
  font-weight: 500;
}

.pack-list {
  max-height: 50vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  margin: 8px 0 0;
}

.pack-row {
  align-items: flex-start;
  margin: 8px 0;
}

.pack-clash {
  margin-top: 6px;
}

.pack-clash .check-row {
  margin: 4px 0;
  font-weight: 400;
}

.preview-list {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

.preview-item {
  display: grid;
  grid-template-columns: 100px 110px 1fr;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.preview-item:last-child {
  border-bottom: none;
}

.preview-item.error {
  color: var(--danger);
}

.toast-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.toast {
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px 14px;
  min-width: 220px;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.empty {
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.select-table {
  min-width: 120px;
  padding: 4px 6px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.data-table th.num,
.data-table td.num {
  text-align: right;
}

.progress {
  height: 6px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width 0.2s;
}
