/* ─── 招商蛇口品牌色系 — 招商蓝风格 ─── */
:root {
  /* 招商蛇口品牌核心色 */
  --cmsk-gold: #B8860B;
  --cmsk-gold-dark: #8B6508;
  /* 招商蓝 */
  --cmsk-blue: #0D3B66;
  --cmsk-blue-mid: #145A99;
  --cmsk-blue-light: #1B6DBF;
  /* 辅助 */
  --cmsk-gold: #B8860B;
  --cmsk-green: #2E8B57;
  /* 中性色 */
  --bg: #F4F6F9;
  --bg-warm: #FAFBFC;
  --line: #DDE3EA;
  --line-light: #EBF0F5;
  --text: #1A2B3C;
  --text-secondary: #4A5C6D;
  --text-muted: #8A97A5;
  --white: #FFFFFF;
  --shadow-sm: 0 1px 3px rgba(13,59,102,0.06);
  --shadow-md: 0 2px 8px rgba(13,59,102,0.08);
  --shadow-lg: 0 4px 16px rgba(13,59,102,0.10);
  --radius: 8px;
  --radius-sm: 5px;
  font-family: "Microsoft YaHei", "PingFang SC", -apple-system, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { min-width: 1200px; min-height: 780px; overflow: hidden; }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { border: 0; cursor: pointer; background: none; }
button:disabled { cursor: not-allowed; opacity: .5; }

/* ─── 布局 ─── */
.app-shell {
  display: grid;
  grid-template-columns: 272px 1fr;
  height: 100dvh;
}

/* ─── 侧边栏 — 招商蓝底 + 招商金品牌线 ─── */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 0;
  background: var(--cmsk-blue);
  color: #B8C8DA;
  overflow: hidden;
}

.brand {
  padding: 28px 20px 22px;
  border-bottom: 3px solid var(--cmsk-gold);
}

.brand-text { }
.brand-text strong {
  display: block;
  font-size: 22px;
  color: #fff;
  letter-spacing: 2px;
  font-weight: 700;
}
.brand-text small {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  letter-spacing: 1px;
}

.nav { display: grid; gap: 2px; padding: 12px 12px 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  color: rgba(255,255,255,0.6);
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 14px;
  transition: all 0.15s;
}
.nav-item:hover { color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.06); }
.nav-item.active {
  color: #fff;
  background: rgba(255,255,255,0.1);
  box-shadow: inset 3px 0 0 var(--cmsk-gold);
}

.history {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 20px 20px;
}
.history h2 {
  margin-bottom: 12px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 2px;
}
.week-list {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.week-button {
  padding: 10px 12px;
  color: rgba(255,255,255,0.7);
  background: rgba(184,134,11,0.05);
  border: 1px solid rgba(184,134,11,0.15);
  border-radius: var(--radius-sm);
  text-align: left;
  transition: all 0.15s;
}
.week-button:hover {
  background: rgba(184,134,11,0.12);
  border-color: rgba(184,134,11,0.35);
}
.week-button.active {
  color: #fff;
  border-color: rgba(184,134,11,0.6);
  background: rgba(184,134,11,0.18);
}
.week-button strong { display: block; margin-bottom: 3px; font-size: 13px; }
.week-button span { color: rgba(255,255,255,0.4); font-size: 11px; }

/* ─── 工作区 ─── */
.workspace {
  height: 100dvh;
  overflow: auto;
  padding: 20px 24px 28px;
  background: var(--bg);
}

/* ─── 顶栏 ─── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 0 0 16px;
  background: var(--bg);
}
.topbar-title h1 {
  font-size: 22px;
  color: var(--cmsk-blue);
  font-weight: 700;
  letter-spacing: 0;
}
.topbar-title p {
  margin-top: 3px;
  font-size: 13px;
  color: var(--text-muted);
}
.top-actions { display: flex; gap: 8px; align-items: center; }

/* ─── 按钮 ─── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 16px;
  color: #fff;
  background: var(--cmsk-blue-mid);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  box-shadow: 0 1px 3px rgba(13,59,102,0.2);
}
.btn-primary:hover:not(:disabled) { background: var(--cmsk-blue); }
.btn-primary.btn-sm { min-height: 30px; padding: 0 12px; font-size: 13px; }

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 16px;
  color: var(--cmsk-blue);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: all 0.15s;
}
.btn-outline:hover:not(:disabled) { border-color: var(--cmsk-blue-mid); color: var(--cmsk-blue-mid); }
.btn-outline.btn-sm { min-height: 30px; padding: 0 12px; font-size: 13px; }

/* ─── 视图控制 ─── */
.view { display: none; }
.view.active { display: block; }

/* ─── 输入行 ─── */
.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

/* 上传卡片 */
.upload-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
  cursor: pointer;
}
.upload-card:hover { border-color: var(--cmsk-blue-mid); box-shadow: var(--shadow-md); }
.upload-card.dragover { border-color: var(--cmsk-blue-mid); background: #EDF4FA; }
.upload-icon-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: #EDF4FA;
  border-radius: var(--radius);
}
.upload-icon-wrap svg { stroke: var(--cmsk-blue-mid); }
.upload-body { flex: 1; min-width: 0; }
.upload-body h3 { font-size: 15px; color: var(--cmsk-blue); font-weight: 600; }
.upload-body p { margin-top: 3px; font-size: 12px; color: var(--text-muted); }

/* 文字卡片 */
.text-card {
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.text-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-light);
  background: var(--bg-warm);
}
.text-card-header h3 { font-size: 15px; color: var(--cmsk-blue); font-weight: 600; }
.text-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
}

.input-field {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-warm);
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.15s;
}
.input-field:focus { outline: none; border-color: var(--cmsk-blue-mid); box-shadow: 0 0 0 2px rgba(20,90,153,0.1); }

.textarea-field {
  width: 100%;
  min-height: 64px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-warm);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  transition: border-color 0.15s;
}
.textarea-field:focus { outline: none; border-color: var(--cmsk-blue-mid); box-shadow: 0 0 0 2px rgba(20,90,153,0.1); }

/* ─── 口径条 ─── */
.scope-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 14px 0;
}
.scope-btn {
  min-height: 30px;
  padding: 0 14px;
  color: var(--text-secondary);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  transition: all 0.15s;
}
.scope-btn:hover { border-color: var(--cmsk-blue); color: var(--cmsk-blue); }
.scope-btn.active {
  color: #fff;
  background: var(--cmsk-blue);
  border-color: var(--cmsk-blue);
}
.scope-hint {
  margin-left: 6px;
  color: var(--text-muted);
  font-size: 12px;
}

/* ─── 指标卡 ─── */
.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.metric-card {
  position: relative;
  padding: 16px 18px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.metric-card.accent {
  border-left: 3px solid var(--cmsk-gold);
}
.metric-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.metric-value {
  display: block;
  font-size: 24px;
  color: var(--cmsk-blue);
  font-weight: 700;
  letter-spacing: 0;
}
.metric-unit {
  font-size: 13px;
  color: var(--text-muted);
  font-style: normal;
  margin-left: 2px;
}

/* ─── 内容区 ─── */
.content-grid {
  display: grid;
  grid-template-columns: minmax(380px, .7fr) minmax(640px, 1.3fr);
  gap: 14px;
  align-items: stretch;
}
.data-panel, .preview-panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 290px);
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.panel-head h2 {
  font-size: 16px;
  color: var(--cmsk-blue);
  font-weight: 600;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 999px;
}

.table-wrap {
  flex: 1;
  overflow: auto;
  max-height: calc(100vh - 350px);
}
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td {
  padding: 8px;
  border-bottom: 1px solid var(--line-light);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}
th {
  color: var(--text-secondary);
  background: var(--bg-warm);
  font-weight: 600;
  font-size: 12px;
}
.tag {
  display: inline-block;
  padding: 2px 8px;
  color: var(--cmsk-green);
  background: #E8F5EE;
  border-radius: 999px;
  font-size: 12px;
}
.tag.stage-signed { color: #1B6DBF; background: #E3EDF7; }
.tag.stage-strong { color: #B8860B; background: #FBF3E0; }
.tag.stage-medium { color: #145A99; background: #E8F0F8; }
.tag.stage-early { color: #5A5A5A; background: #F0F0F0; }
.tag.stage-lost { color: #C8102E; background: #FDE8EB; }

.empty-state { color: var(--text-muted); font-size: 13px; }
.workspace .empty-state { color: var(--text-muted); }

#reportFrame {
  flex: 1;
  width: 100%;
  min-height: 500px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

/* ─── 响应式 ─── */

/* Tablet & narrow desktop */
@media (max-width: 1240px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100dvh; }
  .input-row, .content-grid { grid-template-columns: 1fr; }
}

/* Hamburger button — hidden on desktop */
.menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: var(--cmsk-blue);
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.menu-btn:active { background: var(--line-light); }

/* Sidebar overlay — hidden on desktop */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0,0,0,0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}
.sidebar-overlay.visible {
  opacity: 1;
  visibility: visible;
}

/* ─── Mobile (≤768px) ─── */
@media (max-width: 768px) {
  body {
    min-width: unset;
    min-height: unset;
    min-height: -webkit-fill-available;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    -webkit-tap-highlight-color: transparent;
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* Sidebar: off-canvas drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
  }
  .sidebar-overlay {
    display: block;
    pointer-events: none;
  }
  .sidebar-overlay.visible {
    pointer-events: auto;
  }

  /* App shell: full-width */
  .app-shell {
    display: block;
    height: auto;
    min-height: 100dvh;
    grid-template-columns: unset;
  }

  /* Workspace */
  .workspace {
    height: auto;
    min-height: 100dvh;
    padding: 10px 12px 80px;
  }

  /* Show hamburger */
  .menu-btn { display: flex; }

  /* ── Topbar ── */
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 0 0 14px;
  }
  .topbar-title { display: flex; align-items: center; gap: 10px; }
  .topbar-title h1 { font-size: 17px; line-height: 1.3; }
  .topbar-title p { font-size: 12px; }
  .top-actions {
    display: flex;
    gap: 8px;
  }
  .top-actions .btn-outline,
  .top-actions .btn-primary {
    flex: 1;
    justify-content: center;
    min-height: 40px;
    font-size: 13px;
  }
  .top-actions .btn-outline svg,
  .top-actions .btn-primary svg { display: none; }

  /* ── Input row ── */
  .input-row {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 10px;
  }

  /* Upload card */
  .upload-card {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px;
  }
  .upload-card .upload-icon-wrap {
    width: 100%;
    height: 48px;
    border-radius: var(--radius-sm);
    background: #EDF4FA;
  }
  .upload-body { text-align: center; }
  .upload-body h3 { font-size: 14px; }
  .upload-body p { font-size: 12px; }
  .upload-card .btn-primary {
    width: 100%;
    justify-content: center;
    min-height: 42px;
  }

  /* Text card */
  .text-card-header { padding: 10px 14px; }
  .text-card-header h3 { font-size: 14px; }
  .text-card-body { padding: 10px 14px; }
  .textarea-field { min-height: 72px; font-size: 13px; }
  .input-field { font-size: 13px; height: 36px; }

  /* ── Scope bar ── */
  .scope-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    margin: 10px 0;
    padding: 0 0 4px;
  }
  .scope-bar::-webkit-scrollbar { display: none; }
  .scope-btn {
    flex-shrink: 0;
    min-height: 36px;
    padding: 0 14px;
    font-size: 13px;
  }
  .scope-hint { flex-shrink: 0; font-size: 11px; }

  /* ── Metrics: 2×2 grid ── */
  .metric-strip {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
  }
  .metric-card {
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .metric-card.accent { border-left: none; border-top: 3px solid var(--cmsk-gold); }
  .metric-label { font-size: 11px; margin-bottom: 4px; }
  .metric-value { font-size: 20px; }

  /* ── Content grid: stacked ── */
  .content-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .data-panel, .preview-panel {
    min-height: 260px;
    padding: 12px;
  }
  .panel-head {
    margin-bottom: 10px;
  }
  .panel-head h2 { font-size: 15px; }

  /* Table → card layout on mobile */
  .table-wrap {
    max-height: none;
    -webkit-overflow-scrolling: touch;
    overflow: hidden;
  }
  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap th,
  .table-wrap td,
  .table-wrap tr {
    display: block;
    width: 100%;
  }
  .table-wrap thead {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
  }
  .table-wrap tr {
    padding: 12px;
    margin-bottom: 8px;
    border: 1px solid var(--line-light);
    border-radius: var(--radius);
    background: var(--bg-warm);
  }
  .table-wrap tr:last-child { margin-bottom: 0; }
  .table-wrap td {
    padding: 3px 0;
    font-size: 13px;
    text-align: left;
    border: none;
    position: relative;
    padding-left: 72px;
    min-height: 24px;
  }
  .table-wrap td::before {
    position: absolute;
    left: 0;
    width: 64px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .table-wrap td:nth-child(1)::before { content: '项目'; }
  .table-wrap td:nth-child(2)::before { content: '客户'; }
  .table-wrap td:nth-child(3)::before { content: '面积'; }
  .table-wrap td:nth-child(4)::before { content: '来源'; }
  .table-wrap td:nth-child(5)::before { content: '阶段'; }
  .table-wrap td:nth-child(6)::before { content: '进展'; }

  /* Iframe */
  #reportFrame { min-height: 50vh; }

  /* ── Mobile action bar (sticky bottom) ── */
  .panel-head .btn-primary {
    min-height: 40px;
    font-size: 14px;
  }
  .status-badge { font-size: 11px; padding: 2px 8px; }
}

/* ── Small phones (≤375px) ── */
@media (max-width: 375px) {
  .workspace { padding: 8px 10px 80px; }
  .topbar-title h1 { font-size: 15px; }
  .metric-strip { gap: 6px; }
  .metric-card { padding: 10px; }
  .metric-value { font-size: 18px; }
  .top-actions .btn-outline,
  .top-actions .btn-primary { font-size: 12px; min-height: 36px; }
  .scope-btn { min-height: 32px; padding: 0 10px; font-size: 12px; }
  .upload-body h3 { font-size: 13px; }
}
