/* ============================================================
   公网质检看板 v2 — DESIGN_public_dashboard.md § 6 视觉规范
   Mobile-first (380px+), breakpoints at 768/1024px.
   ============================================================ */

:root {
  /* 中性色 */
  --bg: #ffffff;
  --bg-muted: #f9fafb;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04);

  /* 品牌色 */
  --accent: #1f5fa8;
  --accent-soft: #dbeafe;

  /* 状态色 */
  --ok: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --ok-soft: #d1fae5;
  --warn-soft: #fef3c7;
  --bad-soft: #fee2e2;
  --ok-text: #065f46;
  --warn-text: #92400e;
  --bad-text: #991b1b;

  /* shape_abnormal 紫色（DESIGN § 5.5 形状异常分类色） */
  --shape: #5b21b6;
  --shape-soft: #ede9fe;
}

/* HTML5 [hidden] 必须胜过任何 display 设置（已知的坑 #28） */
[hidden] { display: none !important; }

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { background: var(--bg); }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

button, select, input { font-family: inherit; }

/* ============================================================
   Status banner — 数据延迟时显示
   ============================================================ */
.status-banner {
  background: var(--bad);
  color: #fff;
  font-size: 13px;
  padding: 8px 16px;
  text-align: center;
  font-weight: 500;
}

/* ============================================================
   Header
   ============================================================ */
header {
  height: 56px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
header h1 { font-size: 16px; font-weight: 600; letter-spacing: 0.01em; }
header .spacer { flex: 1; }
header .me { font-size: 12px; color: var(--text-faint); }

/* ============================================================
   Filter bar — sticky + chip rows
   ============================================================ */
.filter-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
}
.filter-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.filter-control { display: flex; flex-direction: column; gap: 2px; }
.filter-label {
  font-size: 11px;
  color: var(--text-faint);
  margin-left: 2px;
}
.filter-select {
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  min-width: 100px;
}
.filter-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
.filter-reset {
  font-size: 12px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  margin-left: auto;
  align-self: flex-end;
}
.filter-reset:hover { background: var(--bg-muted); }

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  min-height: 0;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 500;
}
.filter-chip-x {
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0.6;
}
.filter-chip-x:hover { opacity: 1; }

/* ============================================================
   Main + cards
   ============================================================ */
main { padding: 12px; max-width: 1280px; margin: 0 auto; }

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 500;
}

/* ============================================================
   HERO 大数字
   ============================================================ */
.hero { text-align: center; padding: 32px 16px 28px; }
.hero .number {
  font-size: 64px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}
.hero .number.good { color: var(--ok); }
.hero .number.warn { color: var(--warn); }
.hero .number.bad { color: var(--bad); }
.hero .label { font-size: 16px; color: var(--text-muted); margin-top: 10px; }
.hero .sub { font-size: 13px; color: var(--text-faint); margin-top: 8px; }
.hero .status-line {
  font-size: 14px;
  margin-top: 16px;
  padding: 6px 14px;
  display: inline-block;
  border-radius: 6px;
  font-weight: 500;
}
.hero .status-line.good { background: var(--ok-soft); color: var(--ok-text); }
.hero .status-line.warn { background: var(--warn-soft); color: var(--warn-text); }
.hero .status-line.bad { background: var(--bad-soft); color: var(--bad-text); }
.hero .updated {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 14px;
}

/* ============================================================
   COMPARE
   ============================================================ */
.compare-rows { display: flex; flex-direction: column; }
.compare-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.compare-row:last-child { border-bottom: 0; }
.compare-row .name { color: var(--text-muted); font-size: 14px; }
.compare-row .value {
  font-size: 16px;
  font-weight: 600;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}
.compare-row .delta { font-size: 13px; min-width: 80px; text-align: right; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--text-faint); }

/* ============================================================
   TREND chart (inline SVG, no Chart.js dependency)
   ============================================================ */
.trend-chart svg { width: 100%; height: 200px; display: block; }
.trend-min-note {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 8px;
  text-align: right;
}

/* ============================================================
   PARETO horizontal bars
   ============================================================ */
.pareto-rows { display: flex; flex-direction: column; gap: 8px; }
.pareto-row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.pareto-name { color: var(--text-muted); }
.pareto-bar-wrap {
  background: var(--bg-muted);
  border-radius: 4px;
  height: 16px;
  overflow: hidden;
  position: relative;
}
.pareto-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.pareto-bar.shape { background: var(--shape); }
.pareto-bar.oversize { background: var(--bad); }
.pareto-bar.undersize { background: var(--warn); }
.pareto-bar.error { background: var(--text-faint); }
.pareto-count {
  font-size: 13px;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
}

/* ============================================================
   BREAKDOWN
   ============================================================ */
.breakdown-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 10px;
  padding: 10px 0;
  align-items: center;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.breakdown-row:last-child { border-bottom: 0; }
.breakdown-row .name { font-weight: 500; }
.breakdown-row .count { color: var(--text-muted); font-size: 13px; }
.breakdown-row .rate {
  font-weight: 600;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  min-width: 50px;
  text-align: right;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.dot.good { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.dot.empty { background: var(--text-faint); }

.empty-note {
  color: var(--text-faint);
  font-size: 13px;
  padding: 12px 0;
  text-align: center;
}

/* ============================================================
   RECENT NG grid — V1 灰底卡片（DESIGN § 5.7 + § 8.5 Phase 1.5）
   不显示 broken-image，看着像有意为之的简洁卡片
   ============================================================ */
.ng-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.ng-cell {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 10px;
  cursor: default;
  display: flex;
  flex-direction: column;
  gap: 4px;
  aspect-ratio: 1 / 1;
  justify-content: space-between;
}
.ng-cell .reason {
  display: inline-block;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 500;
  align-self: flex-start;
}
.reason.shape { background: var(--shape-soft); color: var(--shape); }
.reason.oversize { background: var(--bad-soft); color: var(--bad-text); }
.reason.undersize { background: var(--warn-soft); color: var(--warn-text); }
.reason.error { background: var(--bg-muted); color: var(--text-muted); border: 1px solid var(--border); }
.ng-cell .ng-time {
  color: var(--text-muted);
  font-size: 11px;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}
.ng-cell .ng-sku {
  color: var(--text-faint);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   Lightbox (used when has_full Phase 1.5+)
   ============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: pointer;
  padding: 20px;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  object-fit: contain;
}

/* ============================================================
   Footer
   ============================================================ */
footer {
  text-align: center;
  color: var(--text-faint);
  font-size: 11px;
  padding: 24px 16px 32px;
  line-height: 1.7;
}

/* ============================================================
   Responsive — DESIGN § 6.5
   ============================================================ */

/* tablet+ */
@media (min-width: 768px) {
  header { height: 64px; padding: 0 24px; }
  header h1 { font-size: 18px; }
  main { padding: 20px 24px 40px; }
  .card { padding: 24px; margin-bottom: 16px; }
  .hero { padding: 48px 24px 40px; }
  .hero .number { font-size: 72px; }

  .breakdown-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .breakdown-cols .card { margin-bottom: 0; }
  .breakdown-cols-wrap { margin-bottom: 16px; }

  .filter-bar { padding: 14px 24px; }
}

/* desktop */
@media (min-width: 1024px) {
  .hero .number { font-size: 80px; }
  .hero-compare {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 16px;
    align-items: stretch;
  }
  .hero-compare .card { margin-bottom: 0; }
  .hero-compare-wrap { margin-bottom: 16px; }
  .ng-grid { grid-template-columns: repeat(6, 1fr); }
  .trend-chart svg { height: 280px; }
  .pareto-row { grid-template-columns: 120px 1fr auto; }
}

/* Print stylesheet — Phase 6 enhancement, just baseline for V1 */
@media print {
  .filter-bar, .status-banner, footer { display: none !important; }
  body { background: white; }
  .card { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
}
