/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: #F5F7FA;
  color: #1a2332;
  height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}
a { color: #1A73E8; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input, select, textarea { font-family: inherit; outline: none; }

/* ===== App Shell ===== */
#app {
  max-width: 430px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  background: #F5F7FA;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.screen {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.screen.active { display: flex; }
.screen-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  -webkit-overflow-scrolling: touch;
}
.screen-body::-webkit-scrollbar { width: 3px; }
.screen-body::-webkit-scrollbar-thumb { background: #d0d5dd; border-radius: 3px; }
.with-tab { padding-bottom: 80px; }

/* ===== Header ===== */
.screen-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #e8ecf2;
  flex-shrink: 0;
}
.screen-header h1 {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
}
.screen-header .back {
  font-size: 20px;
  margin-right: 8px;
  padding: 4px;
  color: #1a2332;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: transparent;
}
.screen-header .back:active { background: #f0f2f5; }
.header-right {
  font-size: 13px;
  color: #1A73E8;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  background: transparent;
}
.header-right:active { background: #e8eaf6; }

/* ===== Bottom Tab ===== */
.bottom-tab {
  display: flex;
  background: #fff;
  border-top: 1px solid #e8ecf2;
  flex-shrink: 0;
  padding: 4px 0;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  font-size: 10px;
  color: #8b9aaa;
  font-weight: 500;
  background: transparent;
  transition: color 0.15s;
}
.tab-item .tab-icon { font-size: 20px; line-height: 1; }
.tab-item.active { color: #1A73E8; }
.tab-item:active { opacity: 0.7; }

/* ===== Cards ===== */
.card {
  background: #fff;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-bottom: 12px;
}
.card-title {
  font-size: 13px; font-weight: 600; color: #6b7a8f;
  margin-bottom: 8px; letter-spacing: 0.3px;
}

/* ===== Form ===== */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: #3d4a5c; margin-bottom: 5px; }
.form-select, .form-input {
  width: 100%; padding: 11px 14px; border: 1.5px solid #e0e4ea; border-radius: 10px;
  font-size: 15px; color: #1a2332; background: #fff;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%238B9AAA' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.form-input { background-image: none; }
textarea.form-input { resize: vertical; min-height: 72px; line-height: 1.6; }

/* ===== Buttons ===== */
.btn-primary {
  width: 100%; padding: 14px; background: #1A73E8; color: #fff;
  border-radius: 12px; font-size: 16px; font-weight: 600; text-align: center;
}
.btn-primary:active { background: #1557B0; }
.btn-primary-lg { padding: 16px; font-size: 17px; border-radius: 14px; }
.btn-outline {
  padding: 8px 16px; background: transparent; color: #1A73E8;
  border: 1.5px solid #1A73E8; border-radius: 8px; font-size: 13px; font-weight: 500; text-align: center;
}
.btn-outline:active { background: #e8eaf6; }
.btn-ghost { background: #f0f2f5; color: #6b7a8f; border-radius: 10px; padding: 12px; font-size: 14px; font-weight: 600; }

/* ===== Tags ===== */
.tag {
  font-size: 11px; padding: 3px 10px; border-radius: 12px; font-weight: 500; display: inline-block;
}
.tag-win { background: #e6f4ea; color: #1e7e34; }
.tag-loss { background: #fce8e6; color: #c62828; }
.tag-gray { background: #e8ecf2; color: #6b7a8f; }
.tag-blue { background: #e8eaf6; color: #1A73E8; }
.tag-green { background: #e6f4ea; color: #1e7e34; }
.tag-yellow { background: #fff8e1; color: #f9a825; }
.tag-red { background: #fce8e6; color: #c62828; }

/* ===== Stats ===== */
.stats-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.stat-card { background: #fff; border-radius: 12px; padding: 12px 8px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.stat-num { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 11px; color: #8b9aaa; margin-top: 4px; }

/* ===== Progress bar ===== */
.bar-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.bar-label { font-size: 13px; color: #1a2332; min-width: 70px; }
.bar-track { flex: 1; height: 8px; background: #e8ecf2; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; }
.bar-pct { font-size: 12px; color: #6b7a8f; min-width: 36px; text-align: right; }

/* ===== Mini table ===== */
.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-table th {
  text-align: left; font-weight: 600; color: #6b7a8f; font-size: 11px;
  padding: 6px 4px; border-bottom: 1px solid #e0e4ea;
}
.mini-table td { padding: 7px 4px; border-bottom: 1px solid #f0f2f5; color: #1a2332; }

/* ===== NPS ===== */
.nps-grid { display: flex; gap: 4px; justify-content: center; }
.nps-btn {
  width: 30px; height: 38px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; border: none;
}
.nps-det { background: #fce8e6; color: #c62828; }
.nps-pas { background: #fff8e1; color: #f9a825; }
.nps-pro { background: #e6f4ea; color: #1e7e34; }
.nps-btn.selected { outline: 3px solid #1A73E8; outline-offset: -1px; }

/* ===== Recording ===== */
.record-circle {
  width: 80px; height: 80px; border-radius: 50%; margin: 0 auto 8px;
  display: flex; align-items: center; justify-content: center;
}
.record-idle { background: #f0f2f5; border: 3px solid #d0d5dd; }
.record-idle::after { content: ''; width: 28px; height: 28px; border-radius: 50%; background: #EA4335; }
.record-active {
  background: #fce8e6; border: 3px solid #EA4335; animation: pulse 1.5s ease-in-out infinite;
}
.record-active::after { content: ''; width: 22px; height: 22px; border-radius: 4px; background: #EA4335; }
.record-paused {
  background: #fce8e6; border: 3px solid #f9a825;
}
.record-paused::after {
  content: '❚❚'; font-size: 16px; color: #f9a825; font-weight: 700;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(234,67,53,0.4); }
  50% { box-shadow: 0 0 0 14px rgba(234,67,53,0); }
}
.waveform { height: 44px; display: flex; align-items: center; justify-content: center; gap: 3px; margin: 12px 0; }
.wave-bar {
  width: 4px; background: #EA4335; border-radius: 2px; animation: wave 0.8s ease-in-out infinite;
}
.wave-bar:nth-child(1) { height: 16px; animation-delay: 0s; }
.wave-bar:nth-child(2) { height: 28px; animation-delay: 0.1s; }
.wave-bar:nth-child(3) { height: 38px; animation-delay: 0.2s; }
.wave-bar:nth-child(4) { height: 22px; animation-delay: 0.3s; }
.wave-bar:nth-child(5) { height: 34px; animation-delay: 0.15s; }
.wave-bar:nth-child(6) { height: 26px; animation-delay: 0.25s; }
.wave-bar:nth-child(7) { height: 30px; animation-delay: 0.05s; }
.wave-bar:nth-child(8) { height: 18px; animation-delay: 0.35s; }
.wave-bar:nth-child(9) { height: 36px; animation-delay: 0.12s; }
.wave-bar:nth-child(10) { height: 24px; animation-delay: 0.28s; }
@keyframes wave { 0%,100%{opacity:0.4} 50%{opacity:1} }

/* ===== Progress ring ===== */
.progress-ring-wrap { display: flex; align-items: center; gap: 16px; padding: 4px 0; }
.progress-ring { width: 72px; height: 72px; position: relative; flex-shrink: 0; }
.progress-ring svg { width: 72px; height: 72px; transform: rotate(-90deg); }
.progress-ring-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 16px; font-weight: 700; color: #1a2332; }

/* ===== NPS Meter ===== */
.nps-meter { display: flex; gap: 10px; margin: 10px 0; }
.nps-mi { text-align: center; padding: 8px 12px; border-radius: 10px; flex: 1; }
.nps-mi .num { font-size: 20px; font-weight: 700; }
.nps-mi .label { font-size: 11px; margin-top: 2px; }
.nm-green { background: #e6f4ea; } .nm-green .num { color: #1e7e34; }
.nm-yellow { background: #fff8e1; } .nm-yellow .num { color: #f9a825; }
.nm-red { background: #fce8e6; } .nm-red .num { color: #c62828; }

/* ===== Report ===== */
.rpt-section { margin-bottom: 16px; }
.rpt-section-title {
  font-size: 14px; font-weight: 700;
  padding-bottom: 6px; border-bottom: 2px solid #1A73E8; margin-bottom: 10px;
}
.rpt-one-liner {
  background: linear-gradient(135deg, #1A73E8, #1557B0); color: #fff; border-radius: 10px;
  padding: 14px 16px; font-size: 14px; line-height: 1.6;
}
.rpt-qa-q { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.rpt-qa-summary { font-size: 13px; color: #3d4a5c; margin-bottom: 4px; }
.rpt-qa-quote {
  font-size: 12px; color: #6b7a8f; background: #f5f7fa; padding: 8px 10px; border-radius: 8px;
  border-left: 3px solid #1A73E8; line-height: 1.6;
}
.rpt-insight-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.rpt-insight-item { background: #f5f7fa; border-radius: 8px; padding: 8px 10px; }
.rpt-insight-dim { font-size: 11px; color: #8b9aaa; font-weight: 500; }
.rpt-insight-text { font-size: 12px; color: #1a2332; margin: 2px 0; }
.rpt-action-item { font-size: 13px; padding: 6px 0; border-bottom: 1px solid #f0f2f5; }
.rpt-action-item:last-child { border-bottom: none; }
.rpt-action-item::before { content: '▶ '; color: #1A73E8; font-weight: 700; }
.rpt-field-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.rpt-field-table td { padding: 4px 6px; border: 1px solid #e0e4ea; vertical-align: top; }
.rpt-field-table .fl { background: #f5f7fa; font-weight: 600; color: #3d4a5c; width: 28%; }
.rpt-field-table .fv { color: #1a2332; }

/* ===== Import area ===== */
.import-area {
  border: 2px dashed #d0d5dd; border-radius: 12px; padding: 24px;
  text-align: center; color: #8b9aaa; font-size: 13px; margin-bottom: 12px;
}
.import-area .icon { font-size: 28px; margin-bottom: 8px; }

/* ===== Chart containers ===== */
.chart-container { height: 140px; margin: 8px 0; position: relative; }
.chart-sm { height: 100px; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-end; justify-content: center; z-index: 100;
}
.modal-sheet {
  background: #fff; width: 100%; max-width: 430px;
  border-radius: 20px 20px 0 0; padding: 20px 16px max(20px, env(safe-area-inset-bottom));
  max-height: 80vh; overflow-y: auto;
}
.modal-handle { width: 36px; height: 4px; background: #d0d5dd; border-radius: 2px; margin: 0 auto 16px; }

/* ===== Toast ===== */
.toast {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
  background: #1a2332; color: #fff; font-size: 13px; padding: 10px 20px;
  border-radius: 10px; z-index: 200; opacity: 0; transition: opacity 0.3s;
  max-width: 360px; text-align: center;
}
.toast.show { opacity: 1; }

/* ===== Loading ===== */
.loading {
  text-align: center; padding: 40px 0; color: #8b9aaa; font-size: 14px;
}
.spinner {
  width: 32px; height: 32px; border: 3px solid #e0e4ea; border-top-color: #1A73E8;
  border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Empty state ===== */
.empty-state { text-align: center; padding: 40px 20px; color: #8b9aaa; font-size: 14px; line-height: 1.6; }

/* ===== Phase tags ===== */
.phase-tag { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 6px; display: inline-block; letter-spacing: 0.3px; margin-bottom: 10px; }
.phase-main { background: #e8eaf6; color: #283593; }
.phase-win { background: #e6f4ea; color: #1e7e34; }
.phase-loss { background: #fce8e6; color: #c62828; }

/* ===== Recents ===== */
.recent-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid #f0f2f5;
}
.recent-item:last-child { border-bottom: none; }
.recent-name { font-size: 14px; font-weight: 500; color: #1a2332; }
.recent-meta { font-size: 12px; color: #8b9aaa; margin-top: 2px; }

/* ===== Nav buttons ===== */
.nav-btns { display: flex; gap: 10px; margin-top: 14px; }
.nav-btn { flex: 1; padding: 12px; border-radius: 10px; font-size: 14px; font-weight: 600; text-align: center; }
.nav-prev { background: #f0f2f5; color: #6b7a8f; }
.nav-prev:active { background: #e0e4ea; }
.nav-next { background: #1A73E8; color: #fff; }
.nav-next:active { background: #1557B0; }

/* ===== Agg KPI cards ===== */
.agg-kpi { background: #fff; border-radius: 12px; padding: 14px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.05); flex: 1; }
.agg-kpi .num { font-size: 24px; font-weight: 700; }
.agg-kpi .lbl { font-size: 11px; color: #8b9aaa; margin-top: 2px; }
