/* ============================================================
   巨量引擎 智能广告搭建 v4 — 完整样式
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif; background: #f2f3f7; color: #1f2937; min-height: 100vh; line-height: 1.5; }

/* ===== 应用头部 ===== */
.app-header {
  background: linear-gradient(135deg, #1a56db 0%, #1e3a8a 100%);
  color: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
}
.header-left h1 { font-size: 18px; font-weight: 600; }
.header-left p { font-size: 12px; opacity: 0.8; margin-top: 1px; }
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  background: rgba(255,255,255,0.12);
  padding: 6px 14px;
  border-radius: 20px;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #9ca3af;
}
.status-dot.online { background: #22c55e; box-shadow: 0 0 6px #22c55e; }
.status-dot.offline { background: #6b7280; }

/* ===== 主布局 ===== */
.main-layout {
  display: flex;
  max-width: 1600px;
  margin: 0 auto;
  min-height: calc(100vh - 56px);
}

/* ===== 侧边栏 ===== */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  padding: 12px 0;
}
.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 8px;
  text-decoration: none;
  color: #4b5563;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  position: relative;
}
.nav-item:hover { background: #f3f4f6; color: #1f2937; }
.nav-item.active { background: #eff6ff; color: #1d4ed8; font-weight: 600; }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: #1d4ed8;
  border-radius: 0 3px 3px 0;
}
.nav-item.disabled {
  opacity: 0.4;
  pointer-events: none;
}
.nav-icon { font-size: 18px; width: 24px; text-align: center; }
.nav-label { flex: 1; }
.nav-badge {
  font-size: 11px;
  color: #16a34a;
  font-weight: 700;
}
.nav-count {
  background: #1d4ed8;
  color: #fff;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}
.sidebar-footer {
  padding: 12px 22px;
  border-top: 1px solid #e5e7eb;
  color: #9ca3af;
  font-size: 11px;
}

/* ===== 主内容 ===== */
.content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ===== 面板卡片 ===== */
.panel-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid #e5e7eb;
}
.panel-card h2 {
  font-size: 17px;
  color: #111827;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-desc {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 16px;
  line-height: 1.7;
}
.panel-desc code {
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  color: #1d4ed8;
}
.hint-text { font-size: 13px; color: #9ca3af; font-weight: 400; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 5px;
}
input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: #1f2937;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
textarea { resize: vertical; min-height: 90px; font-family: 'SF Mono', 'Consolas', 'Courier New', monospace; font-size: 12px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.form-grid .form-group { margin-bottom: 0; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  font-family: inherit;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: #1d4ed8; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1e40af; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-outline {
  background: #fff;
  color: #374151;
  border: 1.5px solid #d1d5db;
}
.btn-outline:hover:not(:disabled) { background: #f9fafb; border-color: #9ca3af; }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }
.btn-xl { padding: 14px 40px; font-size: 16px; font-weight: 600; border-radius: 10px; }
.btn-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* ===== 工具栏 ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar-info { font-size: 13px; color: #6b7280; white-space: nowrap; }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  background: #f9fafb;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: #4b5563;
  border-bottom: 2px solid #e5e7eb;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
tr:hover td { background: #f9fafb; }
tr.selected td { background: #eff6ff; }
.empty-cell { text-align: center; padding: 40px 20px !important; color: #9ca3af; font-size: 14px; }

.account-checkbox {
  width: 18px; height: 18px;
  accent-color: #1d4ed8;
  cursor: pointer;
}

/* ===== 标签 ===== */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  margin: 2px;
}
.tag-blue { background: #eff6ff; color: #1d4ed8; }
.tag-green { background: #f0fdf4; color: #16a34a; }
.tag-red { background: #fef2f2; color: #dc2626; }
.tag-gray { background: #f3f4f6; color: #6b7280; }
.tag-yellow { background: #fffbeb; color: #d97706; }

/* ===== 素材网格 ===== */
.material-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}
.material-card {
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s;
  background: #fff;
  position: relative;
}
.material-card:hover { border-color: #93c5fd; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.material-card.selected { border-color: #1d4ed8; box-shadow: 0 0 0 3px rgba(29,78,216,0.2); }
.material-card .mat-cover {
  width: 100%;
  height: 200px;
  background: #e5e7eb;
  background-size: cover;
  background-position: center;
  position: relative;
}
.material-card .mat-cover .mat-duration {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
}
.material-card .mat-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #d1d5db;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: transparent;
  transition: all 0.15s;
  z-index: 2;
}
.material-card.selected .mat-check {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #fff;
}
.material-card .mat-info { padding: 10px 12px; }
.material-card .mat-title {
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}
.material-card .mat-meta {
  font-size: 11px;
  color: #9ca3af;
  display: flex;
  gap: 8px;
}

/* ===== 程序网格 ===== */
.program-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.program-card {
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.15s;
  background: #fff;
}
.program-card:hover { border-color: #93c5fd; }
.program-card.selected { border-color: #1d4ed8; background: #eff6ff; }
.program-card .prog-name { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.program-card .prog-detail { font-size: 12px; color: #6b7280; display: flex; gap: 16px; }
.program-card .prog-detail .key { color: #9ca3af; }
.program-card .prog-detail .val { font-family: 'SF Mono', 'Consolas', monospace; }

/* ===== 单元行 ===== */
.unit-row {
  display: flex;
  gap: 12px;
  align-items: end;
  background: #f9fafb;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.unit-row .form-group { margin-bottom: 0; flex: 1; min-width: 160px; }
.unit-row .form-group.unit-title-group { flex: 2; min-width: 240px; }
.unit-row .form-group.unit-name-group { flex: 1; min-width: 140px; }
.unit-row .form-group.unit-budget-group { flex: 0 0 120px; }
.unit-row .form-group.unit-action-group { flex: 0 0 40px; }
.unit-row .unit-index {
  font-size: 12px;
  color: #9ca3af;
  font-weight: 600;
  min-width: 50px;
  padding-bottom: 10px;
}

/* ===== 落地页内容 ===== */
#landingContent { padding: 8px 0; }
.landing-item {
  background: #f9fafb;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}
.landing-item .landing-key { font-weight: 600; color: #374151; }
.landing-item .landing-val { color: #6b7280; font-family: 'SF Mono', monospace; font-size: 12px; }

/* ===== 分页 ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
}
.pagination button {
  padding: 6px 14px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  color: #374151;
}
.pagination button:hover:not(:disabled) { background: #f3f4f6; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination button.active { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }
.pagination span { font-size: 13px; color: #6b7280; padding: 0 4px; }

/* ===== 子标签 ===== */
.sub-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: #f3f4f6;
  padding: 4px;
  border-radius: 10px;
}
.sub-tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.sub-tab:hover { color: #374151; }
.sub-tab.active {
  background: #fff;
  color: #1d4ed8;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.sub-panel { display: none; }
.sub-panel.active { display: block; }

.cnt-badge {
  background: #e5e7eb;
  color: #6b7280;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  font-weight: 600;
}
.sub-tab.active .cnt-badge { background: #eff6ff; color: #1d4ed8; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 72px;
  right: 24px;
  padding: 14px 24px;
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  animation: slideIn 0.3s ease;
}
.toast-success { background: linear-gradient(135deg, #16a34a, #15803d); }
.toast-error { background: linear-gradient(135deg, #ef4444, #dc2626); }
.toast-info { background: linear-gradient(135deg, #1d4ed8, #1e40af); }
.toast-warn { background: linear-gradient(135deg, #f59e0b, #d97706); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== 加载动画 ===== */
.loading-spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2.5px solid #d1d5db;
  border-top-color: #1d4ed8;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 空状态 ===== */
.empty-state { text-align: center; padding: 48px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { color: #9ca3af; font-size: 14px; }

/* ===== 进度条 ===== */
.progress-wrap { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.progress-bar.outer {
  flex: 1;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #1d4ed8, #3b82f6);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.progress-text { font-size: 13px; color: #6b7280; font-weight: 600; min-width: 50px; }

/* ===== 日志区 ===== */
.log-area {
  background: #1a1a2e;
  color: #d4d4d4;
  padding: 16px;
  border-radius: 10px;
  font-family: 'SF Mono', 'Consolas', 'Courier New', monospace;
  font-size: 12px;
  max-height: 500px;
  overflow-y: auto;
  line-height: 1.7;
}
.log-placeholder { color: #6b7280; text-align: center; padding: 20px; }
.log-info { color: #6ee7b7; }
.log-success { color: #4ade80; }
.log-error { color: #f87171; }
.log-warn { color: #fbbf24; }
.log-system { color: #93c5fd; }
.log-separator { color: #4b5563; border-bottom: 1px dashed #374151; margin: 4px 0; }

/* ===== 广告户标记 ===== */
.account-badge {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  color: #16a34a;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== 创建操作区 ===== */
.create-action { text-align: center; }

/* ===== 隐藏 ===== */
.hidden { display: none !important; }

/* ===== 搜索框高亮 ===== */
input[type="text"]::placeholder { color: #9ca3af; }

/* ===== 响应式 ===== */
@media (max-width: 1100px) {
  .main-layout { flex-direction: column; }
  .sidebar { width: 100%; min-width: 0; flex-direction: row; overflow-x: auto; padding: 8px; }
  .sidebar-nav { flex-direction: row; gap: 4px; }
  .nav-item { white-space: nowrap; padding: 8px 14px; font-size: 13px; }
  .nav-item.active::before { display: none; }
  .sidebar-footer { display: none; }
  .material-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .unit-row { flex-direction: column; }
}

/* ===== 模块标记 ===== */
.module-badge {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  color: #92400e;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== 分区标题 ===== */
.section-label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #374151;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e5e7eb;
}

/* ===== 投放场景选择 ===== */
.scene-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.scene-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.15s;
  background: #f9fafb;
  user-select: none;
}
.scene-card:hover { border-color: #93c5fd; }
.scene-card:has(.scene-check:checked) {
  border-color: #1d4ed8;
  background: #eff6ff;
}
.scene-check {
  width: 18px; height: 18px;
  accent-color: #1d4ed8;
  cursor: pointer;
}
.scene-name { font-size: 15px; font-weight: 600; color: #1f2937; }
.scene-desc { font-size: 12px; color: #9ca3af; }
.scene-bid {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #374151;
  margin-top: 2px;
}
.scene-bid-input {
  width: 80px;
  padding: 4px 8px;
  font-size: 13px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
}

/* ===== 模板输入区 ===== */
.template-input-wrap { position: relative; }
.template-input-wrap input {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 13px;
}
.template-vars {
  display: flex;
  gap: 5px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.var-chip {
  display: inline-block;
  padding: 3px 10px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  font-size: 11px;
  font-family: 'SF Mono', 'Consolas', monospace;
  cursor: pointer;
  transition: all 0.15s;
}
.var-chip:hover {
  background: #1d4ed8;
  color: #fff;
  border-color: #1d4ed8;
}

/* ===== 模板预览 ===== */
.template-preview {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 14px 18px;
  margin-top: 16px;
  font-size: 13px;
}
.template-preview strong { color: #166534; display: block; margin-bottom: 8px; }
.preview-list { display: flex; flex-direction: column; gap: 8px; }
.preview-item {
  background: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  border: 1px solid #dcfce7;
}
.preview-project { font-size: 14px; margin-top: 4px; color: #065f46; }
.preview-unit { font-size: 13px; color: #374151; margin-top: 2px; }

/* ===== 关键词云 ===== */
.keyword-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px;
  border: 1px dashed #d1d5db;
  border-radius: 10px;
  min-height: 50px;
  align-items: flex-start;
  background: #fafafa;
}
.kw-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
}
.kw-tag.kw-negative {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}
.kw-remove {
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  color: #94a3b8;
  line-height: 1;
  margin-left: 2px;
}
.kw-remove:hover { color: #ef4444; }

/* ===== 响应式补充 ===== */
@media (max-width: 1100px) {
  .scene-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== 滚动条美化 ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
