:root {
    --dash-blue:#1769e0;
    --dash-indigo:#5254d9;
    --dash-cyan:#0aa7c7;
    --dash-green:#12a36d;
    --dash-amber:#e29422;
    --dash-red:#d84c5a;
    --dash-purple:#8b5cf6;
    --dash-card-shadow:0 14px 36px rgba(16,24,40,.06);
}

.sales-dashboard-page { width:min(calc(100% - 32px),1580px); padding-top:28px; }
.dashboard-hero { align-items:center; margin-bottom:18px; }
.dashboard-hero h1 { font-size:clamp(1.9rem,3vw,2.55rem); }
.dashboard-hero .intro { max-width:760px; }
.dashboard-status { display:flex; align-items:center; gap:11px; min-width:210px; padding:12px 16px; background:var(--surface); border:1px solid var(--line); border-radius:13px; box-shadow:var(--dash-card-shadow); }
.dashboard-status > span:last-child { display:grid; gap:2px; }
.dashboard-status small { color:var(--muted); font-size:.68rem; font-weight:700; text-transform:uppercase; letter-spacing:.06em; }
.dashboard-status strong { font-size:.79rem; }
.status-pulse { width:10px; height:10px; background:#12b76a; border:3px solid #d1fadf; border-radius:50%; box-sizing:content-box; }

.dashboard-toolbar { display:flex; align-items:end; gap:12px; margin-bottom:16px; padding:14px; background:var(--surface); border:1px solid var(--line); border-radius:14px; box-shadow:var(--dash-card-shadow); }
.dashboard-filter-form { flex:1 1 auto; display:grid; grid-template-columns:repeat(3,minmax(140px,1fr)) auto; align-items:end; gap:10px; }
.dashboard-filter-form label { display:grid; gap:5px; color:var(--muted); font-size:.69rem; font-weight:800; letter-spacing:.045em; text-transform:uppercase; }
.dashboard-filter-form input,.dashboard-filter-form select { height:40px; padding:8px 10px; color:var(--ink); background:var(--surface-soft); }
.dashboard-apply { display:inline-flex; align-items:center; justify-content:center; gap:7px; min-height:40px; }
.dashboard-apply svg,.icon-action svg { width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.quick-range { display:flex; align-items:center; padding:3px; background:var(--surface-soft); border:1px solid var(--line-soft); border-radius:10px; }
.quick-range button { min-width:auto; min-height:34px; padding:7px 10px; color:var(--muted); background:transparent; border:0; border-radius:7px; font-size:.73rem; white-space:nowrap; }
.quick-range button:hover,.quick-range button.is-active { color:var(--primary); background:var(--surface); box-shadow:0 2px 8px rgba(16,24,40,.08); }
.dashboard-actions { display:flex; gap:7px; }
.icon-action { display:grid; width:40px; min-width:40px; height:40px; padding:0; place-items:center; color:#344054; background:var(--surface); border:1px solid var(--line); border-radius:9px; }
.icon-action:hover { color:var(--primary); background:#eff6ff; border-color:#b9cdf2; }

.kpi-grid { display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); gap:13px; margin-bottom:13px; }
.kpi-card { position:relative; min-width:0; min-height:142px; padding:18px; overflow:hidden; background:var(--surface); border:1px solid var(--line); border-radius:15px; box-shadow:var(--dash-card-shadow); }
.kpi-card::after { position:absolute; right:-26px; bottom:-31px; width:92px; height:92px; content:""; background:currentColor; border-radius:50%; opacity:.055; }
.kpi-icon { display:grid; width:34px; height:34px; margin-bottom:13px; place-items:center; color:currentColor; background:currentColor; border-radius:9px; }
.kpi-icon svg { width:19px; height:19px; fill:none; stroke:#fff; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.kpi-label { display:block; overflow:hidden; color:var(--muted); font-size:.71rem; font-weight:800; letter-spacing:.04em; text-overflow:ellipsis; text-transform:uppercase; white-space:nowrap; }
.kpi-card strong { display:block; margin:5px 0 4px; overflow:hidden; color:var(--ink); font-size:clamp(1.08rem,1.45vw,1.48rem); letter-spacing:-.035em; text-overflow:ellipsis; white-space:nowrap; }
.kpi-card small { display:block; overflow:hidden; color:var(--muted); font-size:.72rem; text-overflow:ellipsis; white-space:nowrap; }
.kpi-sales { color:var(--dash-blue); border-top:3px solid var(--dash-blue); }
.kpi-invoices { color:var(--dash-indigo); border-top:3px solid var(--dash-indigo); }
.kpi-ticket { color:var(--dash-cyan); border-top:3px solid var(--dash-cyan); }
.kpi-discount { color:var(--dash-amber); border-top:3px solid var(--dash-amber); }
.kpi-collection { color:var(--dash-green); border-top:3px solid var(--dash-green); }
.kpi-balance { color:var(--dash-red); border-top:3px solid var(--dash-red); }

.insight-strip { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); margin-bottom:13px; overflow:hidden; background:linear-gradient(115deg,#102a56,#173f75 58%,#155b82); border-radius:14px; box-shadow:0 15px 35px rgba(18,57,104,.18); }
.insight-strip article { min-width:0; padding:17px 20px; color:#fff; border-right:1px solid rgba(255,255,255,.16); }
.insight-strip article:last-child { border-right:0; }
.insight-strip span,.insight-strip small { display:block; color:#c5d7ef; font-size:.7rem; }
.insight-strip span { font-weight:800; letter-spacing:.055em; text-transform:uppercase; }
.insight-strip strong { display:block; margin:4px 0 3px; overflow:hidden; font-size:1.15rem; text-overflow:ellipsis; white-space:nowrap; }

.dashboard-grid { display:grid; grid-template-columns:minmax(0,1.55fr) minmax(310px,.75fr); gap:13px; margin-bottom:13px; }
.dashboard-card { min-width:0; overflow:hidden; background:var(--surface); border:1px solid var(--line); border-radius:15px; box-shadow:var(--dash-card-shadow); }
.dashboard-wide { grid-column:1/-1; }
.card-heading { min-height:84px; display:flex; align-items:flex-start; justify-content:space-between; gap:18px; padding:18px 20px 13px; border-bottom:1px solid var(--line-soft); }
.card-heading h2 { margin:1px 0 3px; font-size:1rem; letter-spacing:-.015em; }
.card-heading > div > span { color:var(--muted); font-size:.74rem; }
.card-kicker { margin:0; color:var(--primary); font-size:.62rem; font-weight:850; letter-spacing:.11em; }
.chart-legend { display:flex; align-items:center; gap:12px; padding-top:8px; }
.chart-legend span { display:flex; align-items:center; gap:5px; color:var(--muted); font-size:.7rem; }
.chart-legend i { width:9px; height:9px; border-radius:50%; }
.legend-gross { background:var(--dash-indigo); }
.legend-net { background:var(--dash-blue); }
.chart-stage { min-height:285px; padding:16px 16px 8px; }
.chart-stage svg { display:block; width:100%; height:265px; overflow:visible; }
.chart-grid-line { stroke:var(--line-soft); stroke-width:1; }
.chart-axis-label { fill:var(--muted); font:10px Inter,Segoe UI,sans-serif; }
.chart-line-gross,.chart-line-net { fill:none; stroke-width:2.5; stroke-linecap:round; stroke-linejoin:round; }
.chart-line-gross { stroke:var(--dash-indigo); }
.chart-line-net { stroke:var(--dash-blue); }
.chart-area-net { fill:url(#salesAreaGradient); }
.chart-point { stroke:var(--surface); stroke-width:2; }
.chart-point-gross { fill:var(--dash-indigo); }
.chart-point-net { fill:var(--dash-blue); }
.chart-empty { display:grid; min-height:260px; place-items:center; color:var(--muted); font-size:.85rem; }

.payment-visual { min-height:285px; display:grid; grid-template-columns:150px minmax(0,1fr); align-items:center; gap:18px; padding:20px; }
.payment-donut { position:relative; display:grid; width:146px; height:146px; place-items:center; background:#edf1f6; border-radius:50%; }
.payment-donut::after { position:absolute; width:88px; height:88px; content:""; background:var(--surface); border-radius:50%; box-shadow:inset 0 0 0 1px var(--line-soft); }
.payment-donut > span { z-index:1; display:grid; width:76px; text-align:center; }
.payment-donut small { color:var(--muted); font-size:.62rem; }
.payment-donut strong { margin-top:3px; overflow:hidden; font-size:.76rem; text-overflow:ellipsis; white-space:nowrap; }
.payment-legend { display:grid; gap:10px; }
.payment-legend-row { display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:center; gap:8px; }
.payment-legend-dot { width:9px; height:9px; border-radius:3px; }
.payment-legend-label { overflow:hidden; color:var(--muted); font-size:.73rem; text-overflow:ellipsis; white-space:nowrap; }
.payment-legend-value { font-size:.75rem; font-weight:800; text-align:right; }
.payment-legend-percent { grid-column:2/-1; height:3px; overflow:hidden; background:var(--line-soft); border-radius:99px; }
.payment-legend-percent i { display:block; height:100%; border-radius:inherit; }

.bar-chart-stage { display:flex; align-items:end; gap:5px; min-height:285px; overflow-x:auto; }
.volume-column { min-width:25px; flex:1 0 25px; height:245px; display:flex; flex-direction:column; align-items:center; justify-content:end; gap:6px; }
.volume-value { color:var(--muted); font-size:.61rem; font-weight:750; }
.volume-bar-track { width:min(72%,34px); height:190px; display:flex; align-items:end; overflow:hidden; background:var(--surface-soft); border-radius:6px 6px 2px 2px; }
.volume-bar { width:100%; min-height:2px; background:linear-gradient(180deg,var(--dash-cyan),var(--dash-blue)); border-radius:6px 6px 2px 2px; transition:height .25s ease; }
.volume-label { color:var(--muted); font-size:.59rem; white-space:nowrap; }

.composition-list { min-height:285px; display:grid; align-content:center; gap:17px; padding:20px; }
.composition-row { display:grid; grid-template-columns:92px minmax(0,1fr) auto; align-items:center; gap:10px; }
.composition-label { color:var(--muted); font-size:.72rem; }
.composition-track { height:9px; overflow:hidden; background:var(--surface-soft); border-radius:99px; }
.composition-fill { display:block; height:100%; min-width:0; border-radius:inherit; }
.composition-value { min-width:92px; font-size:.73rem; font-weight:800; text-align:right; }

.branch-layout { display:grid; grid-template-columns:minmax(260px,.65fr) minmax(0,1.35fr); gap:20px; padding:18px 20px 20px; }
.branch-bars { display:grid; align-content:start; gap:15px; max-height:310px; overflow:auto; padding:2px 4px 2px 0; }
.branch-bar-row { display:grid; grid-template-columns:minmax(80px,120px) minmax(90px,1fr); gap:10px; align-items:center; }
.branch-bar-label { overflow:hidden; font-size:.72rem; font-weight:750; text-overflow:ellipsis; white-space:nowrap; }
.branch-bar-value { display:flex; align-items:center; gap:8px; }
.branch-bar-track { flex:1; height:9px; overflow:hidden; background:var(--surface-soft); border-radius:99px; }
.branch-bar-fill { display:block; height:100%; background:linear-gradient(90deg,var(--dash-indigo),var(--dash-blue)); border-radius:inherit; }
.branch-bar-value small { min-width:82px; color:var(--muted); font-size:.66rem; text-align:right; }
.branch-table-wrap { border:1px solid var(--line-soft); border-radius:10px; }

.dashboard-table { width:100%; min-width:920px; table-layout:auto; }
.dashboard-table th { position:sticky; top:0; z-index:2; padding:10px 11px; white-space:nowrap; }
.dashboard-table td { width:auto !important; min-width:0 !important; padding:10px 11px; font-size:.75rem; white-space:nowrap; }
.dashboard-table td:not(:first-child):not(:nth-child(2)),.dashboard-table th:not(:first-child):not(:nth-child(2)) { text-align:right; }
.dashboard-table tbody tr:hover { background:#f7faff; }
.dashboard-table .primary-cell { color:var(--ink); font-weight:750; }
.dashboard-table .negative-value { color:var(--dash-red); font-weight:750; }
.dashboard-table .positive-value { color:var(--dash-green); font-weight:750; }
.dashboard-table tfoot td { position:sticky; bottom:0; z-index:2; color:var(--ink); background:#eef4ff; border-top:2px solid #bfd2f6; font-weight:850; }
.detail-card { margin-bottom:20px; }
.detail-heading { align-items:center; }
.detail-search { width:min(320px,42vw); display:flex; align-items:center; gap:7px; padding-left:11px; background:var(--surface-soft); border:1px solid var(--line); border-radius:9px; }
.detail-search svg { flex:0 0 auto; width:17px; height:17px; fill:none; stroke:var(--muted); stroke-width:2; stroke-linecap:round; }
.detail-search input { min-width:0; height:38px; padding:7px 10px 7px 0; background:transparent; border:0; box-shadow:none; }
.detail-table-wrap { max-height:440px; }
.detail-table { min-width:2380px; }
.detail-table th:first-child,.detail-table td:first-child { position:sticky; left:0; z-index:1; background:inherit; }
.detail-table th:nth-child(2),.detail-table td:nth-child(2) { position:sticky; left:94px; z-index:1; min-width:150px !important; background:inherit; box-shadow:5px 0 9px -8px #344054; }
.detail-table thead th:first-child,.detail-table thead th:nth-child(2) { z-index:4; background:var(--surface-soft); }
.detail-table tfoot td:first-child,.detail-table tfoot td:nth-child(2) { z-index:4; background:#eef4ff; }
.empty-dashboard { display:grid; min-height:260px; place-items:center; align-content:center; gap:5px; color:var(--muted); text-align:center; }
.empty-dashboard span { font-size:2rem; }
.empty-dashboard strong { color:var(--ink); }
.empty-dashboard p { margin:0; font-size:.8rem; }

html[data-theme="dark"] .dashboard-status,html[data-theme="dark"] .dashboard-toolbar,html[data-theme="dark"] .kpi-card,html[data-theme="dark"] .dashboard-card { background:var(--surface); border-color:var(--line); }
html[data-theme="dark"] .dashboard-filter-form input,html[data-theme="dark"] .dashboard-filter-form select,html[data-theme="dark"] .quick-range,html[data-theme="dark"] .volume-bar-track,html[data-theme="dark"] .composition-track,html[data-theme="dark"] .branch-bar-track,html[data-theme="dark"] .detail-search { background:#0d1828 !important; }
html[data-theme="dark"] .quick-range button.is-active,html[data-theme="dark"] .quick-range button:hover { background:#22334a; }
html[data-theme="dark"] .icon-action { color:var(--ink); background:var(--surface); border-color:var(--line); }
html[data-theme="dark"] .dashboard-table tbody tr:hover { background:#172438 !important; }
html[data-theme="dark"] .dashboard-table tfoot td,html[data-theme="dark"] .detail-table tfoot td:first-child,html[data-theme="dark"] .detail-table tfoot td:nth-child(2) { background:#173052 !important; border-color:#315f9c; }
html[data-theme="dark"] .detail-table thead th:first-child,html[data-theme="dark"] .detail-table thead th:nth-child(2) { background:#172438 !important; }
html[data-theme="dark"] .payment-donut::after { background:var(--surface); border-color:var(--line); }

@media (max-width:1280px) {
    .dashboard-toolbar { flex-wrap:wrap; }
    .dashboard-filter-form { flex-basis:100%; }
    .kpi-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
    .quick-range { flex:1; }
    .quick-range button { flex:1; }
}
@media (max-width:960px) {
    .dashboard-grid { grid-template-columns:1fr; }
    .dashboard-wide { grid-column:auto; }
    .branch-layout { grid-template-columns:1fr; }
    .branch-bars { max-height:none; }
}
@media (max-width:720px) {
    .sales-dashboard-page { width:min(calc(100% - 20px),1580px); padding-top:20px; }
    .dashboard-hero { align-items:flex-start; flex-direction:column; }
    .dashboard-status { width:100%; }
    .dashboard-filter-form { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .dashboard-filter-form label:nth-child(3),.dashboard-apply { grid-column:1/-1; }
    .quick-range { width:calc(100% - 94px); overflow-x:auto; }
    .quick-range button { flex:0 0 auto; }
    .kpi-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .insight-strip { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .insight-strip article:nth-child(2) { border-right:0; }
    .insight-strip article:nth-child(-n+2) { border-bottom:1px solid rgba(255,255,255,.16); }
    .payment-visual { grid-template-columns:1fr; justify-items:center; }
    .payment-legend { width:100%; }
    .detail-heading { align-items:stretch; flex-direction:column; }
    .detail-search { width:100%; }
}
@media (max-width:450px) {
    .kpi-grid { grid-template-columns:1fr; }
    .kpi-card { min-height:125px; }
    .insight-strip { grid-template-columns:1fr; }
    .insight-strip article { border-right:0; border-bottom:1px solid rgba(255,255,255,.16); }
    .dashboard-filter-form { grid-template-columns:1fr; }
    .dashboard-filter-form label:nth-child(3),.dashboard-apply { grid-column:auto; }
}

@media print {
    body { background:#fff !important; }
    .app-header,.erp-shell-sidebar,.erp-shell-backdrop,.erp-shell-menu-button,.erp-shell-page-footer,.dashboard-toolbar,.detail-search,.api-processing,.toast { display:none !important; }
    .erp-shell-workspace { margin:0 !important; }
    .sales-dashboard-page { width:100%; padding:0; }
    .dashboard-card,.kpi-card,.dashboard-status { break-inside:avoid; box-shadow:none; }
    .dashboard-grid { grid-template-columns:1fr 1fr; }
    .detail-table-wrap { max-height:none; overflow:visible; }
    .detail-table { min-width:100%; font-size:7px; }
    .detail-table th,.detail-table td { position:static !important; padding:4px !important; }
}
