/* ============================================================
 * DVTV-102 パインズ積算エンジン CSS (v3.1.0-alpha2)
 * F041 明細集計画面 + F042 集計係数設定 上下分割統合UI
 *   v3.1.0-alpha2: ヘッダーコンパクト化、見積情報＋集計サマリー統合、
 *                  スプリッターを高さ20pxに拡大＋hitbox広域化、
 *                  パディング全般削減、上下ペイン最低高200px
 * ============================================================ */

/* ワークフロー (他プラグインのページでも共通利用) */
@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; }

/* 重複部材の枝番 (1-1, 1-2) 表示 */
.dvtv-sekisan-wrap .sk-dup-no { color: #9aa; font-size: 11px; font-weight: 500; font-style: italic; letter-spacing: -0.5px; }

.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: 8px 20px !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: 16px !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: 6px 20px; }

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

/* v3.1.0-alpha2: 見積情報バーをコンパクト化＋集計サマリー統合 */
.dvtv-sekisan-wrap .dvtv-info-bar { background: #f0f4ff; padding: 6px 16px; display: flex; gap: 14px; font-size: 13px; border-bottom: 1px solid #e0e7ff; align-items: center; flex-wrap: wrap; }
.dvtv-sekisan-wrap .dvtv-info-bar strong { color: #0f3460; }
/* 旧 sk-grand-total は非表示（互換のためHTML残置のみ） */
.dvtv-sekisan-wrap .sk-grand-total { display: none; }

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

/* ============================================
 * ビュー切替タブ (v3.1.0: モバイル時のみ表示)
 * ============================================ */
.sk-mobile-only { display: none; }
.sk-layout-mobile .sk-mobile-only { display: flex; }

.sk-viewswitch { 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; }

/* v3.1.0-alpha2: ペイン内スクロール、パディング縮小 */
.sk-view { padding: 8px 12px; background: #f8f9ff; }

/* ============================================
 * 統合情報バー (見積情報＋集計サマリー、v3.1.0-alpha2)
 * ============================================ */
.dvtv-sekisan-wrap .dvtv-info-bar.sk-summary-bar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 6px 16px;
    background: linear-gradient(90deg, #fff8e1, #fff3c4 60%, #fff8e1);
    border-top: 1px solid #f0c060; border-bottom: 1px solid #f0c060;
    font-size: 12px; color: #5d4037;
}
.dvtv-sekisan-wrap .sk-info-mno {
    color: #1565c0; font-weight: 600; padding-right: 6px;
    border-right: 1px solid rgba(141,110,99,0.3); margin-right: 4px;
}
.dvtv-sekisan-wrap .sk-info-mno strong { color: #0d47a1; font-size: 14px; font-family: 'Consolas','monospace'; }
.dvtv-sekisan-wrap .sk-info-name { color: #5d4037; font-size: 12px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dvtv-sekisan-wrap .sk-info-name:empty { display: none; }
.dvtv-sekisan-wrap .sk-info-ucd { color: #6d4c41; padding-right: 6px; }
.dvtv-sekisan-wrap .sk-info-ucd strong { color: #4e342e; font-size: 13px; }

.dvtv-sekisan-wrap .sk-sum-item {
    display: inline-flex; align-items: baseline; gap: 5px;
    padding: 3px 8px; background: rgba(255,255,255,0.7);
    border-radius: 5px; border: 1px solid rgba(244,196,48,0.4);
    transition: background 0.3s, box-shadow 0.3s;
}
.dvtv-sekisan-wrap .sk-sum-item label {
    font-size: 10px; color: #8d6e63; font-weight: 600;
    letter-spacing: 0.2px;
}
.dvtv-sekisan-wrap .sk-sum-item strong {
    font-family: 'Consolas','monospace'; font-size: 13px; color: #0f3460;
    font-weight: 700; min-width: 40px; display: inline-block; text-align: right;
}
.dvtv-sekisan-wrap .sk-sum-grand strong { color: #c62828; font-size: 15px; min-width: 60px; }
.dvtv-sekisan-wrap .sk-sum-sep {
    width: 1px; height: 18px; background: rgba(141,110,99,0.3); margin: 0 2px;
}
.dvtv-sekisan-wrap .sk-sum-refresh {
    margin-left: auto; padding: 3px 8px; border: 1px solid #d0a050;
    background: #fff; color: #b8860b; font-size: 12px; border-radius: 5px;
    cursor: pointer; transition: all .15s;
}
.dvtv-sekisan-wrap .sk-sum-refresh:hover { background: #fff3c4; }

/* 差分ハイライト (5秒間フラッシュ) */
@keyframes sk-diff-flash-up-anim {
    0%   { background: rgba(255,255,255,0.7); box-shadow: none; }
    8%   { background: #c8e6c9; box-shadow: 0 0 0 2px rgba(76,175,80,0.5); }
    60%  { background: #c8e6c9; box-shadow: 0 0 0 2px rgba(76,175,80,0.5); }
    100% { background: rgba(255,255,255,0.7); box-shadow: none; }
}
@keyframes sk-diff-flash-down-anim {
    0%   { background: rgba(255,255,255,0.7); box-shadow: none; }
    8%   { background: #ffcdd2; box-shadow: 0 0 0 2px rgba(239,83,80,0.5); }
    60%  { background: #ffcdd2; box-shadow: 0 0 0 2px rgba(239,83,80,0.5); }
    100% { background: rgba(255,255,255,0.7); box-shadow: none; }
}
.dvtv-sekisan-wrap .sk-sum-item.sk-diff-flash.sk-diff-up {
    animation: sk-diff-flash-up-anim 5s ease-in-out;
}
.dvtv-sekisan-wrap .sk-sum-item.sk-diff-flash.sk-diff-down {
    animation: sk-diff-flash-down-anim 5s ease-in-out;
}

/* ============================================
 * メインラッパー (v3.1.0-alpha10: 上下分割廃止 → 部材リスト全画面)
 * ============================================ */
.dvtv-sekisan-wrap .sk-main-wrap {
    display: grid; grid-template-columns: 1fr 200px; gap: 12px;
    padding: 8px 16px; background: #f8f9ff;
}
.dvtv-sekisan-wrap .sk-main-pane {
    background: #fff; border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    overflow: auto;
    min-height: calc(100vh - 240px);
    max-height: calc(100vh - 240px);
}

/* ============================================
 * フローティングウィンドウ (v3.1.0-alpha10 NEW)
 * F042 集計係数設定をドラッグ可能・リサイズ可能なウィンドウとして表示
 * ============================================ */
.dvtv-sekisan-wrap .sk-keisu-window {
    position: fixed; z-index: 9999;
    background: #fff;
    border: 1px solid #5c6bc0;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25), 0 2px 8px rgba(0,0,0,0.15);
    display: flex; flex-direction: column;
    overflow: hidden;
    min-width: 500px; min-height: 350px;
    transition: box-shadow 0.2s;
}
.dvtv-sekisan-wrap .sk-keisu-window:hover {
    box-shadow: 0 12px 40px rgba(0,0,0,0.3), 0 3px 10px rgba(0,0,0,0.2);
}

/* タイトルバー (ドラッグハンドル) */
.dvtv-sekisan-wrap .sk-kw-titlebar {
    flex: 0 0 auto;
    background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
    color: #fff;
    padding: 8px 12px;
    display: flex; align-items: center; gap: 12px;
    cursor: move; user-select: none;
    border-radius: 9px 9px 0 0;
    height: 36px; box-sizing: border-box;
}
.dvtv-sekisan-wrap .sk-kw-title {
    font-size: 14px; font-weight: 700; letter-spacing: 0.3px;
    flex: 0 0 auto;
}
.dvtv-sekisan-wrap .sk-kw-status {
    flex: 1; font-size: 11px; opacity: 0.85; font-weight: 500;
    text-align: center;
}
.dvtv-sekisan-wrap .sk-kw-controls {
    flex: 0 0 auto; display: flex; gap: 4px;
}
.dvtv-sekisan-wrap .sk-kw-btn {
    width: 26px; height: 22px;
    border: 1px solid rgba(255,255,255,0.3); background: rgba(255,255,255,0.1);
    color: #fff; font-size: 14px; font-weight: 700;
    cursor: pointer; padding: 0; line-height: 1;
    border-radius: 3px; transition: all 0.15s;
    display: flex; align-items: center; justify-content: center;
}
.dvtv-sekisan-wrap .sk-kw-btn:hover { background: rgba(255,255,255,0.25); }
.dvtv-sekisan-wrap .sk-kw-close:hover { background: #e53935; border-color: #c62828; }

/* ウィンドウ本体 (タブ群+パネル) */
.dvtv-sekisan-wrap .sk-kw-body {
    flex: 1; overflow: auto; background: #fff;
    border-radius: 0 0 10px 10px;
}
.dvtv-sekisan-wrap .sk-kw-body .sk-view {
    padding: 0; background: transparent;
}

/* リサイズハンドル (右下角) */
.dvtv-sekisan-wrap .sk-kw-resize {
    position: absolute; right: 0; bottom: 0;
    width: 18px; height: 18px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, #9fa8da 50%, #5c6bc0 70%, #5c6bc0 80%, #9fa8da 80%, #9fa8da 95%, transparent 95%);
    border-radius: 0 0 9px 0;
    z-index: 2;
}

/* 最小化状態: タイトルバーだけ残す (画面下に配置) */
.dvtv-sekisan-wrap .sk-keisu-window.sk-kw-minimized .sk-kw-body,
.dvtv-sekisan-wrap .sk-keisu-window.sk-kw-minimized .sk-kw-resize {
    display: none;
}
.dvtv-sekisan-wrap .sk-keisu-window.sk-kw-minimized {
    height: auto !important;
    min-height: 0;
}

/* 最大化状態: 画面いっぱい (z-index最前面でタイトルバー確実表示) */
.dvtv-sekisan-wrap .sk-keisu-window.sk-kw-maximized {
    left: 0 !important; top: 0 !important;
    width: 100vw !important; height: 100vh !important;
    border-radius: 0;
    z-index: 99999 !important; /* 管理バー等より前面 */
}
.dvtv-sekisan-wrap .sk-keisu-window.sk-kw-maximized .sk-kw-titlebar {
    border-radius: 0; cursor: default;
    /* タイトルバーが必ず見えるよう先頭固定+背景重め */
    position: sticky; top: 0; z-index: 2;
    background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
}
.dvtv-sekisan-wrap .sk-keisu-window.sk-kw-maximized .sk-kw-resize { display: none; }
/* 最大化中の制御ボタンを大きく目立たせる */
.dvtv-sekisan-wrap .sk-keisu-window.sk-kw-maximized .sk-kw-btn {
    width: 36px; height: 28px; font-size: 16px;
}

/* ドラッグ/リサイズ中の挙動 */
body.sk-kw-dragging, body.sk-kw-dragging *,
body.sk-kw-resizing, body.sk-kw-resizing * {
    user-select: none !important;
    -webkit-user-select: none !important;
}
body.sk-kw-dragging * { cursor: move !important; }
body.sk-kw-resizing * { cursor: nwse-resize !important; }

/* 「⚙ 集計係数設定」開閉ボタン (操作パネル最上段) */
.sk-f041-side .sk-side-btn.sk-side-keisu-toggle {
    background: linear-gradient(135deg, #5c6bc0, #3949ab);
    color: #fff; border: 2px solid #3949ab;
    font-weight: 700; font-size: 14px;
    padding: 14px 14px;
    text-align: center;
    box-shadow: 0 3px 10px rgba(57,73,171,0.3);
    position: relative;
    animation: sk-keisu-pulse 2.5s ease-in-out infinite;
}
.sk-f041-side .sk-side-btn.sk-side-keisu-toggle:hover {
    background: linear-gradient(135deg, #3949ab, #283593);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(57,73,171,0.5);
    animation: none;
}
.sk-f041-side .sk-side-btn.sk-side-keisu-toggle.sk-keisu-active {
    background: linear-gradient(135deg, #2e7d32, #1b5e20);
    border-color: #1b5e20;
    animation: none;
    box-shadow: 0 3px 10px rgba(46,125,50,0.3);
}
@keyframes sk-keisu-pulse {
    0%, 100% { box-shadow: 0 3px 10px rgba(57,73,171,0.3); }
    50%      { box-shadow: 0 3px 18px rgba(57,73,171,0.65), 0 0 0 4px rgba(92,107,192,0.15); }
}

/* バッジ（開状態） */
.dvtv-sekisan-wrap .sk-keisu-badge {
    display: inline-block;
    background: #fff; color: #2e7d32;
    font-size: 11px; font-weight: 800;
    padding: 1px 6px; border-radius: 8px;
    margin-left: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ヒントテキスト */
.dvtv-sekisan-wrap .sk-keisu-hint {
    font-size: 10px; color: #5c6bc0;
    text-align: center;
    padding: 0 4px 2px;
    font-style: italic;
    letter-spacing: 0.3px;
}
.sk-f041-side .sk-side-btn.sk-side-keisu-toggle.sk-keisu-active + .sk-keisu-hint {
    display: none;
}

/* ============================================
 * F041 明細集計画面 (上下分割対応版)
 * ============================================ */
.sk-f041-layout { display: block; }
.sk-f041-main { background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }

/* 共通サイド (上下分割の右端、両ペイン共通操作パネル) */
.dvtv-sekisan-wrap .sk-side-shared {
    display: flex; flex-direction: column; gap: 6px; padding: 10px;
    background: #fff; border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    /* v3.1.0-alpha9: コンテナ全高に拡張（動作ログが空きスペースを埋める） */
    height: calc(100vh - 240px);
    min-height: 480px;
    align-self: start;
}
/* 動作ログをサイドパネルの末尾に伸ばす */
.dvtv-sekisan-wrap .sk-side-shared .sk-action-log {
    flex: 1; min-height: 100px;
    display: flex; flex-direction: column;
}
.dvtv-sekisan-wrap .sk-side-shared .sk-action-log .sk-action-log-body {
    flex: 1; max-height: none;
}
.sk-f041-side .sk-side-btn { padding: 9px 12px; background: #e8eaf6; border: 1px solid #c5cae9; border-radius: 6px; color: #333; font-size: 12px; 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: 8px 12px; 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; }

/* v3.1.0: ペイン内スクロールするので max-height 制限を解除 */
.sk-buzai-table-wrap { overflow: visible; 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; align-items: center; }

/* ============================================
 * 自動保存ステータス (v3.1.0-alpha7 NEW / alpha8 強化)
 * ============================================ */
/* 各タブ内のステータス */
.sk-auto-save-hint {
    background: #f0f4ff; border: 1px dashed #c5cae9; border-radius: 6px;
    padding: 8px 14px; justify-content: space-between !important;
}
.sk-auto-save-msg {
    color: #5e6dab; font-size: 12px; font-style: italic;
}
.sk-tab-save-status {
    font-size: 12px; font-weight: 600; min-width: 140px; text-align: right;
    transition: opacity 0.3s;
}
.sk-tab-save-status.saving { color: #1976d2; animation: sk-status-pulse 1.2s ease-in-out infinite; }
.sk-tab-save-status.saved  { color: #2e7d32; }
.sk-tab-save-status.error  { color: #c62828; }
.sk-tab-save-status.skip   { color: #f57c00; }

/* サマリーバー右の保存ステータス (alpha8: より目立つ表示) */
.dvtv-sekisan-wrap .sk-save-status {
    display: inline-block; font-size: 12px; font-weight: 700;
    padding: 4px 10px; border-radius: 6px; min-width: 0;
    transition: background 0.3s, color 0.3s;
    border: 2px solid transparent;
}
.dvtv-sekisan-wrap .sk-save-status:empty { display: none; }
.dvtv-sekisan-wrap .sk-save-status.saving {
    color: #fff; background: #1976d2; border-color: #1565c0;
    animation: sk-status-pulse 1.2s ease-in-out infinite;
}
.dvtv-sekisan-wrap .sk-save-status.saved {
    color: #fff; background: #2e7d32; border-color: #1b5e20;
}
.dvtv-sekisan-wrap .sk-save-status.error {
    color: #fff; background: #c62828; border-color: #b71c1c;
    animation: sk-status-flash 0.5s ease-in-out 3;
}
@keyframes sk-status-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.55; }
}
@keyframes sk-status-flash {
    0%, 100% { background: #c62828; }
    50%      { background: #ff5252; }
}

/* v3.1.0-alpha8: 入力欄保存成功時の緑フラッシュ (1秒) */
@keyframes sk-saved-flash-anim {
    0%   { box-shadow: 0 0 0 0 rgba(76,175,80,0); border-color: inherit; }
    20%  { box-shadow: 0 0 0 4px rgba(76,175,80,0.5); border-color: #4caf50 !important; background-color: #e8f5e9; }
    100% { box-shadow: 0 0 0 0 rgba(76,175,80,0); border-color: inherit; background-color: inherit; }
}
.dvtv-sekisan-wrap input.sk-saved-flash,
.dvtv-sekisan-wrap select.sk-saved-flash {
    animation: sk-saved-flash-anim 1s ease-out !important;
}

/* v3.1.0-alpha9: 動作ログエリア (操作パネル下) */
.dvtv-sekisan-wrap .sk-action-log {
    background: #f8f9ff; border: 1px solid #d0d8f0; border-radius: 6px;
    padding: 0; overflow: hidden; margin-top: 4px;
}
.dvtv-sekisan-wrap .sk-action-log-header {
    background: linear-gradient(90deg, #5c6bc0, #3949ab); color: #fff;
    padding: 6px 10px; font-size: 11px; font-weight: 700;
    letter-spacing: 0.5px;
}
.dvtv-sekisan-wrap .sk-action-log-body {
    max-height: 280px; overflow-y: auto;
    padding: 4px 0; background: #fff;
}
.dvtv-sekisan-wrap .sk-action-log-empty {
    padding: 10px; font-size: 11px; color: #999; text-align: center;
    font-style: italic;
}
.dvtv-sekisan-wrap .sk-action-log-row {
    padding: 4px 8px; font-size: 11px; border-bottom: 1px dotted #e8eaf6;
    display: flex; gap: 5px; align-items: flex-start;
    transition: background 0.2s;
}
.dvtv-sekisan-wrap .sk-action-log-row:hover { background: #f0f4ff; }
.dvtv-sekisan-wrap .sk-action-log-row:last-child { border-bottom: none; }
.dvtv-sekisan-wrap .sk-action-log-row.sk-log-ok  { background: rgba(232,245,233,0.4); }
.dvtv-sekisan-wrap .sk-action-log-row.sk-log-err { background: rgba(255,235,238,0.6); }
.dvtv-sekisan-wrap .sk-log-time {
    color: #888; font-family: 'Consolas','monospace'; font-size: 10px;
    flex-shrink: 0; min-width: 52px;
}
.dvtv-sekisan-wrap .sk-log-icon { flex-shrink: 0; min-width: 14px; }
.dvtv-sekisan-wrap .sk-log-ok .sk-log-icon { color: #2e7d32; font-weight: 700; }
.dvtv-sekisan-wrap .sk-log-err .sk-log-icon { color: #c62828; font-weight: 700; }
.dvtv-sekisan-wrap .sk-log-msg {
    color: #333; word-break: break-all; line-height: 1.3;
}

/* 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: linear-gradient(90deg, #c8e6c9 0%, #a5d6a7 100%) !important;
    font-weight: 700; color: #1b5e20 !important;
    box-shadow: inset 3px 0 0 #2e7d32;
    position: relative;
}
.sk-keihi-table tr.sk-keihi-selected td:first-child::before {
    content: '✓ ';
    color: #2e7d32; font-weight: 900;
}

/* v3.1.0-alpha4: ランク未設定時のフォーム警告枠 */
@keyframes sk-k2-warn-pulse {
    0%, 100% { box-shadow: inset 0 0 0 2px transparent; background: transparent; }
    50%      { box-shadow: inset 0 0 0 2px #ff9800; background: rgba(255,243,224,0.6); }
}
.sk-k2-form.sk-k2-empty-warn {
    animation: sk-k2-warn-pulse 2.5s ease-in-out infinite;
    border-radius: 6px;
    position: relative;
}
.sk-k2-form.sk-k2-empty-warn::before {
    content: '⚠ ランク未設定 — 左の一覧から選択してください';
    display: block; padding: 8px 12px; margin-bottom: 8px;
    background: #fff3e0; border: 1px solid #ffb74d; border-radius: 5px;
    color: #e65100; font-size: 12px; 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) {
    .dvtv-sekisan-wrap .sk-main-wrap { grid-template-columns: 1fr; }
    .dvtv-sekisan-wrap .sk-side-shared {
        flex-direction: row; flex-wrap: wrap;
        position: static; height: auto; min-height: 0;
    }
    .dvtv-sekisan-wrap .sk-side-shared .sk-action-log { flex: 1 1 100%; min-height: 100px; }
    .sk-k2-layout { grid-template-columns: 1fr; }
}

/* モバイル(<768px): フローティングウィンドウを画面ほぼ全面に */
@media (max-width: 768px) {
    .dvtv-sekisan-wrap .dvtv-info-bar.sk-summary-bar {
        padding: 6px 10px; font-size: 11px; gap: 6px;
    }
    .dvtv-sekisan-wrap .sk-sum-item strong { font-size: 12px; min-width: 36px; }
    .dvtv-sekisan-wrap .sk-sum-grand strong { font-size: 13px; min-width: 50px; }

    .dvtv-sekisan-wrap .sk-main-wrap { padding: 6px 8px; }
    .dvtv-sekisan-wrap .sk-main-pane {
        min-height: 50vh; max-height: none;
    }
    .dvtv-sekisan-wrap .sk-buzai-table-wrap { max-height: 60vh; overflow: auto; }

    /* モバイル時はフローティングウィンドウを画面ほぼ全面に */
    .dvtv-sekisan-wrap .sk-keisu-window {
        left: 5px !important; top: 60px !important;
        width: calc(100vw - 10px) !important;
        height: calc(100vh - 70px) !important;
        min-width: 0; min-height: 0;
    }
    .dvtv-sekisan-wrap .sk-kw-resize { display: none; }
    .dvtv-sekisan-wrap .sk-kw-titlebar { cursor: default; }
}

/* 多案(見積案)タブ */
.dvtv-sekisan-wrap .sk-plan-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; padding: 6px 16px; margin: 4px 0;
    background: linear-gradient(135deg, #fafbff, #f0f4ff);
    border: 1px solid #d8dff3; border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    flex-wrap: wrap;
}
.dvtv-sekisan-wrap .sk-plan-tabs { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.dvtv-sekisan-wrap .sk-plan-loading { color: #8899aa; font-size: 12px; font-style: italic; }
.dvtv-sekisan-wrap .sk-plan-tab {
    padding: 4px 12px;
    background: #fff;
    border: 2px solid #d0d8f0;
    border-radius: 16px;
    font-size: 12px; font-weight: 600; color: #556;
    cursor: pointer; transition: all .2s;
    min-width: 56px;
}
.dvtv-sekisan-wrap .sk-plan-tab:hover:not(.sk-plan-current) {
    background: #eef2ff; border-color: #a5b0e0; transform: translateY(-1px);
}
.dvtv-sekisan-wrap .sk-plan-current {
    background: linear-gradient(135deg, #667eea, #764ba2) !important;
    color: #fff !important; border-color: #667eea !important;
    box-shadow: 0 2px 8px rgba(102,126,234,0.4);
    animation: dvtv-neon-pulse 2.5s ease-in-out infinite;
}
.dvtv-sekisan-wrap .sk-plan-saiyo:not(.sk-plan-current) {
    background: linear-gradient(135deg, #fff9e5, #fff3c4);
    border-color: #f4c430;
    color: #b8860b;
}
.dvtv-sekisan-wrap .sk-plan-saiyo.sk-plan-current {
    /* 採用中かつ選択中 → 星を強調 */
    background: linear-gradient(135deg, #8b5cf6, #6366f1) !important;
    box-shadow: 0 2px 12px rgba(139,92,246,0.5);
}
.dvtv-sekisan-wrap .sk-plan-empty {
    background: #fafbfc; color: #98a0b0; border-style: dashed;
    border-color: #c8cedc;
}
.dvtv-sekisan-wrap .sk-plan-empty:hover {
    background: #eef2ff; color: #667eea; border-style: solid;
}
.dvtv-sekisan-wrap .sk-plan-actions { display: flex; align-items: center; gap: 6px; }

/* ============================================================
 * v3.2.3: 見積総額表示パネル (部材リスト最上部)
 * 行を無駄にせず、見やすく・分かりやすく
 * ============================================================ */
.dvtv-sekisan-wrap .sk-grand-panel {
    background: linear-gradient(135deg, #f5f8ff 0%, #ffffff 100%);
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 8px 14px;
    margin: 8px 0 10px 0;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.12);
    transition: all 0.3s ease;
}
.dvtv-sekisan-wrap .sk-grand-panel.sk-grand-stale {
    background: linear-gradient(135deg, #fff8e1 0%, #fff 100%);
    border-color: #ffa726;
    box-shadow: 0 2px 8px rgba(255, 167, 38, 0.18);
}
.dvtv-sekisan-wrap .sk-grand-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
}
.dvtv-sekisan-wrap .sk-grand-main {
    margin-bottom: 4px;
}
.dvtv-sekisan-wrap .sk-grand-label {
    font-size: 14px;
    font-weight: 700;
    color: #4c5cdc;
    letter-spacing: 0.5px;
}
.dvtv-sekisan-wrap .sk-grand-plan {
    background: #4c5cdc;
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.dvtv-sekisan-wrap .sk-grand-stale {
    background: #ff9800;
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    animation: sk-grand-stale-pulse 2s ease-in-out infinite;
}
@keyframes sk-grand-stale-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.65; }
}
.dvtv-sekisan-wrap .sk-grand-spacer {
    flex: 1;
    min-width: 8px;
}
.dvtv-sekisan-wrap .sk-grand-amount {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    padding: 0 4px;
}
.dvtv-sekisan-wrap .sk-grand-amount label {
    font-size: 11px;
    color: #666;
    font-weight: 500;
    margin-right: 2px;
}
.dvtv-sekisan-wrap .sk-grand-amount .num {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.1;
    font-family: 'Roboto Mono', 'Consolas', monospace;
    letter-spacing: -0.3px;
}
/* 提出金額: 青系 */
.dvtv-sekisan-wrap .sk-grand-teishutsu .num {
    color: #1976d2;
}
/* 社内金額: 緑系 */
.dvtv-sekisan-wrap .sk-grand-shanai .num {
    color: #2e7d32;
}
/* 粗利益: オレンジ系 (負の場合は赤) */
.dvtv-sekisan-wrap .sk-grand-rieki .num {
    color: #f57c00;
    font-size: 16px;
}
.dvtv-sekisan-wrap .sk-grand-rieki .num.sk-grand-loss {
    color: #c62828;
}
.dvtv-sekisan-wrap .sk-grand-rieki-rate {
    font-size: 12px;
    color: #f57c00;
    font-weight: 600;
}
/* 税込: グレー系 (補助情報) */
.dvtv-sekisan-wrap .sk-grand-zeikomi .num {
    color: #555;
    font-size: 16px;
}
.dvtv-sekisan-wrap .sk-grand-zeikomi-tax {
    font-size: 10px;
    color: #999;
    margin-left: 2px;
}

/* 内訳行 */
.dvtv-sekisan-wrap .sk-grand-detail {
    border-top: 1px dashed #d8dee9;
    padding-top: 6px;
    gap: 12px;
}
.dvtv-sekisan-wrap .sk-grand-detail-label {
    font-size: 11px;
    color: #888;
    font-weight: 600;
    margin-right: 4px;
}
.dvtv-sekisan-wrap .sk-grand-detail-item {
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    font-size: 12px;
}
.dvtv-sekisan-wrap .sk-grand-detail-item label {
    font-size: 10px;
    color: #888;
    font-weight: 500;
}
.dvtv-sekisan-wrap .sk-grand-detail-item .num {
    font-size: 12px;
    font-weight: 600;
    color: #444;
    font-family: 'Roboto Mono', 'Consolas', monospace;
}
.dvtv-sekisan-wrap .sk-grand-detail-spacer {
    flex: 1;
    min-width: 8px;
}
.dvtv-sekisan-wrap .sk-grand-meta {
    color: #888;
    font-size: 11px;
}
.dvtv-sekisan-wrap .sk-grand-meta span {
    color: #555;
    font-weight: 600;
    margin-left: 2px;
}

/* モバイル時のレスポンシブ */
@media (max-width: 720px) {
    .dvtv-sekisan-wrap .sk-grand-amount .num {
        font-size: 18px;
    }
    .dvtv-sekisan-wrap .sk-grand-rieki .num,
    .dvtv-sekisan-wrap .sk-grand-zeikomi .num {
        font-size: 14px;
    }
    .dvtv-sekisan-wrap .sk-grand-row {
        gap: 8px;
    }
}

/* ダークモード対応 */
.dvtv-sekisan-wrap[data-theme="dark"] .sk-grand-panel {
    background: linear-gradient(135deg, #2a2f4a 0%, #1e2235 100%);
    border-color: #7c8cdf;
}
.dvtv-sekisan-wrap[data-theme="dark"] .sk-grand-panel.sk-grand-stale {
    background: linear-gradient(135deg, #3d3826 0%, #2b2820 100%);
    border-color: #ffb74d;
}
.dvtv-sekisan-wrap[data-theme="dark"] .sk-grand-label {
    color: #a0aef8;
}
.dvtv-sekisan-wrap[data-theme="dark"] .sk-grand-amount label,
.dvtv-sekisan-wrap[data-theme="dark"] .sk-grand-detail-label,
.dvtv-sekisan-wrap[data-theme="dark"] .sk-grand-detail-item label {
    color: #aaa;
}
.dvtv-sekisan-wrap[data-theme="dark"] .sk-grand-teishutsu .num { color: #64b5f6; }
.dvtv-sekisan-wrap[data-theme="dark"] .sk-grand-shanai .num { color: #81c784; }
.dvtv-sekisan-wrap[data-theme="dark"] .sk-grand-rieki .num { color: #ffb74d; }
.dvtv-sekisan-wrap[data-theme="dark"] .sk-grand-zeikomi .num { color: #ddd; }
.dvtv-sekisan-wrap[data-theme="dark"] .sk-grand-detail-item .num { color: #ccc; }
.dvtv-sekisan-wrap[data-theme="dark"] .sk-grand-detail { border-top-color: #444a6b; }
