:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #d9e1ea;
  --text: #172033;
  --muted: #68758a;
  --blue: #2868c7;
  --blue-soft: #e8f0ff;
  --green: #15845b;
  --green-soft: #e6f6ef;
  --red: #c43d4b;
  --red-soft: #fdecef;
  --amber: #a76a11;
  --amber-soft: #fff4db;
  --shadow: 0 8px 28px rgba(28, 39, 59, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

button,
input,
textarea,
select {
  font: inherit;
}

button,
a.solid-link {
  border: 0;
  cursor: pointer;
}

.app {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 251, 0.94);
  backdrop-filter: blur(12px);
}

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

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

h2 {
  font-size: 15px;
}

.market-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.top-actions,
.row-actions,
.curve-footer,
.data-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.mini-button,
.solid-button,
.ghost-button,
.solid-link,
.data-file {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
}

.icon-button,
.solid-button,
.solid-link {
  padding: 0 13px;
  background: var(--blue);
  color: #fff;
}

.icon-button.subtle,
.ghost-button {
  background: #eef3f8;
  color: var(--text);
}

.icon-button.primary {
  background: #1f6f63;
}

.icon-button.notice-on {
  background: #fff4db;
  color: #6e4b0e;
}

.mini-button {
  width: 32px;
  height: 32px;
  min-height: 32px;
  background: #eef3f8;
  color: var(--text);
}

.ghost-button {
  padding: 0 12px;
  border: 1px solid var(--line);
}

.data-actions {
  flex-wrap: wrap;
  margin-top: 8px;
}

.data-actions > * {
  flex: 1 1 120px;
}

.data-file {
  position: relative;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #eef3f8;
  color: var(--text);
  overflow: hidden;
}

.data-file input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.data-status {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.panel-separator {
  height: 1px;
  margin: 12px 0;
  background: #e8edf3;
}

.cloud-sync {
  display: grid;
  gap: 8px;
}

.cloud-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.cloud-fields,
.cloud-auth-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cloud-auth-actions > * {
  min-width: 0;
  width: 100%;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.check-row input {
  width: 16px;
  height: 16px;
  padding: 0;
}

svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

main {
  padding: 22px 28px 36px;
  max-width: 1720px;
  margin: 0 auto;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric,
.panel,
.image-output {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric {
  padding: 14px 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  line-height: 1.25;
}

.grid {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr) minmax(280px, 320px);
  gap: 16px;
  align-items: start;
}

.dashboard-column {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
}

.panel {
  min-width: 0;
  padding: 14px;
}

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

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.query-panel,
.holding-panel {
  position: relative;
}

.suggestions {
  position: absolute;
  z-index: 6;
  left: 14px;
  right: 72px;
  top: 86px;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.suggestion-item {
  display: block;
  width: 100%;
  min-height: 42px;
  padding: 7px 10px;
  border: 0;
  border-bottom: 1px solid #edf2f7;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.suggestion-item:hover {
  background: var(--blue-soft);
}

.suggestion-item small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.holding-suggestions {
  left: 14px;
  right: 14px;
  top: 106px;
}

input,
textarea,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input,
select {
  height: 38px;
  padding: 0 11px;
}

textarea {
  resize: vertical;
  padding: 10px 11px;
  line-height: 1.45;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #7ba5e7;
  box-shadow: 0 0 0 3px rgba(40, 104, 199, 0.12);
}

.single-result {
  margin-top: 12px;
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.single-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.single-title strong {
  display: block;
  font-size: 17px;
}

.single-title small {
  color: var(--muted);
}

.quote-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.quote-cell {
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  border: 1px solid #e6edf5;
}

.quote-cell span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.quote-cell b {
  display: block;
  margin-top: 4px;
  font-size: 17px;
}

.holding-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(110px, 0.45fr) minmax(110px, 0.45fr) auto;
  gap: 8px;
  margin-bottom: 10px;
}

.threshold-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 10px;
}

.import-grid {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.upload-box {
  display: flex;
  min-height: 112px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  border: 1px dashed #9fb2c9;
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--muted);
  cursor: pointer;
}

.upload-box input {
  display: none;
}

.upload-box svg {
  width: 24px;
  height: 24px;
}

#importPreview {
  display: block;
  width: 100%;
  min-height: 112px;
  max-height: 210px;
  object-fit: contain;
  border: 1px solid #e6edf5;
  border-radius: 8px;
  background: #fbfcfe;
}

.ocr-status {
  min-height: 24px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

#importText {
  margin-bottom: 8px;
}

.import-panel table {
  min-width: 560px;
}

.import-panel input[type="checkbox"] {
  width: 16px;
  height: 16px;
  padding: 0;
}

.import-panel .row-input {
  height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 540px;
}

th,
td {
  padding: 9px 8px;
  border-bottom: 1px solid #e8edf3;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.sort-head {
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}

.sort-head.active {
  color: var(--blue);
}

td small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

canvas {
  display: block;
  width: 100%;
  height: var(--chart-height, 220px);
  border-radius: 8px;
  background: #fbfcfe;
  border: 1px solid #e6edf5;
}

.compare-panel canvas {
  --chart-height: 180px;
  margin: 10px 0;
}

.curve-footer {
  justify-content: space-between;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.curve-panel {
  position: relative;
}

.curve-panel canvas {
  --chart-height: 230px;
  margin-top: 4px;
}

.curve-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.curve-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  max-width: 100%;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.curve-chip.active {
  border-color: #7ba5e7;
  background: var(--blue-soft);
  color: #17437e;
}

.curve-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
}

.curve-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.curve-tooltip {
  position: absolute;
  z-index: 4;
  max-width: 230px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  pointer-events: none;
  font-size: 12px;
}

.curve-tooltip strong,
.curve-tooltip span,
.curve-tooltip b {
  display: block;
}

.curve-tooltip span {
  margin-top: 2px;
  color: var(--muted);
}

.curve-tooltip b {
  margin-top: 4px;
  font-size: 15px;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #eef3f8;
  color: var(--muted);
}

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

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

.flat {
  color: var(--muted);
}

.alert-list {
  display: grid;
  gap: 8px;
  min-height: 160px;
}

.notice-status {
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid #d7e5d9;
  border-radius: 8px;
  background: #f4faf5;
  color: #24613c;
  font-size: 13px;
}

.notice-status.warn {
  border-color: #f1d8a8;
  background: var(--amber-soft);
  color: #6e4b0e;
}

.notice-status.blocked {
  border-color: #f0c3c9;
  background: var(--red-soft);
  color: #8b2633;
}

.alert-item {
  border: 1px solid #f1d8a8;
  border-radius: 8px;
  padding: 10px;
  background: var(--amber-soft);
  color: #5d3b05;
  font-size: 13px;
}

.alert-item strong {
  display: block;
  margin-bottom: 3px;
}

.alert-item small {
  color: #7b5615;
}

.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
}

pre {
  min-height: 180px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid #e6edf5;
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.55;
}

.image-output {
  margin-top: 14px;
  padding: 14px;
}

.image-output img {
  display: block;
  width: 100%;
  max-width: 920px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: #17437e;
  font-size: 12px;
}

.row-danger {
  background: rgba(196, 61, 75, 0.05);
}

.row-good {
  background: rgba(21, 132, 91, 0.05);
}

@media (min-width: 1500px) {
  main {
    padding-left: 36px;
    padding-right: 36px;
    max-width: 1560px;
  }

  .topbar {
    padding-left: 36px;
    padding-right: 36px;
  }

  .metrics {
    grid-template-columns: repeat(4, minmax(190px, 1fr));
    gap: 16px;
  }

  .grid {
    grid-template-columns: minmax(320px, 360px) minmax(0, 1fr) minmax(300px, 340px);
    gap: 16px;
  }

  .holding-form {
    grid-template-columns: minmax(260px, 1fr) minmax(130px, 0.4fr) minmax(130px, 0.4fr) auto;
  }
}

@media (max-width: 1160px) {
  .grid {
    grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
  }

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

@media (max-width: 820px) {
  .topbar,
  main {
    padding-left: 14px;
    padding-right: 14px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

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

  .aside-column {
    grid-column: auto;
    grid-template-columns: 1fr;
  }

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

  .holding-form button {
    grid-column: span 2;
  }

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

  .threshold-form button {
    grid-column: span 2;
  }

  .cloud-fields,
  .cloud-auth-actions {
    grid-template-columns: 1fr;
  }

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

  .metric strong {
    font-size: 19px;
  }
}
