:root {
    --waterfall-graph-height: 260px; /* デフォルトのウォーターフォールグラフの高さ */
}

/* 全体的な財務インパクトグラフ */
.summary-graph {
    margin-bottom: 30px;
    position: relative; /* z-indexとposition:absoluteの基準点として追加 */
}

.graph-bar-container {
    display: flex;
    width: 100%;
    height: 30px;
    border-radius: 5px;
    overflow: hidden;
    background-color: #f0f0f0; /* 背景色 */
}

.graph-bar-segment {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.9em;
    white-space: nowrap;
    overflow: hidden;
    transition: width 0.5s ease-in-out;
}

.graph-bar-final-price {
    background-color: #4CAF50; /* 実質負担額の色 */
}

.graph-bar-coupon {
    background-color: #FFC107; /* クーポンの色 */
}

.graph-bar-points {
    background-color: var(--primary-color); /* ポイントの色 */
}

.graph-legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    font-size: 0.9em;
}

.legend-color-box {
    width: 15px;
    height: 15px;
    margin-right: 8px;
    border-radius: 3px;
}

/* ポイント内訳円グラフ */
.pie-chart-container {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    margin: 0 auto 15px auto;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pie-chart-center-text {
    width: 70%;
    height: 70%;
    background-color: white;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 1.2em;
    color: #333;
}

.pie-chart-center-text span {
    font-size: 0.6em;
    font-weight: normal;
    color: #666;
}

/* ウォーターフォールチャート */
.graph-title {
    text-align: center;
    font-size: 1.1em;
    margin-bottom: 15px;/* タイトル下のスペース */
    color: #2e2e2e;
}

.waterfall-chart-title {
    margin-bottom: 40px; /* ウォーターフォールチャートのタイトル下のスペース */
}

.waterfall-chart-container {

    display: flex;

    width: 100%;

    position: relative;

    padding-bottom: 0; /* 補助線を底辺に表示するためpaddingを削除 */

    margin-bottom: 60px; /* ラベル用のスペースをマージンで確保 */

    /* border-bottom はJSで描画するため削除 */

}



.waterfall-y-axis {

    width: 1px;

    background-color: #ccc;

    position: absolute;

    left: 0;

    top: 0;

    height: calc(100% - 40px);

}



.waterfall-chart {

    display: flex;

    justify-content: space-around;

    width: 100%;

    height: 100%;

}



.waterfall-item {

    flex: 1;

    position: relative;

    display: flex;

    flex-direction: column;

    align-items: center;

    justify-content: flex-end; /* 下揃え */

}



.waterfall-bar {

    width: 60%;

    position: absolute;

    transition: height 0.5s ease-out, bottom 0.5s ease-out;

}



.waterfall-start {

    background-color: #07c707; /* 開始（灰色） */

}

.waterfall-increase {

    background-color: #28a745; /* 増加（緑） */

}



.waterfall-decrease {

    background-color: #e74dac; /* 減少（赤） */

}



.waterfall-end {

    background-color: #007bff; /* 終了（青） */

}



.waterfall-label-name {

    position: absolute;

    bottom: 15px; /* グラフの底辺より10px上にラベルの最下部を揃える */

    left: 50%; /* 棒の中心に配置 */

    transform: translateX(-50%); /* X座標を中央に調整 */

    writing-mode: vertical-rl; /* 縦書き（右から左） */

    text-orientation: mixed; /* 欧文や数字は横向きに */

    font-size: 0.8em;

    color: #333;

    white-space: nowrap; /* 縦書きでの改行を防ぐ */

    font-weight: bold;

    z-index: 1;

}

.waterfall-value-label {
    position: absolute;
    width: 100%;
    text-align: center;
    font-size: 1.2em;
    color: #1a1919;
    transition: bottom 0.5s ease-out;
    font-weight: bold;
    z-index: 10; /* ラベルが他の要素より前面に表示されるように設定 */
}

.label-above {
    /* 増加バーの上にラベルを配置 */
}

.label-below {
    /* 減少バーの下にラベルを配置 */
}

/* Multi Donut Chart */
.multi-donut-chart {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}

.donut-segment {
    transition: fill 0.2s ease-in-out; /* fillプロパティにトランジションを追加 */
    cursor: pointer;
    stroke: #6b6b6b; /* 境目の色を白に設定 */
    stroke-width: 0.28px; /* 境目の太さを2pxに設定 */
}

.donut-segment:hover {
    fill: #666666 !important; /* ホバー時にグレーに変更し、!importantで優先 */
}

.donut-center-text {
    font-family: 'Segoe UI', 'Meiryo', sans-serif;
}

.donut-center-total {
    font-size: 1.4em;
    font-weight: bold;
    fill: #333;
}

.donut-center-label {
    font-size: 0.9em;
    fill: #666;
}

.multi-donut-legend {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.legend-layer {
    border: var(--legend-layer-border-width) var(--legend-layer-border-style) var(--legend-layer-border-color);
    border-radius: 6px;
    padding: 10px;
}

.legend-master-toggle {
    margin-top: 20px; /* SVGと凡例の間のスペース */
}

.legend-layer summary {
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    outline: none;
    padding: 5px 0;
    list-style: none; /* マーカーを非表示 (古いブラウザ用) */
    display: flex;
    align-items: center;
}

.legend-layer summary::after {
    content: '▼'; /* 閉じた状態のマーカー */
    font-size: 0.8em;
    margin-left: 10px;
}

.legend-layer[open] > summary::after {
    content: '▲'; /* 開いた状態のマーカー */
}

.legend-layer summary::-webkit-details-marker,
.legend-layer summary::marker {
    display: none; /* 標準的なマーカー非表示 */
}

.legend-layer[open] > summary {
    margin-bottom: 10px;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.legend-items-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 15px;
}

.chart-tooltip {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.9em;
    pointer-events: none;
    position: fixed;
    z-index: 9999;
    display: none;
}

.donut-segment-label {
    font-family: 'Segoe UI', 'Meiryo', sans-serif;
    font-size: 9px;
    fill: #ffffff;
    font-weight: bold;
    pointer-events: none; /* テキストがマウスイベントを妨げないようにする */
    text-shadow: 0 0 2px rgba(0,0,0,0.7); /* 読みやすさのための影 */
}

/* レスポンシブ対応: グラフの横並び表示 */
@media (min-width: 769px) {
    .graphs-container {
        display: flex;
        gap: 20px; /* グラフ間の余白 */
        margin-bottom: 25px; /* 下の要素との間隔 */
    }
    .graphs-container > .summary-graph {
        flex: 1; /* 利用可能なスペースを均等に分割 */
        min-width: 0; /* Flexアイテムの縮小問題を回避 */
    }

    :root {
        --waterfall-graph-height: 350px; /* PC表示時のウォーターフォールグラフの高さ */
    }
}

/* --- 結果発表メッセージのスタイル (スタイリッシュ版) --- */
.result-announcement {
    text-align: center;
    padding: 25px;
    margin: 40px auto;
    max-width: 700px;
    background-color: var(--section-bg-color);
    border: var(--result-announcement-border-width) var(--result-announcement-border-style) var(--result-announcement-border-color);
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    animation: slideInUp 0.8s ease-out forwards;
    opacity: 0;
    font-family: 'Segoe UI', 'Meiryo', sans-serif;
}

.result-announcement .result-title {
    color: #333;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.6em;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.result-announcement .result-message {
    font-weight: bold;
    font-size: 1.2em; /* 親要素のフォントサイズを小さく */
    color: #333; /* 変更なし */
    margin: 0;
    line-height: 1.2;
}

.result-announcement .highlight-amount {
    color: #28a745; /* 節約感を出す緑色 */
    font-size: 1.8em; /* 金額を大きく強調 */
    text-shadow: none;
}

.result-announcement .result-suffix {
    font-size: 1em;
    color: #333;
    font-weight: bold;
}

/* 新しいアニメーションの定義 */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}