* { box-sizing: border-box; }
:root {
  --sidebar-width: 332px;
}
body {
  margin: 0; padding: 0;
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", sans-serif;
  background: #f5f7fa; color: #222;
}

.topbar {
  background: #2c3e50; color: white;
  padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar .brand { font-size: 18px; font-weight: 600; }
.topbar select { padding: 4px 8px; border-radius: 4px; border: none; font-size: 14px; }
.topbar label { font-size: 14px; margin-right: 4px; }
.date-source {
  display: none;
}
.range-summary-top {
  color: #d7dee8;
  font-size: 13px;
}
.logout-link {
  margin-left: 12px;
  color: #d7dee8;
  font-size: 12px;
  text-decoration: none;
}
.logout-link:hover { color: #fff; }

.layout {
  display: flex;
  height: calc(100vh - 56px);
}

.sidebar {
  width: var(--sidebar-width);
  min-width: 268px;
  max-width: 560px;
  background: white;
  border-right: 1px solid #e0e0e0;
  overflow-y: auto;
  padding: 0;
  flex: 0 0 var(--sidebar-width);
}
.sidebar-resizer {
  width: 6px;
  flex: 0 0 6px;
  cursor: col-resize;
  background: linear-gradient(to right, #f1f5f9, #e2e8f0, #f8fafc);
  border-right: 1px solid #d9dee8;
}
.sidebar-resizer:hover,
.resizing-sidebar .sidebar-resizer {
  background: #cfe0f5;
}
.resizing-sidebar {
  cursor: col-resize;
  user-select: none;
}

.side-tabbar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: 42px;
  border-bottom: 1px solid #d9dee8;
  background: #edf3f8;
}
.side-tab {
  border: 0;
  border-right: 1px solid #d3dbe4;
  background: transparent;
  color: #1f2933;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
}
.side-tab:last-child { border-right: none; }
.side-tab.active {
  background: #fff;
  color: #1a5490;
}
.filter-panels {
  padding: 10px;
  border-bottom: 1px solid #e5e8ec;
}
.filter-panel { display: none; }
.filter-panel.active { display: block; }
.chip-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  padding-bottom: 2px;
}
.filter-chip {
  border: 1px solid #d9dee8;
  background: #fff;
  color: #526173;
  border-radius: 5px;
  cursor: pointer;
  padding: 5px 8px;
  font-size: 12px;
}
.filter-chip.active {
  border-color: #1a5490;
  background: #e8f2ff;
  color: #1a5490;
  font-weight: 600;
}
.filter-chip .count {
  color: #8792a2;
  margin-left: 4px;
}
.range-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.range-fields label {
  color: #667085;
  font-size: 12px;
}
.range-fields input {
  display: block;
  width: 100%;
  margin-top: 4px;
  border: 1px solid #d9dee8;
  border-radius: 5px;
  padding: 5px 6px;
  color: #1f2933;
  font-size: 12px;
}
.calendar-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 0;
  border: 1px solid #d9dee8;
  border-radius: 6px;
  background: #f8fafc;
  color: #526173;
  cursor: pointer;
  padding: 7px 9px;
  font-size: 12px;
}
.calendar-toggle:hover {
  border-color: #1a5490;
  color: #1a5490;
}
.calendar-toggle-icon {
  font-size: 14px;
  transition: transform 0.12s;
}
.calendar-toggle.expanded {
  margin-bottom: 8px;
}
.calendar-toggle.expanded .calendar-toggle-icon {
  transform: rotate(180deg);
}
.calendar-box {
  border: 1px solid #e0e5eb;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}
.calendar-box.collapsed {
  display: none;
}
.calendar-head {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  height: 34px;
  background: #f6f8fb;
  border-bottom: 1px solid #e6ebf0;
  text-align: center;
}
.calendar-head button {
  height: 34px;
  border: 0;
  background: transparent;
  color: #526173;
  cursor: pointer;
  font-size: 20px;
}
.calendar-head strong {
  color: #1f2933;
  font-size: 13px;
}
.calendar-week,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.calendar-week span {
  padding: 6px 0 4px;
  color: #8792a2;
  text-align: center;
  font-size: 11px;
}
.calendar-grid {
  padding: 2px 5px 7px;
  gap: 2px;
}
.calendar-day {
  position: relative;
  height: 28px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #26323f;
  cursor: pointer;
  font-size: 12px;
}
.calendar-day:hover {
  background: #edf5ff;
}
.calendar-day.muted {
  color: #b7bec8;
}
.calendar-day.has-data::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: #1a73e8;
}
.calendar-day.in-range {
  background: #e8f2ff;
}
.calendar-day.range-start,
.calendar-day.range-end {
  background: #1a5490;
  color: #fff;
  font-weight: 700;
}
.calendar-day.range-start.has-data::after,
.calendar-day.range-end.has-data::after {
  background: #fff;
}

.list-section .list-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  font-weight: 600;
  font-size: 13px;
  color: #555;
  border-bottom: 1px solid #eef1f4;
}
.list-scope {
  color: #7b8794;
  font-size: 12px;
  font-weight: 400;
}
.market-list-head {
  display: grid;
  grid-template-columns: 96px minmax(76px, 1fr) 78px;
  gap: 7px;
  padding: 5px 10px;
  border-bottom: 1px solid #dfe4ea;
  color: #111827;
  font-size: 12px;
  font-weight: 700;
}
.market-list-head span:last-child { text-align: right; }
.stock-list { height: calc(100vh - 214px); overflow-y: auto; }
.filter-panels:has(.calendar-toggle.expanded) ~ .list-section .stock-list {
  height: calc(100vh - 354px);
}

.stock-item {
  position: relative;
  display: grid;
  grid-template-columns: 96px minmax(76px, 1fr) 78px;
  align-items: center;
  gap: 7px;
  min-height: 58px;
  padding: 6px 10px;
  border: 0;
  border-bottom: 1px solid #eef0f3;
  border-radius: 0;
  margin-bottom: 0;
  cursor: pointer;
  transition: background 0.12s, box-shadow 0.12s;
}
.stock-item:hover { background: #f8fbff; }
.stock-item.active {
  background: #edf5ff;
  box-shadow: inset 3px 0 0 #1a5490;
}
.stock-item.discarded {
  background: #f3f4f6;
  color: #8a94a6;
  opacity: 0.72;
}
.stock-item.discarded.active {
  background: #e4e7eb;
}
.stock-item.discarded .name,
.stock-item.discarded .code,
.stock-item.discarded .quote-cell {
  color: #8a94a6;
}
.stock-name {
  min-width: 0;
}
.stock-item .name {
  display: block;
  color: #111827;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.18;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stock-item .code {
  display: block;
  color: #64748b;
  font-size: 12px;
  line-height: 1.2;
  margin-top: 3px;
}
.mini-chart {
  width: 100%;
  height: 34px;
}
.quote-cell {
  position: relative;
  text-align: right;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  padding-right: 2px;
}
.quote-cell .quote-change {
  font-size: 15px;
  font-weight: 600;
}
.quote-cell .quote-price {
  display: block;
  margin-top: 4px;
  font-size: 14px;
}
.quote-up { color: #d73a49; }
.quote-down { color: #28a745; }
.quote-flat { color: #222; }
.quote-loading {
  color: #a0a7b2;
  font-size: 12px;
}
.row-tags {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 3px;
  overflow: hidden;
  min-height: 12px;
}
.strategy-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.9), 0 0 0 2px rgba(15,23,42,0.08);
  flex: 0 0 auto;
}
.stock-action-btn {
  position: absolute;
  right: 5px;
  top: 5px;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(26, 84, 144, 0.16);
  border-radius: 50%;
  background: rgba(255,255,255,0.92);
  color: #64748b;
  cursor: pointer;
  font-size: 15px;
  line-height: 17px;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  transition: opacity 0.12s, border-color 0.12s, background 0.12s, color 0.12s, transform 0.12s;
}
.stock-item:hover .stock-action-btn,
.stock-item.active .stock-action-btn {
  opacity: 1;
  pointer-events: auto;
}
.stock-action-btn:hover {
  border-color: rgba(26, 84, 144, 0.36);
  background: #fff;
  color: #1a5490;
  transform: translateY(-1px);
}

.pill {
  display: inline-block;
  background: #eef2f7;
  color: #526173;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 10px;
  line-height: 14px;
  margin-right: 2px;
  margin-top: 0;
}
.pill-industry { background: #e8f5ee; color: #20834a; }
.pill-board { background: #fff4df; color: #b45309; }
.pill-strategy { background: #eef4ff; color: #1a5490; }
.pill-hit { background: #eef2f7; color: #526173; }
.pill-label { background: #f3ecff; color: #6d3ac2; }
.pill-holding { background: #fff1f2; color: #d73a49; }
.pill-bought { background: #e7f7f3; color: #0f766e; }
.pill-discarded { background: #f1f3f5; color: #8a94a6; }
.pill-custom { background: #eef2f7; color: #475569; }

.main {
  flex: 1; padding: 20px; overflow-y: auto;
  background: white;
}
.stock-header {
  font-size: 18px; font-weight: 600; margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid #e0e0e0;
}
.stock-header .price { color: #d73a49; margin-left: 12px; }
.stock-header .pill { vertical-align: middle; }
.header-strategy-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 8px;
  vertical-align: middle;
}
.header-strategy-dots .strategy-dot {
  width: 8px;
  height: 8px;
}
.row-label-menu {
  position: fixed;
  z-index: 30;
  width: 236px;
  padding: 12px;
  border: 1px solid #dbe3ef;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.18);
}
.row-label-menu[hidden] { display: none; }
.menu-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  color: #111827;
  font-size: 14px;
  font-weight: 700;
}
.menu-title span {
  color: #7b8794;
  font-weight: 500;
  font-size: 12px;
  white-space: nowrap;
}
.menu-section-label {
  color: #8a94a6;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 4px 0 7px;
}
.menu-tag-label {
  margin-top: 12px;
}
.menu-status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.menu-status,
.menu-tag-form button {
  border: 1px solid #d8dee8;
  border-radius: 5px;
  background: #fff;
  color: #526173;
  cursor: pointer;
  padding: 6px 8px;
  font-size: 12px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.menu-status:hover,
.menu-tag-form button:hover {
  border-color: #a9b7c8;
  background: #f8fafc;
}
.menu-status.active {
  color: #fff;
  font-weight: 700;
}
.menu-status.status-holding {
  border-color: #f2c2c7;
  color: #b4232f;
  background: #fff7f8;
}
.menu-status.status-bought {
  border-color: #b9ddd7;
  color: #0f766e;
  background: #f4fbf9;
}
.menu-status.status-discarded {
  border-color: #d7dce4;
  color: #64748b;
  background: #f8fafc;
}
.menu-status.status-clear {
  border-color: #e4e7ec;
  color: #667085;
  background: #fff;
}
.menu-status.status-holding.active {
  border-color: #d73a49;
  background: #d73a49;
}
.menu-status.status-bought.active {
  border-color: #0f766e;
  background: #0f766e;
}
.menu-status.status-discarded.active {
  border-color: #6b7280;
  background: #6b7280;
}
.menu-status.status-clear.active {
  border-color: #1a5490;
  background: #1a5490;
}
.menu-tag-form {
  display: flex;
  gap: 6px;
}
.menu-tag-form input {
  min-width: 0;
  flex: 1;
  border: 1px solid #d8dee8;
  border-radius: 5px;
  padding: 6px 8px;
  font-size: 12px;
}
.menu-tag-form button {
  color: #1a5490;
  font-weight: 600;
}
.menu-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}
.menu-tag {
  border: 0;
  border-radius: 12px;
  background: #475569;
  color: #fff;
  cursor: pointer;
  padding: 3px 8px;
  font-size: 11px;
}
.menu-empty {
  color: #9aa4b2;
  font-size: 12px;
}

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  min-height: 32px;
}
.chart-tabs {
  display: inline-flex;
  border: 1px solid #d9dee8;
  border-radius: 6px;
  overflow: hidden;
  background: #f8fafc;
}
.chart-tab {
  min-width: 56px;
  padding: 6px 12px;
  border: none;
  border-right: 1px solid #d9dee8;
  background: transparent;
  color: #526173;
  cursor: pointer;
  font-size: 13px;
}
.chart-tab:last-child { border-right: none; }
.chart-tab.active {
  background: #1a5490;
  color: #fff;
  font-weight: 600;
}
.chart-status {
  color: #7b8794;
  font-size: 12px;
}
.indicator-summary {
  min-height: 32px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 8px 2px;
  color: #667085;
  font-size: 13px;
  font-weight: 600;
}
.indicator-label {
  color: #1f2933;
}
.indicator-up {
  color: #ff8f1f;
}
.indicator-mid {
  color: #8e5bc7;
}
.indicator-dn {
  color: #1677ff;
}
.indicator-turnover {
  color: #0f766e;
}

.chart-container {
  width: 100%; height: 480px;
  border: 1px solid #e0e0e0; border-radius: 4px;
}
.intraday-container {
  width: 100%; height: 480px;
  border: 1px solid #e0e0e0; border-radius: 4px;
  background: #fff;
}
.intraday-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.trades-panel {
  margin-top: 16px; padding: 12px;
  background: #fafafa; border-radius: 4px;
  font-size: 13px;
}
.trades-panel .trade-row {
  padding: 6px 0; border-bottom: 1px solid #eaeaea;
  display: flex; justify-content: space-between;
}
.trades-panel .trade-row:last-child { border-bottom: none; }
.trades-panel .buy { color: #d73a49; font-weight: 600; }
.trades-panel .sell { color: #28a745; font-weight: 600; }
.trades-panel .pnl-pos { color: #d73a49; }
.trades-panel .pnl-neg { color: #28a745; }

.webhook-panel {
  margin-top: 12px;
  padding: 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 12px;
}
.panel-title {
  margin-bottom: 8px;
  color: #1f2933;
  font-size: 13px;
  font-weight: 700;
}
.webhook-log-list {
  display: grid;
  gap: 8px;
  color: #7b8794;
}
.webhook-log-row {
  padding-bottom: 8px;
  border-bottom: 1px solid #f0f2f5;
}
.webhook-log-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}
.webhook-log-row.error .webhook-kind {
  background: #fee2e2;
  color: #b91c1c;
}
.webhook-log-main,
.webhook-log-sub {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.webhook-log-main {
  align-items: center;
  margin-bottom: 4px;
  color: #1f2933;
  font-weight: 600;
}
.webhook-log-sub {
  color: #8a95a5;
}
.webhook-kind {
  flex: 0 0 auto;
  padding: 2px 6px;
  border-radius: 999px;
  background: #eef4ff;
  color: #1a5490;
  font-size: 11px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  background: #fff;
}
.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
  background: #fff;
}
.login-visual {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  padding: 56px;
  background:
    linear-gradient(90deg, rgba(5, 15, 27, 0.74), rgba(5, 15, 27, 0.24) 54%, rgba(5, 15, 27, 0.58)),
    url("/static/login-trading-floor.jpg") center / cover no-repeat,
    #0f2236;
  color: #fff;
}
.login-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(7, 18, 32, 0.18), rgba(7, 18, 32, 0.62)),
    radial-gradient(circle at 76% 22%, rgba(40, 199, 111, 0.18), transparent 26%),
    radial-gradient(circle at 22% 72%, rgba(255, 71, 87, 0.16), transparent 26%);
}
.login-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255,255,255,0.08) 1px, transparent 1px);
  background-size: 70px 100%;
  opacity: 0.28;
}
.market-hero-copy {
  position: relative;
  z-index: 3;
  max-width: 520px;
}
.market-kicker {
  color: rgba(226, 232, 240, 0.84);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.market-hero-copy h1 {
  margin: 16px 0 10px;
  color: #fff;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1.08;
  letter-spacing: 0;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.35);
}
.market-hero-copy p {
  margin: 0;
  color: rgba(248, 250, 252, 0.86);
  font-size: 16px;
  line-height: 1.7;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.32);
}
.market-card {
  position: absolute;
  z-index: 3;
  display: grid;
  gap: 4px;
  min-width: 132px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background: rgba(9, 18, 30, 0.58);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
}
.market-card span {
  color: rgba(226, 232, 240, 0.76);
  font-size: 12px;
}
.market-card strong {
  color: #fff;
  font-size: 22px;
}
.card-one {
  right: 48px;
  top: 56px;
}
.card-one strong { color: #39d98a; }
.card-two {
  left: 56px;
  bottom: 56px;
}
.visual-credit {
  position: absolute;
  right: 18px;
  bottom: 14px;
  z-index: 3;
  color: rgba(226, 232, 240, 0.58);
  font-size: 11px;
}
.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 34px;
  background: #fff;
  box-shadow: -18px 0 60px rgba(15, 23, 42, 0.12);
}
.login-brand {
  margin-bottom: 8px;
  color: #1f2933;
  font-size: 26px;
  font-weight: 700;
}
.login-subtitle {
  margin: 0 0 28px;
  color: #667085;
  font-size: 14px;
  line-height: 1.7;
}
.login-form {
  display: grid;
  gap: 16px;
}
.login-form label {
  color: #526173;
  font-size: 13px;
}
.login-form input {
  width: 100%;
  margin-top: 6px;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  padding: 11px 12px;
  color: #111827;
  font-size: 14px;
}
.login-form input:focus {
  outline: none;
  border-color: #1a5490;
  box-shadow: 0 0 0 3px rgba(26, 84, 144, 0.12);
}
.login-form button {
  border: 0;
  border-radius: 8px;
  background: #1a5490;
  color: #fff;
  cursor: pointer;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 12px 24px rgba(26, 84, 144, 0.2);
}
.login-form button:hover {
  background: #15477b;
}
.login-error {
  border-radius: 8px;
  background: #fff1f2;
  color: #be123c;
  padding: 8px 10px;
  font-size: 13px;
}

@media (max-width: 820px) {
  .login-shell {
    grid-template-columns: minmax(0, 1fr) 310px;
  }
  .login-visual {
    min-height: 100vh;
    padding: 30px 24px;
  }
  .market-card {
    min-width: 118px;
    padding: 12px 13px;
  }
  .market-card strong { font-size: 19px; }
  .card-one { display: none; }
  .card-two {
    left: 24px;
    bottom: 42px;
  }
  .login-panel { padding: 30px 22px; }
}

@media (max-width: 560px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-visual {
    min-height: 46vh;
    padding: 26px;
  }
  .login-panel {
    min-height: 54vh;
    box-shadow: none;
  }
  .market-card,
  .visual-credit {
    display: none;
  }
}
