/* 管理画面(運営画面・企業ポータル)の共通の決まり。docs/ADMIN_UI_SPEC.md 1・2
   - 1: 管理画面ではアニメーションしない(layouts/application の <body class="admin-static">)
   - 2: 値を見やすく(表の罫線・列の区切り・見出しの背景と太線・ゼブラ・数値の右寄せと桁そろえ・見出しの固定)
   - 作業ダッシュボード / 分析ダッシュボード / 操作ログの部品(KPI カード・要対応・グラフ・タブ)
   application.css より先に読まれる(ファイル名順)ので、既存の .table などを上書きするところは
   .admin-static を前に付けて強くしてある。スマホ幅の指定はこのファイルの最後にまとめる。 */

/* ---- 1. 動きを止める ---------------------------------------------------- */
.admin-static *, .admin-static *::before, .admin-static *::after {
  animation: none !important; transition: none !important; scroll-behavior: auto !important;
}
/* Turbo の進み具合の線(.turbo-progress-bar)は <body> ではなく <html> 直下に入るので .admin-static * が届かず、
   遷移のたびに幅の transition で動く。管理画面では出さない(管理画面の共通方針 1) */
html:has(body.admin-static) .turbo-progress-bar { display: none !important; }
html:has(body.admin-static) { scroll-behavior: auto !important; }
/* 遷移のローディング(うさぎ)は、管理画面では跳ねるうさぎを出さず「読み込み中…」の文字だけ */
.admin-static .rabbit-loading__stage { display: none !important; }
.admin-static .rabbit-loading { background: rgba(255, 255, 255, 0.9); -webkit-backdrop-filter: none; backdrop-filter: none; }
.admin-static .rabbit-loading__text {
  padding: 10px 18px; border: 1px solid #9aa7b8; border-radius: 8px; background: #fff; color: #1f2733; letter-spacing: 0.05em;
}

/* ---- 2. 表に線を引く ------------------------------------------------------ */
.admin-static .table { border: 1px solid #b8c2cf; border-collapse: collapse; }
.admin-static .table th, .admin-static .table td {
  border-bottom: 1px solid #d3dae3; border-right: 1px solid #e1e6ed; vertical-align: top;
}
.admin-static .table th:last-child, .admin-static .table td:last-child { border-right: none; }
.admin-static .table thead th {
  background: #e6ebf2; color: #1f2733; font-weight: 700; border-bottom: 2px solid #8796aa; white-space: nowrap;
}
.admin-static .table tbody tr:nth-child(even) > td { background: #f1f4f8; }
.admin-static .table tbody tr:hover > td { background: #eaf1ff; }
.admin-static .table tbody tr:last-child td { border-bottom: none; }
.admin-static .table td.num, .admin-static .table th.num, .admin-static .num {
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum";
}
.admin-static .table td.num, .admin-static .table th.num { text-align: right; }

/* 長い表は枠の中でスクロールし、見出しを固定する(枠がスクロールの入れ物。表自身は横スクロールさせない) */
.admin-table-wrap {
  overflow: auto; max-height: 70vh; margin-top: 12px; border: 1px solid #b8c2cf; border-radius: 8px; background: #fff;
}
.admin-table-wrap--short { max-height: 420px; }
.admin-table-wrap--tall { max-height: 80vh; }
.admin-static .admin-table-wrap > .table {
  display: table; width: 100%; margin: 0; border: none; border-radius: 0; overflow: visible; background-image: none;
}
.admin-static .admin-table-wrap > .table thead th { position: sticky; top: 0; z-index: 1; }
.admin-static .table th.is-sortable { cursor: pointer; user-select: none; }
.admin-static .table th.is-sortable::after { content: " ↕"; color: #626d7d; font-weight: 400; }
.admin-static .table th[aria-sort="ascending"]::after { content: " ▲"; color: #1f2733; }
.admin-static .table th[aria-sort="descending"]::after { content: " ▼"; color: #1f2733; }
.admin-static .table th.is-sortable:focus-visible { outline: 2px solid #1d4ed8; outline-offset: -2px; }

/* ---- タブ(作業 / 分析 / 操作ログ) ---------------------------------------- */
.admin-tabs { display: flex; flex-wrap: wrap; gap: 0; margin: 4px 0 16px; border-bottom: 2px solid #8796aa; }
.admin-tab {
  display: inline-flex; align-items: center; min-height: 40px; padding: 6px 16px; margin-bottom: -2px;
  border: 1px solid #b8c2cf; border-bottom: 2px solid #8796aa; border-radius: 8px 8px 0 0; background: #eef1f6;
  color: #1f2733; font-weight: 700; font-size: 14px;
}
.admin-tab + .admin-tab { margin-left: 4px; }
.admin-tab:hover { background: #e2e8f2; text-decoration: none; }
.admin-tab.is-current { background: #fff; border-bottom-color: #fff; color: #1d4ed8; }

/* ---- パネルの見出し --------------------------------------------------------- */
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.panel-head h2 { margin: 0 0 6px; }
.panel-subtitle { font-size: 13px; margin: 12px 0 4px; padding-bottom: 2px; border-bottom: 1px solid #d3dae3; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: 6px 0; border-bottom: 1px solid #e1e6ed; display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.plain-list li:last-child { border-bottom: none; }
.panel + .panel, .work-panel + .panel { margin-top: 16px; }
.two-col > .panel { margin-top: 0; }
.chart-stack { display: grid; gap: 16px; margin-top: 16px; }
.chart-stack > .panel { margin-top: 0; }
.chart-stack .achart { max-width: 1100px; }
.recent-ops-table td:nth-child(2) { white-space: nowrap; }

/* ---- KPI カード(ラベル / 値 / 前期比 を線で分ける) ----------------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 8px; }
.kpi-card {
  display: flex; flex-direction: column; background: #fff; border: 1px solid #b8c2cf; border-radius: 8px; color: #1f2733;
}
.kpi-card--link:hover { border-color: #1d4ed8; text-decoration: none; }
.kpi-label { padding: 8px 12px; font-size: 12px; font-weight: 700; color: #3d4a5c; border-bottom: 1px solid #d3dae3; background: #f3f6fa; border-radius: 8px 8px 0 0; }
.kpi-value {
  padding: 10px 12px 6px; font-size: 28px; font-weight: 700; line-height: 1.2; color: #101828;
  font-family: var(--font-display); font-variant-numeric: tabular-nums; font-feature-settings: "tnum";
}
.kpi-unit { font-size: 13px; font-weight: 400; color: #3d4a5c; margin-left: 4px; }
.kpi-change { padding: 6px 12px 8px; font-size: 12px; border-top: 1px solid #d3dae3; font-variant-numeric: tabular-nums; }
.kpi-change.is-good { color: #166534; }
.kpi-change.is-bad { color: #b42318; }
.kpi-change.is-flat { color: #3d4a5c; }
.kpi-note { padding: 0 12px 8px; font-size: 11px; color: #626d7d; }

/* ---- 要対応(作業ダッシュボード) --------------------------------------------- */
.work-panel { margin-bottom: 16px; }
.work-panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.work-panel-head h2 { margin: 0; }
.work-total { font-size: 14px; }
.work-empty { margin: 10px 0; padding: 10px 12px; border: 1px solid #b8c2cf; border-radius: 8px; background: #f3f6fa; font-weight: 700; }
.work-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 12px; }
.work-item { border: 1px solid #b8c2cf; border-radius: 8px; background: #fff; display: flex; flex-direction: column; }
.work-item.is-pending { border-left: 6px solid #1d4ed8; }
.work-item--high.is-pending { border-left-color: #b42318; }
.work-item.is-clear { background: #f8fafc; }
.work-item-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 8px 12px; border-bottom: 1px solid #d3dae3; }
.work-item-head h3 { margin: 0; font-size: 14px; }
.work-count { white-space: nowrap; font-size: 13px; }
.work-count strong { font-size: 20px; }
.work-item.is-clear .work-count strong { color: #626d7d; }
.work-rows { list-style: none; margin: 0; padding: 0 12px; }
.work-rows li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid #e1e6ed; }
.work-rows li:last-child { border-bottom: none; }
.work-row-main { min-width: 0; overflow-wrap: anywhere; }
.work-row-detail { display: block; font-size: 12px; color: #3d4a5c; }
.work-row-form { margin: 0; flex: none; }
.work-more, .work-note, .work-item-clear { margin: 6px 12px; font-size: 12px; color: #3d4a5c; }
.work-action { align-self: flex-start; margin: 8px 12px 12px; }

.shortcut-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.shortcut-grid .btn { text-align: center; }

/* ---- 期間の切り替え ---------------------------------------------------------- */
.period-form { align-items: flex-end; flex-wrap: wrap; }
.period-choices { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; border: none; min-width: 0; }
.period-choices legend { font-size: 12px; font-weight: 700; color: #3d4a5c; padding: 0; margin-bottom: 4px; }
.period-choice { display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; border: 1px solid #b8c2cf; border-radius: 6px; background: #fff; font-size: 13px; cursor: pointer; }
.period-choice:has(input:checked) { border-color: #1d4ed8; background: #eaf1ff; font-weight: 700; }
.period-label { margin: 8px 0 12px; font-size: 13px; }

/* ---- 折れ線グラフ(目盛り線・軸ラベル・値ラベル・凡例) ------------------------- */
.achart-wrap { margin-top: 8px; }
.achart { width: 100%; height: auto; display: block; background: #fff; border: 1px solid #d3dae3; border-radius: 6px; }
.achart-grid { stroke: #d3dae3; stroke-width: 1; }
.achart-axis { stroke: #5b6778; stroke-width: 1.2; }
.achart-label { font-size: 13px; fill: #3d4a5c; font-variant-numeric: tabular-nums; }
.achart-line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.achart-value { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.achart-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0 0; padding: 0; font-size: 13px; }
.achart-legend li { display: inline-flex; align-items: center; gap: 4px; }

/* ---- 操作ログ ------------------------------------------------------------- */
.op-filter { flex-wrap: wrap; align-items: flex-end; }
.op-summary { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; margin-top: 12px; padding: 8px 12px; border: 1px solid #b8c2cf; border-radius: 8px; background: #fff; }
.op-summary p { margin: 0; font-size: 13px; }
.op-summary-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.op-table td { font-size: 13px; }
.op-time { white-space: nowrap; }
.op-role, .op-category, .op-target-type {
  display: inline-block; margin: 2px 0 0; padding: 0 6px; border: 1px solid #b8c2cf; border-radius: 4px; font-size: 11px; color: #3d4a5c; background: #f3f6fa;
}
.op-role, .op-category { margin-left: 4px; }
.op-target-type { margin-right: 4px; }
.op-real-actor { display: block; font-size: 11px; color: #8a2a0a; }
.op-action { font-weight: 700; }
.op-result { display: inline-block; padding: 0 8px; border-radius: 4px; font-size: 12px; font-weight: 700; border: 1px solid; white-space: nowrap; }
.op-result--success { color: #166534; border-color: #86c49a; background: #f0faf3; }
.op-result--failure { color: #b42318; border-color: #f0a39b; background: #fff3f1; }
.op-status { font-size: 11px; color: #3d4a5c; margin-left: 2px; }
.admin-static .table tbody tr.op-row--failure > td { background: #fff6f5; }
.op-client { font-size: 12px; white-space: nowrap; }
.op-detail { font-size: 12px; max-width: 360px; overflow-wrap: anywhere; }
.op-changes { margin: 0; padding-left: 16px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 16px 0; }
.pager-status { font-variant-numeric: tabular-nums; }
.inactive-list { list-style: none; margin: 0; padding: 0; columns: 3 220px; column-gap: 24px; }
.inactive-list li { padding: 4px 0; border-bottom: 1px solid #e1e6ed; break-inside: avoid; }
.admin-static .table tbody tr.row-inactive > td { background: #fffaf0; }

/* ---- スマホ(〜720px) ---------------------------------------------------------- */
@media (max-width: 720px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi-value { font-size: 22px; }
  .work-grid { grid-template-columns: minmax(0, 1fr); }
  .shortcut-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-tab { padding: 6px 10px; font-size: 13px; }
  .admin-table-wrap { max-height: none; }
  .admin-static .admin-table-wrap > .table { min-width: 640px; }
  .admin-static .admin-table-wrap > .table.op-table { min-width: 980px; }
  .op-summary { flex-direction: column; align-items: flex-start; }
  .achart-label { font-size: 26px; }
  .achart-value { font-size: 22px; }
}
@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: minmax(0, 1fr); }
}
