/* ============================================================
 * DVTV-102 パインズ積算エンジン CSS (v2.4.0)
 * F041 明細集計画面 + F042 集計係数設定 統合UI
 * ============================================================ */

/* ワークフロー (他プラグインのページでも共通利用) */
@keyframes dvtv-neon-pulse {
  0%,100% { box-shadow:0 0 4px #667eea, 0 0 12px rgba(102,126,234,0.4); border-color:#667eea; }
  50% { box-shadow:0 0 8px #667eea, 0 0 24px rgba(102,126,234,0.7); border-color:#8fa4f0; }
}
@keyframes dvtv-input-neon {
  0%,100% { box-shadow:0 0 3px rgba(102,126,234,0.5); border-color:#667eea; }
  50% { box-shadow:0 0 8px rgba(102,126,234,0.8); border-color:#8fa4f0; }
}

/* ワークフローバー: グローバルスコープ (自動注入でも動くように) */
.dvtv-workflow-bar { display: flex; align-items: center; gap: 4px; padding: 10px 20px; background: linear-gradient(90deg,#f0f4ff,#e8eaf6); border: 1px solid #d0d8f0; border-radius: 10px; margin: 12px 0 16px 0; flex-wrap: wrap; font-family: 'Segoe UI','Meiryo',sans-serif; max-width: 1500px; }
.dvtv-workflow-bar .dvtv-wf-step { padding: 5px 14px; border-radius: 20px; font-size: 12px; font-weight: 600; color: #555; background: #fff; border: 2px solid transparent; text-decoration: none !important; white-space: nowrap; transition: all .2s; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.dvtv-workflow-bar .dvtv-wf-step:hover { background: #e8eaf6; color:#333; border-color:#c5cae9; }
.dvtv-workflow-bar .dvtv-wf-current { color: #fff !important; background: linear-gradient(135deg,#667eea,#764ba2) !important; border: 2px solid #667eea !important; animation: dvtv-neon-pulse 2s ease-in-out infinite !important; }
.dvtv-workflow-bar .dvtv-wf-arrow { color: #aab; font-weight: 700; font-size: 13px; }

.dvtv-sekisan-wrap { max-width: 1500px; margin: 0 auto; font-family: 'Segoe UI','Meiryo',sans-serif !important; }
.dvtv-sekisan-wrap * { box-sizing: border-box; }
.dvtv-sekisan-wrap input:focus,
.dvtv-sekisan-wrap select:focus,
.dvtv-sekisan-wrap textarea:focus { outline: none !important; animation: dvtv-input-neon 1.5s ease-in-out infinite !important; }

.dvtv-sekisan-wrap .dvtv-header { background: linear-gradient(135deg,#1a1a2e,#16213e,#0f3460) !important; color:#fff !important; padding: 14px 24px !important; border-radius: 12px 12px 0 0 !important; display: flex; align-items: center; justify-content: space-between; }
.dvtv-sekisan-wrap .dvtv-header h2 { margin: 0 !important; font-size: 19px !important; color:#fff !important; background: none !important; }
.dvtv-sekisan-wrap .dvtv-ver { font-size: 11px; opacity: 0.6; }

/* 旧セレクタ互換 (積算画面内のフローバー) */
.dvtv-sekisan-wrap .dvtv-workflow-bar { margin: 0; border-radius: 0; border-left: none; border-right: none; border-top: none; padding: 8px 24px; }

.dvtv-sekisan-wrap .dvtv-select-bar { background: #f8f9ff; padding: 10px 24px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid #e0e7ff; }
.dvtv-sekisan-wrap .dvtv-select-bar label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #555; white-space: nowrap; }
.dvtv-sekisan-wrap .dvtv-select-bar input,
.dvtv-sekisan-wrap .dvtv-select-bar select { padding: 5px 8px; border: 1px solid #ccd; border-radius: 6px; font-size: 14px; }

.dvtv-sekisan-wrap .dvtv-info-bar { background: #f0f4ff; padding: 9px 24px; display: flex; gap: 20px; font-size: 13px; border-bottom: 1px solid #e0e7ff; align-items: center; }
.dvtv-sekisan-wrap .dvtv-info-bar strong { color: #0f3460; }
.dvtv-sekisan-wrap .sk-grand-total { margin-left: auto; font-size: 14px; color: #444; }
.dvtv-sekisan-wrap .sk-grand-total strong { color: #c62828; font-size: 16px; font-family: 'Consolas',monospace; }

.dvtv-sekisan-wrap .dvtv-notice-info { background: #e3f2fd; border: 1px solid #90caf9; color: #1565c0; padding: 12px 20px; border-radius: 8px; margin: 16px 24px; }

/* ============================================
 * ビュー切替タブ
 * ============================================ */
.sk-viewswitch { display: flex; background: #1a1a2e; padding: 0; border-bottom: 3px solid #667eea; }
.sk-view-btn { flex: 1; padding: 14px 24px; background: transparent; border: none; color: #aab; font-size: 15px; font-weight: 600; cursor: pointer; transition: all .2s; border-bottom: 3px solid transparent; margin-bottom: -3px; }
.sk-view-btn:hover { color: #fff; background: rgba(102,126,234,0.15); }
.sk-view-btn.sk-view-active { color: #fff; background: linear-gradient(180deg, rgba(102,126,234,0.3), rgba(102,126,234,0.1)); border-bottom-color: #667eea; }

.sk-view { padding: 20px 24px; background: #f8f9ff; min-height: 500px; }

/* ============================================
 * F041 明細集計画面
 * ============================================ */
.sk-f041-layout { display: grid; grid-template-columns: 1fr 200px; gap: 16px; }
.sk-f041-main { background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 6px rgba(0,0,0,0.06); }
.sk-f041-side { display: flex; flex-direction: column; gap: 6px; padding: 12px; background: #fff; border-radius: 10px; box-shadow: 0 2px 6px rgba(0,0,0,0.06); height: fit-content; }

.sk-f041-side .sk-side-btn { padding: 10px 14px; background: #e8eaf6; border: 1px solid #c5cae9; border-radius: 6px; color: #333; font-size: 13px; cursor: pointer; transition: all .15s; text-align: left; font-weight: 500; }
.sk-f041-side .sk-side-btn:hover { background: #c5cae9; border-color: #7986cb; }
.sk-f041-side .sk-side-btn.sk-side-primary { background: linear-gradient(135deg,#667eea,#764ba2); color: #fff; border-color: #667eea; font-weight: 600; }
.sk-f041-side .sk-side-btn.sk-side-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(102,126,234,.4); }
.sk-f041-side .sk-side-btn.sk-side-secondary { background: #fff8e1; border-color: #ffca28; color: #5d4037; }
.sk-f041-side .sk-side-btn.sk-side-warn { background: #ffebee; border-color: #ef5350; color: #c62828; }
.sk-f041-side hr { border: none; border-top: 1px dashed #d0d7f0; margin: 6px 0; }

.sk-buzai-header { padding: 10px 14px; background: linear-gradient(90deg,#f0f4ff,#fff); border-bottom: 1px solid #e0e7ff; display: flex; gap: 12px; align-items: center; }
.sk-buzai-header label { font-size: 13px; display: flex; align-items: center; gap: 6px; }
.sk-buzai-header select { padding: 5px 8px; border: 1px solid #ccd; border-radius: 6px; font-size: 14px; min-width: 240px; }

.sk-buzai-table-wrap { max-height: 450px; overflow: auto; border-bottom: 1px solid #e0e7ff; }
.sk-buzai-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sk-buzai-table th { background: linear-gradient(180deg,#1a1a2e,#16213e); color: #fff; padding: 8px 6px; font-size: 12px; white-space: nowrap; text-align: center; position: sticky; top: 0; z-index: 2; font-weight: 600; }
.sk-buzai-table td { padding: 6px; border-bottom: 1px solid #e8eaf6; background: #fff; color: #333; font-size: 13px; }
.sk-buzai-table td.num { text-align: right; font-family: 'Consolas','monospace'; }
.sk-buzai-table td.total { font-weight: 700; color: #0f3460; }
.sk-buzai-table .sk-buzai-koushu td { background: #fff9e6 !important; font-weight: 700; color: #f57c00 !important; border-top: 2px solid #ffc107; }
.sk-buzai-table .sk-row-ikkatsu td { background: #e3f2fd !important; color: #1565c0 !important; font-style: italic; }
.sk-buzai-table .sk-row-shukei td { background: #f3e5f5 !important; color: #6a1b9a !important; font-weight: 600; }
.sk-buzai-table tbody tr:hover td { background: #f0f4ff !important; }
.sk-buzai-table .sk-editable { cursor: pointer; position: relative; }
.sk-buzai-table .sk-editable:hover { background: #fff59d !important; }
.sk-buzai-table .sk-editable::after { content: '✎'; opacity: 0; margin-left: 4px; color: #888; }
.sk-buzai-table .sk-editable:hover::after { opacity: 1; }
.sk-buzai-table .sk-loading { text-align: center; padding: 40px; color: #888; }
.sk-buzai-table .sk-err { text-align: center; padding: 40px; color: #c62828; }

/* 下部タブ */
.sk-bottom-tabs { display: flex; background: #e8eaf6; border-top: 2px solid #7986cb; }
.sk-btab { flex: 1; padding: 10px 6px; background: #e8eaf6; border: none; border-right: 1px solid #c5cae9; color: #555; font-size: 12px; font-weight: 600; cursor: pointer; transition: all .15s; }
.sk-btab:last-child { border-right: none; }
.sk-btab:hover { background: #c5cae9; color: #333; }
.sk-btab.sk-btab-active { background: #fff; color: #1a1a2e; border-bottom: 2px solid #667eea; margin-bottom: -2px; }

.sk-bottom-panel { background: #fff; padding: 14px 18px; min-height: 120px; }
.sk-bpanel { display: none; }
.sk-bpanel.sk-bpanel-active { display: block; }
.sk-bp-row { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; }
.sk-bp-col { display: flex; flex-direction: column; gap: 6px; }
.sk-bp-label { font-size: 11px; color: #888; text-transform: uppercase; letter-spacing: 0.5px; }
.sk-koushu-name { padding: 6px 10px; background: #fff9c4; border: 1px solid #ffc107; border-radius: 4px; font-size: 13px; color: #5d4037; min-width: 200px; }
.sk-bp-col label { font-size: 13px; color: #333; display: flex; gap: 6px; align-items: center; }

/* ============================================
 * F042 集計係数設定
 * ============================================ */
.sk-f042-tabs { display: flex; background: #fff; border: 1px solid #c5cae9; border-bottom: none; border-radius: 10px 10px 0 0; overflow: hidden; }
.sk-ktab { flex: 1; padding: 12px 10px; background: #e8eaf6; border: none; border-right: 1px solid #c5cae9; color: #555; font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s; }
.sk-ktab:last-child { border-right: none; }
.sk-ktab:hover { background: #c5cae9; color: #333; }
.sk-ktab.sk-ktab-active { background: #fff; color: #1a1a2e; }

.sk-f042-panel { background: #fff; padding: 20px 24px; border: 1px solid #c5cae9; border-top: none; border-radius: 0 0 10px 10px; box-shadow: 0 2px 6px rgba(0,0,0,0.06); min-height: 400px; }
.sk-kpanel { display: none; }
.sk-kpanel.sk-kpanel-active { display: block; }
.sk-kpanel h3 { margin: 0 0 14px !important; padding: 0 0 6px !important; font-size: 15px !important; color: #1a1a2e !important; border-bottom: 2px solid #667eea; }

.sk-keisu-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sk-keisu-table thead th { background: linear-gradient(180deg,#1a1a2e,#16213e); color: #fff; padding: 8px; font-size: 12px; text-align: center; }
.sk-keisu-table tbody th { background: #f0f4ff; padding: 8px 10px; text-align: left; font-weight: 600; color: #333; border: 1px solid #e0e7ff; }
.sk-keisu-table tbody td { padding: 6px 10px; border: 1px solid #e8eaf6; background: #fff; color: #333; }
.sk-keisu-table tbody td.num { text-align: right; font-family: 'Consolas','monospace'; }
.sk-keisu-table tbody td.total { font-weight: 700; color: #0f3460; }
.sk-keisu-table input[type="number"],
.sk-keisu-table input[type="text"],
.sk-keisu-table select { padding: 4px 6px; border: 1px solid #ccd; border-radius: 4px; font-size: 13px; }
.sk-keisu-table tr.sk-total-row td { background: #fff3e0 !important; border-top: 2px solid #ff9800 !important; }

.sk-hint { margin: 10px 0; color: #666; font-size: 12px; }
.sk-kactions { margin-top: 18px; display: flex; gap: 10px; justify-content: flex-end; }

/* Tab 2 ランク */
.sk-k2-layout { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; }
.sk-k-sub { font-size: 12px; color: #666; margin-bottom: 8px; }
.sk-keihi-wrap { max-height: 360px; overflow: auto; border: 1px solid #c5cae9; border-radius: 4px; }
.sk-keihi-table tbody tr { cursor: pointer; transition: background .1s; }
.sk-keihi-table tbody tr:hover td { background: #fff9c4 !important; }
.sk-keihi-table tr.sk-keihi-selected td { background: #c8e6c9 !important; font-weight: 600; }

/* Tab 3 部材単価 */
.sk-k3-abc-toggle { display: flex; gap: 4px; margin-bottom: 12px; }
.sk-abc-btn { padding: 8px 18px; background: #e8eaf6; border: 1px solid #c5cae9; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; color: #555; transition: all .15s; }
.sk-abc-btn:hover { background: #c5cae9; }
.sk-abc-btn.sk-abc-active { background: linear-gradient(135deg,#667eea,#764ba2); color: #fff; border-color: #667eea; }
.sk-k3-table-wrap { max-height: 450px; overflow: auto; border: 1px solid #e0e7ff; border-radius: 4px; }
.sk-k3-table thead th { padding: 6px 8px; }
.sk-k3-table thead tr:last-child th { background: linear-gradient(180deg,#2d2d4a,#252540); font-size: 11px; font-weight: 500; }
.sk-k3-table tbody td:first-child { text-align: center; color: #888; }
.sk-k3-table tbody td:nth-child(2) { font-weight: 500; }

/* フォーカス中の行をハイライト (Tab3/Tab4) */
.sk-k3-table tbody tr:has(input:focus),
.sk-keisu-table tbody tr:has(input:focus) { background: #fffde7 !important; }
.sk-k3-table tbody tr:has(input:focus) td,
.sk-keisu-table tbody tr:has(input:focus) td { background: #fffde7 !important; }

/* Tab 4 雑材 */
.sk-k4-mode { padding: 12px 14px; background: #f0f4ff; border-radius: 6px; margin-bottom: 14px; display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; }
.sk-k4-mode label { display: flex; gap: 6px; align-items: center; }

/* Tab 5 その他 */
.sk-k5-table tr.sk-k5-section th { background: #e8eaf6; font-size: 13px; padding: 10px; color: #1a237e; }
.sk-k5-table td label { margin-right: 14px; font-size: 13px; }

/* ボタン */
.dvtv-sekisan-wrap .dvtv-btn { padding: 9px 20px; border: none; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all .2s; }
.dvtv-sekisan-wrap .dvtv-btn-sm { padding: 5px 12px !important; font-size: 12px !important; }
.dvtv-sekisan-wrap .dvtv-btn-primary { background: linear-gradient(135deg,#667eea,#764ba2); color: #fff; }
.dvtv-sekisan-wrap .dvtv-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(102,126,234,.4); }
.dvtv-sekisan-wrap .dvtv-btn-secondary { background: #e8eaf6; color: #333; }
.dvtv-sekisan-wrap .dvtv-btn-secondary:hover { background: #c5cae9; }
.dvtv-sekisan-wrap .dvtv-btn-success { background: linear-gradient(135deg,#43a047,#2e7d32); color: #fff; }
.dvtv-sekisan-wrap .dvtv-btn-success:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(67,160,71,.4); }

/* グローバルメッセージ */
.sk-global-msg { padding: 10px 20px; margin: 12px 24px 0; border-radius: 6px; font-size: 14px; font-weight: 600; min-height: 20px; display: inline-block; }
.sk-global-msg:empty { display: none; }
.sk-global-msg.ok { background: #e8f5e9; color: #2e7d32; border: 1px solid #81c784; }
.sk-global-msg.err { background: #ffebee; color: #c62828; border: 1px solid #ef5350; }
.sk-global-msg.loading { background: #e3f2fd; color: #1565c0; border: 1px solid #64b5f6; }

/* レスポンシブ */
@media (max-width: 1100px) {
    .sk-f041-layout { grid-template-columns: 1fr; }
    .sk-f041-side { flex-direction: row; flex-wrap: wrap; }
    .sk-k2-layout { grid-template-columns: 1fr; }
}
