:root {
  --ink: #162b3a;
  --ink-soft: #52636f;
  --paper: #f5f8fa;
  --surface: #ffffff;
  --line: #d9e2e7;
  --line-dark: #b8c7d0;
  --blue: #176b87;
  --blue-soft: #dceef3;
  --coral: #dd6048;
  --coral-soft: #f8e5e0;
  --amber: #d39b2a;
  --amber-soft: #f5ecd6;
  --green: #2c7864;
  --green-soft: #dcece7;
  --shadow: 0 18px 42px rgba(28, 56, 72, 0.11);
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input, select { font: inherit; }
button, select, label.file-button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, label.file-button:focus-within {
  outline: 3px solid rgba(23, 107, 135, 0.25);
  outline-offset: 2px;
}

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 228px minmax(0, 1fr); }
.side-rail {
  position: sticky; top: 0; height: 100vh; padding: 28px 18px; color: #edf7fa;
  background: #173343; display: flex; flex-direction: column; z-index: 4;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 28px; color: white; text-decoration: none; font-weight: 800; letter-spacing: .02em; }
.brand-mark { width: 27px; height: 27px; display: flex; align-items: end; gap: 3px; padding: 5px; border: 1px solid #72a9b9; border-radius: 7px 7px 2px 7px; }
.brand-mark i { flex: 1; background: #86c0ce; border-radius: 2px 2px 0 0; }
.brand-mark i:nth-child(1) { height: 35%; }
.brand-mark i:nth-child(2) { height: 90%; background: #f0b64d; }
.brand-mark i:nth-child(3) { height: 60%; }
.primary-nav { display: grid; gap: 7px; }
.nav-item { width: 100%; border: 0; color: #bcd1d9; background: transparent; display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 7px; cursor: pointer; text-align: left; }
.nav-item:hover { color: white; background: rgba(255,255,255,.06); }
.nav-item.active { color: white; background: #285063; }
.nav-icon { width: 24px; font-size: 21px; text-align: center; }
.nav-count { margin-left: auto; min-width: 22px; padding: 2px 7px; border-radius: 999px; background: rgba(255,255,255,.12); font-size: 12px; text-align: center; }
.rail-note { margin-top: auto; padding: 14px 10px 4px; border-top: 1px solid rgba(255,255,255,.12); display: flex; gap: 9px; align-items: flex-start; }
.rail-note div { display: grid; gap: 2px; }
.rail-note strong { font-size: 12px; }
.rail-note span:last-child { color: #9eb9c4; font-size: 11px; }
.status-dot { margin-top: 5px; width: 8px; height: 8px; border-radius: 50%; background: #5bc49c; box-shadow: 0 0 0 4px rgba(91,196,156,.14); }

main { min-width: 0; }
.topbar { min-height: 118px; padding: 28px 36px 22px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); background: rgba(245,248,250,.9); }
.kicker { margin: 0 0 3px; color: var(--ink-soft); font-size: 12px; }
h1 { margin: 0; font-size: 28px; letter-spacing: -.04em; }
.topbar-actions { display: flex; gap: 8px; }
.button { min-height: 40px; border: 1px solid var(--line-dark); padding: 9px 15px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 700; }
.button.secondary { color: var(--ink); background: var(--surface); }
.button.secondary:hover { border-color: var(--blue); color: var(--blue); }
.file-button input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }

.strategy-strip { padding: 22px 36px; display: grid; grid-template-columns: repeat(4, minmax(180px, 1fr)); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.strategy { border: 0; min-height: 82px; padding: 15px 16px; background: var(--surface); display: grid; grid-template-columns: 34px minmax(0,1fr) auto; gap: 10px; align-items: center; color: var(--ink); cursor: pointer; text-align: left; }
.strategy:first-child { border-radius: 8px 0 0 8px; }
.strategy:last-child { border-radius: 0 8px 8px 0; }
.strategy:hover { background: #fbfdfe; }
.strategy.active { position: relative; background: #edf6f8; box-shadow: inset 0 -3px var(--blue); }
.strategy-symbol { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--ink); font-size: 12px; font-weight: 800; }
.strategy-symbol.demand { background: var(--blue); }
.strategy-symbol.improve { background: var(--coral); }
.strategy-symbol.gap { background: var(--amber); color: #49340b; }
.strategy span:nth-child(2) { min-width: 0; display: grid; gap: 4px; }
.strategy strong { font-size: 13px; white-space: nowrap; }
.strategy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); font-size: 11px; }
.strategy b { color: var(--ink-soft); font-size: 18px; font-weight: 600; }

.summary-band { min-height: 116px; padding: 20px 36px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 28px; }
.headline-metric { min-width: 150px; display: grid; grid-template-columns: auto auto; align-items: baseline; column-gap: 8px; }
.headline-metric span { grid-column: 1 / -1; color: var(--ink-soft); font-size: 12px; }
.headline-metric strong { font-size: 42px; line-height: 1; letter-spacing: -.06em; color: var(--blue); }
.headline-metric small { color: var(--ink-soft); font-size: 11px; }
.summary-divider { height: 56px; width: 1px; background: var(--line); }
.mini-metric { min-width: 128px; display: grid; gap: 6px; }
.mini-metric span { color: var(--ink-soft); font-size: 11px; }
.mini-metric strong { font-size: 20px; letter-spacing: -.02em; }
.score-key { margin-left: auto; display: grid; gap: 7px; font-size: 11px; color: var(--ink-soft); }
.score-key span { display: flex; align-items: center; gap: 7px; }
.key-dot { width: 8px; height: 8px; border-radius: 50%; }
.key-dot.high { background: var(--green); }
.key-dot.mid { background: var(--amber); }

.workbench { padding: 24px 36px 44px; }
.filter-row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 30px; }
.search-field { min-width: 280px; flex: 1; height: 43px; border: 1px solid var(--line-dark); background: var(--surface); border-radius: 7px; display: flex; align-items: center; gap: 9px; padding: 0 13px; }
.search-field:focus-within { border-color: var(--blue); }
.search-field span { font-size: 21px; color: var(--ink-soft); }
.search-field input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; }
.select-field { min-width: 140px; display: grid; gap: 5px; }
.select-field.compact { min-width: 118px; }
.select-field span, .sort-field span { color: var(--ink-soft); font-size: 10px; }
select { height: 43px; border: 1px solid var(--line-dark); border-radius: 7px; padding: 0 32px 0 11px; color: var(--ink); background: var(--surface); cursor: pointer; }
.text-button { height: 43px; padding: 0 6px; border: 0; background: transparent; color: var(--blue); cursor: pointer; font-size: 12px; }
.results-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 13px; }
.results-heading h2 { margin: 0 0 4px; font-size: 19px; letter-spacing: -.02em; }
.results-heading p { margin: 0; color: var(--ink-soft); font-size: 12px; }
.sort-field { display: grid; gap: 5px; }
.sort-field select { height: 36px; min-width: 160px; }

.table-wrap { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: auto; }
table { width: 100%; min-width: 950px; border-collapse: collapse; }
th { height: 44px; padding: 0 13px; color: var(--ink-soft); background: #edf2f5; border-bottom: 1px solid var(--line); font-size: 10px; font-weight: 700; text-align: left; white-space: nowrap; }
td { padding: 14px 13px; border-bottom: 1px solid #e7edf0; font-size: 12px; vertical-align: middle; }
tbody tr { cursor: pointer; transition: background .12s ease; }
tbody tr:hover { background: #f7fbfc; }
tbody tr:last-child td { border-bottom: 0; }
.save-column { width: 45px; text-align: center; }
.save-button { width: 30px; height: 30px; border: 0; background: transparent; cursor: pointer; color: #8da0aa; font-size: 20px; line-height: 1; border-radius: 50%; }
.save-button:hover { background: var(--blue-soft); color: var(--blue); }
.save-button.saved { color: var(--coral); }
.product-cell { min-width: 220px; }
.product-name { display: block; margin-bottom: 4px; font-weight: 800; font-size: 13px; }
.product-meta { display: flex; gap: 8px; color: var(--ink-soft); font-size: 10px; }
.reason-tags { display: flex; gap: 5px; flex-wrap: wrap; max-width: 230px; }
.tag { padding: 4px 7px; border-radius: 3px; background: #eaf0f3; color: #445863; font-size: 10px; white-space: nowrap; }
.tag.demand { background: var(--blue-soft); color: #14566b; }
.tag.improve { background: var(--coral-soft); color: #a83d2d; }
.tag.gap { background: var(--amber-soft); color: #7a5712; }
.market { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.market-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); }
.market-dot.rakuten { background: var(--coral); }
.market-dot.yahoo { background: #7b66aa; }
.number { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-soft); }
.rating-low { color: var(--coral); font-weight: 800; }
.score-column { min-width: 128px; }
.score-block { display: grid; grid-template-columns: 36px 1fr; gap: 8px; align-items: center; }
.score-value { font-size: 17px; font-weight: 850; font-variant-numeric: tabular-nums; }
.score-bar { height: 5px; border-radius: 99px; overflow: hidden; background: #e3eaed; }
.score-bar i { display: block; height: 100%; background: var(--amber); border-radius: inherit; }
.score-block.high .score-value { color: var(--green); }
.score-block.high .score-bar i { background: var(--green); }
.score-block.low .score-value { color: var(--ink-soft); }
.score-block.low .score-bar i { background: #91a2aa; }
.empty-state { padding: 72px 24px; text-align: center; color: var(--ink-soft); }
.empty-state strong, .empty-state span { display: block; }
.empty-state strong { color: var(--ink); margin-bottom: 6px; }

.detail-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 44px); padding: 0; border: 0; border-radius: 10px; color: var(--ink); box-shadow: 0 28px 80px rgba(9,30,40,.3); }
.detail-dialog::backdrop { background: rgba(12, 33, 44, .5); backdrop-filter: blur(2px); }
.dialog-head { padding: 24px 26px 19px; display: flex; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 4px 0 4px; font-size: 22px; }
.dialog-head p { margin: 0; color: var(--ink-soft); font-size: 12px; }
.close-button { width: 36px; height: 36px; flex: 0 0 auto; border: 1px solid var(--line); background: white; border-radius: 50%; cursor: pointer; font-size: 19px; }
.dialog-body { padding: 22px 26px 26px; }
.dialog-scoreline { display: grid; grid-template-columns: 120px 1fr; gap: 22px; margin-bottom: 24px; }
.big-score { padding: 16px; color: white; background: var(--ink); border-radius: 8px 8px 2px 8px; }
.big-score span { display: block; font-size: 11px; opacity: .72; }
.big-score strong { display: block; margin-top: 4px; font-size: 38px; line-height: 1; }
.verdict { align-self: center; }
.verdict strong { display: block; margin-bottom: 5px; font-size: 14px; }
.verdict p { margin: 0; color: var(--ink-soft); line-height: 1.7; font-size: 12px; }
.market-grid { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); margin-bottom: 22px; }
.market-card { padding: 14px; border-right: 1px solid var(--line); }
.market-card:last-child { border: 0; }
.market-card h3 { margin: 0 0 13px; font-size: 12px; }
.market-stat { display: flex; justify-content: space-between; padding: 6px 0; border-top: 1px dashed var(--line); font-size: 11px; }
.market-stat span { color: var(--ink-soft); }
.market-stat strong { font-variant-numeric: tabular-nums; }
.insight-box { padding: 17px 18px; border-left: 4px solid var(--coral); background: #faf4f1; }
.insight-box h3 { margin: 0 0 7px; font-size: 13px; }
.insight-box p { margin: 0; line-height: 1.7; color: #5b4b46; font-size: 12px; }
.dialog-actions { padding-top: 20px; display: flex; justify-content: flex-end; gap: 8px; }
.button.primary { color: white; background: var(--blue); border-color: var(--blue); }
.button.primary:hover { background: #105c76; }
.button:disabled { cursor: wait; opacity: .58; }
.rakuten-dialog { width: min(590px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 10px; color: var(--ink); box-shadow: 0 28px 80px rgba(9,30,40,.3); }
.rakuten-dialog::backdrop { background: rgba(12, 33, 44, .5); backdrop-filter: blur(2px); }
.rakuten-dialog .dialog-head h2 { margin-top: 2px; }
.rakuten-form-body { padding: 23px 26px 26px; display: grid; grid-template-columns: 1fr 130px; gap: 17px 12px; }
.rakuten-form-body label { display: grid; gap: 6px; }
.rakuten-form-body label > span { color: var(--ink-soft); font-size: 11px; }
.rakuten-form-body input { height: 43px; width: 100%; border: 1px solid var(--line-dark); border-radius: 7px; padding: 0 12px; color: var(--ink); }
.live-data-note { grid-column: 1 / -1; padding: 13px 15px; display: grid; gap: 4px; border-left: 3px solid var(--blue); background: var(--blue-soft); }
.live-data-note strong { font-size: 12px; }
.live-data-note span { color: var(--ink-soft); font-size: 11px; line-height: 1.55; }
.form-status { grid-column: 1 / -1; min-height: 18px; margin: -3px 0 0; color: var(--coral); font-size: 11px; }
.rakuten-form-body .dialog-actions { grid-column: 1 / -1; padding-top: 0; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 20; transform: translate(-50%, 18px); padding: 11px 16px; color: white; background: var(--ink); border-radius: 6px; font-size: 12px; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 1080px) {
  .strategy-strip { grid-template-columns: repeat(2, 1fr); }
  .strategy, .strategy:first-child, .strategy:last-child { border-radius: 0; }
  .summary-band { gap: 20px; }
  .score-key { display: none; }
}

@media (max-width: 900px) {
  .app-shell { display: block; }
  .side-rail { position: static; width: 100%; height: auto; padding: 14px 16px; flex-direction: row; align-items: center; }
  .brand { padding: 0; margin-right: auto; }
  .primary-nav { display: flex; }
  .nav-item { width: auto; padding: 9px; }
  .nav-item span:not(.nav-icon) { display: none; }
  .rail-note { display: none; }
  .topbar { min-height: auto; padding: 20px 18px; align-items: flex-start; gap: 16px; }
  .kicker { display: none; }
  h1 { font-size: 23px; }
  .topbar-actions { flex-direction: column; }
  .button { min-height: 36px; padding: 7px 10px; font-size: 11px; text-align: center; }
  .strategy-strip { padding: 14px 18px; display: flex; overflow-x: auto; }
  .strategy { min-width: 210px; min-height: 70px; }
  .summary-band { padding: 18px; overflow-x: auto; }
  .summary-divider { display: none; }
  .mini-metric { min-width: 108px; }
  .workbench { padding: 19px 18px 36px; }
  .search-field { min-width: 100%; }
  .select-field { flex: 1; }
  .results-heading { align-items: flex-start; gap: 15px; }
  .results-heading p { display: none; }
  .dialog-scoreline { grid-template-columns: 1fr; }
  .market-grid { grid-template-columns: 1fr; }
  .market-card { border-right: 0; border-bottom: 1px solid var(--line); }
  .rakuten-form-body { grid-template-columns: 1fr; }
  .rakuten-form-body > * { grid-column: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
