/* SQM Quality Dashboard — Apple Design Language（明亮、現代、有質感） */

:root {
  --ink:        #1D1D1F;
  --ink-2:      #424245;
  --ink-3:      #86868B;
  --ink-4:      #B0B0B6;
  --bg:         #FAFAFA;
  --card:       #FFFFFF;
  --border:     #E5E5EA;
  --border-2:   #D2D2D7;

  --accent:     #1D3557;
  --accent-soft:#E0E7FF;
  --accent-2:   #2563EB;

  --series-pcb:    #FF9500;
  --series-ee:     #007AFF;
  --series-me:     #AF52DE;
  --series-total:  #1D1D1F;
  --series-target: #FF3B30;
  --series-bar:    #F2F2F7;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-table: 0 1px 3px rgba(0,0,0,0.05), 0 0 0 1px rgba(0,0,0,0.02);
}

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

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ========== Header ========== */
.report-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.report-header-inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: 22px 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.brand-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 14px;
  color: var(--ink-2);
  margin-top: 4px;
}
.report-meta { display: flex; gap: 36px; }
.meta-row { font-size: 12px; color: var(--ink-2); }
.meta-row span {
  display: block;
  margin-bottom: 3px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.meta-row b { font-size: 15px; color: var(--ink); font-weight: 600; }

/* ========== Main ========== */
.report-main {
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px 36px 60px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ========== Downloads bar ========== */
.downloads-bar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px;
  box-shadow: var(--shadow-sm);
}
.downloads-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.downloads-title svg { color: var(--accent-2); flex-shrink: 0; }
.downloads-meta {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  margin-left: auto;
  letter-spacing: 0.02em;
}
.downloads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.download-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  text-decoration: none;
  color: var(--ink);
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
}
.download-card:hover {
  border-color: var(--accent-2);
  background: rgba(37, 99, 235, 0.04);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.12);
}
.download-card-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: linear-gradient(135deg, #1F7A4D, #34A853);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.04em;
}
.download-card-body {
  flex: 1;
  min-width: 0;
}
.download-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
}
.download-card-meta {
  font-size: 11.5px;
  color: var(--ink-3);
  font-feature-settings: 'tnum';
}
.download-card-arrow {
  color: var(--ink-3);
  transition: transform 200ms, color 200ms;
}
.download-card:hover .download-card-arrow {
  color: var(--accent-2);
  transform: translateX(2px);
}

/* ========== KPI Block (section + 旁邊的複製按鈕欄) ========== */
.kpi-block {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.kpi-block > .kpi-section { flex: 1; min-width: 0; }

.kpi-aside {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}

/* ========== Copy Button (Apple-style pill) ========== */
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  background: rgba(37, 99, 235, 0.08);
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: 999px;          /* pill */
  cursor: pointer;
  transition: all 220ms cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  white-space: nowrap;
}
.copy-btn:hover {
  background: var(--accent-2);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.32),
              0 2px 6px rgba(37, 99, 235, 0.18);
}
.copy-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2);
}
.copy-btn .copy-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  stroke-width: 2.2;
}

/* ========== KPI Section ========== */
.kpi-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 26px 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 200ms;
}
.kpi-section:hover { box-shadow: var(--shadow-md); }

.kpi-row {
  display: flex;
  align-items: stretch;
  gap: 14px;
}

/* 縱向標題 */
.kpi-title {
  flex: 0 0 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-weight: 700;
  text-align: center;
  padding: 8px;
  user-select: none;
}
.kpi-title .line-1, .kpi-title .line-2 {
  font-size: 30px;
  letter-spacing: 0.01em;
  line-height: 1.1;
}
.kpi-title .line-2 { margin-top: 4px; }
.kpi-title-sm .line-1, .kpi-title-sm .line-2 { font-size: 22px; }

.kpi-chart-wrap {
  flex: 1;
  position: relative;
  min-height: 380px;
}
.kpi-section-compact .kpi-chart-wrap { min-height: 260px; }
.kpi-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ========== Data Table（升級版：圓角、陰影、Total 強調、hover） ========== */
.kpi-table-wrap {
  margin-top: 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-table);
}
.kpi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-feature-settings: 'tnum';
}

/* 表頭 */
.kpi-table thead th {
  background: linear-gradient(180deg, #FAFAFA 0%, #F5F5F7 100%);
  border-bottom: 1px solid var(--border-2);
  padding: 12px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 0.05em;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}
.kpi-table thead th:first-child {
  text-align: left;
  padding-left: 20px;
  width: 250px;
}

/* 表身 */
.kpi-table tbody th {
  background: var(--card);
  text-align: left;
  font-weight: 500;
  color: var(--ink);
  font-size: 14px;
  padding: 12px 14px 12px 20px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: relative;
}
.kpi-table tbody td {
  padding: 12px 14px;
  text-align: center;
  font-weight: 500;
  color: var(--ink);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  transition: background 120ms;
}
.kpi-table tbody tr:last-child th,
.kpi-table tbody tr:last-child td {
  border-bottom: 0;
}

/* hover row */
.kpi-table tbody tr:hover th,
.kpi-table tbody tr:hover td {
  background: rgba(0, 122, 255, 0.04);
}

/* Total 列強調 */
.kpi-table tbody tr.row-total th,
.kpi-table tbody tr.row-total td {
  background: rgba(29, 29, 31, 0.025);
  font-weight: 700;
  color: var(--ink);
  font-size: 14.5px;
}
.kpi-table tbody tr.row-total:hover th,
.kpi-table tbody tr.row-total:hover td {
  background: rgba(29, 29, 31, 0.05);
}

/* 「重點週」高亮：柔色填底 + 上下實線 accent，無虛線 */
.kpi-table thead th.current,
.kpi-table tbody td.current {
  background: rgba(37, 99, 235, 0.075);
  color: var(--accent-2);
  font-weight: 700;
}
.kpi-table thead th.current {
  border-top: 3px solid var(--accent-2);
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.18), rgba(37, 99, 235, 0.08));
}
.kpi-table tbody tr:last-child td.current {
  border-bottom: 3px solid var(--accent-2);
}
.kpi-table tbody tr:hover td.current,
.kpi-table tbody tr.row-total td.current {
  background: rgba(37, 99, 235, 0.12);
}
.kpi-table tbody tr.row-total td.current {
  background: rgba(37, 99, 235, 0.13);
}

/* Legend icons (data table 第一欄) */
.lg {
  display: inline-flex;
  align-items: center;
  width: 26px;
  height: 14px;
  margin-right: 10px;
  vertical-align: middle;
  position: relative;
}
.lg-bar {
  background: var(--series-bar);
  width: 22px; height: 14px;
  border: 1px solid var(--border-2);
  border-radius: 3px;
}
.lg-line {
  height: 2.5px;
  width: 30px;
  position: relative;
}
.lg-line::after {
  content: '';
  position: absolute;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: currentColor;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
}
.lg-line.line-pcb    { background: var(--series-pcb);    color: var(--series-pcb); }
.lg-line.line-ee     { background: var(--series-ee);     color: var(--series-ee); }
.lg-line.line-me     { background: var(--series-me);     color: var(--series-me); }
.lg-line.line-total  { background: var(--series-total);  color: var(--series-total); height: 4px; }
.lg-line.line-target { background: var(--series-target); color: var(--series-target); height: 2.5px; }
.lg-line.line-target::after { background: var(--card); border: 2px solid var(--series-target); }

/* SQMClarifyNCM / MRB cofirm time 沒有資料表，給 chart 多留下方空間 */
#sec-sqm-clarify .kpi-chart-wrap,
#sec-mrb-confirm-time .kpi-chart-wrap {
  min-height: 320px;
}
#sec-mrb-confirm-time .kpi-chart-wrap { min-height: 380px; }

/* ========== Toast ========== */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(29, 29, 31, 0.95);
  color: white;
  padding: 13px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 28px rgba(0,0,0,0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms, transform 220ms;
  z-index: 9999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: rgba(255, 59, 48, 0.95); }
.toast.success { background: rgba(52, 199, 89, 0.95); }

/* ========== Loading ========== */
.loading {
  text-align: center;
  padding: 60px 0;
  color: var(--ink-3);
  font-size: 15px;
}

/* ========== Responsive ========== */
@media (max-width: 1100px) {
  .kpi-block { flex-direction: column; }
  .kpi-aside {
    flex-direction: row;
    width: 100%;
    justify-content: flex-end;
    padding-top: 0;
  }
}
@media (max-width: 900px) {
  .report-header-inner { padding: 16px 18px; }
  .report-main { padding: 18px; gap: 22px; }
  .kpi-section { padding: 16px 14px; }
  .kpi-title { flex-basis: 70px; }
  .kpi-title .line-1, .kpi-title .line-2 { font-size: 22px; }
  .kpi-chart-wrap { min-height: 300px; }
  .report-meta { gap: 18px; }
  .copy-btn .copy-text { display: none; }
  .copy-btn { padding: 8px 10px; }
}
