:root {
  --primary-color: #2c3e50;
  --accent-color: #3498db;
  --bg-color: #f4f6f9;
  --card-bg: #ffffff;
  --text-color: #333;
  --success-color: #2ecc71;
  --danger-color: #e74c3c;
  --sidebar-width: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-color);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#app { display: flex; flex-direction: column; height: 100vh; }

.header-bar {
  background: linear-gradient(135deg, #1a252f 0%, #2c3e50 50%, #34495e 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 30px;
  min-height: 60px;
  box-shadow: 0 2px 15px rgba(0,0,0,0.2);
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}
.header-bar::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #3498db, #2ecc71, #3498db);
}

.brand-section { display: flex; align-items: center; gap: 24px; }
.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.brand-logo i { font-size: 22px; color: #3498db; }
.demo-badge {
  font-size: 11px;
  background: linear-gradient(135deg, #f39c12, #e67e22);
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
}
.brand-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-left: 16px;
  border-left: 2px solid rgba(255,255,255,0.2);
}
.brand-meta .author { font-size: 12px; opacity: 0.9; }
.brand-meta .author i, .brand-meta .website i { width: 14px; margin-right: 4px; opacity: 0.7; }
.brand-meta .website a { font-size: 11px; color: #5dade2; text-decoration: none; transition: color 0.2s; }
.brand-meta .website a:hover { color: #85c1e9; text-decoration: underline; }

.qr-section { display: flex; gap: 16px; }
.qr-item {
  text-align: center;
  background: rgba(255,255,255,0.08);
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.2s;
}
.qr-item:hover { background: rgba(255,255,255,0.15); }
.qr-item img { width: 40px; height: 40px; border-radius: 4px; background: #fff; padding: 2px; }
.qr-item p { margin: 4px 0 0; font-size: 9px; opacity: 0.75; }

.demo-toggle-bar {
  display: none;
  background: linear-gradient(135deg, #e3f2fd, #bbdefb);
  padding: 10px 20px;
  cursor: pointer;
  font-size: 13px;
  color: #1565c0;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s;
  flex-shrink: 0;
}
.demo-toggle-bar:hover { background: linear-gradient(135deg, #bbdefb, #90caf9); }
.demo-toggle-bar.visible { display: flex; }
.demo-toggle-bar .toggle-icon { transition: transform 0.3s; }
.demo-toggle-bar.expanded .toggle-icon { transform: rotate(180deg); }

.demo-input-collapse {
  transition: all 0.3s ease;
  overflow: hidden;
}
.demo-input-collapse.collapsed {
  max-height: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin-bottom: 0 !important;
  opacity: 0;
  border: none;
}

.auth-panel {
  background: linear-gradient(180deg, #f8f9fa 0%, #fff 100%);
  padding: 12px 24px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid #e9ecef;
  flex-shrink: 0;
}
.control-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: nowrap;
}
.auth-panel .field { display: flex; flex-direction: column; gap: 4px; }
.auth-panel .field.hidden { display: none; }
.quota-remaining.hidden { display: none; }
.file-name.hidden { display: none; }
.file-input-hidden { display: none; }
.auth-panel label {
  font-size: 11px;
  color: #6c757d;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.auth-panel input[type="text"],
.auth-panel input[type="password"] {
  padding: 6px 10px;
  border: 1px solid #dde2e6;
  border-radius: 6px;
  font-size: 12px;
  width: 150px;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
}
.auth-panel select {
  padding: 6px 10px;
  border: 1px solid #dde2e6;
  border-radius: 6px;
  font-size: 12px;
  width: 200px;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
}
.auth-panel select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(52,152,219,0.15);
}
.auth-panel input[type="text"]:disabled,
.auth-panel input[type="password"]:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
  color: #888;
}
.auth-panel input[type="text"]:focus,
.auth-panel input[type="password"]:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(52,152,219,0.15);
}

.mode-options { display: flex; gap: 6px; flex-wrap: nowrap; }
.mode-option {
  border: 1px solid #d6dde4;
  background: #fff;
  color: #4f5b66;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}
.mode-option:hover { border-color: var(--accent-color); color: var(--accent-color); }
.mode-option.active {
  border-color: var(--accent-color);
  color: #fff;
  background: var(--accent-color);
}

.auth-panel input[type="file"] {
  padding: 6px 10px;
  border: 1px dashed #c5ccd3;
  border-radius: 6px;
  font-size: 11px;
  width: 180px;
  background: #fafbfc;
  cursor: pointer;
  transition: border-color 0.2s;
}
.auth-panel input[type="file"]:hover { border-color: var(--accent-color); }
.auth-panel input[type="file"]:disabled { background: #f0f0f0; cursor: not-allowed; }

.auth-panel .actions { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; }
.auth-panel .compact-actions button { padding: 7px 14px; font-size: 12px; }
.auth-panel button {
  padding: 7px 16px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.auth-panel button#generate-btn {
  background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(52,152,219,0.25);
}
.auth-panel button#generate-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(52,152,219,0.35);
}
.auth-panel button#export-btn {
  background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(46,204,113,0.25);
}
.auth-panel button#export-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(46,204,113,0.35);
}
.auth-panel button:disabled {
  background: #bdc3c7;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.demo-help-btn {
  background: #f5f5f5 !important;
  border: 1px solid #ddd !important;
  color: #555 !important;
  box-shadow: none !important;
}
.demo-help-btn:hover { background: #eee !important; border-color: #ccc !important; }

.demo-template-btn {
  background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%) !important;
  color: #fff !important;
}
.demo-template-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(155,89,182,0.35) !important;
}

.quota-remaining {
  font-size: 12px;
  color: #495057;
  padding: 6px 12px;
  background: #f8f9fa;
  border-radius: 4px;
}
.quota-remaining strong { color: var(--accent-color); }

.auth-panel .status {
  font-size: 11px;
  font-weight: 500;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: #c0392b;
}
.auth-panel .status:empty { display: none; }
.auth-panel .status.success { background: rgba(46,204,113,0.1); color: #27ae60; }

.hint-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px dashed #e0e0e0;
  padding-top: 6px;
}
.demo-tip-line {
  font-size: 11px;
  color: #666;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.hint-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
}
.file-name {
  color: #4f5b66;
  background: #eef2f6;
  padding: 2px 8px;
  border-radius: 999px;
}
.hint-meta .quota-remaining {
  padding: 0;
  background: transparent;
  border-radius: 0;
}
.demo-tip-line .sep { margin: 0 8px; color: #ccc; }
.demo-tip-line i { color: #f39c12; }

.quota-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  z-index: 999;
}
.quota-modal.active { display: flex; }
.quota-modal-card {
  width: 360px;
  background: #fff;
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.18);
}
.quota-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #2c3e50;
  margin: 0 0 12px;
}
.quota-modal-desc {
  font-size: 13px;
  color: #5c6770;
  line-height: 1.5;
  margin: 0 0 18px;
}
.quota-modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.quota-modal-actions button {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.quota-modal-actions .cancel { background: #eef2f5; color: #4f5b66; }
.quota-modal-actions .cancel:hover { background: #e0e5ea; }
.quota-modal-actions .confirm { background: var(--success-color); color: #fff; }
.quota-modal-actions .confirm:hover { background: #27ae60; }

.demo-help-modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  justify-content: center;
  align-items: center;
}
.demo-help-modal.active { display: flex; }
.demo-help-modal-content {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.demo-help-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8f9fa;
}
.demo-help-header h3 { margin: 0; font-size: 16px; color: #333; }
.demo-help-header h3 i { margin-right: 8px; color: var(--accent-color); }
.demo-help-close {
  background: none; border: none; font-size: 24px; cursor: pointer; color: #666;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
}
.demo-help-close:hover { background: #eee; }
.demo-help-body { padding: 0; }
.demo-tabs { display: flex; border-bottom: 2px solid #e0e0e0; background: #fff; }
.demo-tab {
  flex: 1;
  padding: 12px 16px;
  cursor: pointer;
  border: none;
  background: none;
  font-size: 13px;
  color: #666;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  text-align: center;
}
.demo-tab:hover { color: var(--accent-color); background: #f5f5f5; }
.demo-tab.active { color: var(--accent-color); border-bottom-color: var(--accent-color); font-weight: 500; }
.demo-tab-content { display: none; padding: 20px; max-height: 50vh; overflow-y: auto; }
.demo-tab-content.active { display: block; }
.demo-tab-content h4 { font-size: 14px; font-weight: 600; color: #333; margin: 0 0 12px 0; }
.demo-tab-content ol { padding-left: 20px; color: #555; line-height: 1.8; font-size: 13px; margin: 0; }
.demo-tab-content ol li { margin-bottom: 4px; }
.demo-tab-content ul.param-list { padding-left: 20px; color: #555; line-height: 1.8; font-size: 13px; margin: 0; list-style-type: disc; }
.demo-tab-content ul.param-list li { margin-bottom: 6px; }
.demo-tab-content ul.param-list li strong { color: #333; }
.demo-tab-content ul.param-list ul { margin-top: 4px; padding-left: 18px; list-style-type: circle; }
.fields-table-wrap { overflow-x: auto; }
.demo-tab-content table { width: 100%; border-collapse: collapse; font-size: 12px; }
.demo-tab-content th { background: #f5f5f5; padding: 8px 10px; text-align: left; font-weight: 500; border: 1px solid #e0e0e0; white-space: nowrap; }
.demo-tab-content td { padding: 8px 10px; border: 1px solid #eee; color: #555; }
.demo-tab-content .faq-item { margin-bottom: 14px; }
.demo-tab-content .faq-item:last-child { margin-bottom: 0; }
.demo-tab-content .faq-q { font-weight: 600; color: #333; margin-bottom: 4px; font-size: 13px; }
.demo-tab-content .faq-a { color: #666; line-height: 1.6; font-size: 13px; }
.demo-tab-content .note { font-size: 12px; color: #e67e22; margin-top: 12px; }
.demo-tab-content .note i { margin-right: 4px; }
.demo-tab-content .help-guide-section {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 18px;
  border-left: 3px solid var(--accent-color);
}
.demo-tab-content .help-guide-section h4 { margin-bottom: 10px; }

.report-root { display: none; flex: 1; min-height: 0; }
.report-root.active { display: flex; }
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--primary-color);
  color: #ecf0f1;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}
.sidebar-header { padding: 20px; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-header h2 { margin: 0; font-size: 18px; font-weight: 600; }
.sidebar-header p { margin: 6px 0 0; font-size: 12px; opacity: 0.8; }
.nav-links { list-style: none; padding: 0; margin: 20px 0; flex: 1; overflow-y: auto; }
.nav-item {
  cursor: pointer;
  padding: 15px 20px;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  border-left: 4px solid transparent;
}
.nav-item:hover { background-color: rgba(255,255,255,0.05); }
.nav-item.active { background-color: rgba(255,255,255,0.1); border-left-color: var(--accent-color); color: #fff; }
.nav-item i { margin-right: 12px; width: 20px; text-align: center; }

.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 30px;
  position: relative;
  min-width: 0;
}

.upload-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: #95a5a6;
}
.upload-hint i { font-size: 64px; margin-bottom: 20px; opacity: 0.5; }
.upload-hint p { font-size: 16px; }

.tab-panel { display: none; animation: fadeIn 0.4s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.section-title {
  border-left: 5px solid var(--accent-color);
  padding-left: 15px;
  margin: 30px 0 20px;
  color: var(--primary-color);
  font-size: 16px;
  font-weight: 600;
}

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 15px; margin-bottom: 30px; }
.kpi-card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.kpi-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--accent-color);
}
.kpi-val { font-size: 24px; font-weight: bold; margin: 10px 0; color: var(--primary-color); }
.kpi-label { font-size: 13px; color: #7f8c8d; }
.text-success { color: var(--success-color) !important; }
.text-danger { color: var(--danger-color) !important; }

.chart-row { display: flex; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.chart-box {
  flex: 1;
  min-width: 400px;
  background: var(--card-bg);
  border-radius: 8px;
  padding: 15px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  height: 400px;
}
.chart-box.large { height: 500px; }
.chart-box.small { height: 320px; min-width: 320px; }
.chart-box .chart-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 10px;
  padding-left: 10px;
  border-left: 3px solid var(--accent-color);
}
.chart-box .chart-inner { height: calc(100% - 30px); }

.table-container {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  margin-bottom: 30px;
  overflow-x: auto;
}
.table-container table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
}
.table-container th {
  background-color: #f8f9fa;
  color: var(--primary-color);
  font-weight: 600;
  padding: 12px 8px;
  white-space: nowrap;
  text-align: left;
  border: 1px solid #dee2e6;
}
.table-container td {
  padding: 10px 8px;
  white-space: nowrap;
  border: 1px solid #eee;
}
.table-container tbody tr:hover { background-color: #f8f9fa; }
.text-right { text-align: right; }
.text-center { text-align: center; }
table.data-table th { border: 1px solid #dee2e6; }
table.data-table td { border: 1px solid #eee; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }

@media (max-width: 1024px) {
  .header-bar { padding: 10px 15px; flex-wrap: wrap; gap: 10px; }
  .brand-logo { font-size: 14px; }
  .brand-logo i { font-size: 18px; }
  .brand-meta { display: none; }
  .qr-section { display: none; }
  .auth-panel { padding: 10px 15px; gap: 8px; }
  .auth-panel input[type="text"],
  .auth-panel input[type="password"] { width: 130px; }
  .sidebar { width: 200px; }
  .main-content { padding: 15px; }
  .chart-box { min-width: 300px; height: 350px; }
}

@media (max-width: 768px) {
  .header-bar { justify-content: center; }
  .brand-logo span:not(.demo-badge) { display: none; }
  .control-row { flex-direction: column; align-items: stretch; }
  .auth-panel .field { width: 100%; }
  .auth-panel input[type="text"],
  .auth-panel input[type="password"],
  .auth-panel input[type="file"],
  .auth-panel select { width: 100%; }
  .mode-options { width: 100%; }
  .mode-option { flex: 1; justify-content: center; }
  .auth-panel .actions { width: 100%; flex-direction: column; }
  .auth-panel .actions button { width: 100%; }
  .hint-row { flex-direction: column; align-items: flex-start; }
  .demo-tip-line { white-space: normal; }
  .report-root { flex-direction: column; }
  .sidebar { width: 100%; height: auto; max-height: 200px; }
  .nav-links { display: flex; flex-wrap: wrap; margin: 10px 0; }
  .nav-item { padding: 10px 15px; flex: 1; min-width: 50%; justify-content: center; border-left: none; border-bottom: 3px solid transparent; }
  .nav-item.active { border-bottom-color: var(--accent-color); border-left: none; }
  .main-content { padding: 10px; }
  .chart-box { min-width: 100%; height: 300px; }
  .table-container { padding: 10px; }
  .demo-help-modal-content { width: 95%; max-height: 90vh; }
}

/* ========== 授权弹窗 ========== */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  background: #fff;
  padding: 40px;
  border-radius: 12px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  text-align: center;
}

.auth-card h2 {
  margin: 0 0 8px;
  color: #2c3e50;
  font-size: 22px;
}

.auth-card h2 i {
  color: #3498db;
  margin-right: 10px;
}

.auth-subtitle {
  color: #7f8c8d;
  font-size: 13px;
  margin: 0 0 24px;
}

.auth-field {
  margin-bottom: 16px;
  text-align: left;
}

.auth-field label {
  display: block;
  font-size: 12px;
  color: #95a5a6;
  margin-bottom: 6px;
}

.auth-field input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
}

.auth-field input:focus {
  outline: none;
  border-color: #3498db;
}

#auth-verify-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

#auth-verify-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(52,152,219,0.4);
}

.auth-note {
  text-align: center;
  margin: 16px 0 0;
  font-size: 11px;
  color: #bdc3c7;
}

/* 正式版徽章 */
.pro-badge {
  background: linear-gradient(135deg, #27ae60, #2ecc71) !important;
}
