/* ─── Design Tokens ─── */
:root {
  --ln: #06C755;
  --ln-l: #EBF9F0;
  --ln-d: #049B40;
  --bg: #F4F5F7;
  --card: #FFFFFF;
  --bd: #EBEBEB;
  --t1: #1A1A1A;
  --t2: #5F6368;
  --t3: #9AA0A6;
  --red: #B93A2B;
  --red-l: #FEF0EE;
  --red-bd: #F0BDB6;
  --amber: #9A7B1A;
  --amber-l: #FDF6E3;
  --amber-bd: #EDD992;
  --green: #049B40;
  --green-l: #EBF9F0;
  --green-bd: #C2E8D0;
  --save-blue: #2563EB;
  --save-blue-l: #EFF6FF;
  --save-purple: #7C3AED;
  --save-purple-l: #F5F3FF;
  --price-accent: #5B8DEF;
  --price-bg: #F7F9FF;
  --stock-accent: #F59E0B;
  --stock-bg: #FFFBF0;
  --news-accent: #A855F7;
  --news-bg: #FAF5FF;
}

/* ─── Reset & Base ─── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--t1);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

#report-root {
  max-width: 414px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ─── Loading ─── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 12px;
  color: var(--t3);
  font-size: 13px;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--bd);
  border-top-color: var(--ln);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Header ─── */
.report-header {
  height: 48px;
  background: var(--ln);
  display: flex;
  align-items: center;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.report-header .logo-area {
  display: flex;
  align-items: center;
  gap: 6px;
}

.report-header .logo-icon {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.report-header .brand-name {
  color: white;
  font-size: 15px;
  font-weight: 800;
}

.report-header .report-date {
  color: rgba(255,255,255,0.8);
  font-size: 11px;
  margin-left: 4px;
}

.report-header .total-count {
  margin-left: auto;
  color: rgba(255,255,255,0.7);
  font-size: 11px;
}

/* ─── Content area ─── */
.report-content {
  padding: 12px 16px 24px;
}

/* ─── AI Hitokoto ─── */
.hitokoto {
  display: flex;
  gap: 10px;
  margin-bottom: 4px;
  align-items: flex-start;
  animation: fadeIn 0.4s ease-out;
}

.hitokoto-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--ln), var(--ln-d));
  display: flex;
  align-items: center;
  justify-content: center;
}

.hitokoto-bubble {
  background: white;
  border-radius: 3px 14px 14px 14px;
  padding: 9px 12px;
  border: 1px solid var(--bd);
  flex: 1;
}

.hitokoto-label {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 3px;
}

.hitokoto-label span {
  font-size: 10px;
  font-weight: 700;
  color: var(--ln-d);
}

.hitokoto-text {
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--t1);
}

/* ─── Section Header ─── */
.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  margin-top: 16px;
  padding: 8px 12px;
  border-radius: 8px;
}

.section-header[data-signal="red"] {
  background: var(--red-l);
  border: 1px solid var(--red-bd);
}

.section-header[data-signal="yellow"] {
  background: var(--amber-l);
  border: 1px solid var(--amber-bd);
}

.section-header[data-signal="blue"] {
  background: var(--green-l);
  border: 1px solid var(--green-bd);
}

.section-header .section-text {
  flex: 1;
}

.section-header .section-title {
  font-size: 13px;
  font-weight: 800;
}

.section-header .section-subtitle {
  font-size: 10px;
  opacity: 0.8;
}

.section-header[data-signal="red"] .section-title,
.section-header[data-signal="red"] .section-subtitle {
  color: var(--red);
}

.section-header[data-signal="yellow"] .section-title,
.section-header[data-signal="yellow"] .section-subtitle {
  color: var(--amber);
}

.section-header[data-signal="blue"] .section-title,
.section-header[data-signal="blue"] .section-subtitle {
  color: var(--green);
}

.section-header .section-count {
  font-size: 11px;
  font-weight: 700;
  background: rgba(255,255,255,0.6);
  padding: 2px 8px;
  border-radius: 4px;
}

.section-header[data-signal="red"] .section-count { color: var(--red); }
.section-header[data-signal="yellow"] .section-count { color: var(--amber); }
.section-header[data-signal="blue"] .section-count { color: var(--green); }

/* ─── Card list ─── */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ─── Item Card ─── */
.item-card {
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--bd);
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.item-card-header {
  width: 100%;
  border: none;
  cursor: pointer;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  min-height: 68px;
  text-align: left;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

/* Product image */
.product-image-wrap {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  background: #F0F0F0;
  flex-shrink: 0;
  position: relative;
  border: 1px solid var(--bd);
}

.product-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-image-wrap img.img-error {
  display: none;
}

.signal-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid white;
}

.signal-dot[data-signal="red"] { background: var(--red); }
.signal-dot[data-signal="yellow"] { background: var(--amber); }
.signal-dot[data-signal="blue"] { background: var(--green); }

/* Card info */
.card-info {
  flex: 1;
  min-width: 0;
}

.card-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--t1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-price-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.card-price {
  font-size: 15px;
  font-weight: 800;
  color: var(--t1);
}

.card-badge-row {
  margin-top: 3px;
}

/* Chevron icon */
.chevron-icon {
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.chevron-icon.open {
  transform: rotate(180deg);
}

/* ─── Score Ring ─── */
.score-ring {
  flex-shrink: 0;
}

/* ─── Savings Badge ─── */
.savings-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}

.savings-badge[data-signal="red"] {
  color: var(--red);
  background: var(--red-l);
  border: 1px solid var(--red-bd);
}

.savings-badge[data-signal="yellow"] {
  color: var(--amber);
  background: var(--amber-l);
  border: 1px solid var(--amber-bd);
}

.savings-badge[data-signal="blue"] {
  color: var(--green);
  background: var(--green-l);
  border: 1px solid var(--green-bd);
}

/* ─── Detail Panel ─── */
.detail-panel {
  padding: 10px 12px 10px;
  background: #FAFBFC;
  border-top: 1px solid var(--bd);
  animation: fadeIn 0.25s ease-out;
}

/* ─── Savings Panel ─── */
.savings-panel {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.savings-card {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
}

.savings-card.confirmed {
  background: var(--save-blue-l);
  border: 1px solid #BFDBFE;
}

.savings-card.dream {
  background: var(--save-purple-l);
  border: 1px solid #DDD6FE;
}

.savings-card .savings-label {
  font-size: 9px;
  font-weight: 600;
  margin-bottom: 2px;
}

.savings-card.confirmed .savings-label {
  color: var(--save-blue);
}

.savings-card.dream .savings-label {
  color: var(--save-purple);
}

.savings-card .savings-amount {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}

.savings-card.confirmed .savings-amount {
  color: var(--save-blue);
}

.savings-card.dream .savings-amount {
  color: var(--save-purple);
}

.savings-card .dream-sublabel {
  display: flex;
  align-items: center;
  gap: 3px;
}

.savings-card .dream-sublabel .gachi {
  font-size: 8px;
  opacity: 0.7;
}

.savings-card .savings-condition {
  font-size: 8px;
  opacity: 0.7;
  margin-top: 1px;
}

.savings-card.dream .savings-condition {
  color: var(--save-purple);
}

/* ─── Chart Container ─── */
.chart-container {
  margin-top: 10px;
}

.chart-container svg {
  border-radius: 6px;
  display: block;
  width: 100%;
}

.chart-legend {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 3px;
}

.chart-legend-item {
  font-size: 8px;
  color: var(--t3);
  display: flex;
  align-items: center;
  gap: 3px;
}

.chart-legend-line {
  width: 12px;
  height: 0;
  display: inline-block;
}

.chart-legend-line.market {
  border-top: 1.5px solid #CCC;
}

/* ─── AI Judgment ─── */
.ai-judgment {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 8px;
  background: var(--ln-l);
  border-left: 3px solid var(--ln);
}

.ai-judgment-header {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 3px;
}

.ai-judgment-icon {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  background: var(--ln);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-judgment-title {
  font-size: 9px;
  font-weight: 700;
  color: var(--ln-d);
}

.ai-judgment .conf-badge {
  margin-left: auto;
}

.ai-judgment-headline {
  font-size: 12.5px;
  font-weight: 700;
  color: #1E4D2B;
  line-height: 1.45;
}

.ai-judgment-action {
  font-size: 10.5px;
  color: #2D6A4F;
  line-height: 1.55;
  margin-top: 3px;
}

/* ─── Confidence Badge ─── */
.conf-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 9px;
  font-weight: 600;
}

.conf-badge .conf-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.conf-badge[data-level="high"] { color: var(--green); }
.conf-badge[data-level="high"] .conf-dot { background: var(--green); }
.conf-badge[data-level="medium"] { color: var(--amber); }
.conf-badge[data-level="medium"] .conf-dot { background: var(--amber); }
.conf-badge[data-level="low"] { color: var(--t3); }
.conf-badge[data-level="low"] .conf-dot { background: var(--t3); }

/* ─── Analysis Table ─── */
.analysis-table {
  margin-top: 8px;
  border-radius: 8px;
  border: 1px solid var(--bd);
  overflow: hidden;
}

.analysis-row {
  display: flex;
}

.analysis-row:not(:last-child) {
  border-bottom: 1px solid #F0F0F0;
}

.analysis-row[data-type="price"] {
  border-left: 3px solid var(--price-accent);
  background: var(--price-bg);
}

.analysis-row[data-type="stock"] {
  border-left: 3px solid var(--stock-accent);
  background: var(--stock-bg);
}

.analysis-row[data-type="news"] {
  border-left: 3px solid var(--news-accent);
  background: var(--news-bg);
}

.analysis-row .row-icon-area {
  width: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 8px 0;
  flex-shrink: 0;
}

.analysis-row .row-icon-area .row-label {
  font-size: 8px;
  font-weight: 700;
}

.analysis-row[data-type="price"] .row-label { color: var(--price-accent); }
.analysis-row[data-type="stock"] .row-label { color: var(--stock-accent); }
.analysis-row[data-type="news"] .row-label { color: var(--news-accent); }

.analysis-row .row-text {
  flex: 1;
  padding: 7px 10px 7px 0;
  min-width: 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--t1);
}

.analysis-row .row-impact {
  display: flex;
  align-items: center;
  padding-right: 10px;
  flex-shrink: 0;
}

/* ─── Impact Badge ─── */
.impact-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
}

.impact-badge.positive {
  color: var(--green);
  background: var(--green-l);
}

.impact-badge.zero {
  color: var(--t3);
  font-weight: 600;
  background: none;
}

.impact-badge.negative {
  color: var(--red);
  background: var(--red-l);
}

/* ─── Link Button ─── */
.link-btn {
  display: block;
  margin-top: 10px;
  padding: 9px 0;
  text-align: center;
  background: var(--ln);
  border-radius: 8px;
  color: white;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.link-btn-disabled {
  display: block;
  margin-top: 8px;
  padding: 7px 0;
  text-align: center;
  color: var(--t3);
  font-size: 10.5px;
}

/* ─── Footer ─── */
.report-footer {
  text-align: center;
  margin-top: 24px;
  padding: 12px 0;
  font-size: 10px;
  color: var(--t3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* ─── Animations ─── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
