:root {
  --blue-950: #09264a;
  --blue-800: #0b4c8c;
  --blue-600: #1479d1;
  --blue-100: #e8f3ff;
  --cyan: #26a6d1;
  --green: #07966f;
  --green-bg: #e9f8f2;
  --red: #d94a55;
  --red-bg: #fff0f1;
  --amber: #d88a13;
  --ink: #172235;
  --muted: #68778d;
  --line: #dfe7f0;
  --surface: #fff;
  --page: #f4f8fc;
  --shadow: 0 12px 35px rgba(20, 55, 90, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: "Noto Sans JP", system-ui, sans-serif;
  line-height: 1.65;
}
button, input, select { font: inherit; }
button, label.button { cursor: pointer; }
.muted { margin: .35rem 0 0; color: var(--muted); font-size: .9rem; }
.eyebrow {
  margin: 0 0 .2rem;
  color: var(--blue-600);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .13em;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 26px clamp(20px, 5vw, 72px);
  color: #fff;
  background:
    radial-gradient(circle at 80% -40%, rgba(63, 181, 255, .5), transparent 42%),
    linear-gradient(130deg, var(--blue-950), var(--blue-800));
}
.app-header .eyebrow { color: #7ed3ff; }
.app-header .muted { color: rgba(255,255,255,.72); }
h1 { margin: 0; font-size: clamp(1.45rem, 3vw, 2.1rem); line-height: 1.3; }
h2, h3 { margin: 0; line-height: 1.35; }
h2 { font-size: clamp(1.25rem, 2vw, 1.6rem); }
h3 { font-size: 1rem; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.status-pill {
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 99px;
  background: rgba(255,255,255,.1);
  font-size: .78rem;
  font-weight: 700;
}
.status-pill.success { color: #baf5dd; }
.status-pill.error { color: #ffd4d7; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 15px;
  border: 0;
  border-radius: 10px;
  font-size: .84rem;
  font-weight: 700;
  text-decoration: none;
}
.button-primary { color: var(--blue-950); background: #fff; }
.button-secondary { color: #fff; border: 1px solid rgba(255,255,255,.35); background: transparent; }

main { width: min(1500px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 70px; }
section { margin-top: 42px; }
.filter-panel { margin-top: 0; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.section-heading { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 17px; }
.section-heading.compact { margin-bottom: 14px; }
.text-button { align-self: center; padding: 5px; border: 0; color: var(--blue-600); background: none; font-weight: 700; }
.filter-grid { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 12px; }
.filter-grid label { color: var(--muted); font-size: .78rem; font-weight: 700; }
select, input[type="date"] {
  width: 100%;
  min-height: 44px;
  margin-top: 5px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
}
select:focus, input:focus { outline: 3px solid rgba(20,121,209,.15); border-color: var(--blue-600); }
.filter-summary { margin: 14px 0 0; color: var(--blue-800); font-size: .85rem; font-weight: 600; }

.message { margin-top: 18px; padding: 14px 16px; border: 1px solid #ffc7ca; border-radius: 12px; color: #8b2831; background: var(--red-bg); }
.loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--blue-950);
  background: rgba(244,248,252,.9);
  backdrop-filter: blur(5px);
}
.loading[hidden] { display: none; }
.spinner { width: 24px; height: 24px; border: 3px solid var(--blue-100); border-top-color: var(--blue-600); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(220px, 1fr)); gap: 14px; }
.kpi-card {
  min-height: 164px;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.kpi-card.featured { color: #fff; border: 0; background: linear-gradient(145deg, var(--blue-800), var(--blue-600)); }
.kpi-label { margin: 0; color: var(--muted); font-size: .82rem; font-weight: 700; }
.featured .kpi-label { color: rgba(255,255,255,.75); }
.kpi-value { margin: 12px 0 5px; font-size: clamp(1.75rem, 3vw, 2.5rem); font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.kpi-unit { margin-left: .2em; font-size: .42em; letter-spacing: 0; }
.kpi-rank { margin: 9px 0 0; color: var(--muted); font-size: .75rem; }
.featured .kpi-rank { color: rgba(255,255,255,.74); }
.comparison { display: inline-flex; margin-top: 10px; padding: 4px 8px; border-radius: 99px; font-size: .72rem; font-weight: 700; }
.comparison.up { color: var(--green); background: var(--green-bg); }
.comparison.down { color: var(--red); background: var(--red-bg); }
.comparison.flat { color: var(--muted); background: #eef2f6; }
.featured .comparison { border: 1px solid rgba(255,255,255,.22); color: #fff; background: rgba(255,255,255,.12); }
.featured .comparison.up { color: #064e3b; background: #c8f6e3; }
.featured .comparison.down { color: #9a2530; background: #ffe1e4; }
.featured .comparison.flat { color: #fff; background: rgba(255,255,255,.12); }
.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(140px, 1fr)); gap: 10px; }
.summary-card { padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.summary-card.featured { color: #fff; border: 0; background: linear-gradient(145deg, var(--blue-800), var(--blue-600)); box-shadow: var(--shadow); }
.summary-label { margin: 0; color: var(--muted); font-size: .72rem; font-weight: 700; }
.summary-card.featured .summary-label { color: rgba(255,255,255,.76); }
.summary-value { margin: 7px 0 0; color: var(--blue-950); font-size: 1.35rem; font-weight: 800; line-height: 1.2; }
.summary-card.featured .summary-value { color: #fff; font-size: clamp(1.7rem, 3vw, 2.35rem); }
.summary-value small { margin-left: .2em; font-size: .58em; color: var(--muted); }
.summary-card.featured .summary-value small { color: rgba(255,255,255,.72); }
.summary-rank { margin: 8px 0 0; color: var(--muted); font-size: .74rem; font-weight: 700; }
.summary-card.featured .summary-rank { color: rgba(255,255,255,.78); }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.chart-panel { min-width: 0; padding: 20px; }
.chart-wide { grid-column: span 1; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 8px; }
.panel-title span { color: var(--muted); font-size: .74rem; }
.chart-box { position: relative; height: 300px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .8rem; white-space: nowrap; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: right; }
th { position: sticky; top: 0; z-index: 1; color: var(--muted); background: #f8fbfe; font-size: .72rem; }
th:first-child, td:first-child { text-align: left; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f7fbff; }
.error-cell { max-width: 390px; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.text-cell { max-width: 440px; white-space: normal; text-align: left; }
.sibling-table-wrap { max-width: 980px; }
.sibling-table { table-layout: fixed; }
.sibling-table th,
.sibling-table td { text-align: left; vertical-align: top; }
.sibling-table th:nth-child(1),
.sibling-table td:nth-child(1) { width: 140px; }
.sibling-table th:nth-child(2),
.sibling-table td:nth-child(2) { width: 48%; }
.sibling-table th:nth-child(3),
.sibling-table td:nth-child(3) { width: 34%; }
.sibling-table .text-cell { max-width: none; }

.voice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.voice-panel { min-width: 0; padding: 20px; }
.voice-panel h3 { margin-bottom: 14px; }
.attention-panel { border-top: 4px solid var(--red); }
.voice-grid .attention-panel,
.voice-grid .advice-panel { grid-column: span 1; }
.advice-panel { border-top: 4px solid var(--green); }
.keyword-cloud { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.keyword {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 99px;
  color: var(--blue-800);
  background: var(--blue-100);
  font-size: .76rem;
  font-weight: 700;
}
.review-list { display: grid; gap: 10px; }
.review {
  padding: 11px 12px;
  border-left: 3px solid var(--blue-600);
  border-radius: 0 9px 9px 0;
  background: #f7fafe;
  font-size: .82rem;
}
.attention-panel .review { border-color: var(--red); background: #fff7f7; }
.review p { display: -webkit-box; margin: 0; overflow: hidden; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.review time { display: block; margin-top: 5px; color: var(--muted); font-size: .68rem; }
.review-meta {
  display: inline-flex;
  margin-top: 7px;
  padding: 3px 8px;
  border-radius: 99px;
  color: #9a2530;
  background: #ffe5e7;
  font-size: .68rem;
  font-weight: 700;
}
.advice-list { display: grid; gap: 11px; }
.advice-item {
  padding: 13px;
  border: 1px solid #cfeee2;
  border-radius: 12px;
  background: var(--green-bg);
}
.advice-item div { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.advice-item strong { color: #065f49; font-size: .9rem; }
.advice-item span {
  flex: 0 0 auto;
  padding: 2px 7px;
  border-radius: 99px;
  color: #065f49;
  background: rgba(255,255,255,.75);
  font-size: .68rem;
  font-weight: 800;
}
.advice-item p { margin: 7px 0 0; font-size: .82rem; }
.empty { margin: 0; color: var(--muted); font-size: .82rem; }
footer { padding: 24px 20px; border-top: 1px solid var(--line); color: var(--muted); background: #fff; text-align: center; font-size: .75rem; }

@media (min-width: 1250px) {
  .chart-wide { grid-column: span 1; }
}
@media (max-width: 1100px) {
  .filter-grid { grid-template-columns: repeat(3, 1fr); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-grid { grid-template-columns: repeat(4, 1fr); }
  .voice-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .app-header { align-items: flex-start; flex-direction: column; padding: 22px 20px; }
  .header-actions { justify-content: flex-start; }
  main { width: min(100% - 24px, 1500px); padding-top: 12px; }
  section { margin-top: 30px; }
  .filter-panel { padding: 16px; }
  .filter-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-card { min-height: 150px; padding: 16px; }
  .chart-grid, .voice-grid { grid-template-columns: 1fr; }
  .chart-box { height: 275px; }
  .panel-title { align-items: flex-start; flex-direction: column; gap: 2px; }
}
@media (max-width: 430px) {
  .filter-grid, .kpi-grid, .summary-grid { grid-template-columns: 1fr; }
  .kpi-card { min-height: 135px; }
  .header-actions .button { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; }
}
