/* =====================================================================
   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; }

/* ---------- Column chart (months) ---------- */
.column-chart { margin: 0; }
.columns { height: var(--chart-height, 180px); display: flex; align-items: flex-end; gap: 10px; border-bottom: 1px solid #cbd5e1; padding-top: 22px; }
.column { position: relative; flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; outline: none; }
.column-bar { width: min(44px, 70%); border-radius: 6px 6px 0 0; background: var(--dash-series); transition: filter .15s; }
.column:hover .column-bar, .column:focus-visible .column-bar { filter: brightness(1.15); }
.column-value { font-size: .72rem; font-weight: 700; color: var(--dash-ink); margin-bottom: 4px; white-space: nowrap; }
.column .chart-tip { bottom: auto; top: 0; }
.column:hover .chart-tip, .column:focus-visible .chart-tip { opacity: 1; }
.columns-axis { display: flex; gap: 10px; margin-top: 6px; }
.columns-axis span { flex: 1; text-align: center; font-size: .74rem; color: var(--dash-muted); text-transform: capitalize; }

/* ---------- Admin tables & detail ---------- */
.filters-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters-row > * { min-width: 200px; }
.store-cell { display: flex; align-items: center; gap: 10px; }
.store-avatar { width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.store-cell a { color: inherit; text-decoration: none; }
.store-cell a:hover b { color: #4f46e5; text-decoration: underline; }
.detail-hero { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.detail-hero .store-avatar { width: 56px; height: 56px; border-radius: 16px; font-size: 1.4rem; }
.detail-hero-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: .9rem; }
.facts dt { color: var(--dash-muted); }
.facts dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.plan-tile { border: 1px solid var(--dash-line); border-radius: 14px; padding: 18px; background: #fff; display: grid; gap: 8px; height: 100%; }
.plan-tile.default { border: 2px solid #6366f1; }
.plan-tile.inactive { opacity: .6; }
.plan-tile-price b { font-size: 1.8rem; letter-spacing: -.02em; }
.plan-tile ul { margin: 0; padding-left: 18px; font-size: .88rem; color: #334155; }
.plan-stats { display: flex; gap: 18px; font-size: .85rem; color: var(--dash-muted); }
.plan-stats b { color: var(--dash-ink); }
.status-strip { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 12px 16px; border-radius: 12px; background: #fff; border: 1px solid var(--dash-line); font-size: .9rem; }
.status-strip a { color: inherit; text-decoration: none; }
.status-strip a:hover { text-decoration: underline; }
.status-strip .bad b { color: var(--dash-bad); }
.status-strip .warn b { color: #b45309; }
.clickable-row { cursor: pointer; }
.share { display: flex; align-items: center; gap: 8px; }
.share .bar-track { flex: 1; }
.share small { width: 44px; text-align: right; color: var(--dash-muted); }
.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; }
