body {
  background-image: linear-gradient(rgba(7, 12, 20, .72), rgba(7, 12, 20, .78)), url('/assets/neon-ocean-bg.webp');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

@media (max-width: 620px) {
  body { overflow-x: hidden; }
  .app-shell { display: block; min-height: 100vh; }

  .sidebar {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    max-height: 48vh;
    padding: 12px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    overflow: hidden;
  }
  .brand { display: flex; padding: 0 4px 12px; }
  .brand-mark { width: 32px; height: 32px; font-size: 16px; }
  .brand div { display: block; }
  .brand strong { font-size: 17px; }
  .brand small { font-size: 9px; }
  .sidebar nav { display: block; width: 100%; max-height: calc(48vh - 58px); overflow-y: auto; }
  .nav-label { display: block; margin: 12px 8px 6px; font-size: 11px; }
  .nav-item { justify-content: flex-start; min-height: 44px; padding: 10px 12px; font-size: 15px; }
  .nav-item em { display: block; }
  .nav-item b { position: static; margin: 0; padding: 2px 8px; font-size: 12px; }
  .strategy-nav { min-height: 44px; padding: 9px 12px; font-size: 15px; }
  .strategy-nav em, .strategy-toggle { display: block; }
  .strategy-children { margin-left: 8px; padding-left: 4px; }
  .date-sublist { display: grid; max-height: none; margin-left: 26px; overflow: visible; }
  .date-heading { min-height: 38px; font-size: 16px; }
  .date-item { min-height: 34px; font-size: 13px; }
  .side-note { display: none; }

  main { width: 100%; max-width: none; padding: 18px 12px 28px; }
  main > header { align-items: flex-start; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
  h1 { font-size: 25px; }
  .header-actions { width: 100%; flex-wrap: wrap; }
  .header-actions button { flex: 1 1 auto; min-width: 0; }
  .status-card { padding: 14px; gap: 10px; }
  .status-copy { min-width: 0; }
  .status-copy strong, .status-copy small { overflow-wrap: anywhere; }
  .progress-wrap { width: 100%; }
  .metric-grid { grid-template-columns: 1fr; gap: 10px; }
  .overview-layout { grid-template-columns: 1fr; gap: 12px; }
  .overview-tools { order: 2; }
  .time-card, .calendar-card { padding: 16px; }
  .time-card strong { font-size: 32px; }
  .calendar-day { min-height: 38px; }
  .metric-grid .metric:last-child { grid-column: auto; }
  .metric { padding: 16px; }
  .metric strong { font-size: 32px; }

  .energy-head { align-items: flex-start; flex-wrap: wrap; padding: 15px; }
  .energy-head-actions { width: 100%; margin-left: 20px; justify-content: space-between; }
  .energy-facts { padding: 10px 14px 4px; }
  .energy-fact { grid-template-columns: 30px minmax(0, 1fr); gap: 9px; padding: 7px 0; }
  .energy-fact i { width: 28px; height: 28px; }
  .energy-fact span { min-width: 0; font-size: 14px; }
  .energy-fact strong { grid-column: 2; margin: 0; font-size: 18px; overflow-wrap: anywhere; }
  .energy-fact.previous span small { display: block; margin: 3px 0 0; }
  .risk-notice { padding: 24px 8px 0; font-size: 13px; line-height: 1.7; }

  body:has(.view.list-panel.active) { overflow: auto; }
  body:has(.view.list-panel.active) main { height: auto; overflow: visible; }
  .list-panel { height: auto; min-height: 60vh; }
  .table-tools { align-items: stretch; flex-direction: column; gap: 14px; padding: 16px; }
  .table-tools h2 { font-size: 19px; overflow-wrap: anywhere; }
  .list-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .list-actions input { grid-column: 1 / -1; width: 100%; }
  .list-actions button { width: 100%; padding-inline: 8px; }
  .table-wrap {
    height: min(65dvh, 640px);
    min-height: 320px;
    overflow: auto;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: auto;
    touch-action: pan-x pan-y;
    -webkit-overflow-scrolling: touch;
  }
  .signal-table { min-width: 880px; }
  .signal-table th, .signal-table td { padding-left: 10px; padding-right: 10px; font-size: 13px; }
  .signal-table th:first-child, .signal-table td:first-child { padding-left: 14px; }

  .stock-modal { display: block; padding: 0; }
  .stock-dialog { width: 100%; height: 100dvh; max-height: none; border: 0; border-radius: 0; overflow: auto; }
  .dialog-head { position: sticky; top: 0; z-index: 8; align-items: flex-start; flex-direction: column; gap: 12px; padding: 14px; background: #222a33; cursor: default; }
  .dialog-head h2 { font-size: 21px; }
  .detail-nav { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 42px; }
  .detail-nav > button:not(.close-dialog) { height: 40px; padding: 0 5px; }
  .close-dialog { width: 42px; height: 40px; }
  .chart-tabs { padding: 12px 10px 0; overflow-x: auto; }
  .chart-tab { flex: 1; min-width: 120px; }
  .chart-stage { height: 360px; margin: 8px 4px 0; overflow: hidden; }
  .daily-controls { grid-template-columns: 1fr; gap: 10px; padding: 8px 12px 0; }
  .chart-legend { padding: 12px; gap: 8px 12px; font-size: 12px; }
  .crosshair-tip { max-width: calc(100vw - 24px); font-size: 12px; }
  .crosshair-tip b { font-size: 13px; }

  .login-dialog { width: calc(100vw - 24px); padding: 20px; }
}

/* 窄屏保留月份和日期目录，但不显示冗余的“买入候选”层级。 */
@media (max-width: 900px) {
  .strategy-children { display: block; }
  .candidate-nav { display: none !important; }
  .date-sublist { display: grid !important; }
}

/* Prevent scan status text from expanding or overflowing its card at any width. */
.status-card{min-width:0;overflow:hidden}
.status-copy{min-width:0;overflow:hidden}
.status-copy strong,.status-copy small{display:-webkit-box;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:normal;-webkit-box-orient:vertical}
.status-copy strong{-webkit-line-clamp:2;line-height:1.25}
.status-copy small{-webkit-line-clamp:2;line-height:1.35}
.status-copy .next-task{display:inline;white-space:nowrap}
.progress-wrap{min-width:0;max-width:100%}
@media (max-width:620px){
  .status-card{display:grid;grid-template-columns:auto minmax(0,1fr);align-items:center}
  .progress-wrap{grid-column:1 / -1;width:100%}
}

@media (max-width:900px){
  .overview-layout,.overview-main,.overview-tools,.metric-grid,.market-energy,.index-chart{width:100%;min-width:0;max-width:100%}
  .metric-grid{grid-template-columns:minmax(0,1fr)}
  .status-card{width:100%;min-width:0;max-width:100%;overflow:hidden}
  .status-copy{min-width:0;max-width:100%;overflow:hidden}
  .status-copy strong,.status-copy small{display:-webkit-box;max-width:100%;white-space:normal;overflow:hidden;text-overflow:ellipsis;-webkit-box-orient:vertical}
  .index-chart-stage{width:100%;max-width:100%;overflow:hidden}
  .index-chart-stage canvas{width:100%;max-width:100%}
  .index-chart-controls{flex-wrap:wrap;gap:10px;padding-inline:12px}
  .index-chart-controls label{min-width:0;flex:1 1 100%}
  .risk-notice{width:100%;max-width:100%;overflow:hidden;text-align:center}
}
