:root {
  --navy: #1c3f6e;
  --navy-d: #14304f;
  --navy-l: #e8eef6;
  --accent: #c07a2c;
  --ink: #1b2430;
  --ink-2: #5a6675;
  --ink-3: #8c98a6;
  --line: #e2e7ee;
  --bg: #f5f7fa;
  --white: #fff;
  --ok: #2e7d5b;
  --warn: #b4741d;
  --danger: #c0453c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20,40,70,.06), 0 6px 20px rgba(20,40,70,.05);
  --diff-add: #e6f4ea;
  --diff-del: #fdecea;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", "Yu Gothic", "Hiragino Sans", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: .01em; }
p { margin: 0; }
a { color: var(--navy); }
input, textarea, select, button { font-family: inherit; font-size: 14px; color: inherit; }

/* ---------- header ---------- */
.app-header {
  background: var(--white);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.header-inner {
  max-width: 1180px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; text-decoration: none; color: inherit; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 7px; flex: none;
  background: linear-gradient(140deg, var(--navy) 55%, var(--accent) 55%);
}
.brand-title { font-weight: 700; font-size: 15px; letter-spacing: .02em; }
.brand-sub { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topnav { display: flex; gap: 4px; flex-wrap: wrap; }
.topnav a {
  border: 0; background: none; cursor: pointer; padding: 8px 12px;
  color: var(--ink-2); border-radius: 7px; white-space: nowrap;
  font-size: 13px; text-decoration: none;
}
.topnav a:hover { color: var(--navy); background: var(--bg); }
.topnav a.active { color: var(--navy); background: var(--navy-l); font-weight: 700; }

/* ---------- layout ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 24px 20px 64px; }
.pane-head { margin-bottom: 18px; }
.pane-head h1 { font-size: 22px; margin-bottom: 6px; }
.pane-head p { color: var(--ink-2); font-size: 13px; max-width: 860px; }

.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card-title { font-size: 14px; margin-bottom: 12px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head .card-title { margin-bottom: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.muted-sm { font-size: 12px; color: var(--ink-3); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.btn {
  border: 1px solid var(--line); background: var(--white); border-radius: 7px;
  padding: 7px 13px; cursor: pointer; font-size: 13px; font-weight: 500;
  transition: all .15s; white-space: nowrap; text-decoration: none; display: inline-block;
}
.btn:hover { border-color: var(--navy); color: var(--navy); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-d); border-color: var(--navy-d); color: #fff; }
.btn-sm { padding: 4px 9px; font-size: 12px; }

/* ---------- hero (home) ---------- */
.hero { margin-bottom: 20px; }
.hero h1 { font-size: 24px; margin-bottom: 8px; }
.hero .sub { color: var(--ink-2); font-size: 14px; margin-bottom: 6px; }
.hero .generated { font-size: 12px; color: var(--ink-3); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: #fcfdfe; }
.stat-label { font-size: 11px; color: var(--ink-3); }
.stat-value { font-size: 24px; font-weight: 700; color: var(--navy); line-height: 1.3; }
.stat-value small { font-size: 12px; color: var(--ink-3); font-weight: 500; margin-left: 3px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 3px; border-radius: 8px; margin-bottom: 14px; width: fit-content; }
.tab-btn {
  border: 0; background: none; padding: 7px 16px; border-radius: 6px;
  cursor: pointer; font-size: 13px; color: var(--ink-2);
}
.tab-btn.active { background: #fff; color: var(--navy); font-weight: 700; box-shadow: 0 1px 3px rgba(20,40,70,.10); }

/* ---------- bars ---------- */
.barlist { display: flex; flex-direction: column; gap: 8px; }
.barrow { display: grid; grid-template-columns: 96px 1fr 52px; gap: 10px; align-items: center; font-size: 12px; }
.barrow .barlabel { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barrow .bartrack { height: 12px; border-radius: 4px; background: var(--navy-l); overflow: hidden; }
.barrow .barfill { display: block; height: 100%; background: var(--navy); border-radius: 4px; }
.barrow .barcount { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* ---------- badges / chips ---------- */
.badge { display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.badge-細分化 { background: #e7f3ec; border-color: #b9dcc8; color: var(--ok); }
.badge-同等 { background: #eef1f5; border-color: var(--line); color: var(--ink-2); }
.badge-粗くなった { background: #fdf3e3; border-color: #e8d3ac; color: var(--warn); }
.badge-判定不能 { background: #fdecea; border-color: #f0c2bd; color: var(--danger); }
.badge-muted { background: #f0f2f5; border-color: var(--line); color: var(--ink-3); }

.chips-static { display: flex; flex-wrap: wrap; gap: 5px; }
.chip-static {
  display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--navy-l); color: var(--navy); white-space: nowrap;
}

.pct-up { color: var(--ok); font-variant-numeric: tabular-nums; }
.pct-down { color: var(--danger); font-variant-numeric: tabular-nums; }
.pct-zero { color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table.data { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; background: #fff; }
table.data th, table.data td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; white-space: nowrap; }
table.data thead th {
  position: sticky; top: 0; background: #f0f3f8; z-index: 2; font-weight: 700;
  font-size: 12px; color: var(--ink-2);
}
table.data thead th.sortable { cursor: pointer; user-select: none; }
table.data thead th.sortable:hover { color: var(--navy); }
table.data thead th .arrow { font-size: 10px; margin-left: 3px; color: var(--ink-3); }
table.data tbody tr:hover td { background: #f8fafc; cursor: pointer; }
table.data tbody tr.row-pending td { color: var(--ink-3); background: #fbfbfc; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.name-cell { white-space: normal; min-width: 180px; }
table.data td.name-cell a { color: var(--ink); text-decoration: none; font-weight: 500; }
table.data td.name-cell a:hover { color: var(--navy); text-decoration: underline; }

/* ---------- list filters ---------- */
.filters { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 14px; }
.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-group .fg-label { font-size: 11px; color: var(--ink-3); font-weight: 500; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; max-width: 420px; }
.filter-chip {
  border: 1px solid var(--line); background: var(--white); border-radius: 999px;
  padding: 4px 12px; font-size: 12px; cursor: pointer; transition: all .15s;
}
.filter-chip:hover { border-color: var(--navy); }
.filter-chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.filter-check { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.search-input {
  width: 100%; max-width: 320px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px;
  background: #fcfdfe;
}
.search-input:focus { outline: 0; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(28,63,110,.09); background: #fff; }
.result-count { font-size: 12px; color: var(--ink-3); margin-bottom: 10px; }

/* ---------- mobile card list ---------- */
.card-list { display: none; flex-direction: column; gap: 8px; }
.company-card {
  border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 12px; cursor: pointer;
}
.company-card.row-pending { color: var(--ink-3); background: #fbfbfc; }
.company-card .cc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.company-card .cc-code { font-family: ui-monospace, monospace; color: var(--ink-3); font-size: 11px; }
.company-card .cc-name { font-weight: 700; font-size: 14px; margin: 4px 0 8px; }
.company-card .cc-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12px; }

@media (max-width: 720px) {
  .table-wrap { display: none; }
  .card-list { display: flex; }
}

/* ---------- about ---------- */
.def-block { margin-bottom: 14px; }
.def-block h3 { font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.def-block p { font-size: 13px; line-height: 1.8; }
table.simple { border-collapse: collapse; width: 100%; font-size: 13px; }
table.simple th, table.simple td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
table.simple th { background: #f0f3f8; font-size: 12px; color: var(--ink-2); }
ul.notes { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.9; }
ul.notes li { margin-bottom: 4px; }
.rubric-body { font-size: 13px; line-height: 1.85; }
.rubric-body h1, .rubric-body h2 { font-size: 15px; margin: 16px 0 8px; }
.rubric-body h1:first-child, .rubric-body h2:first-child { margin-top: 0; }
.rubric-body ul { padding-left: 20px; margin: 8px 0; }
.rubric-body strong { font-weight: 700; }

/* ---------- boot / empty / error ---------- */
.boot { text-align: center; color: var(--ink-3); font-size: 13px; padding: 80px 0; }
.spinner {
  width: 26px; height: 26px; margin: 0 auto 12px;
  border: 3px solid var(--navy-l); border-top-color: var(--navy);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty { color: var(--ink-3); font-size: 13px; padding: 30px; text-align: center; border: 1px dashed var(--line); border-radius: 8px; }
.error-box { color: var(--danger); font-size: 13px; padding: 30px; text-align: center; border: 1px dashed #f0c2bd; border-radius: 8px; background: #fdecea; }

/* ---------- footer ---------- */
.app-footer { border-top: 1px solid var(--line); background: #fff; padding: 14px 20px; text-align: center; font-size: 11px; color: var(--ink-3); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: rgba(24,36,52,.94); color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; z-index: 200; box-shadow: 0 8px 28px rgba(0,0,0,.25); max-width: 90vw;
}
.toast[hidden] { display: none; }

/* ---------- nav badge ---------- */
.nav-badge {
  display: inline-block; min-width: 16px; margin-left: 5px; padding: 0 5px;
  border-radius: 999px; background: var(--accent); color: #fff; font-size: 10px;
  font-weight: 700; text-align: center; line-height: 16px; vertical-align: middle;
}
.nav-badge[hidden] { display: none; }

/* ---------- company screen ---------- */
.company-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.company-head-main { min-width: 0; flex: 1 1 320px; }
.company-head-main h1 { font-size: 20px; margin-bottom: 6px; }
.company-meta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.company-headline-row { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.company-headline { font-size: 13px; color: var(--ink-2); flex: 1 1 auto; }
.company-head-nav { flex: 0 0 auto; }
.pn-links { display: flex; gap: 8px; flex-wrap: wrap; }
.pn-disabled { color: var(--ink-3); cursor: default; opacity: .5; }
.pn-disabled:hover { border-color: var(--line); color: var(--ink-3); }

.mini-head { font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.clip-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.reason-block {
  font-size: 15px; line-height: 1.8; padding: 14px 16px; margin-top: 4px;
  background: #fdecea; border: 1px solid #f0c2bd; border-radius: 8px; color: var(--ink);
}

table.metrics-table th:first-child { width: 140px; color: var(--ink-2); font-weight: 500; background: #fff; }
table.metrics-table td { font-variant-numeric: tabular-nums; }

.fulltext-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .fulltext-grid { grid-template-columns: 1fr; } }
.fulltext-col { min-width: 0; }
.ft-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.ft-label { font-weight: 700; font-size: 13px; }
.ft-charcount { font-size: 12px; color: var(--ink-3); }
.fulltext-body {
  border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: #fcfdfe;
  font-size: 13px; line-height: 1.9; max-height: 640px; overflow-y: auto;
  user-select: text;
}
.fulltext-body p { margin-bottom: 12px; }
.fulltext-body p:last-child { margin-bottom: 0; }
.fulltext-body .diff-add { background: var(--diff-add); }
.fulltext-body .diff-del { background: var(--diff-del); }

.clip-float-btn {
  position: absolute; z-index: 150; border: 1px solid var(--navy); background: var(--navy); color: #fff;
  border-radius: 999px; padding: 6px 14px; font-size: 12px; font-weight: 500; cursor: pointer;
  box-shadow: 0 6px 18px rgba(20,40,70,.25);
}
.clip-float-btn:hover { background: var(--navy-d); }

/* ---------- clips screen ---------- */
.clip-cards { display: flex; flex-direction: column; gap: 12px; }
.clip-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.clip-card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.clip-select-label { margin: 0; }
.clip-company { font-weight: 700; color: var(--ink); text-decoration: none; }
.clip-company:hover { color: var(--navy); text-decoration: underline; }
.clip-date { margin-left: auto; }
.clip-text { font-size: 13px; line-height: 1.8; white-space: pre-wrap; margin-bottom: 6px; }
.clip-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0; }
.clip-tag { display: inline-flex; align-items: center; gap: 4px; }
.clip-tag-remove { border: 0; background: none; cursor: pointer; color: var(--ink-3); font-size: 12px; padding: 0; line-height: 1; }
.clip-tag-remove:hover { color: var(--danger); }
.clip-tag-input {
  border: 1px dashed var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px;
  background: #fcfdfe; width: 160px;
}
.clip-memo {
  width: 100%; min-height: 56px; border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px;
  font-size: 13px; resize: vertical; background: #fcfdfe; margin-bottom: 10px;
}
.clip-memo:focus { outline: 0; border-color: var(--navy); background: #fff; }
.sort-select { border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; background: #fcfdfe; }
