:root {
    --hub-bg: #f8fafc;
    --hub-sidebar: #0f172a;
    --hub-primary: #2563eb;
    --hub-text: #111827;
    --hub-muted: #6b7280;
    --hub-card: #ffffff;
    --hub-border: #e5e7eb;
}
body { background: var(--hub-bg); color: var(--hub-text); }
.app-shell { min-height: 100vh; display: flex; }
.app-sidebar { width: 280px; min-height: 100vh; position: sticky; top: 0; background: var(--hub-sidebar); color: #fff; padding: 20px 16px; }
.app-sidebar .nav-link { color: #cbd5e1; border-radius: 12px; padding: 11px 12px; display: flex; align-items: center; gap: 10px; }
.app-sidebar .nav-link:hover, .app-sidebar .nav-link.active { color: #fff; background: rgba(37, 99, 235, .95); }
.offcanvas .nav-link { color: #111827; border-radius: 12px; padding: 11px 12px; display: flex; align-items: center; gap: 10px; }
.offcanvas .nav-link.active { background: #eff6ff; color: var(--hub-primary); font-weight: 700; }
.brand-box { display: flex; align-items: center; gap: 12px; padding: 4px 6px 22px; }
.brand-mark { width: 44px; height: 44px; border-radius: 14px; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff; font-weight: 800; }
.brand-title { font-weight: 800; line-height: 1.1; }
.brand-subtitle { color: #94a3b8; font-size: 12px; }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,.08); padding-top: 14px; }
.app-main { flex: 1; padding: 24px; min-width: 0; }
.page-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; }
.page-header h1 { margin: 0; font-size: clamp(24px, 3vw, 34px); font-weight: 800; letter-spacing: -0.03em; }
.card, .stat-card { border: 1px solid var(--hub-border); border-radius: 18px; box-shadow: 0 12px 30px rgba(15, 23, 42, .04); }
.stat-card { background: var(--hub-card); padding: 18px; display: flex; gap: 14px; align-items: center; height: 100%; }
.stat-icon { width: 46px; height: 46px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex: 0 0 auto; }
.stat-label { color: var(--hub-muted); font-size: 13px; }
.stat-value { font-size: 26px; font-weight: 800; line-height: 1.15; }
.stat-hint { color: var(--hub-muted); font-size: 12px; margin-top: 3px; }
.table { vertical-align: middle; }
.table td, .table th { white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.action-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.search-box { max-width: 520px; }
.badge { font-weight: 600; }
.chart-card { min-height: 320px; }
.chart-card canvas { max-height: 240px; }
.small-muted { font-size: 12px; color: var(--hub-muted); }
.code-soft { background: #f1f5f9; border: 1px solid #e2e8f0; color: #334155; border-radius: 8px; padding: 2px 7px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
@media (max-width: 991.98px) { .app-main { padding: 16px; } .page-header { align-items: flex-start; } .table-responsive-card thead { display: none; } .table-responsive-card tr { display: block; background: #fff; margin-bottom: 12px; border: 1px solid var(--hub-border); border-radius: 16px; padding: 10px; } .table-responsive-card td { display: flex; justify-content: space-between; gap: 16px; border: 0; white-space: normal; } .table-responsive-card td::before { content: attr(data-label); font-weight: 700; color: #475569; } }

/* v4: prevent long card helper text from overflowing on desktop/mobile */
.stat-card {
    min-width: 0;
    align-items: flex-start;
}
.stat-card > div:not(.stat-icon) {
    min-width: 0;
    flex: 1 1 auto;
}
.stat-label,
.stat-hint {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: normal;
}
.stat-hint {
    line-height: 1.25;
}
@media (min-width: 1200px) {
    .stat-card { padding: 16px; }
    .stat-hint { font-size: 11.5px; }
}

/* v10: sidebar should not make the logout button scroll through full page */
.app-sidebar {
    height: 100vh;
    min-height: 0;
    overflow: hidden;
}
.app-sidebar .hub-nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
    margin-right: -4px;
}
.app-sidebar .hub-nav::-webkit-scrollbar { width: 6px; }
.app-sidebar .hub-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 999px; }
.sidebar-footer {
    flex: 0 0 auto;
    margin-top: 14px;
}
.min-w-0 { min-width: 0; }

/* v10: order/payment UI helpers */
.order-total-lines .small-muted,
.money-breakup .small-muted { line-height: 1.35; }
.money-breakup-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px dashed #e5e7eb;
}
.money-breakup-row:last-child { border-bottom: 0; }
.money-breakup-row.total {
    border-top: 2px solid #111827;
    border-bottom: 0;
    margin-top: 6px;
    padding-top: 10px;
    font-weight: 800;
}
.money-breakup-row.negative .amount { color: #dc2626; }
.money-breakup-row.positive .amount { color: #16a34a; }
.order-doc-actions .btn { white-space: nowrap; }
.badge .bi { font-size: .95em; }
@media (max-width: 991.98px) {
    .order-doc-actions { width: 100%; }
    .order-doc-actions .btn { width: 100%; justify-content: center; }
}

/* v11: dashboard overview/store analytics cards */
.hub-summary-card { overflow: hidden; }
.summary-main { font-size: clamp(28px, 3vw, 40px); font-weight: 850; letter-spacing: -0.04em; line-height: 1.05; }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.summary-grid > div { min-width: 0; background: #f8fafc; border: 1px solid #eef2f7; border-radius: 14px; padding: 10px; }
.summary-grid > div.wide { grid-column: span 3; }
.summary-grid strong { display: block; font-size: 15px; line-height: 1.2; overflow-wrap: anywhere; }
.summary-grid span { display: block; color: var(--hub-muted); font-size: 11.5px; margin-top: 2px; }
.report-tile { border: 1px solid #e5e7eb; background: #f8fafc; border-radius: 14px; padding: 12px; height: 100%; }
@media (max-width: 575.98px) {
    .summary-grid { grid-template-columns: 1fr; }
    .summary-grid > div.wide { grid-column: span 1; }
}

/* v15/v16: collapsible desktop sidebar, merged without losing v11 analytics CSS */
.app-shell { transition: none; }
.sidebar-toggle {
    margin-left: auto;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 12px;
    background: rgba(255,255,255,.06);
    color: #cbd5e1;
    align-items: center;
    justify-content: center;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.12); color: #fff; }
body.sidebar-collapsed .app-sidebar { width: 86px; padding-left: 12px; padding-right: 12px; }
body.sidebar-collapsed .brand-box { justify-content: center; flex-direction: column; gap: 10px; padding: 4px 0 16px; }
body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .app-sidebar .nav-link span,
body.sidebar-collapsed .sidebar-footer .small,
body.sidebar-collapsed .sidebar-footer .fw-semibold { display: none !important; }
body.sidebar-collapsed .sidebar-toggle { margin-left: 0; }
body.sidebar-collapsed .sidebar-toggle .bi::before { content: "\F479"; }
body.sidebar-collapsed .app-sidebar .nav-link { justify-content: center; padding: 12px 0; gap: 0; }
body.sidebar-collapsed .app-sidebar .nav-link i { font-size: 18px; }
body.sidebar-collapsed .sidebar-footer { padding-top: 10px; }
body.sidebar-collapsed .sidebar-footer .btn { width: 44px !important; height: 38px; padding: 0; font-size: 0; display: flex; align-items: center; justify-content: center; margin-left: auto; margin-right: auto; }
body.sidebar-collapsed .sidebar-footer .btn::before { content: "\F1C3"; font-family: bootstrap-icons !important; font-size: 18px; }
body.sidebar-collapsed .app-main { min-width: 0; }
@media (prefers-reduced-motion: no-preference) {
    .app-sidebar, .app-main, .app-sidebar .nav-link, .brand-box { transition: width .18s ease, padding .18s ease, gap .18s ease; }
}

/* v16: keep dashboard cards/table layouts stable after sidebar CSS update */
.hub-summary-card .stat-icon { align-self: flex-start; }
.summary-grid > div:empty { display: none; }
.card { overflow: hidden; }
.table-wrap .table { margin-bottom: 0; }
.badge.text-bg-warning.mt-1 { white-space: nowrap; }

/* v20: analytics/filter foundations */
.summary-grid-wide { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.filter-card .form-label { font-size: 12px; color: var(--hub-muted); margin-bottom: 4px; }
.filter-card .form-select,
.filter-card .form-control { min-height: 38px; }
.metric-mini { border: 1px solid #eef2f7; background: #f8fafc; border-radius: 14px; padding: 10px 12px; }
.metric-mini strong { display:block; font-size: 18px; line-height: 1.1; }
.metric-mini span { color: var(--hub-muted); font-size: 12px; }
@media (max-width: 1199.98px) { .summary-grid-wide { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 575.98px) { .summary-grid-wide { grid-template-columns: 1fr; } }
