/* ===== Dashboard Layout ===== */
.dashboard-layout {
    min-height: 100vh;
    background: var(--bg-secondary);
}

/* Hide visible scrollbar tracks while preserving scroll behavior */
html, body, .sidebar, .dashboard-main, .page-main, .page-content {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.dashboard-main::-webkit-scrollbar,
.page-main::-webkit-scrollbar,
.page-content::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

/* ===== Sidebar ===== */
.sidebar {
    background: #ffffff;
    color: #111827;
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 100;
    overflow-y: auto;
    transition: var(--transition);
}

.sidebar-header {
    padding: 0 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 8px;
}

.sidebar-header .logo {
    /* logo colour now handled by .logo-text / .logo-kitaab */
}

.sidebar-nav {
    flex: 1;
    padding: 8px 12px;
}

.nav-section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #6b7280;
    padding: 16px 12px 8px;
    font-weight: 600;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    color: #111827;
    transition: var(--transition);
    margin-bottom: 2px;
    cursor: pointer;
}

.sidebar-link:hover {
    background: #f3f4f6;
    color: #111827;
}

.sidebar-link.active {
    background: linear-gradient(135deg, #6C47FF 0%, #5430E8 60%, #4318D0 100%);
    color: white;
    font-weight: 600;
}

.sidebar-link .link-icon {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1;
    flex-shrink: 0;
    color: #111827;
}

.sidebar-link .link-icon svg {
    width: 1.15rem;
    height: 1.15rem;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-link:hover .link-icon,
.sidebar-link.active .link-icon {
    color: #ffffff;
}

.sidebar-header .logo-icon svg {
    color: #111827;
    stroke: currentColor;
}

.sidebar-link .link-badge {
    margin-left: auto;
    background: var(--secondary);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: default;
    padding: 8px;
    margin: -8px;
    border-radius: var(--radius-md);
    transition: none;
}

.sidebar-user:hover {
    background: transparent;
}

.sidebar-gstin-text {
    font-size: 11px;
    color: var(--text-muted);
}

/* Hide business name + GSTIN line in sidebar footer */
.sidebar #sidebarBizName,
.sidebar #sidebarGSTIN {
    display: none !important;
}

.sidebar-logout-btn {
    margin-top: 8px;
    width: 100%;
    border: none;
    background: none;
    text-align: left;
}

/* ===== Profile Popup ===== */
.profile-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 999;
}

.profile-popup {
    position: absolute;
    bottom: 100%;
    left: 16px;
    right: 16px;
    margin-bottom: 8px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    animation: popupSlideUp 0.2s ease;
    overflow: hidden;
    color: #1a1a2e;
}

@keyframes popupSlideUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.profile-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, #6C47FF 0%, #5430E8 60%, #4318D0 100%);
    color: white;
}

.profile-popup-header h3 {
    font-size: 0.9rem;
    font-weight: 700;
    margin: 0;
}

.profile-popup-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.profile-popup-close:hover {
    opacity: 1;
}

.profile-popup-body {
    padding: 8px 0;
}

.profile-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.profile-row:last-child {
    border-bottom: none;
}

.profile-row-left {
    flex: 1;
    min-width: 0;
}

.profile-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.profile-value {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: #1a1a2e;
    word-break: break-all;
}

.profile-copy-btn {
    background: none;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #6C47FF;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    margin-left: 10px;
    flex-shrink: 0;
}

.profile-copy-btn:hover {
    background: #f5f3ff;
    border-color: #6C47FF;
}

.profile-copy-btn.copied {
    background: #ecfdf5;
    border-color: #10b981;
    color: #059669;
}

/* ===== Profile Completion Banner ===== */
.profile-completion-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #6C47FF 0%, #5430E8 60%, #4318D0 100%);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: var(--radius-lg);
    animation: slideDown 0.3s ease;
}

.pcb-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
}

.pcb-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pcb-text strong {
    font-size: 0.95rem;
    color: #ffffff;
}

.pcb-text span {
    font-size: 0.82rem;
    color: rgba(255,255,255,0.78);
}

.pcb-btn {
    white-space: nowrap;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .profile-completion-banner {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-info strong {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info span {
    font-size: 0.75rem;
    color: #4b5563;
}

/* ===== Main Content ===== */
.dashboard-main {
    margin-left: 260px;
    padding: 0;
}

.dashboard-topbar {
    background: white;
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px;
}

.topbar-greeting h2 {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 1.2rem;
    font-weight: 700;
}

.topbar-greeting p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.topbar-btn:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.topbar-btn .topbar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.notification-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: var(--radius-full);
    border: 2px solid white;
}

.dashboard-content {
    padding: 28px 32px;
}

/* ===== Stat Cards ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    border: 1px solid var(--border-light);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-height: 220px;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 14px;
}

.stat-card-icon.green {
    background: var(--success-light);
}

.stat-card-icon.blue {
    background: var(--info-light);
}

.stat-card-icon.orange {
    background: var(--warning-light);
}

.stat-card-icon.purple {
    background: var(--primary-light);
}

.stat-card-label {
    font-size: var(--ui-subtext-size);
    color: var(--text-muted);
    font-weight: var(--ui-subtext-weight);
    margin-bottom: 4px;
}

.stat-card-value {
    font-size: var(--ui-value-size);
    font-weight: var(--ui-value-weight);
    color: var(--text-primary);
    margin-bottom: 0;
    line-height: 1.15;
    width: 100%;
    display: block !important;
}

.metric-link {
    display: inline-block;
    text-decoration: none;
    color: var(--text-primary);
    border-bottom: 2px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.stat-card-value.metric-link {
    display: block;
}

.metric-link:hover,
.metric-link:focus-visible {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.stat-card-change {
    font-size: 0.78rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: auto;
    align-self: flex-start;
}

.stat-card-change.up {
    color: var(--success);
    background: var(--success-light);
}

.stat-card-change.down {
    color: var(--danger);
    background: var(--danger-light);
}

.stat-card-change.is-neutral {
    color: var(--text-muted);
    background: var(--bg-secondary);
}

/* ===== Dashboard Panels ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 24px;
    margin-bottom: 28px;
}

.panel {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.panel-spaced {
    margin-bottom: 24px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-light);
}

.panel-header h3 {
    font-size: var(--ui-title-size);
    font-weight: var(--ui-title-weight);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    line-height: 1.2;
}

.section-title-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.05em;
    height: 1.05em;
    line-height: 1;
    flex-shrink: 0;
}

.panel-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    background: var(--primary-light);
    color: var(--primary);
    line-height: 1.2;
}

.chart-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-style-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    background: #f5f7fc;
    border: 1px solid #e4e9f4;
    border-radius: 999px;
}

.chart-style-btn {
    border: none;
    background: transparent;
    color: #5f6b7d;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    border-radius: 999px;
    padding: 7px 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chart-style-btn:hover {
    background: #eceffd;
    color: #3d3f66;
}

.chart-style-btn.active {
    background: linear-gradient(135deg, #6C47FF 0%, #5430E8 60%, #4318D0 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(84, 48, 232, 0.25);
}

.panel-body {
    padding: 20px 24px;
}

.chart-empty-state {
    text-align: center;
    padding: 16px 0;
    color: var(--text-muted);
    font-size: 14px;
}

.chart-empty-link {
    margin-top: 8px;
}

.empty-state-center {
    text-align: center;
    padding: 24px 0;
    color: var(--text-muted);
}

.empty-state-center.compact {
    padding: 20px 0;
}

.empty-state-icon-lg {
    font-size: 40px;
    margin-bottom: 8px;
}

.empty-state-icon-md {
    font-size: 36px;
    margin-bottom: 8px;
}

.empty-state-subtext {
    font-size: 13px;
}

.empty-state-subtext-sm {
    font-size: 12px;
    margin-top: 4px;
}

/* ===== Transactions List ===== */
.tx-list {
    display: flex;
    flex-direction: column;
}

.tx-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light);
}

.tx-item:last-child {
    border-bottom: none;
}

.tx-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.tx-icon.sale {
    background: #ffffff;
    border: 1px solid var(--border-light);
}

.tx-icon.purchase {
    background: var(--info-light);
}

.tx-icon.expense {
    background: var(--warning-light);
}

.tx-details {
    flex: 1;
    min-width: 0;
}

.tx-details strong {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-details span {
    font-size: var(--ui-subtext-size);
    font-weight: var(--ui-subtext-weight);
    color: var(--text-muted);
}

.tx-amount {
    font-size: 0.95rem;
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

.tx-amount.positive {
    color: #111827;
}

.tx-amount.negative {
    color: #9f2f6a;
}

/* ===== GST Summary ===== */
.gst-summary-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.gst-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.gst-item-label {
    font-size: 0.88rem;
    font-weight: 600;
}

.gst-item-label small {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
}

.gst-item-value {
    font-size: 1.05rem;
    font-weight: 700;
}

.gst-item-status {
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 700;
}

.status-pending {
    background: var(--warning-light);
    color: var(--warning);
}

.status-done {
    background: var(--success-light);
    color: var(--success);
}

.status-due {
    background: var(--danger-light);
    color: var(--danger);
}

/* ===== Alerts ===== */
.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
}

.alert-item.alert-warning {
    background: var(--warning-light);
    border-left: 3px solid var(--warning);
}

.alert-item.alert-danger {
    background: var(--danger-light);
    border-left: 3px solid var(--danger);
}

.alert-item.alert-info {
    background: var(--info-light);
    border-left: 3px solid var(--info);
}

.alert-item.alert-success {
    background: var(--success-light);
    border-left: 3px solid var(--success);
}

.alert-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
}

.alert-content strong {
    display: block;
    margin-bottom: 2px;
    font-size: 0.85rem;
}

.alert-content p {
    font-size: var(--ui-subtext-size);
    font-weight: var(--ui-subtext-weight);
    color: var(--text-secondary);
    margin: 0;
}

/* ===== Inventory Quick View ===== */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.inventory-item {
    padding: 14px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    text-align: center;
}

.inventory-item .inv-icon {
    font-size: 1.5rem;
    margin-bottom: 6px;
}

.inventory-item .inv-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.inventory-item .inv-stock {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    display: inline-block;
}

.stock-low {
    background: var(--danger-light);
    color: var(--danger);
}

.stock-ok {
    background: var(--success-light);
    color: var(--success);
}

.stock-medium {
    background: var(--warning-light);
    color: var(--warning);
}

/* ===== Quick Actions ===== */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 28px;
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 12px;
    background: white;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    color: var(--text-primary);
    font-family: inherit;
}

.quick-action-btn:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
}

.quick-action-btn .qa-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.qa-icon.qa-green {
    background: var(--success-light);
}

.qa-icon.qa-blue {
    background: var(--info-light);
}

.qa-icon.qa-purple {
    background: var(--primary-light);
}

.qa-icon.qa-orange {
    background: var(--warning-light);
}

.quick-action-btn .qa-label {
    font-size: var(--ui-subtext-size);
    font-weight: var(--ui-title-weight);
    text-align: center;
}

/* ===== Chart Placeholder ===== */
.chart-placeholder {
    height: 100%;
    min-height: 420px;
    background: linear-gradient(180deg, #fbfcff 0%, #f7f9fd 100%);
    border: 1px solid #e9edf5;
    border-radius: 12px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
    padding: 22px 8px 34px;
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
}

.chart-placeholder::before {
    content: '';
    position: absolute;
    inset: 14px 14px 28px;
    border-radius: 8px;
    background:
        linear-gradient(to top, rgba(148, 163, 184, 0.18) 1px, transparent 1px);
    background-size: 100% 25%;
    pointer-events: none;
}

/* ── Chart Panel Header (3 children: title | period toggle | style+badge) ── */
.chart-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.chart-panel-header h3 {
    flex-shrink: 0;
}
.chart-panel-header .chart-header-actions {
    margin-left: auto;
}

/* ── Chart Period Toggle ── */
.chart-period-toggle {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: #f3f4f6;
    border-radius: 10px;
    padding: 4px;
    flex-shrink: 0;
}
.chart-period-btn {
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    border-radius: 7px;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    font-family: inherit;
}
.chart-period-btn:hover {
    background: #fff;
    color: #374151;
}
.chart-period-btn.active,
.chart-period-btn[aria-pressed="true"] {
    background: #fff;
    color: #6C47FF;
    font-weight: 700;
    box-shadow: 0 1px 4px rgba(108, 71, 255, 0.18);
}

/* ── Chart Style Toggle ── */
.chart-style-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #f3f4f6;
    border-radius: 10px;
    padding: 4px;
}

.chart-style-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 2px solid transparent;
    border-radius: 7px;
    background: transparent;
    cursor: pointer;
    padding: 0;
    transition: all 0.15s ease;
}

.chart-style-btn:hover {
    background: #fff;
    border-color: #e5e7eb;
}

.chart-style-btn[aria-pressed="true"],
.chart-style-btn.active {
    background: #fff;
    border-color: #6C47FF;
    box-shadow: 0 1px 4px rgba(108, 71, 255, 0.18);
}

/* Colour swatches inside each button */
.csb-swatch {
    display: block;
    width: 14px;
    height: 14px;
    border-radius: 4px;
}
.csb-soft     { background: linear-gradient(180deg, #c8c2ec 0%, #7366c5 100%); }
.csb-classic  { background: linear-gradient(180deg, #c1b6f4 0%, #6d56d4 100%); }
.csb-elevated { background: linear-gradient(180deg, #d0c9f2 0%, #6353ca 100%); box-shadow: 0 3px 6px rgba(99,83,202,0.3); }
.csb-outline  { background: transparent; border: 2px solid #7366c5; border-radius: 3px; }
.csb-mono     { background: linear-gradient(180deg, #d0d5de 0%, #7f8ca3 100%); }

/* chart-header-actions flex layout */
.chart-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-bar {
    width: 78px;
    max-width: 78px;
    min-width: 78px;
    flex: 0 0 78px;
    border-radius: 10px 10px 4px 4px;
    transition: var(--transition);
    position: relative;
    z-index: 1;
}

.chart-bar.chart-bar--empty {
    opacity: 0.85;
}

.chart-bar-value {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.62rem;
    font-weight: 700;
    color: #4b5563;
    white-space: nowrap;
    pointer-events: none;
}
.chart-bar.chart-bar--first .chart-bar-value {
    left: 0;
    transform: none;
}
.chart-bar.chart-bar--last .chart-bar-value {
    left: auto;
    right: 0;
    transform: none;
}

.chart-bar:hover {
    transform: translateY(-1px);
}

.chart-bar::after {
    content: attr(data-label);
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.66rem;
    color: #6b7280;
    white-space: nowrap;
    font-weight: 600;
    /* Prevent overflow when bars are narrow (daily view) */
    max-width: 120%;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Daily view: even smaller label to fit 14 bars */
.chart-placeholder .chart-bar[style*="flex: 1"]::after {
    font-size: 0.58rem;
    letter-spacing: -0.02em;
}

.chart-placeholder.style-soft .chart-bar.chart-bar--filled {
    background: linear-gradient(180deg, #c8c2ec 0%, #8e83d6 100%);
}

.chart-placeholder.style-soft .chart-bar.chart-bar--filled.latest {
    background: linear-gradient(180deg, #b2abd9 0%, #7366c5 100%);
    box-shadow: 0 6px 14px rgba(115, 102, 197, 0.22);
}

.chart-placeholder.style-soft .chart-bar.chart-bar--empty {
    background: linear-gradient(180deg, #eceff5 0%, #d5dae4 100%);
}

.chart-placeholder.style-mono .chart-bar.chart-bar--filled {
    background: linear-gradient(180deg, #d0d5de 0%, #99a3b5 100%);
}

.chart-placeholder.style-mono .chart-bar.chart-bar--filled.latest {
    background: linear-gradient(180deg, #c3cad6 0%, #7f8ca3 100%);
    box-shadow: 0 6px 14px rgba(100, 116, 139, 0.24);
}

.chart-placeholder.style-mono .chart-bar.chart-bar--empty {
    background: linear-gradient(180deg, #f0f2f6 0%, #d9dee8 100%);
}

.chart-placeholder.style-mono .chart-bar.has-value::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #7f8ca3;
    transform: translateX(-50%);
}

.chart-placeholder.style-classic {
    background: linear-gradient(180deg, #fcfcff 0%, #f4f4fc 100%);
}

.chart-placeholder.style-classic .chart-bar.chart-bar--filled {
    background: linear-gradient(180deg, #c1b6f4 0%, #6d56d4 100%);
}

.chart-placeholder.style-classic .chart-bar.chart-bar--filled.latest {
    background: linear-gradient(180deg, #9d8ff0 0%, #4f35cb 100%);
    box-shadow: 0 8px 16px rgba(79, 53, 203, 0.27);
}

.chart-placeholder.style-classic .chart-bar.chart-bar--empty {
    background: linear-gradient(180deg, #ece9f8 0%, #dad4ef 100%);
}

.chart-placeholder.style-outline {
    background: linear-gradient(180deg, #fbfcff 0%, #f6f8fd 100%);
}

.chart-placeholder.style-outline .chart-bar {
    border: 2px solid #9ba4b8;
    background: rgba(255, 255, 255, 0.35);
}

.chart-placeholder.style-outline .chart-bar.chart-bar--filled {
    border-color: #7366c5;
    background: linear-gradient(180deg, rgba(115, 102, 197, 0.22) 0%, rgba(115, 102, 197, 0.6) 100%);
}

.chart-placeholder.style-outline .chart-bar.chart-bar--filled.latest {
    border-color: #4f46c8;
    background: linear-gradient(180deg, rgba(79, 70, 200, 0.3) 0%, rgba(79, 70, 200, 0.72) 100%);
}

.chart-placeholder.style-outline .chart-bar-value {
    color: #424c5f;
}

.chart-placeholder.style-elevated {
    background: linear-gradient(180deg, #fdfdff 0%, #f7f8fc 100%);
}

.chart-placeholder.style-elevated .chart-bar.chart-bar--filled {
    background: linear-gradient(180deg, #d0c9f2 0%, #8578d5 100%);
    box-shadow: 0 6px 14px rgba(133, 120, 213, 0.23);
}

.chart-placeholder.style-elevated .chart-bar.chart-bar--filled.latest {
    background: linear-gradient(180deg, #b2a8e8 0%, #6353ca 100%);
    box-shadow: 0 12px 20px rgba(99, 83, 202, 0.3);
}

.chart-placeholder.style-elevated .chart-bar.chart-bar--empty {
    background: linear-gradient(180deg, #f0f2f8 0%, #dde2eb 100%);
}

/* ===== Mobile Responsive Utilities ===== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-header-actions {
        gap: 8px;
    }

    .chart-style-toggle {
        max-width: 100%;
        overflow-x: auto;
    }
}

@media (max-width: 768px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        -webkit-transform: translateX(-100%);
        transform: translateX(-100%);
        width: 280px;
        will-change: transform;
    }

    .sidebar.sidebar-open {
        -webkit-transform: translateX(0) !important;
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    .dashboard-main {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }

    .dashboard-topbar {
        padding: 12px 16px;
    }

    .dashboard-content {
        padding: 20px 16px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .quick-actions {
        grid-template-columns: 1fr 1fr;
    }

    .inventory-grid {
        grid-template-columns: 1fr 1fr;
    }

}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Sidebar overlay for mobile ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
}

.sidebar-overlay.active {
    display: block;
}

/* Product-wide kill switch for legacy floating AI Help launcher/panel */
#hkVoiceAssistBtn,
#hkFlowCoachPanel,
#hkFlowCoachLandingPrompt {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* =====================================================
   EXTENDED DASHBOARD METRICS — dm-* namespace
   ===================================================== */

/* Quick Metrics Strip */
.dm-metrics-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.dm-metric-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
}
.dm-metric-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.dm-metric-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
}
.dm-metric-value {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.4px;
    margin: 2px 0 4px;
}
.dm-metric-sub {
    font-size: 0.68rem;
    color: var(--text-muted);
}
.dm-badge {
    font-size: 0.62rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    white-space: nowrap;
}
.dm-badge-green  { background: #ECFDF5; color: #059669; }
.dm-badge-amber  { background: #FFFBEB; color: #D97706; }
.dm-badge-red    { background: #FEF2F2; color: #DC2626; }
.dm-badge-neutral{ background: #F3F4F6; color: #6B7280; }

/* Main layout: left stack (chart + top products) + right (transactions) */
/* Uses minmax so it works at any viewport — no breakpoint collapse until mobile */
.dm-row-main-right {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
    gap: 16px;
    margin-bottom: 16px;
    align-items: stretch;
}
.dm-left-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    height: 100%;
}
.dm-left-stack-panel {
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}
.dm-left-stack-panel > .panel-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.dm-right-tx {
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-self: stretch;
}
.dm-right-tx .panel-body.dm-tx-panel-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}
.dm-tx-panel-body::-webkit-scrollbar { width: 4px; }
.dm-tx-panel-body::-webkit-scrollbar-thumb { background: #E5E7EB; border-radius: 2px; }

/* Only collapse on genuine mobile */
@media (max-width: 768px) {
    .dm-row-main-right { grid-template-columns: 1fr; }
    .dm-tx-panel-body { max-height: none; }
}

/* 2-column row used for all paired panels */
.dm-row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
    align-items: start;
}
/* Remove stacking margin on panels inside 2-col rows */
.dm-row-2col .panel-spaced {
    margin-bottom: 0;
}
.dm-panel-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Top Products */
.dm-product-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid #F3F4F6;
}
.dm-product-item:last-child { border-bottom: none; }
.dm-product-rank {
    width: 22px; height: 22px;
    border-radius: 6px;
    background: #F3F4F6;
    color: #6B7280;
    font-size: 0.68rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.dm-product-rank.gold { background: #FFF7ED; color: #D97706; }
.dm-product-name  { font-size: 0.83rem; font-weight: 600; color: var(--text); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-product-meta  { font-size: 0.7rem; color: var(--text-muted); margin-top: 1px; }
.dm-product-bar-wrap { width: 56px; flex-shrink: 0; }
.dm-product-bar-bg   { height: 4px; background: #F3F4F6; border-radius: 2px; overflow: hidden; }
.dm-product-bar-fill { height: 100%; background: var(--primary); border-radius: 2px; }

/* Outstanding Receivables */
.dm-outstanding-total {
    font-size: 1.55rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.8px;
    margin-bottom: 2px;
}
.dm-outstanding-sub { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 12px; }
.dm-customer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #F3F4F6;
}
.dm-customer-item:last-child { border-bottom: none; }
.dm-customer-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: #EDE9FF;
    color: var(--primary);
    font-size: 0.62rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.dm-customer-name  { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.dm-customer-days  { font-size: 0.68rem; color: var(--text-muted); margin-top: 1px; }
.dm-customer-amount{ margin-left: auto; font-size: 0.83rem; font-weight: 700; color: #D97706; white-space: nowrap; }
.dm-overdue-badge  { font-size: 0.58rem; background: #FEF2F2; color: #DC2626; padding: 1px 5px; border-radius: 4px; font-weight: 700; vertical-align: middle; margin-left: 4px; }

/* Cash Flow */
.dm-cashflow-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.dm-cf-label { font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 3px; }
.dm-cf-label.in  { color: #059669; }
.dm-cf-label.out { color: #DC2626; }
.dm-cf-amount { font-size: 1.35rem; font-weight: 900; letter-spacing: -0.7px; }
.dm-cf-amount.in  { color: #059669; }
.dm-cf-amount.out { color: #DC2626; }
.dm-cf-sub { font-size: 0.67rem; color: var(--text-muted); margin-top: 2px; }
.dm-cf-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.dm-cf-bar-label { font-size: 0.68rem; color: var(--text-muted); width: 58px; font-weight: 500; flex-shrink: 0; }
.dm-cf-bar-wrap  { flex: 1; height: 6px; background: #F3F4F6; border-radius: 3px; overflow: hidden; }
.dm-cf-bar-fill  { height: 100%; border-radius: 3px; }
.dm-cf-bar-fill.in  { background: #10B981; }
.dm-cf-bar-fill.out { background: #EF4444; }
.dm-cf-bar-val { font-size: 0.68rem; font-weight: 700; width: 68px; text-align: right; flex-shrink: 0; }
.dm-cf-net {
    padding: 9px 13px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
}
.dm-cf-net.positive { background: #ECFDF5; }
.dm-cf-net.negative { background: #FEF2F2; }
.dm-cf-net-label { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; }
.dm-cf-net-val  { font-size: 0.93rem; font-weight: 800; }
.dm-cf-net-val.positive { color: #059669; }
.dm-cf-net-val.negative { color: #DC2626; }

/* Generic empty state for dm panels */
.dm-empty {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    padding: 20px 0;
}

/* Responsive — only collapse on mobile */
@media (max-width: 768px) {
    .dm-metrics-strip { grid-template-columns: repeat(2, 1fr); }
    .dm-row-2col { grid-template-columns: 1fr; }
}
