/* ============================================================
   帳簿ツール style.css v2.0
   ============================================================ */

#chobo-app {
    font-family: "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
    font-size: 14px;
    color: #1a1a2e;
    max-width: 1024px;
    margin: 0 auto;
    padding: 16px;
    box-sizing: border-box;
}
#chobo-app *, #chobo-app *::before, #chobo-app *::after { box-sizing: border-box; }

/* ---- 年度バー ---- */
.ch-yearbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.ch-yearbar-label { font-weight: 700; color: #2d4a7a; font-size: 13px; }
.ch-yearbar select {
    padding: 4px 8px;
    border: 1px solid #b8c8e8;
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
    color: #1a1a2e;
}

/* ---- メインナビ ---- */
.ch-nav {
    display: flex;
    border-bottom: 2px solid #2d4a7a;
    margin-bottom: 16px;
}
.ch-nav-btn {
    padding: 9px 28px;
    border: none;
    border-bottom: 3px solid transparent;
    background: none;
    font-size: 14px;
    font-weight: 700;
    color: #888;
    cursor: pointer;
    margin-bottom: -2px;
    transition: all .15s;
    border-radius: 4px 4px 0 0;
}
.ch-nav-btn:hover { color: #2d4a7a; background: #f0f4ff; }
.ch-nav-btn.active { color: #2d4a7a; border-bottom-color: #2d4a7a; background: #f0f4ff; }

/* ---- 画面切替 ---- */
.ch-screen { display: none; }
.ch-screen.active { display: block; }

/* ---- タブ（入力画面内） ---- */
.ch-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #dde;
    margin-bottom: 16px;
}
.ch-tab {
    padding: 7px 20px;
    border: 1px solid #dde;
    border-bottom: none;
    background: #f5f5f8;
    color: #888;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: -1px;
    transition: all .15s;
}
.ch-tab:hover { background: #e8eaf6; color: #2d4a7a; }
.ch-tab.active { background: #fff; color: #2d4a7a; border-bottom-color: #fff; }
.ch-tabcontent { display: none; }
.ch-tabcontent.active { display: block; }

/* ---- 確認画面タブ ---- */
.ch-view-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    border-bottom: 1px solid #dde;
    margin-bottom: 16px;
}
.ch-view-tab {
    padding: 6px 16px;
    border: 1px solid #dde;
    border-bottom: none;
    background: #f5f5f8;
    color: #888;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: -1px;
    transition: all .15s;
}
.ch-view-tab:hover { background: #e8eaf6; color: #2d4a7a; }
.ch-view-tab.active { background: #fff; color: #2d4a7a; border-bottom-color: #fff; }
.ch-view { display: none; }
.ch-view.active { display: block; }

/* ---- セクションタイトル ---- */
.ch-section-title {
    font-size: 11px;
    font-weight: 700;
    color: #2d4a7a;
    letter-spacing: .08em;
    text-transform: uppercase;
    border-left: 3px solid #2d4a7a;
    padding-left: 8px;
    margin: 0 0 8px;
}

/* ---- テンプレートボタン ---- */
.ch-tpl-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}
.ch-tpl-btn {
    padding: 6px 14px;
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
    color: #333;
    cursor: pointer;
    white-space: nowrap;
    transition: all .12s;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    text-align: left;
}
.ch-tpl-btn:hover { background: #fff; border-color: #aaa; }
.ch-tpl-title { font-weight: 700; font-size: 12px; }
.ch-tpl-desc  { font-size: 10px; color: #666; font-weight: 400; }

/* ---- フォーム ---- */
.ch-form {
    background: #fff;
    border: 1px solid #dde;
    border-radius: 8px;
    padding: 20px;
}
.ch-field-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.ch-field-row label {
    min-width: 160px;
    font-size: 13px;
    font-weight: 600;
    color: #444;
    padding-top: 8px;
    flex-shrink: 0;
}
.ch-field-row input[type="text"],
.ch-field-row input[type="number"],
.ch-field-row input[type="date"],
.ch-field-row select {
    flex: 1;
    min-width: 160px;
    padding: 7px 10px;
    border: 1px solid #ccd;
    border-radius: 4px;
    font-size: 13px;
    background: #fafbff;
    transition: border-color .15s;
}
.ch-field-row input:focus,
.ch-field-row select:focus { outline: none; border-color: #2d4a7a; background: #fff; }
.ch-req { color: #e03; font-size: 11px; margin-left: 2px; }

.ch-field-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}
.ch-field-4col {
    display: grid;
    grid-template-columns: 3fr 2fr 3fr 2fr;
    gap: 8px;
    margin-bottom: 12px;
    align-items: end;
    min-width: 0;
}
.ch-field-4col .ch-field-group { min-width: 0; }
.ch-field-4col .ch-field-group select,
.ch-field-4col .ch-field-group input { width: 100%; min-width: 0; }
.ch-field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ch-field-group label {
    font-size: 12px;
    font-weight: 700;
    color: #555;
}
.ch-field-group input,
.ch-field-group select {
    padding: 7px 10px;
    border: 1px solid #ccd;
    border-radius: 4px;
    font-size: 13px;
    background: #fafbff;
}
.ch-field-group input:focus,
.ch-field-group select:focus { outline: none; border-color: #2d4a7a; }

/* 貸方金額＋コピーボタン */
.ch-amount-row {
    display: flex;
    gap: 4px;
}
.ch-amount-row input { flex: 1; }
.ch-btn-copy {
    padding: 7px 10px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 700;
    color: #333;
    cursor: pointer;
    white-space: nowrap;
    transition: all .12s;
}
.ch-btn-copy:hover { background: #f0f0f0; }

/* プラットフォーム */
.ch-platform-wrap { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 160px; }
.ch-platform-wrap input {
    padding: 7px 10px;
    border: 1px solid #ccd;
    border-radius: 4px;
    font-size: 13px;
    background: #fafbff;
}
.ch-platform-wrap input:focus { outline: none; border-color: #2d4a7a; }
.ch-platform-btns { display: flex; flex-wrap: wrap; gap: 4px; }
.ch-platform-btn {
    padding: 4px 10px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 11px;
    color: #333;
    cursor: pointer;
    transition: all .12s;
}
.ch-platform-btn:hover { background: #f0f0f0; border-color: #aaa; }

/* 元丁ボタン */
.ch-moto-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.ch-moto-btn {
    padding: 5px 12px;
    background: #f5f5f8;
    border: 1px solid #ccd;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 700;
    color: #555;
    cursor: pointer;
    transition: all .12s;
    min-width: 40px;
    text-align: center;
}
.ch-moto-btn:hover { background: #e8edf8; color: #2d4a7a; border-color: #b8c8e8; }
.ch-moto-btn.selected { background: #2d4a7a; color: #fff; border-color: #2d4a7a; }

/* 消込 */
.ch-check-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 600;
    color: #444;
    cursor: pointer;
    padding-top: 8px;
}

/* フォームボタン */
.ch-form-btns { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.ch-btn-primary {
    padding: 10px 28px;
    background: #2d4a7a;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: .04em;
    transition: background .15s;
}
.ch-btn-primary:hover { background: #1e3560; }
.ch-btn-ghost {
    padding: 9px 18px;
    background: #fff;
    color: #555;
    border: 1px solid #ccd;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all .15s;
}
.ch-btn-ghost:hover { background: #f0f0f0; color: #333; border-color: #aaa; }
.ch-btn-danger {
    padding: 4px 10px;
    background: #fff;
    color: #c00;
    border: 1px solid #f0a0a0;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all .12s;
}
.ch-btn-danger:hover { background: #fee; }
.ch-btn-edit {
    padding: 4px 10px;
    background: #fff;
    color: #2d4a7a;
    border: 1px solid #b8c8e8;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all .12s;
}
.ch-btn-edit:hover { background: #e8edf8; }

/* メッセージ */
.ch-msg { margin-top: 8px; padding: 8px 12px; border-radius: 4px; font-size: 13px; display: none; }
.ch-msg.ok  { display: block; background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.ch-msg.err { display: block; background: #fce4ec; color: #c62828; border: 1px solid #ef9a9a; }

/* AI相談ノート */
.ch-ai-note {
    background: #f0f4ff;
    border-left: 3px solid #2d4a7a;
    padding: 10px 14px;
    border-radius: 0 6px 6px 0;
    font-size: 13px;
    color: #444;
    margin-bottom: 16px;
    line-height: 1.7;
}

/* ---- ツールバー（編集・確認） ---- */
.ch-toolbar, .ch-view-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.ch-toolbar input {
    padding: 7px 12px;
    border: 1px solid #ccd;
    border-radius: 4px;
    font-size: 13px;
    background: #fafbff;
    width: 100%;
    max-width: 360px;
}
.ch-toolbar input:focus { outline: none; border-color: #2d4a7a; }
.ch-view-toolbar label { font-size: 13px; font-weight: 600; color: #444; }
.ch-view-toolbar select {
    padding: 6px 10px;
    border: 1px solid #ccd;
    border-radius: 4px;
    font-size: 13px;
    background: #fafbff;
}

/* ---- テーブル ---- */
.ch-table-wrap {
    overflow-x: auto;
    border-radius: 6px;
    border: 1px solid #dde;
    margin-bottom: 12px;
}
.ch-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    min-width: 700px;
}
.ch-table th {
    background: #f0f0f0;
    color: #333;
    padding: 8px 10px;
    text-align: left;
    font-weight: 700;
    font-size: 11px;
    white-space: nowrap;
    border-bottom: 2px solid #ccc;
}
.ch-table td {
    padding: 6px 10px;
    border-bottom: 1px solid #eef;
    vertical-align: middle;
    white-space: nowrap;
}
.ch-table tbody tr:last-child td { border-bottom: none; }
.ch-table tbody tr:hover { background: #f5f8ff; }
.ch-table .row-kessai td { background: #f0f9f0; color: #999; }
.ch-table tfoot td {
    font-weight: 700;
    background: #f5f5f5;
    border-top: 2px solid #ccc;
    padding: 8px 10px;
}

/* 消込バッジ */
.ch-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
}
.ch-badge-done { background: #c8e6c9; color: #2e7d32; }
.ch-badge-pending { background: #fff3cd; color: #856404; }

/* 経費合計 */
.ch-keihi-total {
    text-align: right;
    font-size: 13px;
    font-weight: 700;
    color: #2d4a7a;
    padding: 6px 10px;
}

/* ---- 決算表 ---- */
.ch-kessan-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.ch-kessan-block { }
.ch-kessan-title {
    font-size: 13px;
    font-weight: 700;
    color: #2d4a7a;
    border-left: 3px solid #2d4a7a;
    padding-left: 8px;
    margin-bottom: 8px;
}
.ch-kessan-table { min-width: auto; }
.ch-kessan-table td:last-child { text-align: right; }
.ch-kessan-table .ch-pl-total td,
.ch-kessan-table .ch-bs-total td {
    font-weight: 700;
    background: #f0f4ff;
    border-top: 2px solid #2d4a7a;
}
.ch-profit-row td { color: #1565c0; font-weight: 700; }
.ch-loss-row td   { color: #c62828; font-weight: 700; }

/* モーダル */
.ch-modal-bg {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,.5); z-index: 9999;
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.ch-modal-box {
    background: #fff; border-radius: 10px; padding: 24px;
    width: 100%; max-width: 680px; max-height: 90vh; overflow-y: auto;
    box-shadow: 0 4px 32px rgba(0,0,0,.2);
}
.ch-modal-title { margin: 0 0 16px; font-size: 15px; font-weight: 700; color: #2d4a7a; }

/* ---- アドバイスページ ---- */
.ch-advice-wrap { display: flex; flex-direction: column; gap: 24px; }
.ch-advice-block {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 16px 20px;
}
.ch-advice-title {
    font-size: 13px;
    font-weight: 700;
    color: #333;
    border-left: 3px solid #aaa;
    padding-left: 8px;
    margin-bottom: 10px;
}
.ch-advice-note {
    font-size: 12px;
    color: #555;
    line-height: 1.7;
    margin: 8px 0;
}
.ch-advice-table { min-width: auto; margin-bottom: 8px; }

/* レスポンシブ */
@media (max-width: 640px) {
    .ch-nav-btn { padding: 8px 14px; font-size: 12px; }
    .ch-field-row { flex-direction: column; align-items: flex-start; }
    .ch-field-row label { min-width: auto; padding-top: 0; }
    .ch-field-2col { grid-template-columns: 1fr; }
    .ch-field-4col { grid-template-columns: 1fr 1fr; }
    .ch-kessan-wrap { grid-template-columns: 1fr; }
    .ch-view-tabs { gap: 2px; }
    .ch-view-tab { padding: 5px 10px; font-size: 11px; }
}
