/* ======================== DASHBOARD ======================== */

/* ---- KPI cards grid ---- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}
@media (max-width: 1500px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px)  { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }

.kpi {
    background: var(--c-surface);
    border-radius: var(--radius-lg);
    padding: 16px 18px 18px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    transition: transform 160ms ease, box-shadow 160ms ease;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); }

.kpi-row { display: flex; align-items: flex-start; justify-content: space-between; }
.kpi-label {
    color: var(--c-text-soft);
    font-weight: 600;
    font-size: 13px;
    line-height: 1.3;
    text-align: end;
    flex: 1;
}
.kpi-icon {
    width: 38px; height: 38px;
    border-radius: 12px;
    display: grid; place-items: center;
    flex-shrink: 0;
}
.kpi-icon .material-symbols-rounded { font-size: 22px; }

.kpi-value {
    margin-top: 4px;
    font-size: 22px;
    font-weight: 800;
    color: var(--c-text);
    text-align: end;
    display: flex; gap: 6px; align-items: baseline; justify-content: flex-end;
}
.kpi-value .unit { font-size: 12px; font-weight: 600; color: var(--c-text-muted); }

.kpi-change {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: var(--c-text-muted);
    margin-top: 4px;
}
.kpi-change .delta { font-weight: 700; display: inline-flex; align-items: center; gap: 2px; }
.kpi-change .delta .material-symbols-rounded { font-size: 14px; }

/* Color variants */
.kpi-icon.purple { background: var(--c-purple-soft); color: var(--c-purple); }
.kpi-icon.green  { background: var(--c-green-soft);  color: var(--c-green); }
.kpi-icon.blue   { background: var(--c-blue-soft);   color: var(--c-blue); }
.kpi-icon.amber  { background: var(--c-amber-soft);  color: var(--c-amber); }
.kpi-icon.red    { background: var(--c-red-soft);    color: var(--c-red); }
.kpi-icon.orange { background: var(--c-orange-soft); color: var(--c-orange); }
.kpi-icon.teal   { background: var(--c-teal-soft);   color: var(--c-teal); }
.kpi-icon.pink   { background: var(--c-pink-soft);   color: var(--c-pink); }

/* ---- Widget grid rows ---- */
.row-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}
@media (max-width: 1500px) { .row-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px)  { .row-grid { grid-template-columns: 1fr; } }

/* Custom column spans */
.col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
@media (max-width: 1500px) { .col-2, .col-3, .col-4 { grid-column: span 2; } }
@media (max-width: 720px)  { .col-2, .col-3, .col-4 { grid-column: span 1; } }

/* ---- Card shell ---- */
.card {
    background: var(--c-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 18px 18px 16px;
    display: flex;
    flex-direction: column;
    min-height: 240px;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
}
.card-head h3 {
    margin: 0;
    font-size: 14.5px;
    font-weight: 700;
    color: var(--c-text);
}
.card-foot {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--c-border);
    text-align: center;
}
.card-foot a {
    color: var(--c-primary);
    font-weight: 700;
    font-size: 12.5px;
}
.card-foot.left { text-align: start; }
.card-foot.right { text-align: end; }

/* Range pill (filter selector in card head) */
.range-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    background: var(--c-bg-soft);
    border-radius: 10px;
    color: var(--c-text-soft);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.range-pill .material-symbols-rounded { font-size: 16px; color: var(--c-text-muted); }
.range-pill.outline {
    background: transparent;
    border: 1px solid var(--c-border);
}

/* ---- Conic CSS donut ---- */
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut {
    --size: 170px;
    --thickness: 22px;
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    background: conic-gradient(var(--gradient));
    display: grid; place-items: center;
    position: relative;
    flex-shrink: 0;
}
.donut::after {
    content: "";
    position: absolute;
    inset: var(--thickness);
    background: var(--c-surface);
    border-radius: 50%;
}
.donut-inner {
    position: relative; z-index: 1;
    text-align: center;
    line-height: 1.2;
}
.donut-inner .label { color: var(--c-text-muted); font-size: 11.5px; }
.donut-inner .value { font-size: 17px; font-weight: 800; color: var(--c-text); margin-top: 2px; }
.donut-inner .currency { font-size: 11px; color: var(--c-text-muted); margin-top: 2px; }

.legend {
    flex: 1;
    min-width: 140px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.legend-row {
    display: flex; align-items: center; gap: 10px;
    font-size: 12.5px;
}
.legend-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}
.legend-row .name { flex: 1; color: var(--c-text); font-weight: 500; }
.legend-row .pct  { color: var(--c-text-muted); font-weight: 700; }
.legend-row .amt  { color: var(--c-text-muted); font-size: 11px; }

/* ---- Top products list ---- */
.product-list { display: flex; flex-direction: column; gap: 12px; }
.product-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
}
.product-rank {
    width: 28px; height: 28px;
    border-radius: 8px;
    background: var(--c-bg-soft);
    display: grid; place-items: center;
    color: var(--c-text); font-weight: 700; font-size: 12.5px;
}
.product-thumb {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #FFE5C9 0%, #FFC78A 100%);
    display: grid; place-items: center;
    color: #946B00;
    font-weight: 700;
}
.product-info { display: flex; align-items: center; gap: 10px; flex: 1; }
.product-info .name { font-weight: 600; font-size: 13px; color: var(--c-text); }
.product-info .name .small { color: var(--c-text-muted); font-size: 11px; display: block; font-weight: 500; margin-top: 2px; }
.product-qty { text-align: end; }
.product-qty .qty { font-weight: 700; font-size: 13.5px; color: var(--c-text); }
.product-qty .unit { color: var(--c-text-muted); font-size: 11px; display: block; }

/* ---- Cashbox list ---- */
.cashbox-list { display: flex; flex-direction: column; gap: 12px; }
.cashbox-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 12px;
}
.cashbox-avatar {
    width: 34px; height: 34px;
    border-radius: 10px;
    background: var(--c-bg-soft);
    display: grid; place-items: center;
    color: var(--c-text-muted);
}
.cashbox-info { display: flex; flex-direction: column; gap: 2px; }
.cashbox-info .name { font-weight: 700; font-size: 13px; color: var(--c-text); }
.cashbox-info .user { color: var(--c-text-muted); font-size: 11px; }
.cashbox-amount { font-weight: 700; font-size: 13px; color: var(--c-text); }
.cashbox-amount .small { color: var(--c-text-muted); font-size: 11px; display: block; font-weight: 500; }

/* ---- Branch sales bars ---- */
.branch-list { display: flex; flex-direction: column; gap: 14px; }
.branch-row { display: flex; flex-direction: column; gap: 6px; }
.branch-head {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 12.5px;
}
.branch-head .amt {
    font-weight: 700; color: var(--c-text);
}
.branch-head .amt .small { color: var(--c-text-muted); font-size: 11px; font-weight: 500; }
.branch-head .pct { color: var(--c-text-muted); font-weight: 700; }
.branch-bar {
    height: 6px;
    background: var(--c-bg-soft);
    border-radius: 99px;
    overflow: hidden;
}
.branch-bar > div {
    height: 100%;
    border-radius: 99px;
    transition: width 360ms ease;
}

/* ---- Inventory stats ---- */
.invstat-list { display: flex; flex-direction: column; gap: 14px; }
.invstat-row {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 13px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--c-border);
}
.invstat-row:last-child { border: 0; padding-bottom: 0; }
.invstat-row .label { color: var(--c-text-soft); font-weight: 500; }
.invstat-row .val   { color: var(--c-text); font-weight: 700; }
.invstat-row .val .small { color: var(--c-text-muted); font-weight: 500; font-size: 11px; margin-inline-start: 4px; }

/* ---- Alerts ---- */
.alert-list { display: flex; flex-direction: column; gap: 14px; }
.alert-row {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}
.alert-pill {
    border-radius: 8px;
    padding: 6px 0;
    text-align: center;
    color: #fff;
    font-weight: 800;
    font-size: 12.5px;
}
.alert-pill.red { background: var(--c-red); }
.alert-pill.amber { background: var(--c-amber); color: #6b4400; }
.alert-pill.blue { background: var(--c-blue); }
.alert-pill.green { background: var(--c-green); }
.alert-pill.purple { background: var(--c-purple); }
.alert-row .text { color: var(--c-text); font-weight: 500; text-align: end; }
.alert-row .icon { color: var(--c-text-muted); display: grid; place-items: center; }
body.ltr .alert-row .text { text-align: start; }

/* ---- Invoice table ---- */
.invoice-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}
.invoice-table th, .invoice-table td {
    padding: 8px 6px;
    text-align: start;
    border-bottom: 1px solid var(--c-border);
}
.invoice-table th {
    color: var(--c-text-muted);
    font-weight: 600;
    font-size: 11.5px;
}
.invoice-table tr:last-child td { border-bottom: 0; }
.invoice-table td { color: var(--c-text); }

/* ---- Chart hosts ---- */
.chart-host { width: 100%; min-height: 220px; }
.chart-host-sm { width: 100%; min-height: 200px; }
