/* =========================================================
   Repofy アプリ本体 - style.css
   LP（index.html / style.css）と同系統の青系デザイン
   ========================================================= */

:root {
  --color-bg: #ffffff;
  --color-bg-alt: #f5f8fc;
  --color-surface: #ffffff;
  --color-text: #101828;
  --color-text-muted: #4b5768;
  --color-border: #e2e8f0;

  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-primary-light: #eff6ff;
  --color-accent: #16a34a;
  --color-warning: #b45309;
  --color-warning-bg: #fffbeb;
  --color-warning-border: #fde68a;

  --excel-header-bg: #1e7145;
  --excel-header-text: #ffffff;
  --sheet-header-bg: #0f9d58;
  --sheet-header-text: #ffffff;

  --shadow-card: 0 4px 16px rgba(16, 24, 40, 0.06);
  --shadow-card-hover: 0 10px 30px rgba(16, 24, 40, 0.1);
  --radius-md: 12px;
  --radius-lg: 20px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", Meiryo, system-ui, sans-serif;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0b1220;
    --color-bg-alt: #0f1829;
    --color-surface: #141f33;
    --color-text: #e8edf5;
    --color-text-muted: #a2acbd;
    --color-border: #26334a;

    --color-primary: #3b82f6;
    --color-primary-dark: #60a5fa;
    --color-primary-light: #16223c;
    --color-accent: #22c55e;
    --color-warning: #fbbf24;
    --color-warning-bg: #2b2308;
    --color-warning-border: #7c5e10;

    --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-card-hover: 0 10px 30px rgba(0, 0, 0, 0.4);

    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

a {
  color: inherit;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn-primary {
  background: var(--color-primary);
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.3);
}
.btn-primary:hover {
  background: var(--color-primary-dark);
}
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-secondary:hover {
  background: var(--color-primary-light);
}
.btn-lg {
  padding: 16px 32px;
  font-size: 1.05rem;
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.15rem;
  text-decoration: none;
  color: var(--color-text);
}
.logo-mark {
  font-size: 1.3rem;
}
.app-badge {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 6px 14px;
  border-radius: 999px;
}
.header-account {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.account-email {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}
.account-link {
  color: var(--color-primary);
  font-weight: 700;
  font-size: 0.88rem;
  text-decoration: none;
  white-space: nowrap;
}
.account-link:hover {
  text-decoration: underline;
}

.plan-badge {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 6px 14px;
  border-radius: 999px;
  text-decoration: none;
  white-space: nowrap;
}
.plan-badge:hover {
  background: var(--color-primary);
  color: #ffffff;
}

/* ---------- プラン・お支払いページ ---------- */
.billing-page {
  max-width: 560px;
  margin: 0 auto;
}
.billing-page h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0 0 24px;
  text-align: center;
}
.billing-success-banner {
  color: var(--color-accent);
  background: var(--color-primary-light);
  border-color: var(--color-border);
}
.billing-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 32px;
  text-align: center;
}
.billing-card-active {
  border-color: var(--color-accent);
}
.billing-card-expired {
  border-color: var(--color-warning-border);
}
.billing-status-label {
  margin: 0 0 6px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-text-muted);
  letter-spacing: 0.04em;
}
.billing-status-value {
  margin: 0 0 12px;
  font-size: 1.3rem;
  font-weight: 800;
}
.billing-status-desc {
  margin: 0 0 24px;
  color: var(--color-text-muted);
  font-size: 0.92rem;
}
.billing-card form {
  margin: 0;
}
.billing-note {
  margin: 20px 0 0;
  text-align: center;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.app-main {
  padding: 48px 24px 72px;
}

.app-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-alt);
  padding: 20px 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-align: center;
}
.app-footer p {
  margin: 0;
}

/* ---------- Dashboard ---------- */
.dashboard-hero {
  text-align: center;
  margin-bottom: 40px;
}
.dashboard-hero h1 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 800;
  margin: 0 0 10px;
}
.dashboard-hero p {
  color: var(--color-text-muted);
  margin: 0;
}
.hero-login {
  margin-top: 20px !important;
}

.option-group-label {
  margin: 14px 0 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-text-muted);
  letter-spacing: 0.04em;
}

/* ---------- Message page (案内・エラー) ---------- */
.message-page {
  max-width: 640px;
  margin: 40px auto;
  text-align: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 40px 32px;
}
.message-page h1 {
  font-size: 1.3rem;
  font-weight: 800;
  margin: 0 0 16px;
}
.message-body {
  margin: 0 0 12px;
}
.message-hint {
  color: var(--color-text-muted);
  font-size: 0.88rem;
  margin: 0 0 24px;
}
.message-actions {
  margin: 0;
}

.report-form {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 36px;
}
.form-group h2 {
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.option-grid-narrow {
  grid-template-columns: repeat(2, 1fr);
  max-width: 420px;
}
@media (max-width: 640px) {
  .option-grid {
    grid-template-columns: 1fr;
  }
  .option-grid-narrow {
    grid-template-columns: 1fr 1fr;
    max-width: none;
  }
}

.option-card {
  display: block;
  position: relative;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  background: var(--color-surface);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.option-card:hover {
  border-color: var(--color-primary);
}
.option-card input {
  position: absolute;
  opacity: 0;
}
.option-card input:checked ~ .option-title {
  color: var(--color-primary);
}
.option-card:has(input:checked) {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
  background: var(--color-primary-light);
}
.option-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.form-submit {
  text-align: center;
  margin-top: 8px;
}

/* ---------- テンプレートカード（アイコン＋名前＋説明） ---------- */
.template-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (max-width: 640px) {
  .template-grid {
    grid-template-columns: 1fr;
  }
}
.template-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 18px 16px;
}
.template-card-icon {
  font-size: 1.5rem;
  line-height: 1;
  margin-bottom: 4px;
}
.template-card-desc {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-weight: 400;
  line-height: 1.5;
}

/* ---------- Report page ---------- */
.demo-banner {
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning-border);
  color: var(--color-warning);
  font-weight: 700;
  font-size: 0.88rem;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  text-align: center;
}

.report-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 32px;
}
.report-header h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
  font-weight: 800;
}
.report-meta {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.88rem;
}
.report-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- レポートヘッダーのチップ（サイト名・期間） ---------- */
.report-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.report-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 6px 14px;
  border-radius: 999px;
  white-space: nowrap;
}
.report-chip-muted {
  background: var(--color-bg-alt);
  color: var(--color-text-muted);
  font-weight: 500;
}

/* ---------- KPIサマリーカード ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
@media (max-width: 860px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi-label {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-text-muted);
}
.kpi-value {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--color-text);
  letter-spacing: -0.01em;
}
.kpi-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.kpi-badge-row-yoy {
  margin-top: 2px;
}
.kpi-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
}
.kpi-badge-sm {
  font-size: 0.7rem;
  padding: 1px 8px;
  opacity: 0.85;
}
.kpi-badge-up {
  color: #15803d;
  background: #dcfce7;
}
.kpi-badge-down {
  color: #b91c1c;
  background: #fee2e2;
}
.kpi-badge-flat {
  color: var(--color-text-muted);
  background: var(--color-bg-alt);
}
@media (prefers-color-scheme: dark) {
  .kpi-badge-up {
    color: #4ade80;
    background: #14532d;
  }
  .kpi-badge-down {
    color: #f87171;
    background: #450a0a;
  }
}
.kpi-sub {
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

.chart-area {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
  margin-bottom: 32px;
}
@media (max-width: 860px) {
  .chart-area {
    grid-template-columns: 1fr;
  }
}
.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 20px;
}
.chart-card-wide {
  grid-column: 1 / -1;
}
.chart-card h2 {
  margin: 0 0 14px;
  font-size: 1rem;
}
.chart-canvas-wrap {
  position: relative;
  height: 280px;
}
.chart-canvas-tall {
  height: 420px;
}

.table-area {
  margin-bottom: 8px;
}

/* ---------- Data table (shared style with LP samples) ---------- */
.sample-table-wrap {
  overflow-x: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.sample-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 520px;
}
.sample-table th,
.sample-table td {
  padding: 12px 16px;
  text-align: right;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.sample-table th:first-child,
.sample-table td:first-child {
  text-align: left;
}
.sample-table thead th {
  background: var(--sheet-header-bg);
  color: var(--sheet-header-text);
  font-weight: 700;
}
.sample-table tbody tr:last-child td {
  border-bottom: none;
}
.sample-table tbody tr:nth-child(even) {
  background: var(--color-bg-alt);
}
.sample-table tbody tr:hover {
  background: var(--color-primary-light);
}
.table-area-extra {
  margin-top: 16px;
}

/* ---------- 所見・総評カード ---------- */
.insight-card {
  margin-top: 16px;
  margin-bottom: 8px;
  background: var(--color-primary-light);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}
.insight-card-overall {
  margin-top: 0;
  margin-bottom: 32px;
}
.insight-heading {
  margin: 0 0 10px;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--color-primary-dark);
}
.insight-list {
  margin: 0;
  padding-left: 1.2em;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--color-text);
}
.insight-list li {
  line-height: 1.6;
}

/* ---------- カスタム期間指定 ---------- */
.custom-range {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 10px;
}
.custom-range-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-muted);
}
.custom-range-field input[type="date"] {
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface);
  color: var(--color-text);
  font-family: inherit;
  font-size: 0.9rem;
}
.custom-range-sep {
  color: var(--color-text-muted);
}
.custom-range-note {
  width: 100%;
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ---------- 一括レポートのセクション ---------- */
.report-section {
  margin-bottom: 40px;
}
.section-heading {
  font-size: 1.3rem;
  font-weight: 800;
  margin: 36px 0 16px;
  padding-left: 12px;
  border-left: 4px solid var(--color-primary);
}

/* ---------- PDF保存ボタン ---------- */
.pdf-action {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pdf-note {
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

/* ---------- 印刷（PDF保存）用 ---------- */
@media print {
  .app-header,
  .app-footer,
  .report-actions,
  .demo-banner {
    display: none !important;
  }
  body {
    background: #fff;
  }
  .app-main {
    max-width: 100%;
    padding: 0;
  }
  .chart-area {
    display: block;
  }
  .chart-card,
  .sample-table-wrap,
  .kpi-card,
  .insight-card {
    box-shadow: none;
    border: 1px solid #ddd;
    break-inside: avoid;
    margin-bottom: 16px;
  }
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
    break-inside: avoid;
  }
  .report-chip {
    background: #fff;
    border: 1px solid #ddd;
    color: #333;
  }
  .chart-canvas-wrap {
    height: 280px !important;
  }
  .sample-table th,
  .sample-table td {
    font-size: 0.8rem;
    padding: 6px 10px;
  }
  /* 一括レポートはテンプレートごとに改ページする */
  .report-section + .report-section {
    break-before: page;
  }
}

/* ---------- レポート作成履歴 ---------- */
.history-page {
  max-width: 960px;
  margin: 0 auto;
}
.history-page h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0 0 24px;
}
.history-empty {
  margin: 0;
}
.history-table-wrap {
  overflow-x: auto;
}
.sample-table.history-table th,
.sample-table.history-table td {
  text-align: left;
}
.history-actions {
  text-align: right !important;
  white-space: nowrap;
}
.btn-sm {
  padding: 8px 16px;
  font-size: 0.82rem;
}
.history-actions .btn-sm + .btn-sm {
  margin-left: 8px;
}
