/* =====================================================================
   Dashboard: KPIs, cards, area chart, bar lists (Painel)
   ===================================================================== */
:root {
    --dash-ink: #0f172a;
    --dash-muted: #64748b;
    --dash-line: #e8edf3;
    --dash-surface: #ffffff;
    --dash-series: #4f46e5;
    --dash-good: #15803d;
    --dash-bad: #b91c1c;
}

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.period-toggle { background: #fff; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi-card {
    background: var(--dash-surface); border: 1px solid var(--dash-line); border-radius: 14px; padding: 16px 18px;
    display: grid; gap: 6px; min-width: 0;
}
.kpi-card.accent { background: linear-gradient(135deg, #4f46e5, #7c3aed); border-color: transparent; color: #fff; }
.kpi-head { display: flex; align-items: center; gap: 8px; }
.kpi-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: #eef2ff; color: #4f46e5; }
.kpi-card.accent .kpi-icon { background: rgba(255, 255, 255, .18); color: #fff; }
.kpi-label { font-size: .85rem; font-weight: 600; color: var(--dash-muted); }
.kpi-card.accent .kpi-label { color: rgba(255, 255, 255, .85); }
.kpi-value { font-size: 1.65rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-delta { display: flex; align-items: center; gap: 4px; font-size: .82rem; font-weight: 700; }
.kpi-delta small { font-weight: 500; color: var(--dash-muted); margin-left: 2px; }
.kpi-delta.good { color: var(--dash-good); }
.kpi-delta.bad { color: var(--dash-bad); }
.kpi-delta.flat { color: var(--dash-muted); }
.kpi-card.accent .kpi-delta, .kpi-card.accent .kpi-delta small { color: #fff; }
.kpi-hint { font-size: .82rem; color: var(--dash-muted); }

.dash-card { background: var(--dash-surface); border: 1px solid var(--dash-line); border-radius: 14px !important; padding: 18px 20px; }
.dash-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.ship-card { display: flex; align-items: center; gap: 14px; height: auto; }
.ship-card > .mud-icon-root { color: #4f46e5; background: #eef2ff; border-radius: 10px; padding: 8px; width: 40px; height: 40px; }

/* ---------- Area chart ---------- */
.area-chart { margin: 0; color: var(--dash-series); }
.chart-plot { position: relative; height: var(--chart-height, 220px); margin-left: 52px; }
.chart-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.chart-grid { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.chart-gridline { position: relative; border-top: 1px solid var(--dash-line); height: 0; }
.chart-gridline:last-child { border-top-color: #cbd5e1; }
.chart-gridline span { position: absolute; right: calc(100% + 8px); top: -8px; font-size: .72rem; color: var(--dash-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart-hits { position: absolute; inset: 0; display: flex; }
.chart-hit { position: relative; flex: 1; outline: none; cursor: crosshair; }
.chart-cross { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: #94a3b8; opacity: 0; }
.chart-dot {
    position: absolute; left: 50%; width: 9px; height: 9px; margin: 0 0 -4.5px -4.5px; border-radius: 50%;
    background: var(--dash-series); box-shadow: 0 0 0 2px #fff; opacity: 0;
}
.chart-tip {
    position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); z-index: 3;
    display: grid; gap: 1px; padding: 7px 10px; border-radius: 8px; white-space: nowrap; pointer-events: none;
    background: #0f172a; color: #fff; box-shadow: 0 8px 24px rgba(15, 23, 42, .25); opacity: 0; transition: opacity .12s;
}
.chart-tip.left { left: auto; right: 50%; transform: none; }
.chart-tip strong { font-size: .9rem; }
.chart-tip small { font-size: .74rem; color: #cbd5e1; }
.chart-hit:hover .chart-cross, .chart-hit:focus-visible .chart-cross,
.chart-hit:hover .chart-dot, .chart-hit:focus-visible .chart-dot,
.chart-hit:hover .chart-tip, .chart-hit:focus-visible .chart-tip { opacity: 1; }
.chart-xaxis { display: flex; margin: 8px 0 0 52px; }
.chart-xaxis span { flex: 1; text-align: center; font-size: .72rem; color: var(--dash-muted); white-space: nowrap; overflow: visible; }

/* ---------- Bar list ---------- */
.bar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.bar-row { display: flex; justify-content: space-between; gap: 12px; font-size: .9rem; margin-bottom: 6px; }
.bar-label { color: var(--dash-ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.bar-label:hover { color: #4f46e5; text-decoration: underline; }
.bar-value { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-track { height: 8px; border-radius: 999px; background: #f1f5f9; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--dash-series); }
.bar-detail { display: block; margin-top: 4px; font-size: .75rem; color: var(--dash-muted); }
.bar-empty { margin: 8px 0; color: var(--dash-muted); font-size: .9rem; }

/* ---------- Recent orders ---------- */
.recent-orders { list-style: none; margin: 0; padding: 0; }
.recent-orders li + li { border-top: 1px solid var(--dash-line); }
.recent-orders a { display: flex; align-items: center; gap: 12px; padding: 10px 4px; color: inherit; text-decoration: none; border-radius: 8px; }
.recent-orders a:hover { background: #f8fafc; }
.recent-avatar { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #4f46e5; background: #eef2ff; }
.recent-main { display: grid; min-width: 0; }
.recent-main b { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-main small { color: var(--dash-muted); font-size: .78rem; }
.recent-side { margin-left: auto; display: grid; justify-items: end; gap: 2px; font-size: .9rem; }

.catalog-strip { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; padding: 14px 18px; border-radius: 14px; background: #fff; border: 1px solid var(--dash-line); }
.catalog-strip .warn b { color: #b45309; }

/* ---------- Subscription ---------- */
.plan-card-top { padding-bottom: 16px; border-bottom: 1px solid var(--dash-line); }
.plan-price { display: flex; align-items: baseline; gap: 4px; margin-top: 12px; }
.plan-price b { font-size: 2.3rem; letter-spacing: -.03em; line-height: 1; }
.plan-price span { color: var(--dash-muted); font-weight: 600; }
.plan-facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 16px 0; font-size: .9rem; }
.plan-facts dt { color: var(--dash-muted); }
.plan-facts dd { margin: 0; font-weight: 600; text-align: right; }
.plan-features { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: .9rem; }
.plan-features li { display: flex; align-items: center; gap: 8px; }
.invoice-open.overdue { border-color: #fecaca; background: #fffbfb; }
.invoice-pay { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.invoice-pay img { border: 1px solid var(--dash-line); border-radius: 12px; padding: 6px; background: #fff; }
.invoice-pay-info { flex: 1; min-width: 240px; }
.all-paid { display: flex; align-items: center; gap: 16px; height: auto; }

@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) {
    .kpi-grid { gap: 10px; }
    .kpi-card { padding: 12px 14px; }
    .kpi-value { font-size: 1.3rem; }
    .chart-plot, .chart-xaxis { margin-left: 40px; }
    .dash-card { padding: 14px; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---------- Category tree ---------- */
.tree-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.category-tree { list-style: none; margin: 0; padding: 0; }
.tree-row {
    display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px calc(6px + var(--depth) * 26px);
    border-radius: 10px; position: relative;
}
.tree-row + .tree-row { margin-top: 2px; }
.tree-row:hover { background: #f8fafc; }
.tree-row.editing { background: #eef2ff; }
.tree-row::before {
    content: ""; position: absolute; left: calc(var(--depth) * 26px - 8px); top: 0; bottom: 50%; width: 10px;
    border-left: 1px solid #cbd5e1; border-bottom: 1px solid #cbd5e1; border-bottom-left-radius: 6px;
    display: var(--tree-line, block);
}
.tree-row[aria-level="1"]::before { display: none; }
.tree-spacer { width: 34px; flex: none; }
.tree-icon { color: #6366f1; }
.tree-main { display: grid; min-width: 0; flex: 1; }
.tree-main b { font-size: .93rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-main small { color: var(--dash-muted); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.hidden-cat .tree-main b { opacity: .55; }
.kpi-card.accent .kpi-hint { color: rgba(255, 255, 255, .85); }
.facts + .bar-list, .facts + .bar-empty { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--dash-line); }
.invoice-pay-info textarea { font-size: .82rem !important; font-family: ui-monospace, Consolas, monospace !important; }
.settings-overline { display: block; color: #6366f1 !important; font-weight: 700 !important; line-height: 1.4 !important; }

/* ---------- Fulfillment mode (Frete) ---------- */
.fulfillment-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.fulfillment-option {
    display: flex; align-items: flex-start; gap: 12px; text-align: left; padding: 14px; cursor: pointer; font: inherit; color: inherit;
    border: 1.5px solid var(--mud-palette-lines-default); border-radius: 12px; background: #fff; transition: border-color .15s, box-shadow .15s;
}
.fulfillment-option:hover { border-color: #a5b4fc; }
.fulfillment-option.selected { border-color: var(--mud-palette-primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .14); background: #f8f7ff; }
.fulfillment-option .mud-icon-root { color: var(--mud-palette-primary); margin-top: 2px; }
.fulfillment-option span { display: grid; gap: 3px; }
.fulfillment-option small { color: var(--dash-muted); font-size: .82rem; line-height: 1.35; }
@media (max-width: 800px) { .fulfillment-options { grid-template-columns: 1fr; } }

/* ---------- Order: history, tracking, documents ---------- */
.status-timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.status-timeline li { position: relative; display: flex; gap: 12px; padding: 0 0 16px 4px; }
.status-timeline li:not(:last-child)::before { content: ""; position: absolute; left: 9px; top: 14px; bottom: -2px; width: 2px; background: #e2e8f0; }
.timeline-dot { width: 12px; height: 12px; margin-top: 4px; flex: none; border-radius: 50%; background: #4f46e5; box-shadow: 0 0 0 3px #eef2ff; position: relative; z-index: 1; }
.status-timeline li.canceled .timeline-dot { background: #dc2626; box-shadow: 0 0 0 3px #fee2e2; }
.status-timeline li:last-child .timeline-dot { background: #16a34a; box-shadow: 0 0 0 3px #dcfce7; }
.status-timeline li > div { display: grid; gap: 1px; }
.status-timeline small { color: var(--dash-muted); font-size: .8rem; }
.timeline-note { font-style: italic; color: #334155 !important; }
.tracking-form { padding: 12px; margin-bottom: 12px; border-radius: 10px; background: #f8fafc; border: 1px solid var(--dash-line); }
.order-doc { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-top: 1px solid var(--dash-line); }
.order-doc-icon { color: #4f46e5; margin-top: 2px; }
.order-doc-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.order-doc-main small { color: var(--dash-muted); font-size: .8rem; }
.nfe-key { font-family: ui-monospace, Consolas, monospace; letter-spacing: .02em; color: #0f172a !important; overflow-wrap: anywhere; }
.order-doc-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.doc-file { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600;
    color: #4f46e5; background: #eef2ff; text-decoration: none; }
.doc-file:hover { background: #e0e7ff; }
.file-drop { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border: 1.5px dashed #c7d2fe; border-radius: 10px; cursor: pointer;
    color: #4338ca; background: #f8f9ff; font-size: .9rem; overflow: hidden; }
.file-drop:hover { border-color: #6366f1; }
.file-drop input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-drop span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Inventory, promotions, kits ---------- */
.stock-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 12px; }
.stock-filters > .mud-input-control { flex: 1 1 240px; max-width: 360px; }
.stock-list, .promo-list, .movement-list, .kit-items { list-style: none; margin: 0; padding: 0; }
.stock-list li + li, .promo-list li + li { border-top: 1px solid var(--dash-line); }
.stock-row, .promo-row {
    width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 8px; border: 0; background: transparent; cursor: pointer;
    text-align: left; font: inherit; color: inherit; border-radius: 10px;
}
.stock-row:hover, .promo-row:hover, .stock-list li.selected .stock-row, .promo-list li.selected .promo-row { background: var(--mud-palette-action-default-hover); }
.stock-thumb { width: 42px; height: 42px; flex: none; border-radius: 8px; overflow: hidden; background: var(--mud-palette-background-gray); }
.stock-thumb img { width: 100%; height: 100%; object-fit: cover; }
.stock-name, .promo-main { flex: 1; min-width: 0; display: grid; }
.stock-name strong, .promo-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stock-name small, .promo-main small { color: var(--mud-palette-text-secondary); }
.stock-qty { display: grid; justify-items: end; min-width: 84px; }
.stock-qty strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.stock-qty small { font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stock-qty.ok small { color: #15803d; }
.stock-qty.low strong, .stock-qty.low small { color: #b45309; }
.stock-qty.out strong, .stock-qty.out small { color: #dc2626; }
.stock-qty.untracked small { color: var(--mud-palette-text-secondary); text-transform: none; }
.stock-panel-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.stock-balance { display: flex; align-items: baseline; justify-content: space-between; padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; background: var(--mud-palette-background-gray); }
.stock-balance strong { font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.stock-balance.low strong { color: #b45309; }
.stock-balance.out strong { color: #dc2626; }
.movement-list li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px dashed var(--dash-line); }
.movement-qty { min-width: 46px; text-align: center; font-weight: 700; border-radius: 8px; padding: 2px 6px; font-variant-numeric: tabular-nums; }
.movement-qty.in { background: #dcfce7; color: #15803d; }
.movement-qty.out { background: #fee2e2; color: #b91c1c; }
.movement-info { flex: 1; display: grid; font-size: .86rem; }
.movement-info small { color: var(--mud-palette-text-secondary); }
.movement-info a { margin-left: 4px; font-weight: 500; }
.movement-note { font-style: italic; }
.movement-balance { font-weight: 600; color: var(--mud-palette-text-secondary); font-variant-numeric: tabular-nums; }
.coupon-code { font-family: ui-monospace, monospace; font-weight: 700; padding: 4px 10px; border-radius: 8px; border: 1px dashed var(--mud-palette-primary); color: var(--mud-palette-primary); white-space: nowrap; }
.promo-percent { min-width: 64px; text-align: center; font-weight: 800; font-size: 1.05rem; color: #15803d; }
.promo-preview b { color: #15803d; }
.kit-items li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--dash-line); }
.kit-item-name { flex: 1; display: grid; min-width: 0; }
.kit-item-name small { color: var(--mud-palette-text-secondary); }
.kit-qty { max-width: 90px; }
.kit-price-row { display: grid; grid-template-columns: 220px 1fr; gap: 16px; align-items: center; }
.kit-price-info { display: grid; gap: 2px; font-size: .9rem; }
.kit-savings-tag { color: #15803d; font-weight: 600; }
.fee-preview { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 16px 0; }
.fee-preview dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .kit-price-row { grid-template-columns: 1fr; } }

/* ---------- Shipping labels ---------- */
.selection-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 12px; border-radius: 12px;
    background: color-mix(in srgb, var(--mud-palette-primary) 10%, transparent); }
.selection-bar > span { margin-right: auto; }
.label-printed { color: #15803d; }
.order-exception { color: #b91c1c; font-weight: 600; }
.label-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.label-formats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.label-formats .layout-choice { display: flex; align-items: center; gap: 14px; text-align: left; padding: 12px; }
.format-pic { width: 48px; height: 64px; flex: none; border: 2px solid currentColor; border-radius: 4px; padding: 4px; display: grid; gap: 3px; opacity: .75; }
.format-pic.a4 { grid-template-columns: 1fr 1fr; }
.format-pic i { border: 1.5px dashed currentColor; border-radius: 2px; }
.format-pic.thermal { width: 44px; height: 62px; }
.label-help { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: .92rem; }
