/* 財務儀表板：四張圖。顏色用變數；系列色與帳齡的色階都用 dataviz 的驗證過的色票（見 docs 說明）。 */

.fin-grid {
    --fin-series-in: #2a78d6;
    --fin-series-out: #eb6834;
    --fin-ramp-1: #86b6ef;
    --fin-ramp-2: #3987e5;
    --fin-ramp-3: #1c5cab;
    --fin-ramp-4: #0d366b;
    --fin-grid: #e1e0d9;
    --fin-axis: #c3c2b7;
    --fin-ink-muted: #898781;
    --fin-ink-secondary: #52514e;
    --fin-surface: #ffffff;
}

/* 兩欄排版（儀表板預設會依寬度排成三欄，這裡只有兩張並排的圖）；窄螢幕一欄。 */
.fin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 900px) {
    .fin-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.fin-series-in { background: var(--fin-series-in); }
.fin-series-out { background: var(--fin-series-out); }
.fin-ramp-1 { background: var(--fin-ramp-1); }
.fin-ramp-2 { background: var(--fin-ramp-2); }
.fin-ramp-3 { background: var(--fin-ramp-3); }
.fin-ramp-4 { background: var(--fin-ramp-4); }

/* 繪圖區：左邊 40px 留給刻度；上面 18px 留給最高那根柱子的數字；下面 22px 是 X 軸標籤。
   格線層和柱子層用同一個範圍（上 18px、下 22px 以外），所以刻度和柱子的高度對得上。三條水平細線是實線。 */
.fin-plot {
    position: relative;
    margin-top: 12px;
    height: 230px;
    padding-left: 40px;
    box-sizing: border-box;
}

.fin-grid-layer {
    position: absolute;
    left: 40px;
    right: 0;
    top: 18px;
    bottom: 22px;
}

.fin-grid-line {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px solid var(--fin-grid);
}

.fin-grid-line span {
    position: absolute;
    left: -40px;
    top: -8px;
    width: 34px;
    text-align: right;
    font-size: 11px;
    color: var(--fin-ink-muted);
}

.fin-cols {
    position: absolute;
    left: 40px;
    right: 0;
    top: 18px;
    bottom: 0;
    display: flex;
    align-items: stretch;
    gap: 12px;
}

.fin-col,
.fin-group {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    outline-offset: 2px;
}

.fin-col-plot,
.fin-group-plot {
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 2px; /* 相鄰的柱子之間 2px 間隙 */
    border-bottom: 1px solid var(--fin-axis);
    position: relative;
}

.fin-col-plot {
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
}

.fin-col-bar {
    width: 100%;
    max-width: 44px;
    min-height: 0;
    border-radius: 4px 4px 0 0; /* 只有資料那端圓角，貼著底線 */
}

.fin-group-plot .fin-col-bar {
    max-width: 22px;
    width: calc(50% - 1px);
}

.fin-col-value {
    font-size: 12px;
    color: #111827;
    font-weight: 600;
    white-space: nowrap;
}

.fin-col-label {
    margin-top: 8px;
    height: 14px;
    flex: none;
    font-size: 11px;
    color: var(--fin-ink-secondary);
    text-align: center;
    white-space: nowrap;
}

.fin-col:hover .fin-col-bar,
.fin-col:focus-visible .fin-col-bar,
.fin-group:hover .fin-col-bar,
.fin-group:focus-visible .fin-col-bar {
    filter: brightness(1.12);
}

.fin-group:hover,
.fin-group:focus-visible {
    background: rgba(17, 24, 39, 0.04);
}

.fin-group-overdue {
    background: #fff7f7;
    border-radius: 6px 6px 0 0;
}

.fin-scroll {
    overflow-x: auto;
}

.fin-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 10px;
    font-size: 13px;
    color: var(--fin-ink-secondary);
}

.fin-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.fin-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.fin-footnote {
    margin-top: 6px;
    font-size: 13px;
    color: #6b7280;
}

/* 欠款客戶排行 */
.fin-concentration {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 10px 0 14px;
    color: #374151;
    font-size: 14px;
}

.fin-concentration strong {
    font-size: 30px;
    color: #111827;
}

.fin-ranks {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fin-rank {
    outline-offset: 3px;
}

.fin-rank-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
}

.fin-rank-name {
    color: #374151;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fin-rank-value {
    color: #111827;
    font-weight: 600;
    white-space: nowrap;
}

.fin-rank-value small {
    color: #9ca3af;
    font-weight: 400;
}

.fin-rank-track {
    margin-top: 5px;
    height: 8px;
    background: #f3f4f6;
    border-radius: 4px;
}

.fin-rank-fill {
    height: 100%;
    background: var(--fin-series-in);
    border-radius: 4px;
}

.fin-rank-note {
    margin-top: 3px;
    font-size: 12px;
    color: #b91c1c;
}

/* 每張圖的表格版 */
.fin-table {
    margin-top: 12px;
    font-size: 13px;
}

.fin-table summary {
    cursor: pointer;
    color: #6b7280;
}

.fin-table table {
    margin-top: 8px;
}

@media (max-width: 640px) {
    .fin-cols {
        gap: 6px;
    }
}
