/* ============================================================
   CPS-CIK Dashboard
   ============================================================ */

.dashboard-page {
    overflow: auto;
    height: auto;
    margin: 0;
    align-items: stretch;
}

.dash-main {
    max-width: 1280px;
    margin: 60px auto 40px;
    padding: 24px 20px;
    width: 100%;
    box-sizing: border-box;
}

.dash-header {
    margin-bottom: 24px;
}

.dash-title {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--text, #1a1a1a);
}

.dash-subtitle {
    font-size: 12px;
    color: var(--muted-text, #6b6b6b);
}

/* ── KPI Cards ── */
.dash-kpi-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.dash-kpi {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px;
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e6e8f0);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.2s;
}

.dash-kpi:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.dash-kpi-icon {
    font-size: 28px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    flex-shrink: 0;
}

.books-icon { background: #fef2f2; }
.cat-icon { background: #fef9e7; }
.pending-icon { background: #fff7ed; }
.lang-icon { background: #f0fdf4; }
.pub-icon { background: #eff6ff; }

.dash-kpi-data {
    display: flex;
    flex-direction: column;
}

.dash-kpi-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text, #1a1a1a);
    line-height: 1;
}

.dash-kpi-label {
    font-size: 12px;
    color: var(--muted-text, #6b6b6b);
    margin-top: 2px;
}

/* ── Grid layouts ── */
.dash-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.dash-grid-1 {
    margin-bottom: 16px;
}

/* ── Cards ── */
.dash-card {
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e6e8f0);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.dash-card-header {
    padding: 16px 20px 0;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.dash-card-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.dash-card-hint {
    font-size: 11px;
    color: var(--muted-text);
}

.dash-card-body {
    padding: 16px 20px 20px;
}

.dash-card-scroll {
    max-height: 360px;
    overflow-y: auto;
}

.dash-loading {
    text-align: center;
    padding: 24px;
    color: var(--muted-text);
    font-size: 13px;
}

.dash-empty {
    text-align: center;
    padding: 24px;
    color: var(--muted-text);
}

/* ── Horizontal bar chart ── */
.dash-bar-row {
    display: grid;
    grid-template-columns: 40px 1fr 50px 120px;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 12px;
}

.dash-bar-label {
    font-weight: 700;
    color: #8b1a1a;
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 11px;
}

.dash-bar-track {
    height: 20px;
    background: #f5f0eb;
    border-radius: 4px;
    overflow: hidden;
}

.dash-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #8b1a1a, #c0530a);
    border-radius: 4px;
    min-width: 2px;
    transition: width 0.5s ease;
}

.dash-bar-fill.lang-fill {
    background: linear-gradient(90deg, #0b66ff, #7c3aed);
}

.dash-bar-value {
    font-weight: 700;
    color: var(--text);
    text-align: right;
    font-size: 12px;
}

.dash-bar-name {
    color: var(--muted-text);
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Field completeness (vertical bars) ── */
.dash-field-grid {
    display: flex;
    gap: 6px;
    align-items: flex-end;
    height: 200px;
    padding-top: 8px;
}

.dash-field-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.dash-field-bar-bg {
    width: 100%;
    height: 140px;
    background: #f5f0eb;
    border-radius: 4px;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
}

.dash-field-bar-fill {
    width: 100%;
    border-radius: 4px 4px 0 0;
    transition: height 0.5s ease;
}

.dash-field-item.high .dash-field-bar-fill { background: #16a34a; }
.dash-field-item.mid .dash-field-bar-fill { background: #f59e0b; }
.dash-field-item.low .dash-field-bar-fill { background: #dc2626; }

.dash-field-pct {
    font-size: 10px;
    font-weight: 700;
    color: var(--text);
}

.dash-field-name {
    font-size: 9px;
    color: var(--muted-text);
    writing-mode: vertical-lr;
    transform: rotate(180deg);
    text-align: right;
    height: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Year chart (vertical bars) ── */
.dash-year-chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 160px;
    padding-top: 8px;
}

.dash-year-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.dash-year-count {
    font-size: 10px;
    font-weight: 700;
    color: var(--text);
    min-height: 14px;
}

.dash-year-bar {
    width: 100%;
    background: linear-gradient(180deg, #8b1a1a, #c0530a);
    border-radius: 4px 4px 0 0;
    min-height: 0;
    transition: height 0.5s ease;
}

.dash-year-label {
    font-size: 9px;
    color: var(--muted-text);
    transform: rotate(-50deg);
    white-space: nowrap;
    margin-top: 4px;
}

/* ── Tables ── */
.dash-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.dash-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted-text);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

.dash-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.dash-table tbody tr:hover {
    background: var(--muted-surface, #faf5f2);
}

.dash-table-code {
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 11px;
    color: #8b1a1a;
    font-weight: 600;
}

.dash-table-date {
    color: var(--muted-text);
    font-size: 12px;
    white-space: nowrap;
}

.dash-table-rank {
    color: var(--muted-text);
    font-weight: 700;
    width: 30px;
}

.dash-table-count {
    font-weight: 700;
    text-align: right;
}

.dash-status {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.dash-status.pending { background: #fff8e1; color: #b45309; }
.dash-status.approved { background: #f0fdf4; color: #166534; }
.dash-status.rejected { background: #fef2f2; color: #991b1b; }

/* ── Approval stats ── */
.dash-approval-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 8px 0;
}

.dash-approval-stat {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dash-approval-value {
    font-size: 24px;
    font-weight: 700;
    min-width: 50px;
}

.dash-approval-stat.approved .dash-approval-value { color: #16a34a; }
.dash-approval-stat.rejected .dash-approval-value { color: #dc2626; }
.dash-approval-stat.pending .dash-approval-value { color: #f59e0b; }

.dash-approval-label {
    font-size: 13px;
    font-weight: 600;
    min-width: 70px;
    color: var(--text);
}

.dash-approval-bar {
    flex: 1;
    height: 8px;
    background: #f5f0eb;
    border-radius: 4px;
    overflow: hidden;
}

.dash-approval-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s;
}

.dash-approval-stat.approved .dash-approval-fill { background: #16a34a; }
.dash-approval-stat.rejected .dash-approval-fill { background: #dc2626; }
.dash-approval-stat.pending .dash-approval-fill { background: #f59e0b; }

.dash-approval-total {
    margin-top: 8px;
    font-size: 12px;
    color: var(--muted-text);
    text-align: right;
}

/* ── Active link in topbar ── */
.active-link {
    color: #8b1a1a !important;
    font-weight: 700;
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .dash-kpi-row {
        grid-template-columns: repeat(3, 1fr);
    }

    .dash-grid-2 {
        grid-template-columns: 1fr;
    }

    .dash-bar-row {
        grid-template-columns: 40px 1fr 50px;
    }

    .dash-bar-name {
        display: none;
    }
}

@media (max-width: 600px) {
    .dash-kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .dash-main {
        padding: 16px 12px;
    }

    .dash-kpi {
        padding: 14px;
    }

    .dash-kpi-value {
        font-size: 20px;
    }

    .dash-field-grid {
        height: 160px;
    }

    .dash-field-name {
        display: none;
    }
}

/* ── Dark mode ── */
.dark-mode .dash-kpi,
.dark-mode .dash-card {
    background: #222;
    border-color: #333;
}

.dark-mode .dash-bar-track,
.dark-mode .dash-field-bar-bg,
.dark-mode .dash-approval-bar,
.dark-mode .books-icon,
.dark-mode .cat-icon,
.dark-mode .pending-icon,
.dark-mode .lang-icon,
.dark-mode .pub-icon {
    background: #2a2a2a;
}

.dark-mode .dash-table tbody tr:hover {
    background: #2a2a2a;
}
