/* ============================================================
   نظام متابعة طلبيات الشراء — Design System v2
   Visual: deep slate + teal (no purple AI defaults)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800&family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap');

:root {
    --primary: #0f766e;
    --primary-dark: #0d5c56;
    --primary-soft: rgba(15, 118, 110, 0.12);
    --accent: #c2410c;
    --ink: #0f172a;
    --ink-muted: #64748b;
    --surface: #eef3f6;
    --surface-2: #e2eaf0;
    --card: #ffffff;
    --border: #d7e0e8;
    --success: #15803d;
    --danger: #b91c1c;
    --warning: #b45309;
    --info: #0369a1;
    --sidebar-width: 268px;
    --topbar-height: 60px;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 8px 28px rgba(15, 23, 42, 0.07);
    --shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.05);
    --font: 'Cairo', 'IBM Plex Sans Arabic', sans-serif;

    /* Bootstrap bridge */
    --bs-primary: #0f766e;
    --bs-primary-rgb: 15, 118, 110;
    --bs-link-color: #0f766e;
    --bs-link-hover-color: #0d5c56;

    --primary-color: var(--primary);
    --secondary-color: #64748b;
    --success-color: var(--success);
    --danger-color: var(--danger);
    --warning-color: #d97706;
    --info-color: var(--info);
}

* {
    font-family: var(--font);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background:
        radial-gradient(1200px 500px at 100% -10%, rgba(15, 118, 110, 0.08), transparent 55%),
        radial-gradient(900px 420px at 0% 100%, rgba(194, 65, 12, 0.05), transparent 50%),
        var(--surface);
    color: var(--ink);
    min-height: 100vh;
}

body.has-app-sidebar {
    overflow-x: hidden;
}

/* Bootstrap primary overrides */
.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-dark);
    --bs-btn-hover-border-color: var(--primary-dark);
    --bs-btn-active-bg: var(--primary-dark);
    --bs-btn-active-border-color: var(--primary-dark);
    background: linear-gradient(135deg, #0f766e, #0d9488);
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    box-shadow: 0 6px 16px rgba(15, 118, 110, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0d5c56, #0f766e);
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(15, 118, 110, 0.3);
}

.btn-outline-primary {
    --bs-btn-color: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary);
    --bs-btn-hover-border-color: var(--primary);
    --bs-btn-active-bg: var(--primary-dark);
    --bs-btn-active-border-color: var(--primary-dark);
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.bg-primary {
    background-color: var(--primary) !important;
}

.text-primary {
    color: var(--primary) !important;
}

.badge.bg-primary {
    background-color: var(--primary) !important;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(15, 118, 110, 0.18);
}

/* ============================================================
   Page motion
   ============================================================ */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pulseSoft {
    0%, 100% { box-shadow: 0 0 0 0 rgba(15, 118, 110, 0.35); }
    50% { box-shadow: 0 0 0 10px rgba(15, 118, 110, 0); }
}

.animate-fade-in {
    animation: fadeUp 0.45s ease both;
}

.main-content > .page-toolbar,
.main-content > .mb-4,
.main-content > h4 {
    animation: fadeUp 0.4s ease both;
}

.main-content > .dashboard-cards,
.main-content > .custom-card,
.main-content > .row,
.main-content > .alert {
    animation: fadeUp 0.5s ease both;
    animation-delay: 0.05s;
}

.dashboard-cards .stat-card:nth-child(1) { animation-delay: 0.05s; }
.dashboard-cards .stat-card:nth-child(2) { animation-delay: 0.1s; }
.dashboard-cards .stat-card:nth-child(3) { animation-delay: 0.15s; }
.dashboard-cards .stat-card:nth-child(4) { animation-delay: 0.2s; }
.dashboard-cards .stat-card:nth-child(5) { animation-delay: 0.25s; }
.dashboard-cards .stat-card:nth-child(6) { animation-delay: 0.3s; }

/* ============================================================
   Login (base — detailed styles also in login.php)
   ============================================================ */
.login-page {
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}

/* ============================================================
   Layout: content
   ============================================================ */
.main-content {
    margin-top: var(--topbar-height);
    padding: 24px;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.has-app-sidebar .main-content {
    margin-right: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    max-width: calc(100% - var(--sidebar-width));
    box-sizing: border-box;
    overflow-x: hidden;
}

.page-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 1.35rem;
}

.page-toolbar h4,
.page-toolbar h5 {
    margin-bottom: 0;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.page-toolbar .toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ============================================================
   Dashboard stats
   ============================================================ */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
    gap: 16px;
    margin-bottom: 28px;
    width: 100%;
    max-width: 100%;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    border-right: 4px solid var(--primary);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    animation: fadeUp 0.5s ease both;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    inset: auto -20% -40% auto;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--primary-soft), transparent 70%);
    pointer-events: none;
}

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

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 14px;
}

.stat-card .stat-value {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 4px;
    letter-spacing: -0.03em;
    color: var(--ink);
}

.stat-card .stat-label {
    color: var(--ink-muted);
    font-size: 13px;
    font-weight: 600;
}

.stat-card.primary { border-right-color: var(--primary); }
.stat-card.primary .stat-icon { background: var(--primary-soft); color: var(--primary); }

.stat-card.success { border-right-color: var(--success); }
.stat-card.success .stat-icon { background: rgba(21, 128, 61, 0.12); color: var(--success); }

.stat-card.warning { border-right-color: var(--warning); }
.stat-card.warning .stat-icon { background: rgba(180, 83, 9, 0.12); color: var(--warning); }

.stat-card.danger { border-right-color: var(--danger); }
.stat-card.danger .stat-icon { background: rgba(185, 28, 28, 0.1); color: var(--danger); }

.stat-card.info { border-right-color: var(--info); }
.stat-card.info .stat-icon { background: rgba(3, 105, 161, 0.1); color: var(--info); }

.stat-card-split {
    grid-column: span 1;
    min-width: min(100%, 280px);
}

.stat-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.stat-split-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px;
    border-radius: 10px;
    background: rgba(15, 118, 110, 0.06);
    text-decoration: none;
    color: inherit;
    transition: background 0.2s ease, transform 0.2s ease;
}

.stat-split-item:hover {
    background: rgba(15, 118, 110, 0.12);
    transform: translateY(-1px);
    color: inherit;
}

.stat-split-item .split-title {
    font-size: 12px;
    color: var(--ink-muted);
    font-weight: 600;
}

.stat-split-item strong {
    font-size: 18px;
    color: var(--primary);
}

.stat-split-item small {
    font-size: 11px;
    color: var(--ink-muted);
}

.input-stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(15, 118, 110, 0.08);
    border: 1px solid var(--border);
}

.input-stat-chip strong {
    color: var(--primary);
}

/* ============================================================
   Cards / tables
   ============================================================ */
.custom-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    overflow: hidden;
}

.custom-card .card-header {
    background: linear-gradient(180deg, #f8fbfc, #f1f6f9);
    border-bottom: 1px solid var(--border);
    padding: 14px 18px;
    font-weight: 700;
}

.custom-card .card-body {
    padding: 18px;
}

.custom-table {
    width: 100%;
}

.custom-table thead th {
    background: #f4f8fa;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    color: #334155;
    padding: 12px 14px;
    white-space: nowrap;
    font-size: 13px;
}

.custom-table tbody td {
    padding: 12px 14px;
    vertical-align: middle;
    border-bottom: 1px solid #edf2f6;
    font-size: 14px;
}

.custom-table tbody tr {
    transition: background-color 0.15s ease;
}

.custom-table tbody tr:hover {
    background-color: #f5fafb;
}

.table-responsive {
    -webkit-overflow-scrolling: touch;
}

.table-responsive .custom-table {
    min-width: 720px;
}

/* ============================================================
   Status badges
   ============================================================ */
.status-badge {
    padding: 5px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    display: inline-block;
}

.status-draft { background: #e2e8f0; color: #475569; }
.status-pending { background: #ffedd5; color: #9a3412; }
.status-in_progress { background: #ccfbf1; color: #0f766e; }
.status-approved { background: #dcfce7; color: #166534; }
.status-rejected { background: #fee2e2; color: #991b1b; }
.status-completed { background: #dcfce7; color: #166534; }
.status-cancelled { background: #e2e8f0; color: #475569; }
.status-active { background: #dcfce7; color: #166534; }
.status-inactive { background: #e2e8f0; color: #64748b; }
.status-suspended { background: #fee2e2; color: #991b1b; }

.priority-low { color: var(--success); }
.priority-medium { color: var(--primary); }
.priority-high { color: #ea580c; }
.priority-urgent { color: var(--danger); }

/* ============================================================
   Buttons / actions
   ============================================================ */
.btn-action {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    margin: 0;
}

.users-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

/* ============================================================
   Approval timeline / routes
   ============================================================ */
.approval-timeline { position: relative; padding: 20px 0; }

.approval-step {
    display: flex;
    align-items: flex-start;
    margin-bottom: 20px;
    position: relative;
}

.approval-step .step-indicator {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 15px;
    margin-left: 15px;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.approval-step .step-indicator.completed { background: var(--success); color: #fff; }
.approval-step .step-indicator.active { background: var(--primary); color: #fff; animation: pulseSoft 2s infinite; }
.approval-step .step-indicator.pending { background: #e2e8f0; color: #64748b; }
.approval-step .step-indicator.rejected { background: var(--danger); color: #fff; }

.approval-step .step-content {
    flex: 1;
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.approval-step .step-line {
    position: absolute;
    right: 19px;
    top: 40px;
    width: 3px;
    height: calc(100% - 40px);
    background: #dbe4ec;
}

.approval-step:last-child .step-line { display: none; }
.approval-step.completed .step-line { background: var(--success); }

.route-step-card {
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 15px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-right: 3px solid var(--primary);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.route-step-card:hover {
    box-shadow: var(--shadow-sm);
    transform: translateX(-2px);
}

.route-step-card .step-number {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    margin-left: 15px;
    flex-shrink: 0;
}

/* ============================================================
   Topbar
   ============================================================ */
.app-topbar {
    height: var(--topbar-height);
    z-index: 1040;
    overflow: visible !important;
    background: linear-gradient(90deg, #0b3d3a 0%, #0f766e 55%, #0d9488 100%) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 24px rgba(11, 61, 58, 0.22) !important;
}

.app-topbar .container-fluid {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    overflow: visible !important;
    position: relative;
}

.app-topbar .navbar-brand {
    padding-top: 0;
    padding-bottom: 0;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.navbar-brand {
    max-width: 55vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    margin: 0;
    flex-shrink: 0;
    position: static;
}

.topbar-actions .nav-item { display: flex; align-items: center; }

.topbar-actions .nav-link,
.app-topbar #sidebarToggle {
    box-sizing: border-box;
    border: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    transform: none !important;
    transition: background-color 0.15s ease, opacity 0.15s ease !important;
}

.topbar-actions .nav-link:hover,
.topbar-actions .nav-link:focus,
.topbar-actions .nav-link:active,
.topbar-actions .nav-link.show,
.app-topbar #sidebarToggle:hover,
.app-topbar #sidebarToggle:focus,
.app-topbar #sidebarToggle:active {
    transform: none !important;
    box-shadow: none !important;
    border: 0 !important;
    outline: none !important;
    background: rgba(255, 255, 255, 0.12) !important;
    border-radius: 10px;
}

.topbar-actions .nav-link::after,
.topbar-icon-btn::after,
.topbar-user-btn::after,
.notif-bell-btn::after {
    display: none !important;
    content: none !important;
}

.topbar-icon-btn,
.notif-bell-btn {
    position: relative;
    width: 40px;
    height: 40px;
    min-width: 40px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1;
    color: #fff !important;
    border-radius: 10px;
}

.notif-bell-btn .fa-bell { font-size: 1.1rem; line-height: 1; }

.notif-bell-btn .notif-badge {
    position: absolute;
    top: 4px;
    inset-inline-start: 4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 10px;
    line-height: 16px;
    border-radius: 999px;
    pointer-events: none;
}

.topbar-user-btn {
    height: 40px;
    min-height: 40px;
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    padding: 0 8px !important;
    margin: 0 !important;
    color: #fff !important;
    white-space: nowrap;
    border-radius: 10px;
}

.topbar-avatar {
    width: 32px !important;
    height: 32px !important;
    flex-shrink: 0;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.35);
}

.topbar-username {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1;
    font-weight: 600;
}

.app-topbar #sidebarToggle {
    width: 40px;
    height: 40px;
    min-width: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    margin: 0 !important;
    flex-shrink: 0;
    border-radius: 10px;
}

.app-topbar .topbar-actions > .nav-item.dropdown { position: static; }

.app-topbar .dropdown-menu.topbar-dropdown {
    position: absolute !important;
    top: 100% !important;
    inset-inline-end: 0.75rem !important;
    inset-inline-start: auto !important;
    margin: 0.35rem 0 0 !important;
    transform: none !important;
    z-index: 1080;
    float: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.app-topbar .notif-dropdown {
    min-width: 300px;
    width: min(350px, calc(100vw - 24px));
    padding: 0;
}

.app-topbar .dropdown-menu.topbar-dropdown.show { display: block; }

/* ============================================================
   Sidebar — button navigation
   ============================================================ */
.app-sidebar {
    width: var(--sidebar-width);
    height: calc(100vh - var(--topbar-height));
    position: fixed;
    top: var(--topbar-height);
    right: 0;
    background: linear-gradient(180deg, #ffffff 0%, #f3f8f7 100%);
    box-shadow: -8px 0 28px rgba(15, 23, 42, 0.07);
    border-left: 1px solid var(--border);
    z-index: 1030;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.app-sidebar-inner {
    padding: 10px 8px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.app-sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 4px;
    min-width: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, #0b3d3a, #0f766e);
    color: #fff;
    box-shadow: 0 8px 18px rgba(15, 118, 110, 0.24);
}

.app-sidebar-user img {
    flex-shrink: 0;
    width: 44px !important;
    height: 44px !important;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.45);
}

.app-sidebar-user-meta {
    min-width: 0;
    flex: 1;
}

.app-sidebar-user strong {
    font-size: 13px;
    display: block;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #fff;
}

.app-sidebar-user small {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.78);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    margin-top: 1px;
}

.app-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sidebar-group {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.sidebar-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 8px;
    margin: 0;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: #334155;
    text-decoration: none;
    font-weight: 700;
    font-size: 13px;
    text-align: start;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.sidebar-btn-main {
    background: #fff;
    border-color: #dce8e6;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.sidebar-btn-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #e8f2f1;
    color: #0f766e;
    font-size: 12px;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-btn-text {
    flex: 1;
    min-width: 0;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-caret {
    font-size: 11px;
    color: #94a3b8;
    transition: transform 0.2s ease;
    margin-inline-start: 2px;
}

.sidebar-btn:hover {
    background: #f4fbfa;
    border-color: #cfe3e0;
    color: #0f766e;
}

.sidebar-btn:hover .sidebar-btn-icon {
    background: rgba(15, 118, 110, 0.14);
}

.sidebar-btn.active,
.sidebar-btn.active-group {
    background: linear-gradient(90deg, rgba(15, 118, 110, 0.14), rgba(15, 118, 110, 0.05));
    border-color: rgba(15, 118, 110, 0.22);
    color: #0d5c56;
    box-shadow: inset -3px 0 0 #0f766e;
}

.sidebar-btn.active .sidebar-btn-icon,
.sidebar-btn.active-group .sidebar-btn-icon {
    background: linear-gradient(135deg, #0f766e, #0d9488);
    color: #fff;
}

.sidebar-submenu {
    display: none;
    flex-direction: column;
    gap: 2px;
    padding: 3px 0 2px 0;
    margin: 2px 0 2px 10px;
    border-inline-start: 2px solid #d5e7e5;
    padding-inline-start: 6px;
}

.sidebar-group.open > .sidebar-submenu {
    display: flex;
}

.sidebar-group.open > .sidebar-group-toggle .sidebar-caret {
    transform: rotate(180deg);
    color: #0f766e;
}

.sidebar-btn-sub {
    padding: 5px 7px;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: 8px;
    margin: 0;
}

.sidebar-btn-sub .sidebar-btn-icon {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    font-size: 11px;
    background: #eef5f4;
}

.sidebar-btn-sub.active {
    background: rgba(15, 118, 110, 0.12);
    border-color: transparent;
    box-shadow: none;
}

.sidebar-btn-sub.active .sidebar-btn-icon {
    background: #0f766e;
    color: #fff;
}

.sidebar-btn-logout {
    color: #b91c1c;
}

.sidebar-btn-logout .sidebar-btn-icon {
    background: #fee2e2;
    color: #b91c1c;
}

.sidebar-btn-logout:hover {
    background: #fff5f5;
    border-color: #fecaca;
    color: #991b1b;
}

.sidebar-notif-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

html[dir="ltr"] .sidebar-btn.active,
html[dir="ltr"] .sidebar-btn.active-group {
    box-shadow: inset 3px 0 0 #0f766e;
}

html[dir="ltr"] .sidebar-submenu {
    margin: 2px 0 2px 0;
    margin-inline-start: 10px;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--topbar-height);
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
    z-index: 1025;
}

.sidebar-backdrop.show { display: block; }
body.sidebar-open { overflow: hidden; }

@media (max-width: 1199.98px) {
    .app-sidebar { transform: translateX(100%); }
    .app-sidebar.show { transform: translateX(0); }
    .has-app-sidebar .main-content {
        margin-right: 0;
        width: 100%;
        max-width: 100%;
    }
    .dashboard-cards {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
        gap: 12px;
    }
    .stat-card { padding: 16px; }
    .stat-card .stat-value { font-size: 22px; }
}

/* ============================================================
   Notifications
   ============================================================ */
.notif-dropdown { width: min(350px, calc(100vw - 24px)); padding: 0; overflow: hidden; }
.notif-list { max-height: 320px; overflow-y: auto; }

.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #f1f5f9;
    transition: background-color 0.15s;
}

.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: #f5fafb; color: inherit; }
.notif-item.unread { background: #f0fdfa; }
.notif-item.unread:hover { background: #ccfbf1; }

.notif-item-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #ecf4f3;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.notif-item-body {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.notif-item-body strong { font-size: 13px; line-height: 1.35; color: var(--ink); }
.notif-item-body small {
    font-size: 12px;
    color: var(--ink-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.notif-item-body em { font-style: normal; font-size: 11px; color: #94a3b8; }

.notif-page-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid #eef1f4;
}
.notif-page-item.unread { background: #f0fdfa; }
.notif-page-item .notif-item-icon { width: 36px; height: 36px; font-size: 15px; }

/* ============================================================
   Modals / forms extras
   ============================================================ */
.modal-content {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.modal-header {
    background: linear-gradient(180deg, #f8fbfc, #f1f6f9);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
}

.po-item-row {
    background: #f5f9fb;
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 10px !important;
    border: 1px solid var(--border);
}

.po-total-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
}

.po-total-bar > div { flex: 1 1 220px; }

.chart-wrap {
    position: relative;
    width: 100%;
    overflow-x: auto;
}

.chart-wrap canvas {
    max-width: 100%;
    height: auto !important;
}

.custom-card,
.row { max-width: 100%; }

/* ============================================================
   App footer — credit
   ============================================================ */
.app-footer {
    margin-top: 8px;
    margin-right: 0;
    padding: 0 24px 20px;
}

.has-app-sidebar .app-footer {
    margin-right: var(--sidebar-width);
}

.app-footer-inner {
    border-top: 1px solid var(--border);
    padding-top: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.app-footer-credit {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ink-muted);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.app-footer-credit i {
    color: var(--primary);
    font-size: 12px;
    opacity: 0.9;
}

@media (max-width: 1199.98px) {
    .has-app-sidebar .app-footer {
        margin-right: 0;
    }
}

@media (max-width: 767.98px) {
    .app-footer {
        padding: 0 12px 16px;
    }

    .app-footer-credit {
        font-size: 12px;
    }
}

/* ============================================================
   Print
   ============================================================ */
@media print {
    .navbar, .app-sidebar, .sidebar, .sidebar-backdrop, .btn, .toast-container, #sidebarToggle, .app-footer {
        display: none !important;
    }
    .main-content,
    .has-app-sidebar .main-content {
        margin-top: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
    }
    .custom-card {
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
    }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 991.98px) {
    .main-content { padding: 16px; }
    .dashboard-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767.98px) {
    .main-content { padding: 12px; }
    .dashboard-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 20px;
    }
    .stat-card { padding: 14px; border-radius: 12px; }
    .stat-card .stat-icon {
        width: 40px; height: 40px; font-size: 18px; margin-bottom: 10px; border-radius: 10px;
    }
    .stat-card .stat-value { font-size: 20px; }
    .stat-card .stat-label { font-size: 12px; line-height: 1.3; }
    .custom-card { border-radius: 12px; margin-bottom: 14px; }
    .custom-card .card-header,
    .custom-card .card-body { padding: 12px 14px; }
    .page-toolbar { flex-direction: column; align-items: stretch; }
    .page-toolbar .toolbar-actions { width: 100%; }
    .page-toolbar .btn { flex: 1 1 auto; }
    .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-direction: column;
        align-items: stretch !important;
        gap: 12px;
    }
    h4 { font-size: 1.15rem; }
    .toast-container {
        width: calc(100% - 24px);
        left: 50%;
        transform: translateX(-50%);
        margin-top: 64px !important;
        padding: 0 !important;
    }
}

@media (max-width: 575.98px) {
    .dashboard-cards { grid-template-columns: 1fr; }
    .navbar-brand { font-size: 0.95rem; max-width: 48vw; }
    .stat-card {
        display: flex;
        align-items: center;
        gap: 12px;
        border-right-width: 3px;
    }
    .stat-card .stat-icon { margin-bottom: 0; flex-shrink: 0; }
    .table-responsive .custom-table { min-width: 640px; }
}

@media (max-width: 379.98px) {
    .main-content { padding: 8px; }
    .stat-card .stat-value { font-size: 18px; }
}
