/*!
 * 和弈 market/analysis 仿站前端样式
 * 视觉对齐目标站：白卡片圆角20、灰底 #f4f6f8、胶囊 Tab、深色选中态
 */
:root {
  --bg: #f4f6f8;
  --card: #fff;
  --text: #1e1e1e;
  --text-2: #202a39b2;
  --text-3: #4e5969;
  --border: rgba(30, 30, 30, 0.12);
  --primary: #2f6bff;
  --primary-soft: rgba(47, 107, 255, 0.10);
  --sidebar: #ffffff;
  --sidebar-w: 248px;
  --header-h: 56px;
  --radius-card: 20px;
  --tab-bg: #ededed;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-card: 0 1px 3px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.04);
  --shadow-hover: 0 4px 10px rgba(16, 24, 40, 0.06), 0 18px 44px rgba(16, 24, 40, 0.08);
  --ring: 0 0 0 3px rgba(47, 107, 255, 0.16);
  --grad-primary: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-width: 1200px;
  height: 100%;
  background:
    radial-gradient(1200px 560px at 100% -12%, rgba(47, 107, 255, 0.05), transparent 55%),
    var(--bg);
  color: var(--text);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }

/* ========== Shell ========== */
.app {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  color: #334155;
  flex: none;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
  border-right: 1px solid #e8edf3;
  box-shadow: 1px 0 0 rgba(15, 23, 42, 0.02);
}
.logo {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 14px 12px 14px 16px;
  border-bottom: 1px solid #eef2f6;
  background: #fff;
}
.logo img {
  display: none;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #38bdf8 0%, #2563eb 55%, #1d4ed8 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.5px;
  flex: none;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.22);
}
.brand-mark-text { line-height: 1; }
.brand-text { line-height: 1.2; min-width: 0; flex: 1; }
.brand-name {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: 0.5px;
}
.brand-sub {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-collapse {
  width: 28px;
  height: 28px;
  border: 1px solid #e5eaf0;
  background: #f8fafc;
  border-radius: 8px;
  color: #64748b;
  cursor: pointer;
  flex: none;
  line-height: 1;
}
.sidebar-collapse:hover {
  background: #eef2ff;
  color: var(--primary);
}
.app.sidebar-collapsed {
  --sidebar-w: 72px;
}
.app.sidebar-collapsed .brand-text,
.app.sidebar-collapsed .menu-group-label,
.app.sidebar-collapsed .menu-item span:not(.ico),
.app.sidebar-collapsed .menu-caret {
  display: none;
}
.app.sidebar-collapsed .menu-item {
  padding: 10px;
  justify-content: center;
}
.app.sidebar-collapsed .menu-group-title {
  justify-content: center;
  padding: 10px;
}
.app.sidebar-collapsed .menu-children {
  display: none !important;
}
.app.sidebar-collapsed .logo {
  justify-content: center;
  padding: 14px 8px;
}
.app.sidebar-collapsed .sidebar-collapse {
  display: none;
}
.menu {
  padding: 10px 10px 20px;
  overflow: auto;
  flex: 1;
}
.menu-group {
  margin-bottom: 4px;
}
.menu-group-title {
  font-size: 13px;
  color: #334155;
  padding: 10px 12px;
  letter-spacing: 0;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  transition: background .15s, color .15s;
}
.menu-group-title:hover {
  background: #f5f8fc;
  color: #0f172a;
}
.menu-group.open > .menu-group-title {
  color: #0f172a;
}
.menu-group-ico {
  width: 18px;
  color: #64748b;
  text-align: center;
  flex: none;
}
.menu-group-label {
  flex: 1;
  min-width: 0;
}
.menu-caret {
  margin-left: auto;
  color: #94a3b8;
  font-size: 12px;
  width: 16px;
  text-align: center;
  transition: transform .18s ease;
  transform: rotate(-90deg);
  flex: none;
}
.menu-group.open > .menu-group-title .menu-caret {
  transform: rotate(0deg);
  color: #64748b;
}
.menu-children {
  display: none;
  padding: 2px 0 6px;
}
.menu-group.open > .menu-children {
  display: block;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 40px;
  border-radius: 10px;
  color: #64748b;
  cursor: pointer;
  user-select: none;
  transition: background .15s, color .15s;
  margin: 1px 0;
  font-size: 13px;
  line-height: 1.35;
}
.menu-item:hover {
  background: #f5f8fc;
  color: #0f172a;
}
.menu-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--primary);
}
.menu-item.static {
  cursor: default;
  color: #64748b;
}
.menu-item.static:hover {
  background: transparent;
  color: #64748b;
}
.menu-item .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}
.menu-item .ico {
  width: 16px;
  text-align: center;
  opacity: 0.85;
  font-size: 12px;
  color: inherit;
  flex: none;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid #e8ebf0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-3);
}
.crumb-sep { color: #c0c4cc; }
.crumb-cur { color: var(--text); font-weight: 600; }
.badge {
  background: #eaf1ff;
  color: var(--primary);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-3);
}
.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f6f7fb;
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
  cursor: pointer;
  transition: background .15s;
}
.user-pill:hover { background: #eef2ff; }
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c5cff, #3d8bfd);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}

.content {
  padding: 16px 20px 28px;
}

/* ========== Data analysis page ========== */
.data-analysis { position: relative; }
.button-area {
  text-align: right;
  position: relative;
  top: -4px;
  margin-bottom: 4px;
}
.btn {
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #f8f9fb; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-icon {
  width: 42px;
  height: 32px;
  padding: 0;
}
.btn-dark {
  background: linear-gradient(135deg, #2b2f3a 0%, #161b24 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.14);
}
.btn-dark:hover { background: linear-gradient(135deg, #343a47 0%, #1d232e 100%); }

.card {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 20px;
  margin-bottom: 15px;
  border: 1px solid rgba(16, 24, 40, 0.04);
  box-shadow: var(--shadow-card);
  transition: box-shadow .25s ease, transform .25s ease, border-color .25s ease;
}
.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
  border-color: rgba(47, 107, 255, 0.12);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 36px;
}
.title {
  display: flex;
  align-items: center;
  margin: 0;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}
.title-icon {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 12px;
  flex: none;
}
.title-icon.price { background: linear-gradient(135deg, #ff6b6b, #f06595); }
.title-icon.weather { background: linear-gradient(135deg, #4dabf7, #748ffc); }
.title-icon.supply { background: linear-gradient(135deg, #51cf66, #20c997); }

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-wrap: wrap;
}

.line {
  height: 16px;
  width: 1px;
  background: #e5e6eb;
  margin: 0 2px;
}

/* Capsule tabs (hy-tabs) */
.hy-tabs {
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 10px;
  background: var(--tab-bg);
}
.hy-tabs__item {
  min-width: 60px;
  height: 28px;
  line-height: 28px;
  text-align: center;
  border-radius: 23px;
  cursor: pointer;
  color: #1e1e1e;
  padding: 0 10px;
  white-space: nowrap;
  user-select: none;
  font-size: 12px;
}
.hy-tabs__item.selected {
  background: linear-gradient(135deg, #232a36 0%, #161b24 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.16);
}

.date-input {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  background: #fff;
  outline: none;
  width: 140px;
}
.date-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.15); outline: none; }
.date-range {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
}
.date-range span { color: var(--text-3); }

.node-select {
  min-width: 220px;
  max-width: 360px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
  appearance: auto;
}
.node-select.multi {
  height: auto;
  min-height: 36px;
  max-height: 96px;
  padding: 4px 6px;
}

.chart-box {
  width: 100%;
  height: 360px;
}
.chart-box.sm { height: 320px; }
.chart-box.lg { height: 400px; }

/* 卡片内图表区：loading/empty 仅叠在 chart 卡片上 */
.card {
  position: relative;
}
.card > .loading,
.card > .empty {
  position: absolute;
  left: 20px;
  right: 20px;
  top: 72px;
  height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  gap: 8px;
  background: rgba(255, 255, 255, 0.72);
  z-index: 2;
  border-radius: 12px;
  pointer-events: none;
}
.card > .chart-box.lg ~ .loading,
.card > .chart-box.lg ~ .empty {
  height: 400px;
}

.stats-card {
  overflow: visible;
}
.stats-card .metric .v {
  color: var(--text);
  min-height: 28px;
}
.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid #e5e6eb;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.copyright-notice {
  text-align: right;
  margin: 10px 0 0;
  color: var(--text-2);
  font-size: 12px;
}
.copyright-notice b { color: #202a39; }

.source-note {
  margin: 10px 0 0;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.6;
}

.login-tip {
  margin: 0 0 12px;
  height: 40px;
  display: flex;
  align-items: center;
  padding: 9px 16px;
  border-radius: 6px;
  background: #fffbe6;
  color: #25282eb2;
  gap: 10px;
}
.login-tip .accent { color: #f79e2b; }
.login-tip .link { color: var(--primary); cursor: pointer; }

/* Full screen panoramic */
.data-analysis.full-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  padding: 60px 20px 20px;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.data-analysis.full-screen .card {
  height: calc(33.3vh - 30px);
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
}
.data-analysis.full-screen .chart-box {
  flex: 1;
  height: auto !important;
  min-height: 0;
}
.data-analysis.full-screen .button-area {
  position: absolute;
  top: 14px;
  right: 20px;
}

.footer-meta {
  color: var(--text-2);
  font-size: 12px;
  padding: 4px 4px 0;
  display: flex;
  justify-content: space-between;
}

/* Predict panel (local algorithm entry) */
.predict-panel {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
}
.predict-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.field label {
  display: block;
  color: var(--text-3);
  margin-bottom: 6px;
  font-size: 12px;
}
.field select, .field input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field select:focus, .field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.15);
  outline: none;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.metric {
  background: linear-gradient(180deg, #fbfcfe 0%, #f3f5fa 100%);
  border: 1px solid rgba(16, 24, 40, 0.03);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
}
.metric .k { color: var(--text-2); font-size: 12px; }
.metric .v { font-size: 20px; font-weight: 700; margin-top: 4px; }
.metric .v.good { color: #16b179; }
.metric .v.warn { color: #f79e2b; }
.metric .u {
  color: var(--text-2);
  font-size: 11px;
  margin-top: 2px;
}
.pred-badges { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.pred-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 14px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  transition: all 0.2s ease;
}
.pred-badge.info { 
  background: linear-gradient(135deg, #e6f2ff 0%, #f0f8ff 100%); 
  color: #2d8cf0; 
  border: 1px solid #d4e6ff;
}
.pred-badge.warn { 
  background: linear-gradient(135deg, #fef9f0 0%, #fefae0 100%); 
  color: #d98d2d; 
  border: 1px solid #ffdeca;
}
.pred-badge.danger { 
  background: linear-gradient(135deg, #ffe5e5 0%, #ffcccc 100%); 
  color: #f44336; 
  border: 1px solid #ffb3b3;
}
.pred-badge.ok { 
  background: linear-gradient(135deg, #e6ffea 0%, #c8f8e0 100%); 
  color: #16b179; 
  border: 1px solid #c1f2d2;
}

.history-metrics {
  grid-template-columns: repeat(6, 1fr);
  margin-bottom: 4px;
}
.history-card .source-note {
  margin-top: 8px;
}
@media (max-width: 1400px) {
  .history-metrics {
    grid-template-columns: repeat(3, 1fr);
  }
}

.sidebar-foot {
  padding: 12px 16px 18px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 11px;
  color: #6b7485;
}
.server-status {
  color: #9aa4b2;
  margin-bottom: 4px;
}
.server-status.ok { color: #3ecf8e; }
.server-status.bad { color: #ff7b7b; }
.sidebar-hint { opacity: 0.8; }

.stats-card .metrics { margin-bottom: 0; }

.form-help {
  color: #86909c;
  font-size: 12px;
  line-height: 1.6;
  margin: 10px 0 0;
}
.hint {
  color: #86909c;
  font-size: 11px;
  font-weight: 400;
}
.field .hint { margin-left: 6px; }

.compare-wrap {
  margin-top: 16px;
  background: #f8f9fc;
  border-radius: 14px;
  padding: 12px 14px 8px;
}
.compare-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.compare-head h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}
.table-scroll {
  overflow: auto;
  max-height: 320px;
}
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
}
.compare-table th,
.compare-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #eef0f4;
  text-align: left;
  white-space: nowrap;
}
.compare-table th {
  background: #f3f5f9;
  color: #4e5969;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}
.compare-table tr.best {
  background: #f0ebff;
}
.compare-table tr:hover { background: #fafbff; }
.compare-table .muted {
  color: #86909c;
  text-align: center;
  padding: 18px;
}
.compare-table .num { font-variant-numeric: tabular-nums; font-weight: 600; }
.compare-table .btn-mini {
  height: 26px;
  padding: 0 8px;
  font-size: 11px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}
.compare-table .btn-mini:hover { background: #f6f7fb; }
.compare-table th.sortable {
  cursor: pointer;
  user-select: none;
}
.compare-table th.sortable:hover { color: var(--primary); }
.compare-table th.sorted { color: var(--primary); }
.compare-table tr.active-model {
  box-shadow: inset 3px 0 0 var(--primary);
}
.compare-table tr.best td:first-child {
  font-weight: 700;
  color: var(--primary);
}

.pred-status {
  font-size: 12px;
  color: #86909c;
  background: #f6f7fb;
  border-radius: 999px;
  padding: 4px 12px;
}
.pred-status.busy {
  color: #7046e5;
  background: #f0ebff;
}
.pred-status.ok {
  color: #16b179;
  background: #eafaf3;
}
.pred-status.err {
  color: #e5484d;
  background: #fff1f1;
}

.chip-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.chip {
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-3);
  cursor: pointer;
  font-size: 12px;
}
.chip:hover { background: #f8f9fb; }
.chip.active {
  background: linear-gradient(135deg, #232a36 0%, #161b24 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.16);
}
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--text-3);
  font-size: 12px;
  user-select: none;
}
.check-row input { accent-color: var(--primary); }

.app-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2000;
  min-width: 140px;
  max-width: 320px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #0f172a;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.2);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.app-toast.show {
  opacity: 1;
  transform: translateY(0);
}
.app-toast.ok { background: #0f766e; }
.app-toast.err { background: #b42318; }

.hidden { display: none !important; }
