@charset "UTF-8";

/* ===== トークン ===== */
:root {
  --ground: #F1F4F5;
  --surface: #FFFFFF;
  --surface-2: #E9EDEF;
  --ink: #16242B;
  --ink-2: #445A61;
  --ink-3: #6E848C;
  --rule: #D5DDE0;
  --rule-strong: #B6C4C9;
  --accent: #0F6E8C;
  --accent-dark: #0B5570;
  --accent-soft: #DDEBF1;
  --signal: #8F550F;
  --signal-soft: #F7ECDC;
  --good: #1D6B50;
  --good-soft: #DEEEE7;
  --danger: #A32C2C;
  --danger-soft: #F7E3E3;
  --shadow: 0 1px 2px rgba(22, 36, 43, .06), 0 10px 28px -20px rgba(22, 36, 43, .30);

  --font: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, -apple-system, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-dark); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ===== ヘッダー ===== */
.appbar {
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 40;
}
.appbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 56px;
}
.brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .02em;
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
}
.brand::before {
  content: "";
  width: 5px;
  height: 20px;
  background: var(--accent);
  border-radius: 1px;
}
.mainnav { display: flex; gap: 4px; flex: 1; }
/* 項目が7つあり、狭い画面では1行に収まらない。
   折り返さないと本文まで横に広がってしまうため、ナビだけを横スクロールさせる。 */
@media (max-width: 1080px) {
  .appbar-inner { gap: 16px; }
  .mainnav {
    overflow-x: auto;
    /* スクロールバーで文字が隠れないよう少し余白を持たせる */
    padding-bottom: 2px;
    scrollbar-width: thin;
  }
}
@media (max-width: 700px) {
  .appbar-inner { flex-wrap: wrap; padding: 0 14px; row-gap: 0; }
  /* ブランド名と利用者情報を1行目、ナビを2行目に置く */
  .brand { order: 1; }
  .userbox { order: 2; margin-left: auto; }
  .mainnav { order: 3; flex: 1 0 100%; padding-bottom: 6px; }
  .userbox .uname { display: none; }
}
.mainnav a {
  padding: 6px 13px;
  border-radius: 4px;
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}
.mainnav a:hover { background: var(--surface-2); color: var(--ink); }
.mainnav a.is-active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 700; }

.userbox { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.userbox .uname { font-size: 13px; color: var(--ink-2); }
.userbox .urole {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 3px;
  background: var(--surface-2);
  color: var(--ink-3);
  font-weight: 700;
}

/* ===== レイアウト ===== */
.wrap { max-width: 1400px; margin: 0 auto; padding: 24px 20px 64px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-title { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: .01em; }
.page-sub { margin: 2px 0 0; font-size: 13px; color: var(--ink-3); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 18px; }
/* 上の指定は「縦に積むとき」用。grid / flex で並べる場合は gap が間隔を作るため、
   隣接セレクタが効くと2枚目だけ下にずれてしまう。ここで打ち消す。 */
.grid > .panel + .panel,
.stack > .panel + .panel { margin-top: 0; }
.panel-head {
  padding: 13px 18px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.panel-title { margin: 0; font-size: 14px; font-weight: 700; }
.panel-body { padding: 18px; }
.panel-body.tight { padding: 0; }

/* 高さの違うパネルが並ぶため、引き伸ばさず自然な高さにする */
.grid { display: grid; gap: 18px; align-items: start; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }
/* 右カラムの最小幅 280px が優先されるため、画面が狭いと左（本文）が数十pxまで
   潰れて文字が1文字ずつ折り返される。狭い画面では縦積みにする。 */
@media (max-width: 700px) {
  .grid-side { grid-template-columns: minmax(0, 1fr); }
}

/* ===== ボタン ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 15px;
  border-radius: 5px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled, .btn.is-disabled { opacity: .5; pointer-events: none; }

/* ===== フラッシュ ===== */
.flash {
  border-radius: 5px;
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 13.5px;
  border: 1px solid;
}
.flash-ok { background: var(--good-soft); border-color: var(--good); color: #12503B; }
.flash-error { background: var(--danger-soft); border-color: var(--danger); color: #7E2020; }

.errorbox {
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: 5px;
  padding: 12px 16px 12px 34px;
  margin-bottom: 18px;
  font-size: 13px;
  color: #7E2020;
}
.errorbox ul { margin: 0; padding-left: 0; list-style: disc; }
.errorbox li { margin: 2px 0; }

/* ===== 検索バー ===== */
.searchbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.searchbar .field { display: flex; flex-direction: column; gap: 4px; }
.searchbar .field-grow { flex: 1 1 260px; }
.searchbar label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3);
  letter-spacing: .04em;
}

/* ===== フォーム ===== */
input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="tel"], input[type="url"], input[type="number"],
select, textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--rule-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.6;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-soft);
  outline-offset: 0;
}
textarea { resize: vertical; min-height: 84px; }
select { cursor: pointer; }

.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px 16px; }
.f { display: flex; flex-direction: column; gap: 5px; }
/* 1〜12 をすべて定義しておく。未定義のクラスを書くと grid-column が auto に
   なり、1/12 幅（約26px）に潰れて文字が縦に並んでしまう。 */
.f-1  { grid-column: span 1; }
.f-2  { grid-column: span 2; }
.f-3  { grid-column: span 3; }
.f-4  { grid-column: span 4; }
.f-5  { grid-column: span 5; }
.f-6  { grid-column: span 6; }
.f-7  { grid-column: span 7; }
.f-8  { grid-column: span 8; }
.f-9  { grid-column: span 9; }
.f-10 { grid-column: span 10; }
.f-11 { grid-column: span 11; }
.f-12 { grid-column: span 12; }
@media (max-width: 780px) {
  .f-1, .f-2, .f-3, .f-4, .f-5 { grid-column: span 6; }
  .f-6, .f-7, .f-8, .f-9, .f-10, .f-11 { grid-column: span 12; }
}
@media (max-width: 520px) {
  .form-grid > .f { grid-column: span 12; }
}
.f label { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.f .hint { font-size: 11.5px; color: var(--ink-3); }
.f .err { font-size: 12px; color: var(--danger); font-weight: 700; }
.f input.has-error, .f select.has-error, .f textarea.has-error { border-color: var(--danger); }

.req {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--danger);
  border-radius: 2px;
  padding: 0 5px;
  margin-left: 6px;
  vertical-align: 1px;
}

.fieldset-title {
  grid-column: span 12;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--ink-3);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 6px;
  margin-top: 6px;
}

.radio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--rule-strong);
  border-radius: 5px;
  cursor: pointer;
  font-weight: 700;
  font-size: 13.5px;
  background: var(--surface);
}
.radio-card input { margin: 0; accent-color: var(--accent); }
.radio-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 18px;
  border-top: 1px solid var(--rule);
  background: var(--surface-2);
  border-radius: 0 0 6px 6px;
  flex-wrap: wrap;
}
.form-actions .spacer { flex: 1; }

/* ===== テーブル ===== */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  /* width:100% だけだと、列幅の合計がコンテナを超えたときに横スクロールにならず
     列が圧縮されて文字が縦に潰れる。内容に必要な幅を下限にして
     .table-wrap 側でスクロールさせる。 */
  min-width: max-content;
}
table.data th, table.data td {
  padding: 9px 14px;
  text-align: left;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}
table.data thead th {
  background: var(--surface-2);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-2);
  letter-spacing: .04em;
  white-space: nowrap;
  border-bottom: 1px solid var(--rule-strong);
  /* .table-wrap は overflow-x:auto によりスクロールコンテナになるため、
     sticky の基準は枠の内側になる。top は 0 にしないと行の上に重なってずれる。 */
  position: sticky;
  top: 0;
  z-index: 5;
}
table.data thead th a { color: inherit; text-decoration: none; display: inline-flex; gap: 4px; }
table.data thead th a:hover { color: var(--accent); }
table.data tbody tr:hover { background: #F7FAFB; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .code { font-family: var(--mono); font-size: 12px; color: var(--ink-3); white-space: nowrap; }
table.data .nowrap { white-space: nowrap; }
.sort-mark { color: var(--accent); font-size: 10px; }

.rowlink { font-weight: 700; color: var(--ink); text-decoration: none; }
.rowlink:hover { color: var(--accent); text-decoration: underline; }

/* ===== バッジ ===== */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.65;
  padding: 1px 8px;
  border-radius: 3px;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--ink-2);
}
.badge-corp { background: var(--accent-soft); color: var(--accent-dark); }
.badge-indiv { background: #EFE7F3; color: #5C3B70; }
.badge-prospect { background: var(--signal-soft); color: var(--signal); }
.badge-active { background: var(--good-soft); color: var(--good); }
.badge-dormant { background: var(--surface-2); color: var(--ink-3); }
.badge-closed { background: var(--surface-2); color: var(--ink-3); }
.badge-dot { display: inline-flex; align-items: center; gap: 6px; }
.badge-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ===== 定義リスト（詳細画面） ===== */
.dl { display: grid; grid-template-columns: 150px minmax(0, 1fr); }
.dl dt, .dl dd {
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
  margin: 0;
  min-width: 0;
}
.dl dt { font-size: 12px; font-weight: 700; color: var(--ink-3); }
.dl dd { font-size: 13.5px; word-break: break-word; }
.dl dd.empty { color: var(--ink-3); }
.dl > :nth-last-child(-n+2) { border-bottom: 0; }
@media (max-width: 640px) {
  .dl { grid-template-columns: minmax(0, 1fr); }
  .dl dt { border-bottom: 0; padding-bottom: 0; }
}

/* ===== タイムライン ===== */
.timeline { display: flex; flex-direction: column; }
.tl-item {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--rule);
}
.tl-item:last-child { border-bottom: 0; }
.tl-date { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl-title { font-weight: 700; font-size: 13.5px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tl-body { font-size: 13px; color: var(--ink-2); white-space: pre-wrap; margin-top: 3px; }
.tl-next {
  margin-top: 6px;
  font-size: 12px;
  color: var(--signal);
  background: var(--signal-soft);
  border-radius: 4px;
  padding: 4px 10px;
  display: inline-block;
}
@media (max-width: 640px) {
  .tl-item { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}

/* ===== 統計タイル ===== */
.stat {
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat .k { font-size: 11.5px; font-weight: 700; color: var(--ink-3); letter-spacing: .04em; }
.stat .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.3; }
.stat .u { font-size: 12px; color: var(--ink-3); }

.statusbar { display: flex; flex-wrap: wrap; gap: 8px; }
.statuspill {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 7px 13px;
  background: var(--surface);
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-size: 12.5px;
}
.statuspill b { font-size: 16px; font-variant-numeric: tabular-nums; }

/* ===== ページング ===== */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--rule);
  font-size: 12.5px;
  color: var(--ink-3);
  flex-wrap: wrap;
}
.pager .pages { display: flex; gap: 4px; flex-wrap: wrap; }
.pager .pages a, .pager .pages span {
  min-width: 32px;
  text-align: center;
  padding: 4px 8px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  text-decoration: none;
  color: var(--ink-2);
  background: var(--surface);
}
.pager .pages a:hover { border-color: var(--accent); color: var(--accent); }
.pager .pages .cur { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.pager .pages .dis { opacity: .45; }

/* ===== 空状態 ===== */
.empty { padding: 48px 20px; text-align: center; color: var(--ink-3); }
.empty .t { font-size: 15px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.empty .d { font-size: 13px; }

/* ===== ログイン ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--ground);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.login-head { padding: 28px 28px 0; }
.login-head h1 { margin: 0; font-size: 19px; font-weight: 700; }
.login-head p { margin: 6px 0 0; font-size: 12.5px; color: var(--ink-3); }
.login-body { padding: 22px 28px 26px; display: flex; flex-direction: column; gap: 14px; }
.login-body .btn { width: 100%; justify-content: center; padding: 10px; }
.login-foot {
  padding: 14px 28px;
  background: var(--surface-2);
  border-top: 1px solid var(--rule);
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.75;
}
.login-foot code { font-family: var(--mono); background: var(--surface); padding: 1px 5px; border-radius: 3px; }

/* ===== 補助 ===== */
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.tnum { font-variant-numeric: tabular-nums; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row-gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
hr.sep { border: 0; border-top: 1px solid var(--rule); margin: 16px 0; }

@media print {
  .appbar, .page-actions, .form-actions, .pager { display: none; }
  body { background: #fff; }
  .panel { box-shadow: none; }
}

/* ===== 集計・分析 ===== */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.kpi {
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  box-shadow: var(--shadow);
}
.kpi .k {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-3);
  letter-spacing: .04em;
}
.kpi .v {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}
.kpi .v small { font-size: 13px; font-weight: 700; color: var(--ink-3); margin-left: 3px; }
.kpi .s { font-size: 11.5px; color: var(--ink-3); }
.kpi.accent { border-left: 3px solid var(--accent); }
.kpi.warn { border-left: 3px solid var(--signal); }
.kpi.warn .v { color: var(--signal); }
.kpi.money { border-left: 3px solid var(--good); }

/* 横棒グラフ */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) 62px;
  gap: 12px;
  align-items: center;
}
.bar-label {
  font-size: 12.5px;
  color: var(--ink-2);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-track {
  background: var(--surface-2);
  border-radius: 3px;
  height: 20px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  min-width: 2px;
  transition: width .3s ease;
}
.bar-val {
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.bar-val .pct { color: var(--ink-3); font-size: 11px; margin-left: 4px; }
@media (max-width: 560px) {
  .bar-row { grid-template-columns: 78px minmax(0, 1fr) 54px; gap: 8px; }
}

/* ドーナツ */
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut { flex: none; }
/* 幅が足りないとき、凡例は縮まずにドーナツの下へ回り込ませる。
   縮ませると項目名が1文字ずつ折り返されてしまう。 */
.donut-legend { display: flex; flex-direction: column; gap: 8px; flex: 1 1 170px; min-width: 0; }
.donut-legend .li { display: flex; align-items: center; gap: 9px; font-size: 13px; white-space: nowrap; }
.donut-legend .sw { width: 11px; height: 11px; border-radius: 2px; flex: none; }
.donut-legend .n { font-variant-numeric: tabular-nums; font-weight: 700; }
.donut-legend .p { color: var(--ink-3); font-size: 11.5px; }

/* 縦棒グラフ */
.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; min-width: 520px; }
.chart-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 10px;
}
.chart-legend .li { display: flex; align-items: center; gap: 6px; }
.chart-legend .sw { width: 11px; height: 11px; border-radius: 2px; }

.nodata { padding: 32px 12px; text-align: center; color: var(--ink-3); font-size: 13px; }

/* ===== 期間フィルタ ===== */
.periodbar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 22px;
  align-items: center;
  justify-content: space-between;
}
.period-presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.period-cap {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3);
  letter-spacing: .06em;
  margin-right: 4px;
}
.chipbtn {
  display: inline-block;
  padding: 5px 13px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.chipbtn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chipbtn.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.chipbtn.is-on:hover { background: var(--accent-dark); color: #fff; }

.period-custom { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.period-custom label { font-size: 11px; font-weight: 700; color: var(--ink-3); }
.period-custom input[type="date"] { width: auto; padding: 5px 8px; font-size: 12.5px; }
.period-custom .wave { color: var(--ink-3); font-size: 12px; }

.period-now {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px dashed var(--rule-strong);
  font-size: 12.5px;
  color: var(--ink-2);
}

/* ===== セクション見出し ===== */
.sec-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin: 28px 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--ink);
}
.sec-title { margin: 0; font-size: 16px; font-weight: 700; }
.sec-note { font-size: 12px; color: var(--ink-3); }

/* ===== サブタブ ===== */
.subtabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.subtabs a {
  padding: 8px 18px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-3);
  text-decoration: none;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
  margin-bottom: -1px;
}
.subtabs a:hover { color: var(--accent); background: var(--surface-2); }
.subtabs a.is-on {
  background: var(--surface);
  border-color: var(--rule);
  color: var(--ink);
  box-shadow: inset 0 3px 0 var(--accent);
}

/* ===== 説明ボックス ===== */
.callout-box {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 5px;
  padding: 13px 18px;
  margin-bottom: 18px;
  font-size: 13px;
  line-height: 1.8;
}
.callout-box .cb-title {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .06em;
  color: var(--accent-dark);
  margin-bottom: 3px;
}

.note-2col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 10px 24px;
  margin-top: 12px;
  font-size: 12.5px;
  line-height: 1.75;
}

.panel-foot {
  padding: 10px 18px;
  border-top: 1px solid var(--rule);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--ink-2);
  border-radius: 0 0 6px 6px;
}

/* ===== ファネル ===== */
.funnel { display: flex; flex-direction: column; }
.fn-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 58px;
  gap: 12px;
  align-items: center;
}
.fn-label { font-size: 13px; font-weight: 700; text-align: right; }
.fn-bar-wrap { background: var(--surface-2); border-radius: 4px; height: 34px; }
.fn-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  min-width: 46px;
}
.fn-num { color: #fff; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.fn-rate { font-size: 13px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.fn-step {
  padding: 6px 0 6px 100px;
  font-size: 12px;
  color: var(--ink-2);
}
.fn-arrow { color: var(--ink-3); margin-right: 6px; }

/* ===== 受注率セル ===== */
.ratecell { display: flex; align-items: center; gap: 8px; }
.rate-track {
  flex: 1;
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
  min-width: 40px;
}
.rate-fill { height: 100%; background: var(--good); border-radius: 4px; }
.rate-num {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 44px;
  text-align: right;
}

/* ===== 案件・対応履歴 ===== */
.locked-field {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 7px 12px;
  border: 1px solid var(--rule);
  border-radius: 5px;
  background: var(--surface-2);
  font-size: 13.5px;
  min-height: 36px;
}

label.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
label.check input[type="checkbox"] { width: auto; margin: 0; accent-color: var(--accent); }

.linkbtn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--danger);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.linkbtn:hover { color: #7E2020; }

.tl-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  opacity: 0;
  transition: opacity .12s;
}
.tl-item:hover .tl-actions, .tl-actions:focus-within { opacity: 1; }
.tl-actions form { display: inline; }

/* ステータス変更履歴 */
.statuslog { display: flex; flex-direction: column; }
.sl-item {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 12.5px;
}
.sl-item:last-child { border-bottom: 0; }
.sl-date { color: var(--ink-3); font-size: 11.5px; white-space: nowrap; }

/* ===== フロー設定 ===== */
.flowline { display: flex; flex-wrap: wrap; align-items: stretch; gap: 6px; }
.fl-step {
  border: 1px solid var(--rule);
  border-top: 3px solid var(--accent);
  border-radius: 4px;
  padding: 9px 13px;
  background: var(--surface);
  min-width: 128px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}
.fl-badge {
  position: absolute;
  top: -11px; left: 10px;
  width: 19px; height: 19px;
  border-radius: 50%;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.fl-name { font-weight: 700; font-size: 13.5px; margin-top: 5px; }
.fl-day { font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.fl-day strong { color: var(--accent); font-size: 13px; }
.fl-alert { font-size: 11px; color: var(--ink-3); }
.fl-note { font-size: 11px; color: var(--ink-3); border-top: 1px dashed var(--rule); margin-top: 4px; padding-top: 4px; }
.fl-arrow { display: flex; align-items: center; color: var(--rule-strong); font-size: 15px; }

.inline-num { display: flex; align-items: center; gap: 5px; }
.inline-num input { width: 68px; }
.inline-num .unit { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }

.iconbtn {
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: 3px;
  width: 22px; height: 22px;
  line-height: 1;
  font-size: 12px;
  cursor: pointer;
  color: var(--ink-2);
  padding: 0;
}
.iconbtn:hover { border-color: var(--accent); color: var(--accent); }
.iconbtn.danger:hover { border-color: var(--danger); color: var(--danger); }

/* ===== 案件の予定表 ===== */
.progress-row { display: flex; align-items: center; gap: 10px; }
.progress-track { flex: 1; height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--good); border-radius: 5px; transition: width .3s; }
.progress-num { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; }

/* 予定表はサイドバー付きレイアウトの中にも入るため、ビューポート幅では
   「入る／入らない」を判定できない。自分自身の幅で切り替える。 */
.sched { display: flex; flex-direction: column; container-type: inline-size; }
.sc-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) 122px 150px 92px;
  gap: 10px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--rule);
}
.sc-row:last-child { border-bottom: 0; }
.sc-mark {
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 2px solid var(--rule-strong);
  background: var(--surface);
  justify-self: center;
}
.sc-name { font-size: 13.5px; font-weight: 700; }
.sc-plan, .sc-real { font-size: 12.5px; }
.sc-state { text-align: right; }
.sc-badge {
  display: inline-block;
  font-size: 11px; font-weight: 700;
  padding: 1px 8px; border-radius: 3px;
  background: var(--surface-2); color: var(--ink-3);
}
.sc-diff { font-size: 11px; font-weight: 700; margin-left: 5px; }
.sc-diff.minus { color: var(--danger); }
.sc-diff.plus { color: var(--good); }

.sc-done .sc-mark { border-color: var(--good); background: var(--good); }
.sc-done .sc-badge { background: var(--good-soft); color: var(--good); }
.sc-skip { opacity: .55; }
.sc-skip .sc-mark { border-style: dashed; }
.sc-late .sc-mark { border-color: var(--danger); background: var(--danger); }
.sc-late .sc-badge { background: var(--danger-soft); color: var(--danger); }
.sc-late .sc-name { color: var(--danger); }
.sc-late .sc-state .small { color: var(--danger); font-weight: 700; }
.sc-due .sc-mark { border-color: var(--signal); }
.sc-due .sc-badge { background: var(--signal-soft); color: var(--signal); }
.sc-soon .sc-mark { border-color: var(--accent); }
.sc-soon .sc-badge { background: var(--accent-soft); color: var(--accent-dark); }

/* 横1行版は固定列だけで 14+122+150+92 + gap40 = 418px 必要。
   案件名の列（minmax(0,1fr)）がそれ以下だと0pxまで潰れるので、
   余裕を見て 540px を下回ったら縦積みの表示に切り替える。 */
@container (max-width: 540px) {
  .sc-row { grid-template-columns: 14px minmax(0, 1fr) 84px; row-gap: 2px; }
  /* 行内の要素は5つ。列を指定しないと状態バッジが14px幅の1列目に流れ込み、
     文字が1文字ずつ折り返されてしまう。 */
  .sc-name { grid-column: 2; grid-row: 1; }
  .sc-state { grid-column: 3; grid-row: 1; }
  .sc-plan, .sc-real { grid-column: 2 / -1; }
}
/* コンテナクエリ非対応ブラウザ向けの保険（画面幅で判定） */
@supports not (container-type: inline-size) {
  @media (max-width: 900px) {
    .sc-row { grid-template-columns: 14px minmax(0, 1fr) 84px; row-gap: 2px; }
    .sc-name { grid-column: 2; grid-row: 1; }
    .sc-state { grid-column: 3; grid-row: 1; }
    .sc-plan, .sc-real { grid-column: 2 / -1; }
  }
}

/* ===== 案件画面での顧客の見せ方 ===== */
.parent-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 4px 12px 4px 10px;
  margin-bottom: 8px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  background: var(--surface);
  text-decoration: none;
  color: var(--ink);
  max-width: 100%;
}
.parent-line:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.parent-line .pl-name { font-size: 15px; font-weight: 700; }
.parent-line .pl-arrow { font-size: 11.5px; color: var(--ink-3); }

.custpanel { border-left: 3px solid var(--accent); }
.custname {
  display: inline-block;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.45;
}
.custname:hover { color: var(--accent); text-decoration: underline; }

table.data .custcell .rowlink { font-size: 13.5px; }
table.data .custcell .small { margin-top: 1px; }

/* ===== 使い方ガイド ===== */
.guide {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.guide-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.guide-summary::-webkit-details-marker { display: none; }
.guide-summary::after {
  content: "▼";
  margin-left: auto;
  font-size: 10px;
  color: var(--ink-3);
  transition: transform .15s;
}
.guide[open] .guide-summary::after { transform: rotate(180deg); }
.guide-summary:hover { background: var(--surface-2); border-radius: 5px 5px 0 0; }
.g-icon {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.g-title { font-size: 14px; font-weight: 700; }
.g-hint { font-size: 11.5px; color: var(--ink-3); }

.guide-body { padding: 4px 18px 20px; border-top: 1px solid var(--rule); }
.g-h {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--ink-3);
  margin: 20px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
}

/* 3ステップ */
.g-steps { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.g-step {
  flex: 1 1 200px;
  border: 1px solid var(--rule);
  border-top: 3px solid var(--accent);
  border-radius: 5px;
  padding: 12px 14px 14px;
  background: var(--ground);
  position: relative;
}
.g-step.key { border-top-color: var(--signal); background: var(--signal-soft); }
.g-num {
  position: absolute;
  top: -11px; left: 12px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.g-step.key .g-num { background: var(--signal); }
.g-name { font-size: 14px; font-weight: 700; margin-top: 6px; }
.g-desc { font-size: 12.5px; color: var(--ink-2); line-height: 1.7; margin-top: 3px; }
.g-arrow { display: flex; align-items: center; color: var(--rule-strong); font-size: 17px; }

.g-callout {
  margin-top: 12px;
  padding: 12px 16px;
  border: 1px solid var(--signal);
  border-left: 3px solid var(--signal);
  background: var(--signal-soft);
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.8;
}

/* 画面の役割 */
.g-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.g-card {
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 11px 14px;
  background: var(--surface);
  text-decoration: none;
  color: var(--ink);
  display: block;
}
.g-card:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.g-card-t { font-size: 13.5px; font-weight: 700; }
.g-card-d { font-size: 12px; color: var(--ink-2); line-height: 1.65; margin-top: 2px; }

.g-tips {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  line-height: 1.8;
  max-width: 76ch;
}
.g-tips li::marker { color: var(--ink-3); }

@media (max-width: 700px) {
  .g-arrow { display: none; }
}


/* ===== オーダーの流れ（ステップ図） ===== */
.g-h-sub {
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  margin-left: 12px;
  color: var(--ink-3);
  font-size: 11.5px;
}

.oflow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 30px 34px;
  margin-bottom: 6px;
}
.ostep {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 20px 14px 14px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  transition: border-color .14s, box-shadow .14s, transform .14s;
}
.ostep:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 18px -10px rgba(15, 110, 140, .55);
  transform: translateY(-2px);
}
.ostep:hover .o-more { color: var(--accent); }
.ostep:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.o-num {
  position: absolute;
  top: -12px; left: 14px;
  width: 25px; height: 25px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid var(--accent);
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.o-ico { width: 46px; height: 46px; color: var(--accent); margin: 2px 0 6px; }
.o-ico svg { width: 100%; height: 100%; display: block; }
.o-name { font-size: 14px; font-weight: 700; line-height: 1.4; }
.o-lead { font-size: 11.5px; color: var(--ink-3); line-height: 1.55; }
.o-more {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-3);
  border-top: 1px dashed var(--rule-strong);
  padding-top: 6px;
  width: 100%;
}

/* 横向きの矢印（行の途中） */
.ostep::after {
  content: "";
  position: absolute;
  right: -22px; top: 50%;
  width: 0; height: 0;
  transform: translateY(-50%);
  border-left: 9px solid var(--rule-strong);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}
/* 行末で折り返すことを示す下向き矢印 */
.ostep::before {
  content: "";
  position: absolute;
  bottom: -22px; left: 50%;
  width: 0; height: 0;
  transform: translateX(-50%);
  border-top: 9px solid var(--rule-strong);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  display: none;
}
.ostep:last-child::after, .ostep:last-child::before { display: none; }

@media (min-width: 1080px) {
  .oflow { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ostep:nth-child(4n)::after { display: none; }
  .ostep:nth-child(4n):not(:last-child)::before { display: block; }
}
@media (max-width: 1079px) and (min-width: 760px) {
  .oflow { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ostep:nth-child(3n)::after { display: none; }
  .ostep:nth-child(3n):not(:last-child)::before { display: block; }
}
@media (max-width: 759px) and (min-width: 520px) {
  .oflow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ostep:nth-child(2n)::after { display: none; }
  .ostep:nth-child(2n):not(:last-child)::before { display: block; }
}
@media (max-width: 519px) {
  .oflow { grid-template-columns: minmax(0, 1fr); gap: 26px; }
  .ostep::after { display: none; }
  .ostep:not(:last-child)::before { display: block; }
}

/* 流れから外れる場合 */
.oexit {
  margin-top: 24px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--signal);
  border-radius: 5px;
  background: var(--signal-soft);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.oexit-t { font-size: 11.5px; font-weight: 700; color: var(--signal); letter-spacing: .06em; }
.oexit-i { font-size: 12.5px; line-height: 1.75; display: flex; gap: 10px; }
.oexit-i strong { flex: none; min-width: 68px; }

/* ===== モーダル ===== */
/* display:flex が hidden 属性より優先されてしまうため、明示的に打ち消す */
.modal-back[hidden] { display: none; }

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(22, 36, 43, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: mfade .14s ease-out;
}
@keyframes mfade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border-radius: 8px;
  width: min(680px, 100%);
  max-height: min(84vh, 760px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px -20px rgba(0, 0, 0, .5);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--rule);
}
.m-num {
  width: 30px; height: 30px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 14px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.modal-title { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.4; }
.modal-lead { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.modal-close {
  margin-left: auto;
  background: none;
  border: 1px solid var(--rule-strong);
  border-radius: 5px;
  width: 30px; height: 30px;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-2);
  flex: none;
}
.modal-close:hover { background: var(--surface-2); color: var(--ink); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--rule);
  background: var(--surface-2);
}
.modal-count { flex: 1; text-align: center; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.md-do { font-size: 13.5px; line-height: 1.85; margin: 0; }
.md-h {
  font-size: 11.5px; font-weight: 700; letter-spacing: .08em;
  color: var(--ink-3);
  margin: 18px 0 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--rule);
}
.md-ops { margin: 0; padding-left: 0; list-style: none; counter-reset: mop; display: flex; flex-direction: column; gap: 9px; }
.md-ops li {
  counter-increment: mop;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  font-size: 13px;
  line-height: 1.75;
}
.md-ops li::before {
  content: counter(mop);
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-top: 2px;
}
/* li の中は「番号(::before)・見出し(strong)・説明文(span)」の3要素。
   列を指定しないと説明文が24px幅の1列目に入り、1文字ずつ折り返されてしまう。 */
.md-ops li strong { grid-column: 2; display: block; }
.md-ops li span { grid-column: 2; color: var(--ink-2); font-size: 12.5px; }
.md-fields {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--surface-2);
  border-radius: 4px;
  padding: 9px 13px;
  line-height: 1.8;
}
.md-caution {
  margin-top: 16px;
  border: 1px solid var(--signal);
  border-left: 3px solid var(--signal);
  background: var(--signal-soft);
  border-radius: 4px;
  padding: 11px 15px;
  font-size: 12.5px;
  line-height: 1.8;
}
.md-actions { margin-top: 16px; }

/* 画面の高さが低いとき、本文の表示領域が潰れないよう余白を詰める */
@media (max-height: 620px) {
  .modal-back { padding: 10px; }
  .modal { max-height: 96vh; }
  .modal-head { padding: 11px 16px; }
  .modal-body { padding: 13px 16px; }
  .modal-foot { padding: 8px 16px; }
  .modal-title { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  .ostep:hover { transform: none; }
  .modal-back { animation: none; }
}


/* ===== お客様の声 ===== */
.voices { display: flex; flex-direction: column; gap: 14px; }
.voice {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--rule-strong);
  border-radius: 5px;
  padding: 12px 16px 14px;
  background: var(--surface);
}
.voice.is-pending {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}
.v-head {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-bottom: 5px;
}
.v-date { font-size: 12px; color: var(--ink-3); }
.v-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  opacity: 0;
  transition: opacity .12s;
}
.voice:hover .v-actions, .v-actions:focus-within { opacity: 1; }
.v-actions form { display: inline; }
.v-title { font-size: 14px; font-weight: 700; line-height: 1.5; }
.v-content {
  margin: 8px 0 0;
  padding: 9px 14px;
  border-left: 3px solid var(--rule);
  background: var(--surface-2);
  border-radius: 0 4px 4px 0;
  font-size: 13px;
  line-height: 1.85;
  white-space: pre-wrap;
  color: var(--ink);
}
.voice.is-pending .v-content { background: var(--surface); }
.v-response {
  margin-top: 9px;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--ink-2);
}
.v-res-t {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--good);
  background: var(--good-soft);
  border-radius: 3px;
  padding: 1px 7px;
  margin-right: 7px;
}
.v-resolve {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--rule-strong);
  flex-wrap: wrap;
}
.v-resolve input { flex: 1 1 240px; }


/* ===== 添付ファイル ===== */

/* 画像はサムネイルを敷き詰める。
   minmax の下限に min() を挟むのは、パネルが極端に狭いときに
   グリッドが枠からはみ出すのを防ぐため。 */
.att-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(132px, 100%), 1fr));
  gap: 12px;
}

.att-thumb {
  margin: 0;
  border: 1px solid var(--rule);
  border-radius: 5px;
  overflow: hidden;
  background: var(--surface);
}

.att-open {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  border: 0;
  background: var(--surface-2);
  cursor: zoom-in;
}
.att-open img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-open:hover img { opacity: .88; }

/* サムネイルを作れなかった画像（HEIC など）の代わりの表示 */
.att-noimg {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.att-thumb figcaption {
  padding: 7px 9px 5px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
/* ファイル名は折り返さず、入りきらない分は「…」にする。
   日本語は1文字ずつ折り返せるため、狭い枠では縦に伸びてしまう。 */
.att-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.att-meta { font-size: 11px; color: var(--ink-3); }

.att-thumb .att-acts {
  display: flex;
  gap: 10px;
  padding: 0 9px 8px;
  font-size: 11.5px;
}

/* 画像以外のファイル一覧 */
.att-list {
  container-type: inline-size;
  list-style: none;
  margin: 0;
  padding: 0;
}
.att-grid + .att-list { margin-top: 14px; border-top: 1px solid var(--rule); }

.att-list li {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) max-content;
  gap: 4px 10px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--rule);
}
.att-list li:last-child { border-bottom: 0; }

.att-kind {
  font-size: 10.5px;
  font-weight: 700;
  text-align: center;
  padding: 2px 0;
  border-radius: 3px;
  background: var(--surface-2);
  color: var(--ink-3);
}

.att-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.att-body a { font-size: 13px; font-weight: 700; }
.att-body .small { font-size: 11.5px; }

.att-acts { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.att-acts form { display: inline; }

/* 枠が狭いときは操作リンクを次の行へ回す。
   同じ行に残すと、ファイル名の列が0pxまで潰れてしまう。 */
@container (max-width: 380px) {
  .att-list li { grid-template-columns: 52px minmax(0, 1fr); }
  .att-list .att-acts { grid-column: 2; }
}

/* アップロード欄 */
.att-upload { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--rule); }
.att-list + .att-upload, .att-grid + .att-upload { margin-top: 14px; }

.att-up-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.att-up-row input[type="file"] { flex: 1 1 240px; min-width: 0; font-size: 12.5px; }
.att-up-row input[type="text"] { flex: 1 1 180px; min-width: 0; }
.att-up-row .btn { flex: none; }

.att-upload .hint { margin-top: 6px; font-size: 11.5px; color: var(--ink-3); }
.att-upload .err { margin-top: 6px; font-size: 12px; color: var(--danger); font-weight: 700; }

/* ===== 画像の拡大表示 ===== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: rgba(20, 22, 26, .82);
}
/* [hidden] だけでは display:flex に負けるため、明示的に打ち消す */
.lightbox[hidden] { display: none; }

.lightbox-inner {
  margin: 0;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.lightbox-inner img {
  max-width: 100%;
  /* 見出し分を差し引いた高さに収める */
  max-height: calc(100vh - 110px);
  object-fit: contain;
  border-radius: 4px;
  background: #fff;
}
.lightbox-inner figcaption {
  color: #fff;
  font-size: 13px;
  text-align: center;
  max-width: 640px;
}

.lightbox-close {
  position: absolute;
  top: 14px;
  right: 18px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .28); }

@media (max-width: 560px) {
  .lightbox { padding: 16px; }
  .lightbox-inner img { max-height: calc(100vh - 90px); }
}

/* 対応履歴のタイムラインに出す添付 */
.tl-att { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 7px; }

.tl-att-img {
  width: 68px; height: 52px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface-2);
  cursor: zoom-in;
  flex: none;
}
.tl-att-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tl-att-img:hover img { opacity: .85; }

.tl-att-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 9px 4px 5px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-size: 12px;
  text-decoration: none;
  /* ファイル名は1行に収め、はみ出す分は「…」にする */
  white-space: nowrap;
  overflow: hidden;
}
.tl-att-file:hover { background: var(--surface-2); }
.tl-att-file .att-kind { flex: none; padding: 1px 6px; }
.tl-att-file > span:last-child { overflow: hidden; text-overflow: ellipsis; }

/* 添付の説明の書き換え。ふだんは畳んでおく */
.att-cap { font-size: 11.5px; }
.att-thumb .att-cap { padding: 0 9px 8px; }
.att-list .att-cap { grid-column: 2 / -1; }

.att-cap > summary {
  cursor: pointer;
  color: var(--ink-3);
  list-style: none;
  width: fit-content;
}
.att-cap > summary::-webkit-details-marker { display: none; }
.att-cap > summary::before { content: '✎ '; }
.att-cap > summary:hover { color: var(--accent-dark); }

.att-cap form { display: flex; gap: 6px; margin-top: 5px; }
.att-cap input[type="text"] { flex: 1 1 auto; min-width: 0; font-size: 12px; padding: 4px 7px; }
.att-cap .btn { flex: none; }
