/* ==========================================================
   dashboard.css — 仪表盘模块样式
   风格：Apple HIG · Light-first · 高密度经营总览
   ========================================================== */

.dsh {
    --dsh-radius: 18px;
    --dsh-line: var(--color-border);
    --dsh-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 12px 30px -20px rgba(15, 23, 42, .30);
    --dsh-track: rgba(120, 120, 128, .12);
    --dsh-hover: rgba(120, 120, 128, .06);
    --dsh-grid: rgba(0, 0, 0, .055);
    --dsh-bar: rgba(0, 122, 255, .22);
    --dsh-pos: #1f8f3f;
    --dsh-pos-bg: rgba(52, 199, 89, .12);
    --dsh-on-accent: #ffffff;

    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 1520px;
    margin: 0 auto;
    padding-bottom: 28px;
}

[data-theme="dark"] .dsh {
    --dsh-shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 14px 34px -22px #000;
    --dsh-track: rgba(255, 255, 255, .10);
    --dsh-hover: rgba(255, 255, 255, .055);
    --dsh-grid: rgba(255, 255, 255, .075);
    --dsh-bar: rgba(10, 132, 255, .34);
    --dsh-pos: #32d74b;
    --dsh-pos-bg: rgba(50, 215, 75, .15);
}

/* ---------------------------------------------------------
   页头
   --------------------------------------------------------- */
.dsh-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    padding: 2px 2px 4px;
}

.dsh-eyebrow {
    margin: 0 0 7px;
    font-size: 12px;
    color: var(--color-text-tertiary);
    letter-spacing: .02em;
}

.dsh-title {
    margin: 0;
    font-size: 26px;
    line-height: 1.12;
    font-weight: 600;
    letter-spacing: -.03em;
}

.dsh-sub {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 9px;
    margin: 9px 0 0;
    font-size: 13px;
    color: var(--color-text-secondary);
}

.dsh-sub b {
    color: var(--color-text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.dsh-sub .is-danger { color: var(--color-danger); }

.dsh-scope {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--color-primary-bg);
    color: var(--color-primary);
    font-size: 11.5px;
    font-weight: 500;
}

.dsh-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.dsh-seg {
    display: flex;
    padding: 2px;
    border-radius: 10px;
    background: var(--dsh-track);
}

.dsh-seg button {
    border: 0;
    background: transparent;
    padding: 5px 11px;
    border-radius: 8px;
    font-size: 12.5px;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.dsh-seg button:hover { color: var(--color-text); }

.dsh-seg button.is-active {
    background: var(--color-card);
    color: var(--color-text);
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}

.dsh-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border: 0;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: transform var(--transition-fast) var(--ease-out),
                background var(--transition-fast), box-shadow var(--transition-fast);
}

.dsh-btn:active { transform: scale(.98); }

.dsh-btn-primary {
    background: var(--color-primary);
    color: var(--dsh-on-accent);
    box-shadow: 0 6px 16px -8px rgba(0, 122, 255, .75);
}

.dsh-btn-primary:hover { background: var(--color-primary-hover); }

.dsh-btn-ghost {
    width: 34px;
    padding: 0;
    justify-content: center;
    background: var(--color-card);
    border: 1px solid var(--dsh-line);
    color: var(--color-text-secondary);
}

.dsh-btn-ghost:hover { color: var(--color-text); background: var(--dsh-hover); }

/* ---------------------------------------------------------
   KPI 卡
   --------------------------------------------------------- */
.dsh-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.dsh-kpi {
    position: relative;
    overflow: hidden;
    padding: 16px 18px 13px;
    border: 1px solid var(--dsh-line);
    border-radius: var(--dsh-radius);
    background: var(--color-card);
    box-shadow: var(--dsh-shadow);
    min-height: 146px;
    display: flex;
    flex-direction: column;
}

.dsh-kpi.is-hero {
    background:
        linear-gradient(160deg, rgba(0, 122, 255, .055), rgba(0, 122, 255, 0) 58%),
        var(--color-card);
}

[data-theme="dark"] .dsh-kpi.is-hero {
    background:
        linear-gradient(160deg, rgba(10, 132, 255, .12), rgba(10, 132, 255, 0) 58%),
        var(--color-card);
}

.dsh-kpi-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.dsh-kpi-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.dsh-kpi-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.dsh-kpi-dot.is-primary { color: var(--color-primary); }
.dsh-kpi-dot.is-success { color: var(--color-success); }
.dsh-kpi-dot.is-warning { color: var(--color-warning); }
.dsh-kpi-dot.is-purple { color: var(--color-purple); }

.dsh-kpi > * {
    position: relative;
    z-index: 1;
}

.dsh-delta {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.dsh-delta.is-up { color: var(--dsh-pos); background: var(--dsh-pos-bg); }
.dsh-delta.is-down { color: var(--color-danger); background: var(--color-danger-bg); }
.dsh-delta.is-flat { color: var(--color-text-secondary); background: var(--dsh-track); }

.dsh-kpi-value {
    margin-top: 11px;
    font-size: 30px;
    line-height: 1.02;
    font-weight: 600;
    letter-spacing: -.035em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.dsh-kpi-value .dsh-unit {
    margin-right: 1px;
    font-size: 16px;
    font-weight: 500;
    color: var(--color-text-secondary);
    vertical-align: 2px;
}

.dsh-kpi-value .dsh-unit-sm {
    margin-left: 3px;
    font-size: 15px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.dsh-kpi-value.is-danger { color: var(--color-danger); }

.dsh-kpi-foot {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
    padding-top: 9px;
    font-size: 11.5px;
    color: var(--color-text-tertiary);
    min-height: 16px;
}

.dsh-kpi-foot .dsh-muted { color: var(--color-text-tertiary); }

.dsh-progress {
    position: relative;
    z-index: 1;
    height: 5px;
    margin-top: 10px;
    border-radius: 999px;
    background: var(--dsh-track);
    overflow: hidden;
}

.dsh-progress span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--color-primary);
}

.dsh-progress span.is-success { background: var(--color-success); }
.dsh-progress span.is-danger { background: var(--color-danger); }

.dsh-p-58 { width: 57.7%; }
.dsh-p-69 { width: 69.2%; }
.dsh-p-78 { width: 78%; }

.dsh-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
}

.dsh-chip.is-danger { color: var(--color-danger); background: var(--color-danger-bg); }
.dsh-chip.is-warn { color: var(--color-warning); background: var(--color-warning-bg); }

/* ---------------------------------------------------------
   卡片骨架
   --------------------------------------------------------- */
.dsh-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    border: 1px solid var(--dsh-line);
    border-radius: var(--dsh-radius);
    background: var(--color-card);
    box-shadow: var(--dsh-shadow);
}

.dsh-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 0;
}

.dsh-card-title {
    margin: 0;
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: -.01em;
}

.dsh-card-sub {
    margin: 3px 0 0;
    font-size: 12px;
    color: var(--color-text-tertiary);
}

.dsh-card-foot {
    margin-top: auto;
    padding: 12px 18px;
    border-top: 1px solid var(--dsh-line);
}

.dsh-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12.5px;
    color: var(--color-primary);
    text-decoration: none;
}

.dsh-link:hover { color: var(--color-primary-hover); }

.dsh-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding-top: 2px;
    font-size: 11.5px;
    color: var(--color-text-secondary);
}

.dsh-legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.dsh-legend i {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 2px;
}

.dsh-legend .is-bar { background: var(--dsh-bar); }
.dsh-legend .is-line { background: var(--color-primary); }

/* ---------------------------------------------------------
   栅格
   --------------------------------------------------------- */
.dsh-grid {
    display: grid;
    gap: 14px;
}

.dsh-grid--main { grid-template-columns: minmax(0, 1.62fr) minmax(0, 1fr); }
.dsh-grid--triple { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dsh-grid--bottom { grid-template-columns: minmax(0, 1.62fr) minmax(0, 1fr); }
.dsh-grid--aging { grid-template-columns: minmax(0, 1fr); }

/* ---------------------------------------------------------
   应收应付账龄
   --------------------------------------------------------- */
.dsh-aging-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    padding: 4px 2px 14px;
}

.dsh-aging-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dsh-aging-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: var(--color-text-secondary);
}

.dsh-aging-value {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -.01em;
    font-variant-numeric: tabular-nums;
}

.dsh-aging-meta {
    font-size: 11.5px;
    color: var(--color-text-tertiary);
}

.dsh-aging-table {
    border-top: 1px solid var(--dsh-line);
    padding-top: 8px;
}

.dsh-aging-row {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
    align-items: center;
    padding: 6px 2px;
}

.dsh-aging-row.is-head {
    padding-top: 0;
    font-size: 11.5px;
    color: var(--color-text-tertiary);
}

.dsh-aging-bucket {
    font-size: 12.5px;
    color: var(--color-text-secondary);
    font-variant-numeric: tabular-nums;
}

.dsh-aging-cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 6px;
    overflow: hidden;
}

.dsh-aging-cell i {
    position: absolute;
    left: 0;
    top: 2px;
    bottom: 2px;
    border-radius: 5px;
    background: rgba(52, 199, 89, .16);
}

.dsh-aging-cell.is-pay i {
    background: rgba(255, 159, 10, .16);
}

.dsh-aging-cell b {
    position: relative;
    font-size: 12.5px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------
   趋势图
   --------------------------------------------------------- */
.dsh-chart {
    padding: 6px 8px 0;
}

.dsh-chart svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.dsh-chart-grid line {
    stroke: var(--dsh-grid);
    stroke-width: 1;
}

.dsh-chart-axis text {
    fill: var(--color-text-tertiary);
    font-size: 10px;
    font-family: var(--font-family);
    font-variant-numeric: tabular-nums;
}

.dsh-chart-axis.is-right text {
    fill: var(--color-text-tertiary);
    opacity: .72;
}

.dsh-chart-bars .bar {
    fill: var(--dsh-bar);
    transform-box: fill-box;
    transform-origin: 50% 100%;
    animation: dshBar .6s var(--ease-out) both;
}

.dsh-chart-bars .bar.is-current { fill: var(--color-primary); opacity: .72; }

.dsh-chart-bars .bar:nth-child(1) { animation-delay: .02s; }
.dsh-chart-bars .bar:nth-child(2) { animation-delay: .05s; }
.dsh-chart-bars .bar:nth-child(3) { animation-delay: .08s; }
.dsh-chart-bars .bar:nth-child(4) { animation-delay: .11s; }
.dsh-chart-bars .bar:nth-child(5) { animation-delay: .14s; }
.dsh-chart-bars .bar:nth-child(6) { animation-delay: .17s; }
.dsh-chart-bars .bar:nth-child(7) { animation-delay: .20s; }
.dsh-chart-bars .bar:nth-child(8) { animation-delay: .23s; }
.dsh-chart-bars .bar:nth-child(9) { animation-delay: .26s; }
.dsh-chart-bars .bar:nth-child(10) { animation-delay: .29s; }
.dsh-chart-bars .bar:nth-child(11) { animation-delay: .32s; }
.dsh-chart-bars .bar:nth-child(12) { animation-delay: .35s; }

.dsh-chart-area { fill: url(#dshArea); }

.dsh-chart-line {
    fill: none;
    stroke: var(--color-primary);
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: dshDraw 1.05s .18s var(--ease-out) forwards;
}

.dsh-chart-dot {
    fill: var(--color-primary);
    stroke: var(--color-card);
    stroke-width: 2.5;
}

.area-stop-1 { stop-color: var(--color-primary); stop-opacity: .17; }
.area-stop-2 { stop-color: var(--color-primary); stop-opacity: 0; }

[data-theme="dark"] .area-stop-1 { stop-opacity: .28; }

@keyframes dshBar {
    from { transform: scaleY(0); }
    to   { transform: scaleY(1); }
}

@keyframes dshDraw {
    to { stroke-dashoffset: 0; }
}

.dsh-chart-foot {
    display: flex;
    margin-top: 8px;
    border-top: 1px solid var(--dsh-line);
}

.dsh-chart-foot > div {
    flex: 1;
    min-width: 0;
    padding: 11px 18px 13px;
}

.dsh-chart-foot > div + div { border-left: 1px solid var(--dsh-line); }

.dsh-foot--push { margin-top: auto; }

.dsh-foot-label {
    font-size: 11px;
    color: var(--color-text-tertiary);
    white-space: nowrap;
}

.dsh-foot-value {
    margin-top: 3px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ---------------------------------------------------------
   待我处理
   --------------------------------------------------------- */
.dsh-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--color-primary-bg);
    color: var(--color-primary);
    font-size: 11.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.dsh-task-list {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dsh-task {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    border-radius: 12px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.dsh-task:hover { background: var(--dsh-hover); }

.dsh-task-bar {
    position: absolute;
    left: 5px;
    top: 50%;
    width: 3px;
    height: 26px;
    border-radius: 2px;
    background: var(--color-primary);
    transform: translateY(-50%);
}

.dsh-task.is-urgent .dsh-task-bar { background: var(--color-danger); }
.dsh-task.is-warn .dsh-task-bar { background: var(--color-warning); }
.dsh-task.is-info .dsh-task-bar { background: var(--color-primary); }
.dsh-task.is-note .dsh-task-bar { background: var(--color-purple); }

.dsh-task-body {
    flex: 1;
    min-width: 0;
}

.dsh-task-title {
    margin: 0;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.45;
    letter-spacing: -.01em;
}

.dsh-task-title b {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.dsh-task-meta {
    margin: 3px 0 0;
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--color-text-tertiary);
}

.dsh-task-module {
    flex-shrink: 0;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--dsh-track);
    color: var(--color-text-secondary);
    font-size: 10.5px;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
}

.dsh-task-module.is-finance {
    color: var(--color-danger);
    background: var(--color-danger-bg);
}

.dsh-task-module.is-contract {
    color: var(--color-primary);
    background: var(--color-primary-bg);
}

.dsh-task-module.is-project {
    color: var(--color-purple);
    background: var(--color-purple-bg);
}

.dsh-task-module.is-system {
    color: var(--color-warning);
    background: var(--color-warning-bg);
}

.dsh-task-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 36px 20px;
    text-align: center;
    color: var(--color-text-tertiary);
}

.dsh-task-empty i {
    font-size: 22px;
    opacity: .5;
}

.dsh-task-empty b {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.dsh-task-empty span {
    font-size: 11.5px;
    line-height: 1.6;
}

.dsh-task-arrow {
    flex-shrink: 0;
    font-size: 12px;
    color: var(--color-text-tertiary);
    opacity: .7;
}

.dsh-task:hover .dsh-task-arrow { color: var(--color-primary); opacity: 1; }

/* ---------------------------------------------------------
   合同状态构成
   --------------------------------------------------------- */
.dsh-stack {
    display: flex;
    gap: 2px;
    height: 10px;
    margin: 20px 18px 0;
    border-radius: 999px;
    overflow: hidden;
    background: var(--dsh-track);
}

.dsh-stack span { height: 100%; }
.dsh-stack .s-active { flex: 42 1 0; background: var(--color-primary); }
.dsh-stack .s-done { flex: 16 1 0; background: var(--color-success); }
.dsh-stack .s-pending { flex: 5 1 0; background: var(--color-warning); }
.dsh-stack .s-ended { flex: 3 1 0; background: var(--color-text-tertiary); }

.dsh-legend-list {
    list-style: none;
    margin: 16px 0 0;
    padding: 0 18px 16px;
    display: grid;
    gap: 9px;
}

.dsh-legend-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--color-text-secondary);
}

.dsh-legend-list .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dsh-legend-list .dot.is-active { background: var(--color-primary); }
.dsh-legend-list .dot.is-done { background: var(--color-success); }
.dsh-legend-list .dot.is-pending { background: var(--color-warning); }
.dsh-legend-list .dot.is-ended { background: var(--color-text-tertiary); }

.dsh-legend-list .val {
    margin-left: auto;
    color: var(--color-text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.dsh-legend-list .pct {
    width: 42px;
    text-align: right;
    font-size: 11.5px;
    color: var(--color-text-tertiary);
    font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------
   合同类别分布
   --------------------------------------------------------- */
.dsh-bars {
    list-style: none;
    margin: 16px 0 0;
    padding: 0 18px 16px;
    display: grid;
    gap: 12px;
}

.dsh-bars li {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 4px 8px;
    font-size: 12.5px;
}

.dsh-bars .name { color: var(--color-text-secondary); }

.dsh-bars .val {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.dsh-bars .bar {
    grid-column: 1 / -1;
    height: 6px;
    border-radius: 999px;
    background: var(--dsh-track);
    overflow: hidden;
}

.dsh-bars .bar span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--color-primary);
}

.dsh-bars li:nth-child(1) .bar span { opacity: 1; }
.dsh-bars li:nth-child(2) .bar span { opacity: .78; }
.dsh-bars li:nth-child(3) .bar span { opacity: .58; }
.dsh-bars li:nth-child(4) .bar span { opacity: .40; }
.dsh-bars li:nth-child(5) .bar span { opacity: .26; }

.dsh-w-100 { width: 100%; }
.dsh-w-75  { width: 75%; }
.dsh-w-54  { width: 54%; }
.dsh-w-29  { width: 29%; }
.dsh-w-17  { width: 17%; }

/* ---------------------------------------------------------
   项目进度
   --------------------------------------------------------- */
.dsh-proj {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 16px 18px 18px;
}

.dsh-donut {
    position: relative;
    width: 104px;
    height: 104px;
    flex-shrink: 0;
}

.dsh-donut svg {
    display: block;
    width: 104px;
    height: 104px;
    transform: rotate(-90deg);
}

.dsh-donut .ring-track { stroke: var(--dsh-track); }
.dsh-donut .ring-value {
    stroke: var(--color-primary);
    stroke-linecap: round;
    stroke-dasharray: 264;
    stroke-dashoffset: 82;
    animation: dshRing .9s .2s var(--ease-out) both;
}

@keyframes dshRing {
    from { stroke-dashoffset: 264; }
    to   { stroke-dashoffset: 82; }
}

.dsh-donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
}

.dsh-donut-center b {
    font-size: 23px;
    font-weight: 600;
    letter-spacing: -.04em;
    font-variant-numeric: tabular-nums;
}

.dsh-donut-center span {
    font-size: 10.5px;
    color: var(--color-text-tertiary);
}

.dsh-proj-list {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    min-width: 0;
    display: grid;
    gap: 10px;
}

.dsh-proj-list li {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12.5px;
    color: var(--color-text-secondary);
}

.dsh-proj-list .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dsh-proj-list .dot.is-active { background: var(--color-primary); }
.dsh-proj-list .dot.is-done { background: var(--color-success); }
.dsh-proj-list .dot.is-paused { background: var(--color-warning); }

.dsh-proj-list .val {
    margin-left: auto;
    color: var(--color-text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------
   最近合同表
   --------------------------------------------------------- */
.dsh-table {
    width: 100%;
    margin-top: 10px;
    border-collapse: collapse;
    font-size: 12.5px;
}

.dsh-table th {
    padding: 8px 18px;
    border-bottom: 1px solid var(--dsh-line);
    text-align: left;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--color-text-tertiary);
    white-space: nowrap;
}

.dsh-table td {
    padding: 10px 18px;
    border-bottom: 1px solid var(--dsh-line);
    vertical-align: middle;
    white-space: nowrap;
}

.dsh-table tbody tr:last-child td { border-bottom: 0; }
.dsh-table tbody tr { transition: background var(--transition-fast); }
.dsh-table tbody tr:hover { background: var(--dsh-hover); }

.dsh-table .dsh-name {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.dsh-table .dsh-code {
    font-size: 11.5px;
    color: var(--color-text-tertiary);
    font-variant-numeric: tabular-nums;
}

.dsh-table .dsh-num {
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.dsh-table .dsh-date {
    color: var(--color-text-secondary);
    font-variant-numeric: tabular-nums;
}

.dsh-table .dsh-date.is-soon { color: var(--color-warning); font-weight: 600; }

.dsh-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

.dsh-pill::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

.dsh-pill--active { color: var(--color-primary); background: var(--color-primary-bg); }
.dsh-pill--done { color: var(--dsh-pos); background: var(--dsh-pos-bg); }
.dsh-pill--pending { color: var(--color-warning); background: var(--color-warning-bg); }
.dsh-pill--ended { color: var(--color-text-secondary); background: var(--dsh-track); }

/* ---------------------------------------------------------
   动态时间线
   --------------------------------------------------------- */
.dsh-feed {
    list-style: none;
    margin: 14px 0 0;
    padding: 0 18px 16px;
}

.dsh-feed li {
    position: relative;
    padding: 0 0 17px 20px;
}

.dsh-feed li::before {
    content: '';
    position: absolute;
    left: 2px;
    top: 5px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-bg);
}

.dsh-feed li::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 15px;
    bottom: 2px;
    width: 1px;
    background: var(--dsh-line);
}

.dsh-feed li.is-success::before { background: var(--color-success); box-shadow: 0 0 0 3px var(--color-success-bg); }
.dsh-feed li.is-muted::before { background: var(--color-text-tertiary); box-shadow: 0 0 0 3px var(--dsh-track); }

.dsh-feed li:last-child { padding-bottom: 0; }
.dsh-feed li:last-child::after { display: none; }

.dsh-feed p {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.45;
}

.dsh-feed p b { font-weight: 600; }

.dsh-feed time {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    color: var(--color-text-tertiary);
}

/* ---------------------------------------------------------
   入场动效
   --------------------------------------------------------- */
@keyframes dshRise {
    from { opacity: 0; transform: translateY(7px); }
    to   { opacity: 1; transform: none; }
}

.dsh > * {
    animation: dshRise .42s var(--ease-out) both;
}

.dsh > *:nth-child(2) { animation-delay: .04s; }
.dsh > *:nth-child(3) { animation-delay: .08s; }
.dsh > *:nth-child(4) { animation-delay: .12s; }
.dsh > *:nth-child(5) { animation-delay: .16s; }

/* ---------------------------------------------------------
   响应式
   --------------------------------------------------------- */
@media (max-width: 1360px) {
    .dsh-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dsh-grid--main,
    .dsh-grid--bottom { grid-template-columns: minmax(0, 1fr); }
    .dsh-grid--triple { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dsh-aging-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
    .dsh-grid--triple { grid-template-columns: minmax(0, 1fr); }
    .dsh-aging-row { grid-template-columns: 84px minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
    .dsh-head { flex-direction: column; align-items: stretch; gap: 16px; }
    .dsh-head-actions { justify-content: flex-start; }
}

@media (max-width: 760px) {
    .dsh-kpis { grid-template-columns: minmax(0, 1fr); }
    .dsh-title { font-size: 22px; }
    .dsh-table th:nth-child(3),
    .dsh-table td:nth-child(3),
    .dsh-table th:nth-child(6),
    .dsh-table td:nth-child(6) { display: none; }
    .dsh-chart-foot > div { padding: 10px 12px; }
    .dsh-seg { flex: 1; }
    .dsh-seg button { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .dsh > *,
    .dsh-chart-bars .bar,
    .dsh-chart-line,
    .dsh-donut .ring-value {
        animation: none !important;
    }

    .dsh-chart-line { stroke-dashoffset: 0; }
    .dsh-donut .ring-value { stroke-dashoffset: 82; }
}

/* ---------------------------------------------------------
   运行期补充（Chart.js 画布、表格滚动、权限隐藏）
   --------------------------------------------------------- */
[hidden] { display: none !important; }

.dsh-chart-canvas {
    position: relative;
    height: 280px;
    margin-top: 6px;
    padding: 0 14px 0 10px;
}

.dsh-chart-canvas canvas {
    width: 100% !important;
    height: 100% !important;
}

.dsh-table-wrap {
    overflow-x: auto;
}

.dsh-link-btn {
    border: 0;
    background: transparent;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}

.dsh-todo-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.dsh-grid--main.is-single,
.dsh-grid--bottom.is-single {
    grid-template-columns: minmax(0, 1fr);
}

.dsh-kpi-dot.is-danger { color: var(--color-danger); }

@media (max-width: 760px) {
    .dsh-chart-canvas { height: 220px; padding: 0 4px; }
    .dsh-table th:nth-child(3),
    .dsh-table td:nth-child(3),
    .dsh-table th:nth-child(6),
    .dsh-table td:nth-child(6) { display: none; }
}

/* ---------------------------------------------------------
   KPI 紧凑化：桌面端一行放得下
   --------------------------------------------------------- */
.dsh-kpis {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.dsh-kpi {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    min-height: 0;
    padding: 10px 12px 9px;
}

.dsh-kpi-top {
    gap: 6px;
}

.dsh-kpi-label {
    gap: 5px;
    font-size: 11.5px;
}

.dsh-kpi-dot {
    width: 5px;
    height: 5px;
}

.dsh-delta {
    padding: 1px 5px;
    font-size: 10.5px;
}

.dsh-kpi-value {
    margin-top: 6px;
    font-size: clamp(18px, 1.55vw, 24px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dsh-kpi-value .dsh-unit {
    font-size: 13px;
    vertical-align: 1px;
}

.dsh-kpi-value .dsh-unit-sm {
    font-size: 12px;
}

.dsh-kpi-foot {
    padding-top: 6px;
    min-height: 13px;
    font-size: 10.5px;
    gap: 6px;
}

.dsh-kpi-foot > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dsh-progress {
    height: 4px;
    margin-top: 7px;
}

@media (max-width: 760px) {
    .dsh-kpi {
        flex: 1 1 100%;
        max-width: none;
    }
}
