:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --text: #17202a;
  --muted: #697586;
  --border: #d9e0e8;
  --accent: #0f6bff;
  --up: #d92d20;
  --down: #079455;
  --grid: #e7ecf2;
}

* {
  box-sizing: border-box;
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #d92d20;
  color: #ffffff;
  font-weight: 700;
  font-size: 26px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.2;
}

h2 {
  font-size: 24px;
  line-height: 1.25;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.search {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 11px;
  font-size: 14px;
  outline: none;
}

.search::placeholder {
  font-size: 12px;
}

.search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 107, 255, 0.12);
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 12px 12px 0;
  gap: 10px;
}

.chart-title-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-width: 0;
}

.current-summary {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  min-height: 14px;
  padding-left: 2px;
}

.chart-close-button {
  height: 36px;
  border: 0;
  border-left: 0;
  border-radius: 0;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  padding: 0 14px;
  white-space: nowrap;
}

.chart-close-button:hover {
  background: #eef5ff;
  color: var(--accent);
}

.toolbar,
.chart-area {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  overflow: hidden;
  padding: 16px 18px;
}

.label,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.segmented {
  display: flex;
  flex: 0 1 auto;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow-x: auto;
  overflow-y: hidden;
}

.period,
.playback-button {
  min-width: 73px;
  height: 36px;
  border: 0;
  border-right: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  white-space: nowrap;
}

.playback-button {
  min-width: 88px;
  color: var(--text);
}

.period:last-child {
  border-right: 0;
}

.playback-button.playing {
  background: #eef5ff;
  font-weight: 700;
}

.period.active {
  background: #eef5ff;
  box-shadow: inset 0 0 0 1px var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.period-part.cbl-long {
  color: var(--up);
}

.period-part.cbl-short {
  color: #2563eb;
}

.period-separator {
  color: var(--text);
  font-weight: inherit;
}

.period.active .period-separator {
  color: var(--accent);
}

.chart-area {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.chart-head {
  display: none;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  font-size: 14px;
}

.legend-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 100px;
  height: 36px;
  border-right: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  padding: 0 12px;
  user-select: none;
  white-space: nowrap;
}

.legend-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.last-price {
  font-weight: 700;
}

.chart-frame-wrap {
  position: relative;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--panel-soft);
}

#chart-frame {
  display: block;
  width: 100%;
  min-width: 0;
  height: 100%;
  border: 0;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 15px;
  pointer-events: none;
}

.empty-state.hidden {
  display: none;
}

.quotes-panel {
  display: none;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.workspace.quotes-open .chart-area {
  display: none;
}

.workspace.quotes-open .toolbar {
  display: none;
}

.workspace.quotes-open .quotes-panel {
  display: flex;
  flex-direction: column;
}

.workspace.quotes-open {
  grid-template-rows: auto minmax(0, 1fr) 20px;
}

.site-footer {
  display: none;
  color: var(--muted);
  font-size: 12px;
  line-height: 20px;
  min-height: 20px;
  overflow: hidden;
  padding: 0 4px;
  text-align: center;
}

.workspace.quotes-open .site-footer {
  display: block;
}

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

.quotes-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-left: auto;
}

.quotes-search {
  max-width: 260px;
}

.refresh-data-button {
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #eef5ff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  padding: 0 12px;
  white-space: nowrap;
}

.refresh-data-button:disabled {
  cursor: wait;
  opacity: 0.75;
}

.quotes-head h2 {
  font-size: 18px;
}

.quotes-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.quotes-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.quotes-table th,
.quotes-table td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 11px 10px;
  line-height: 1.35;
  text-align: right;
  white-space: nowrap;
}

.quotes-table th:last-child,
.quotes-table td:last-child {
  border-right: 0;
}

.quotes-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-soft);
  color: var(--muted);
  font-weight: 600;
}

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

.quote-name-button {
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-align: left;
}

.quote-name-button:hover {
  text-decoration: underline;
}

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

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

.quote-cbl-long {
  color: var(--up);
  font-weight: 700;
}

.quote-cbl-short {
  color: #2563eb;
  font-weight: 700;
}

.quote-cbl-long,
.quote-cbl-short {
  display: inline-block;
  font-size: 15px;
  line-height: 1;
  vertical-align: -1px;
}

.quote-cbl-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 24px;
  height: 24px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  padding: 0 4px;
}

.quote-cbl-button:hover {
  background: #eef5ff;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .workspace {
    padding: 10px 10px 4px;
  }

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

  .quotes-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .quotes-search {
    max-width: none;
  }
}
