/* ========================================
   全自动BI看板 - 蓝色主题
   样式移植自 每日销售BI看板.html / 数据清洗.html
   ======================================== */
:root {
  --blue-900: #0D47A1; --blue-800: #1565C0; --blue-700: #1976D2;
  --blue-600: #1E88E5; --blue-500: #2196F3; --blue-400: #42A5F5;
  --blue-200: #90CAF9; --blue-100: #BBDEFB; --blue-50: #E3F2FD; --blue-25: #F5F9FF;
  --green-700: #2E7D32; --green-500: #4CAF50; --green-50: #E8F5E9;
  --orange-700: #E65100; --orange-500: #FF9800; --orange-50: #FFF3E0;
  --gray-900: #212121; --gray-800: #424242; --gray-700: #616161; --gray-500: #9E9E9E;
  --gray-300: #E0E0E0; --gray-200: #EEEEEE; --gray-100: #F5F5F5; --gray-50: #FAFAFA;
  --white: #FFFFFF;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px;
  --font-family: -apple-system, BlinkMacSystemFont, "Microsoft YaHei", "PingFang SC", "Helvetica Neue", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font-family); background: var(--gray-100); color: var(--gray-800);
  min-height: 100vh; line-height: 1.6;
}

/* ---- Header ---- */
.header {
  background: linear-gradient(135deg, var(--blue-800) 0%, var(--blue-600) 100%);
  color: var(--white); padding: 20px 40px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow-md); flex-wrap: wrap; gap: 12px;
}
.header-left { display: flex; align-items: center; gap: 14px; }
.header-icon {
  width: 40px; height: 40px; background: rgba(255,255,255,0.2);
  border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.header h1 { font-size: 22px; font-weight: 600; letter-spacing: 0.5px; }
.header-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.header-date { font-size: 14px; color: rgba(255,255,255,0.95); background: rgba(255,255,255,0.12); padding: 6px 16px; border-radius: 20px; }
.header-date span { font-weight: 600; }

/* ---- Filter Bar ---- */
.filter-bar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}
.filter-inner {
  max-width: 1400px; margin: 0 auto;
  padding: 12px 32px;
  display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap;
}
.filter-label {
  font-size: 14px; font-weight: 600; color: var(--blue-700);
  white-space: nowrap;
}
.filter-item {
  display: flex; align-items: center; gap: 6px;
}
.filter-item label {
  font-size: 13px; color: var(--gray-700); font-weight: 500;
  white-space: nowrap;
}
.filter-item select {
  font-family: inherit; font-size: 13px;
  padding: 6px 28px 6px 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--gray-50);
  color: var(--gray-800);
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%23616161' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  min-width: 120px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.filter-item select:hover {
  border-color: var(--blue-400);
}
.filter-item select:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(33,150,243,0.12);
}
.filter-note {
  font-size: 11px; color: var(--gray-500);
  margin-left: auto;
  white-space: nowrap;
}
.view-switcher-bar {
  background: var(--gray-100);
  padding: 14px 32px 0;
}
.view-switcher {
  max-width: 1400px;
  margin: 0 auto;
  display: inline-flex;
  padding: 4px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}
.view-tab {
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--gray-700);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  min-width: 112px;
  padding: 8px 16px;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.view-tab:hover { color: var(--blue-700); background: var(--blue-50); }
.view-tab.active { background: var(--blue-700); color: var(--white); box-shadow: var(--shadow-sm); }
.view-tab:focus-visible { outline: 3px solid rgba(33,150,243,0.25); outline-offset: 1px; }
.dashboard-view[hidden] { display: none !important; }
.history-picker {
  display: flex; align-items: center; gap: 7px; padding: 4px 6px 4px 12px;
  border: 1px solid rgba(255,255,255,0.35); border-radius: 22px;
  background: rgba(255,255,255,0.12);
}
.history-picker label { font-size: 12px; color: rgba(255,255,255,0.88); white-space: nowrap; }
.date-select {
  font-family: inherit; font-size: 13px; padding: 4px 7px; border-radius: 15px;
  border: 0; background: rgba(255,255,255,0.95); color: var(--gray-800);
  cursor: pointer; outline: none; color-scheme: light;
}
.date-select:disabled { cursor: not-allowed; opacity: 0.65; }
.latest-btn {
  font-family: inherit; font-size: 12px; line-height: 1; padding: 7px 10px;
  border: 0; border-radius: 14px; color: var(--blue-800); background: var(--white);
  cursor: pointer; font-weight: 600;
}
.latest-btn:hover:not(:disabled) { background: var(--blue-50); }
.latest-btn:disabled { cursor: not-allowed; opacity: 0.6; }
.history-hint { font-size: 11px; color: rgba(255,255,255,0.78); white-space: nowrap; padding-right: 4px; }
.header-link { font-size: 13px; color: rgba(255,255,255,0.9); text-decoration: none; background: rgba(255,255,255,0.12); padding: 6px 14px; border-radius: 20px; }
.header-link:hover { background: rgba(255,255,255,0.22); }

/* ---- Container ---- */
.container { max-width: 1400px; margin: 0 auto; padding: 24px 32px 40px; }
.active-view { display: block; }

/* ---- Visualization Dashboard ---- */
.visual-note {
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  border-radius: var(--radius-md);
  color: var(--blue-800);
  font-size: 13px;
  margin-bottom: 16px;
  padding: 11px 14px;
}
.visual-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.chart-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-width: 0;
  overflow: hidden;
}
.chart-wide { grid-column: 1 / -1; }
.chart-card-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 68px;
  padding: 16px 20px 12px;
}
.chart-title { color: var(--gray-800); font-size: 15px; font-weight: 700; }
.chart-subtitle { color: var(--gray-500); font-size: 11px; margin-top: 3px; }
.chart-meta { color: var(--blue-700); font-size: 12px; font-weight: 600; white-space: nowrap; }
.chart-box { height: 360px; width: 100%; }
.chart-wide .chart-box { height: 390px; }
.chart-legend {
  align-items: center;
  color: var(--gray-600);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 7px 16px;
  justify-content: center;
  min-height: 36px;
  padding: 0 16px 12px;
}
.chart-legend:empty { display: none; }
.chart-legend-item { align-items: center; display: inline-flex; gap: 6px; max-width: 100%; min-width: 0; }
.chart-legend-swatch { background: var(--legend-color); border-radius: 999px; display: inline-block; height: 2px; position: relative; width: 22px; }
.chart-legend-swatch::after { background: var(--white); border: 2px solid var(--legend-color); border-radius: 50%; box-sizing: border-box; content: ''; height: 10px; left: 6px; position: absolute; top: -4px; width: 10px; }
.chart-legend-label { overflow-wrap: anywhere; }
.customer-filter {
  align-items: center;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  display: grid;
  gap: 10px 12px;
  grid-template-columns: auto minmax(250px, 350px) minmax(0, 1fr);
  padding: 10px 20px;
}
.customer-filter label { color: var(--gray-700); font-size: 12px; font-weight: 600; }
.customer-dropdown { min-width: 0; position: relative; width: 100%; }
.customer-dropdown-toggle {
  align-items: center;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  color: var(--gray-800);
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: 12px;
  justify-content: space-between;
  min-height: 32px;
  padding: 6px 9px;
  text-align: left;
  width: 100%;
}
.customer-dropdown-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.customer-dropdown-toggle:hover, .customer-dropdown-toggle:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(33,150,243,0.12); outline: none; }
.customer-dropdown-toggle:disabled { cursor: not-allowed; opacity: 0.6; }
.dropdown-caret { color: var(--gray-500); font-size: 13px; margin-left: 10px; }
.customer-dropdown-menu {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  left: 0;
  max-height: 270px;
  min-width: 100%;
  overflow: hidden;
  position: absolute;
  top: calc(100% + 5px);
  width: 100%;
  z-index: 20;
}
.customer-dropdown-menu[hidden] { display: none; }
.customer-dropdown-head {
  align-items: center;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  color: var(--gray-500);
  display: flex;
  font-size: 11px;
  justify-content: space-between;
  padding: 8px 10px;
}
.customer-dropdown-head button { background: transparent; border: 0; color: var(--blue-700); cursor: pointer; font: inherit; font-size: 11px; padding: 0; }
.customer-dropdown-options { max-height: 220px; overflow-y: auto; padding: 4px; }
.customer-option {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 4px;
  color: var(--gray-800);
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: 12px;
  gap: 7px;
  overflow: hidden;
  padding: 7px 8px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}
.customer-option:hover { background: var(--blue-50); }
.customer-option.selected { background: #EAF3FE; color: var(--blue-800); font-weight: 600; }
.customer-option-check { color: var(--blue-700); display: inline-block; font-weight: 700; min-width: 14px; text-align: center; }
.customer-dropdown-empty { color: var(--gray-500); font-size: 12px; padding: 12px 8px; }
.customer-filter-hint { color: var(--gray-500); font-size: 11px; min-width: 0; }
.chart-empty { align-items: center; color: var(--gray-500); display: flex; flex-direction: column; font-size: 13px; height: 100%; justify-content: center; text-align: center; }
.chart-empty-icon { font-size: 34px; margin-bottom: 8px; }
.visual-footnote { color: var(--gray-500); font-size: 11px; padding: 12px 2px 0; }

/* ---- Section title ---- */
.section-title { font-size: 15px; font-weight: 600; color: var(--gray-700); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ''; display: inline-block; width: 4px; height: 16px; background: var(--blue-500); border-radius: 2px; }

/* ---- KPI ---- */
.kpi-section { margin-bottom: 20px; }
.kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.kpi-card { background: var(--white); border-radius: var(--radius-md); padding: 20px 18px; box-shadow: var(--shadow-sm); border-top: 3px solid var(--blue-500); transition: box-shadow 0.2s; }
.kpi-card:hover { box-shadow: var(--shadow-md); }
.kpi-card .kpi-label { font-size: 12px; color: var(--gray-500); margin-bottom: 8px; font-weight: 500; }
.kpi-card .kpi-value { font-size: 26px; font-weight: 700; color: var(--blue-800); margin-bottom: 4px; }
.kpi-card .kpi-sub { font-size: 11px; color: var(--gray-500); }
.kpi-card.accent-green { border-top-color: var(--green-500); }
.kpi-card.accent-green .kpi-value { color: var(--green-700); }
.kpi-card.accent-orange { border-top-color: var(--orange-500); }
.kpi-card.accent-orange .kpi-value { color: var(--orange-700); }

/* ---- Table ---- */
.table-section { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.table-header { padding: 16px 24px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.table-info { font-size: 12px; color: var(--gray-500); }
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.data-table thead th { position: sticky; top: 0; z-index: 2; background: var(--blue-800); color: var(--white); padding: 11px 12px; font-weight: 500; font-size: 12px; text-align: right; border-right: 1px solid rgba(255,255,255,0.12); }
.data-table thead th:first-child { text-align: left; min-width: 240px; }
.data-table thead th:last-child { border-right: none; }
.data-table tbody td { padding: 8px 12px; text-align: right; border-bottom: 1px solid var(--gray-200); }
.data-table tbody td:first-child { text-align: left; }
.row-mgr { background: #E8EAF6; }
.row-mgr td { font-weight: 700; font-size: 14px; padding: 10px 12px; border-top: 2px solid var(--blue-500); }
.row-mgr td:first-child { color: var(--blue-800); }
.row-region { background: #F0F4FF; }
.row-region td { font-weight: 600; font-size: 13px; padding: 9px 12px; border-top: 1px solid var(--blue-200); }
.row-region td:first-child { color: var(--blue-700); }
.row-sp { background: var(--blue-25); }
.row-sp td { font-weight: 500; font-size: 13px; padding: 8px 12px; }
.row-customer { background: var(--white); }
.row-customer:hover { background: var(--gray-50); }
.indent-0 { padding-left: 12px !important; }
.indent-1 { padding-left: 40px !important; }
.indent-2 { padding-left: 68px !important; }
.indent-3 { padding-left: 96px !important; }
.level-icon { margin-right: 6px; font-size: 14px; }
.rate-good { color: var(--green-700) !important; font-weight: 600; }
.rate-warn { color: var(--orange-700) !important; font-weight: 600; }
.rate-na { color: var(--gray-500) !important; }

/* ---- Empty / Loading ---- */
.empty-state { text-align: center; padding: 80px 20px; color: var(--gray-500); }
.empty-state .empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-state p { font-size: 15px; margin-bottom: 6px; }
.empty-state .sub { font-size: 13px; }
.empty-state a { color: var(--blue-600); }
.loading-overlay { display: none; position: fixed; inset: 0; background: rgba(255,255,255,0.8); z-index: 999; align-items: center; justify-content: center; flex-direction: column; }
.loading-overlay.show { display: flex; }
.spinner { width: 44px; height: 44px; border: 4px solid var(--gray-300); border-top-color: var(--blue-500); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { margin-top: 16px; font-size: 14px; color: var(--gray-700); }

/* ---- Footer / Copyright ---- */
.footer { text-align: center; padding: 20px; color: var(--gray-500); font-size: 12px; }
.copyright-bar { background: rgba(255,255,255,0.85); border-top: 1px solid var(--gray-200); color: var(--gray-500); font-size: 11px; margin-top: 20px; padding: 6px 0; pointer-events: none; text-align: center; width: 100%; }

/* ============ 管理上传页 ============ */
.admin-main { max-width: 720px; margin: 32px auto; padding: 0 20px 40px; }
.card { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 16px; }
.card .card-header { padding: 18px 24px; border-bottom: 1px solid var(--gray-200); font-size: 15px; font-weight: 600; color: var(--gray-700); display: flex; align-items: center; gap: 8px; }
.card .card-header::before { content: ''; display: inline-block; width: 4px; height: 16px; background: var(--blue-500); border-radius: 2px; }
.card-inner { padding: 22px 24px; }
.upload-zone { border: 2px dashed var(--gray-300); border-radius: var(--radius-md); padding: 36px 20px; text-align: center; cursor: pointer; transition: all 0.25s ease; background: var(--gray-50); }
.upload-zone:hover, .upload-zone.dragover { border-color: var(--blue-400); background: var(--blue-25); box-shadow: 0 0 0 6px rgba(33,150,243,0.06); }
.upload-zone .icon { font-size: 40px; margin-bottom: 10px; display: block; }
.upload-zone .label { font-size: 15px; font-weight: 600; color: var(--gray-700); }
.upload-zone .hint { font-size: 12px; color: var(--gray-500); margin-top: 6px; }
.upload-zone input[type="file"] { display: none; }
.btn { display: inline-block; padding: 10px 22px; border: none; border-radius: var(--radius-sm); background: var(--blue-500); color: var(--white); font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; transition: background 0.2s; }
.btn:hover { background: var(--blue-600); }
.login-form { display: flex; flex-direction: column; gap: 12px; max-width: 360px; margin: 0 auto; }
.login-form input { padding: 11px 14px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); font-size: 14px; font-family: inherit; outline: none; }
.login-form input:focus { border-color: var(--blue-400); box-shadow: 0 0 0 3px rgba(33,150,243,0.12); }
.result-box { margin-top: 16px; padding: 14px 16px; border-radius: var(--radius-sm); font-size: 13px; display: none; }
.result-box.show { display: block; }
.result-box.success { background: var(--green-50); color: var(--green-700); border: 1px solid rgba(76,175,80,0.25); }
.result-box.error { background: var(--orange-50); color: var(--orange-700); border: 1px solid rgba(230,81,0,0.2); }
.result-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin-top: 10px; }
.stat-item { text-align: center; padding: 10px 6px; background: var(--gray-50); border-radius: var(--radius-sm); }
.stat-item .stat-val { font-size: 18px; font-weight: 700; color: var(--blue-800); }
.stat-item .stat-lbl { font-size: 11px; color: var(--gray-500); margin-top: 2px; }
.staff-info { font-size: 12px; color: var(--gray-500); margin-top: 8px; }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(3,1fr); }
  .container { padding: 16px; }
  .history-hint { display: none; }
  .filter-inner { padding: 10px 16px; gap: 10px; }
  .filter-item select { min-width: 100px; font-size: 12px; }
  .view-switcher-bar { padding: 12px 16px 0; }
  .visual-grid { grid-template-columns: 1fr; }
  .chart-wide { grid-column: auto; }
}
@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: repeat(2,1fr); }
  .header { padding: 16px 20px; }
  .header h1 { font-size: 18px; }
  .header-right { width: 100%; }
  .history-picker { width: 100%; justify-content: center; }
  .result-stats { grid-template-columns: repeat(2,1fr); }
  .filter-inner { flex-direction: column; align-items: stretch; }
  .filter-item { flex-direction: column; align-items: stretch; }
  .filter-item select { width: 100%; }
  .filter-note { margin-left: 0; }
  .view-switcher { display: flex; width: 100%; }
  .view-tab { flex: 1; min-width: 0; padding-left: 8px; padding-right: 8px; }
  .chart-card-header { padding-left: 14px; padding-right: 14px; }
  .chart-box, .chart-wide .chart-box { height: 310px; }
  .chart-legend { font-size: 11px; gap: 6px 10px; min-height: 34px; padding: 0 12px 10px; }
  .chart-legend-swatch { width: 18px; }
  .chart-legend-swatch::after { left: 4px; }
  .customer-filter { align-items: stretch; display: flex; flex-direction: column; gap: 8px; padding-left: 14px; padding-right: 14px; }
  .customer-filter label { padding-top: 0; }
  .customer-dropdown { min-width: 0; }
  .customer-dropdown-menu { width: 100%; }
  .customer-filter-hint { padding-top: 0; }
}
