/* =========================================================
   UNIFIED DASHBOARD TABLE TYPOGRAPHY
   ========================================================= */
#dashboard-outstanding-table th,
#top5-deduction-table th,
#recent-stores-table th {
    font-size: 10px;
}

#dashboard-outstanding-table td,
#top5-deduction-table td,
#recent-stores-table td {
    font-size: 10px;
}

/* =========================================================
   COMPACT TABLE STYLES — Top 5 Deduction & Detailed Store
   ========================================================= */
#top5-deduction-table th,
#recent-stores-table th {
    padding: 7px 10px;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

#recent-stores-table thead th {
    text-align: center;
    vertical-align: middle;
}

#top5-deduction-table th:nth-child(1),
#top5-deduction-table td:nth-child(1) {
    width: 34px;
    padding-left: 6px;
    padding-right: 6px;
    text-align: center;
}

#top5-deduction-table th:nth-child(2),
#top5-deduction-table td:nth-child(2) {
    width: 54px;
    min-width: 54px;
    padding-left: 6px;
    padding-right: 6px;
}

#top5-deduction-table th:nth-child(2) {
    line-height: 1.05;
    white-space: normal;
}

#top5-deduction-table th:nth-child(6),
#top5-deduction-table td:nth-child(6) {
    min-width: 92px;
}

#top5-deduction-table th:nth-child(7),
#top5-deduction-table td:nth-child(7) {
    min-width: 112px;
}

#top5-deduction-table td,
#recent-stores-table td {
    padding: 6px 10px;
    line-height: 1.35;
    vertical-align: top;
    /* Clamp each cell to max 2 lines */
    display: table-cell;
    overflow: hidden;
    max-height: 3em;
}

#top5-deduction-table td strong,
#recent-stores-table td strong {
    font-size: 10px;
    font-weight: 700;
    display: block;
    white-space: nowrap;
}

/* Store name — allow max 2 lines then ellipsis */
#top5-deduction-table td:nth-child(3),
#recent-stores-table td:nth-child(4) {
    max-width: 140px;
}

/* Date SO — no wrap, single line */
#top5-deduction-table td:nth-child(4),
#recent-stores-table td:nth-child(2),
#recent-stores-table td:nth-child(5) {
    white-space: nowrap;
    font-size: 10px;
}

/* Area & AM columns in top5 — max 2 lines */
#top5-deduction-table td:nth-child(6),
#top5-deduction-table td:nth-child(7) {
    max-width: 130px;
    font-size: 10px;
    overflow-wrap: anywhere;
}

/* Badge in compact tables */
#recent-stores-table .badge {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
    display: inline-block;
}

#recent-stores-table .badge.surplus {
    background: #DBEAFE;
    color: #1D4ED8;
}

body.dark-theme #recent-stores-table .badge.surplus {
    background: rgba(59, 130, 246, 0.2);
    color: #93C5FD;
}

/* Total deduction value — no wrap */
#top5-deduction-table td:nth-child(5),
#recent-stores-table td:nth-child(7),
#recent-stores-table td:nth-child(8),
#recent-stores-table td:nth-child(9),
#recent-stores-table td:nth-child(10) {
    white-space: nowrap;
    font-size: 10px;
}

/* Row hover stays visible */
#top5-deduction-table tbody tr:hover,
#recent-stores-table tbody tr:hover {
    background-color: var(--bg-color);
}

/* Top 5 shares the final dashboard row with the map. */
.dashboard-top5-widget #top5-deduction-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}

.dashboard-top5-widget #top5-deduction-table th,
.dashboard-top5-widget #top5-deduction-table td {
    padding: 5px 4px;
    font-size: 10px;
    line-height: 1.25;
}

.dashboard-top5-widget #top5-deduction-table th:nth-child(1),
.dashboard-top5-widget #top5-deduction-table td:nth-child(1) {
    width: 5%;
}

.dashboard-top5-widget #top5-deduction-table th:nth-child(2),
.dashboard-top5-widget #top5-deduction-table td:nth-child(2) {
    width: 10%;
    min-width: 0;
}

.dashboard-top5-widget #top5-deduction-table th:nth-child(3),
.dashboard-top5-widget #top5-deduction-table td:nth-child(3) {
    width: 24%;
}

.dashboard-top5-widget #top5-deduction-table th:nth-child(4),
.dashboard-top5-widget #top5-deduction-table td:nth-child(4) {
    width: 13%;
    font-size: 10px;
}

.dashboard-top5-widget #top5-deduction-table th:nth-child(5),
.dashboard-top5-widget #top5-deduction-table td:nth-child(5) {
    width: 20%;
}

.dashboard-top5-widget #top5-deduction-table th:nth-child(6),
.dashboard-top5-widget #top5-deduction-table td:nth-child(6) {
    width: 12%;
    min-width: 0;
    max-width: none;
    font-size: 10px;
}

.dashboard-top5-widget #top5-deduction-table th:nth-child(7),
.dashboard-top5-widget #top5-deduction-table td:nth-child(7) {
    width: 16%;
    min-width: 0;
    max-width: none;
    font-size: 10px;
}

.dashboard-top5-widget #top5-deduction-table td strong,
.dashboard-top5-widget #top5-deduction-table td:nth-child(5) span {
    font-size: 10px;
}

/* Identity fields remain slightly larger for faster scanning. */
#dashboard-outstanding-table td:nth-child(2),
#recent-stores-table td:nth-child(4) {
    font-size: 11px;
}

#recent-stores-table {
    min-width: 1180px;
    table-layout: fixed;
}

#recent-stores-table th:nth-child(1),
#recent-stores-table td:nth-child(1) { width: 3%; }

#recent-stores-table th:nth-child(2),
#recent-stores-table td:nth-child(2) { width: 8%; }

#recent-stores-table th:nth-child(3),
#recent-stores-table td:nth-child(3) { width: 7%; }

#recent-stores-table th:nth-child(4),
#recent-stores-table td:nth-child(4) {
    width: 21%;
    max-width: none;
    overflow-wrap: anywhere;
}

#recent-stores-table th:nth-child(5),
#recent-stores-table td:nth-child(5) { width: 8%; }

#recent-stores-table th:nth-child(6),
#recent-stores-table td:nth-child(6) { width: 12%; }

#recent-stores-table th:nth-child(7),
#recent-stores-table td:nth-child(7),
#recent-stores-table th:nth-child(8),
#recent-stores-table td:nth-child(8) { width: 10%; }

#recent-stores-table th:nth-child(9),
#recent-stores-table td:nth-child(9) { width: 12%; }

#recent-stores-table th:nth-child(10),
#recent-stores-table td:nth-child(10) {
    width: 9%;
    text-align: center;
}

#recent-stores-table .dashboard-detail-number {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

#recent-stores-table .dashboard-detail-money {
    font-weight: 600;
}

#recent-stores-table td.dashboard-detail-center {
    text-align: center;
}

#recent-stores-table .dashboard-impact-ratio {
    font-weight: 700;
}

#recent-stores-table .dashboard-impact-ratio.is-high {
    background: #FCE7E7;
    color: #B42318;
}

body.dark-theme #recent-stores-table .dashboard-impact-ratio.is-high {
    background: rgba(239, 68, 68, 0.18);
    color: #FCA5A5;
}

#recent-stores-table .dashboard-detail-empty {
    padding: 28px 12px;
    color: var(--text-muted);
    text-align: center;
}

.dashboard-top5-widget #top5-deduction-table td:nth-child(3),
.dashboard-top5-widget #top5-deduction-table td:nth-child(6),
.dashboard-top5-widget #top5-deduction-table td:nth-child(7) {
    font-size: 11px;
}

@media (max-width: 600px) {
    .dashboard-top5-widget #top5-deduction-table {
        min-width: 640px;
        table-layout: auto;
    }
}
