/* LisaQ Web UI - Template-driven rebuild */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #ffffff;
  --bg-soft: #f4f6fb;
  --panel: #ffffff;
  --line: #e6e9f0;
  --line-soft: #f0f2f7;
  --text: #1f2937;
  --muted: #6b7280;
  --brand: #2563eb;
  --up: #ca4947;
  --down: #56a970;
  --shadow: 0 2px 10px rgba(17, 24, 39, 0.04);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg);
}

.topbar {
  height: 52px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  background: var(--panel);
  z-index: 5;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 320px;
}

.brand-block {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: var(--brand);
}

.brand-sub {
  margin-top: 3px;
  font-size: 10px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.search-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-wrap {
  position: relative;
  width: 340px;
}

.search-wrap input {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--text);
  background: #f9fafc;
  outline: none;
}

.search-wrap input:focus {
  border-color: #91b6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-btn {
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.search-btn:hover {
  border-color: #cfd7e6;
}

.search-suggestions {
  position: absolute;
  top: 38px;
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 320px;
  overflow-y: auto;
  z-index: 20;
}

.search-suggestions .item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  font-size: 12px;
  cursor: pointer;
}

.search-suggestions .item:hover,
.search-suggestions .item.active {
  background: #f2f6ff;
}

.search-suggestions .item .name {
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-suggestions .item .code {
  color: #64748b;
  font-variant-numeric: tabular-nums;
}

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

.seg {
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn {
  border: 1px solid transparent;
  background: transparent;
  color: #4b5563;
  border-radius: 7px;
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  cursor: pointer;
}

.btn:hover {
  background: #f2f4f8;
}

.btn.active {
  background: #eef4ff;
  color: #1d4ed8;
  border-color: #c7d8ff;
}

.indicator-btn.active {
  background: #fff2e6;
  border-color: #ffd9ad;
  color: #9a3412;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.news-link-btn {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  background: #fff;
  color: #4b5563;
  font-size: 12px;
  text-decoration: none;
}

.news-link-btn:hover {
  border-color: #cfd7e6;
  background: #f8fafc;
}

.icon-btn,
.primary-btn {
  border: 1px solid var(--line);
  background: #fff;
  height: 30px;
  min-width: 30px;
  border-radius: 7px;
  font-size: 12px;
  color: #4b5563;
  cursor: pointer;
  padding: 0 10px;
}

.icon-btn {
  width: 30px;
  padding: 0;
}

.primary-btn {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  font-weight: 600;
}

.primary-btn:hover {
  background: #1d4ed8;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 320px 44px minmax(480px, 1fr) 340px;
  overflow: hidden;
}

.workspace.watch-collapsed {
  grid-template-columns: 74px 44px minmax(480px, 1fr) 340px;
}

.left-sidebar {
  border-right: 1px solid var(--line);
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.sidebar-titlebar {
  height: 38px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
}

.watch-panel-toggle {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: #475569;
  cursor: pointer;
  margin-right: 6px;
  flex-shrink: 0;
}

.watch-panel-toggle:hover {
  background: #f1f5f9;
  border-color: #dbe1ea;
}

.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  flex: 1;
  min-width: 0;
}

.watch-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.watch-action-btn {
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font-size: 11px;
}

.watch-action-btn:hover {
  background: #f1f5f9;
  border-color: #dbe1ea;
}

.watch-profile {
  padding: 10px;
  border-bottom: 1px solid var(--line-soft);
  background: #f8fafc;
}

.watch-profile-name {
  font-size: 14px;
  font-weight: 700;
  color: #111827;
}

.watch-profile-meta {
  margin-top: 2px;
  font-size: 11px;
  color: #64748b;
}

.watchlist-tabs-wrap {
  border-bottom: 1px solid var(--line-soft);
  padding: 8px 8px 6px;
}

.watchlist-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.watchlist-tab {
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #fff;
  color: #475569;
  font-size: 11px;
  line-height: 1;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.watchlist-tab:hover {
  background: #f8fafc;
}

.watchlist-tab.active {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
}

.watchlist-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--line-soft);
}

.watch-sort-select {
  flex: 1;
  height: 30px;
  border: 1px solid #d9e0ea;
  border-radius: 8px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  padding: 0 8px;
}

.watch-sort-dir-btn {
  width: 30px;
  height: 30px;
  border: 1px solid #d9e0ea;
  border-radius: 8px;
  background: #fff;
  color: #334155;
  cursor: pointer;
}

.watch-sort-dir-btn:hover {
  background: #f8fafc;
}

.watchlist-status {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line-soft);
}

.watchlist {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  border-bottom: 1px solid var(--line);
  min-height: 120px;
  flex: 1;
}

.watch-item {
  border-left: 2px solid transparent;
  border-bottom: 1px solid #f6f7fa;
  cursor: pointer;
  padding: 8px 8px;
  font-size: 12px;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 8px;
}

.watch-item-main {
  flex: 1;
  min-width: 0;
}

.watch-name {
  color: #64748b;
  font-size: 11px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.watch-pct {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  min-width: 56px;
  text-align: right;
}

.watch-last-close {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  min-width: 50px;
  text-align: right;
  color: #475569;
}

.watch-item-actions {
  display: flex;
  gap: 4px;
}

.watch-mini-btn {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1px solid transparent;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  padding: 0;
}

.watch-mini-btn:hover {
  background: #f1f5f9;
  border-color: #dbe1ea;
}

.watch-item:hover {
  background: #f8fbff;
}

.watch-item.active {
  background: #eef4ff;
  border-left-color: #2563eb;
}

.watch-symbol {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.left-sidebar.collapsed .sidebar-title {
  display: none;
}

.left-sidebar.collapsed .watch-profile,
.left-sidebar.collapsed .watchlist-tabs-wrap,
.left-sidebar.collapsed .watchlist-controls,
.left-sidebar.collapsed .watchlist-status {
  display: none;
}

.left-sidebar.collapsed .watch-item {
  padding: 8px 6px;
  justify-content: center;
}

.left-sidebar.collapsed .watch-item-main {
  max-width: 56px;
}

.left-sidebar.collapsed .watch-name,
.left-sidebar.collapsed .watch-last-close,
.left-sidebar.collapsed .watch-pct,
.left-sidebar.collapsed .watch-item-actions {
  display: none;
}

.quick-stats {
  padding: 12px;
  background: #f8fafc;
  overflow-y: auto;
  min-height: 150px;
}

.muted {
  color: #94a3b8;
  font-size: 12px;
}

.qs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #475569;
  padding: 4px 0;
  border-bottom: 1px dashed #e5e7eb;
}

.qs-row:last-child {
  border-bottom: 0;
}

.left-toolbar {
  border-right: 1px solid var(--line);
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}

.tool-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font-size: 14px;
}

.tool-btn:hover,
.tool-btn.active {
  background: #eef4ff;
  color: #1d4ed8;
  border-color: #c7d8ff;
}

.tool-sep {
  width: 20px;
  height: 1px;
  background: #e2e8f0;
}

.center {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  padding: 8px;
  gap: 8px;
}

.symbolbar {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
}

.symbol .name {
  font-size: 18px;
  font-weight: 700;
}

.symbol .code {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.quote {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.quote .price {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.quote .change,
.change {
  font-size: 12px;
  font-weight: 600;
}

.quote .change.positive,
.positive {
  color: var(--up);
}

.quote .change.negative,
.negative {
  color: var(--down);
}

.tick-up {
  color: var(--up) !important;
}

.tick-down {
  color: var(--down) !important;
}

.tick-flash {
  animation: tickFlashPulse 0.42s ease;
}

@keyframes tickFlashPulse {
  0% {
    opacity: 0.45;
    filter: brightness(0.92);
  }
  45% {
    opacity: 1;
    filter: brightness(1.18);
  }
  100% {
    opacity: 1;
    filter: brightness(1);
  }
}

.hover-info {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  background: #fff;
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: #374151;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.hover-info .up {
  color: var(--up);
  font-weight: 600;
}

.hover-info .down {
  color: var(--down);
  font-weight: 600;
}

.hover-info .kv {
  margin-right: 10px;
}

.hover-info .sep {
  margin: 0 6px;
  color: #cbd5e1;
}

.chart-stack {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.main-chart,
.volume-chart,
.indicator-panel {
  position: relative;
  background: #fff;
  overflow: hidden;
}

.main-chart {
  flex: 1;
  min-height: 320px;
}

.volume-chart {
  height: 165px;
  border-top: 1px solid var(--line-soft);
}

.indicator-charts {
  display: none;
  flex-direction: column;
}

.indicator-charts.has-visible-panels {
  display: flex;
}

.indicator-panel {
  height: 168px;
  border-top: 1px solid var(--line-soft);
}

.panel-title {
  position: absolute;
  top: 8px;
  left: 10px;
  z-index: 2;
  font-size: 11px;
  color: #64748b;
  pointer-events: none;
}

.panel-title-volume {
  top: 6px;
  left: 8px;
  font-weight: 700;
}

.panel-values {
  margin-left: 8px;
  color: #334155;
  font-variant-numeric: tabular-nums;
}

.crosshair-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(15, 23, 42, 0.28);
  pointer-events: none;
  display: none;
  z-index: 3;
}

.right-sidebar {
  border-left: 1px solid var(--line);
  background: #fff;
  overflow-y: auto;
}

.right-panel {
  border-bottom: 1px solid var(--line);
}

.panel-head {
  height: 34px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 1px solid #edf1f6;
}

.panel-body {
  padding: 12px;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.info-item .label {
  font-size: 11px;
  color: #94a3b8;
}

.info-item .value {
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
  font-variant-numeric: tabular-nums;
}

.board-summary {
  margin-bottom: 8px;
}

.board-table-wrap {
  overflow-x: auto;
}

.board-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.board-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  padding: 6px 4px;
  border-bottom: 1px solid #e5e7eb;
}

.board-table tbody td {
  padding: 8px 4px;
  border-bottom: 1px dashed #edf1f6;
  color: #334155;
  vertical-align: top;
}

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

.board-table .board-col-name {
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board-table .board-col-pct,
.board-table .board-col-count,
.board-table .board-col-type {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.score-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 10px;
}

.score-total {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.score-total .score {
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
  color: var(--brand);
}

.score-total .suffix {
  font-size: 12px;
  color: #94a3b8;
}

.level {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 20px;
  border-radius: 10px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 700;
  padding: 0 8px;
}

.score-breakdown {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.score-item {
  display: grid;
  grid-template-columns: 52px 1fr 40px;
  gap: 8px;
  align-items: center;
}

.score-item .label {
  font-size: 11px;
  color: #64748b;
}

.score-bar {
  height: 6px;
  border-radius: 999px;
  background: #eef2f7;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: #60a5fa;
}

.score-item .score-value {
  font-size: 11px;
  color: #64748b;
  justify-self: end;
}

.limit-display {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.limit-item {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.toplist-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed #ecf1f7;
  gap: 8px;
}

.toplist-row:last-child {
  border-bottom: 0;
}

.toplist-row .broker {
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toplist-row .amount {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.backtest-btn {
  width: 100%;
  border: 1px dashed #bfd4ff;
  border-radius: 9px;
  background: #f8fbff;
  color: #1d4ed8;
  padding: 11px 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.backtest-btn:hover {
  background: #eff6ff;
}

.status-bar {
  height: 28px;
  border-top: 1px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 10px;
  font-size: 11px;
  color: #64748b;
}

.status-bar .spacer {
  flex: 1;
}

.status-ok {
  color: #15803d;
}

.status-bad {
  color: #b91c1c;
}

::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-thumb {
  background: #d9dfeb;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #c4ccda;
}

@media (max-width: 1360px) {
  .workspace {
    grid-template-columns: 280px 40px minmax(420px, 1fr) 300px;
  }

  .workspace.watch-collapsed {
    grid-template-columns: 70px 40px minmax(420px, 1fr) 300px;
  }

  .search-wrap {
    width: 280px;
  }
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 280px minmax(360px, 1fr);
  }

  .workspace.watch-collapsed {
    grid-template-columns: 70px minmax(360px, 1fr);
  }

  .left-toolbar,
  .right-sidebar {
    display: none;
  }
}

@media (max-width: 820px) {
  body {
    overflow: auto;
    height: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
  }

  .topbar {
    height: auto;
    flex-wrap: wrap;
    align-items: flex-start;
    padding: 10px;
    gap: 8px;
  }

  .topbar-left,
  .topbar-center,
  .topbar-right {
    width: 100%;
  }

  .topbar-center {
    overflow-x: auto;
  }

  .search-wrap {
    width: calc(100vw - 94px);
    max-width: none;
  }

  .workspace {
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .left-sidebar {
    width: 100%;
    max-height: 260px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .left-sidebar.collapsed .watch-profile,
  .left-sidebar.collapsed .watchlist-tabs-wrap,
  .left-sidebar.collapsed .watchlist-controls,
  .left-sidebar.collapsed .watchlist-status {
    display: block;
  }

  .left-sidebar.collapsed .sidebar-title {
    display: inline;
  }

  .left-sidebar.collapsed .watch-item {
    justify-content: flex-start;
    padding: 8px 8px;
  }

  .left-sidebar.collapsed .watch-name,
  .left-sidebar.collapsed .watch-last-close,
  .left-sidebar.collapsed .watch-pct {
    display: inline;
  }

  .left-sidebar.collapsed .watch-item-actions {
    display: flex;
  }

  .left-sidebar.collapsed .watch-item-main {
    max-width: none;
  }

  .center {
    min-height: 620px;
  }

  .status-bar {
    position: sticky;
    bottom: 0;
  }
}
