:root {
    --primary-purple: #071BB0;
    --dark-purple: #061894;
    --light-purple: #4A7EF0;
    --primary-orange: #FF6B35;
    --dark-orange: #E55A2B;
    --gradient-purple-orange: linear-gradient(135deg, #071BB0 0%, #FF6B35 100%);
    --gradient-sidebar: linear-gradient(180deg, #051080 0%, #030852 50%, #020640 100%);
    --white: #FFFFFF;
    --light-gray: #F8F6FA;
    --dark-gray: #424242;
    --card-shadow: 0 8px 32px rgba(7, 27, 176, 0.12);
    --card-shadow-hover: 0 16px 48px rgba(7, 27, 176, 0.2);
    --sidebar-width: 280px;
    --transition-normal: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Segoe UI', Tahoma, sans-serif;
    direction: rtl;
    text-align: right;
    background: var(--light-gray);
    color: var(--dark-gray);
    line-height: 1.7;
    margin: 0;
}

.app-sidebar {
    position: fixed; top: 0; right: 0;
    width: var(--sidebar-width); height: 100vh;
    background: var(--gradient-sidebar);
    box-shadow: -4px 0 24px rgba(0,0,0,.15);
    z-index: 1000; overflow-y: auto;
    transition: transform var(--transition-normal);
}
.sidebar-brand {
    padding: 1.25rem; text-align: center;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand a {
    color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem;
    display: flex; align-items: center; justify-content: center; gap: .6rem;
}
.sidebar-nav { padding: 1rem 0; }
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: .75rem;
    padding: .85rem 1.25rem; color: rgba(255,255,255,.88);
    text-decoration: none; font-weight: 500;
    border-right: 3px solid transparent; margin: .15rem .5rem;
    border-radius: .65rem; transition: all .2s ease;
}
.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    background: rgba(255,107,53,.15); color: var(--primary-orange);
    border-right-color: var(--primary-orange);
}
.main-content {
    margin-right: var(--sidebar-width); min-height: 100vh;
    animation: contentFadeIn .6s ease-out;
}
@keyframes contentFadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}
.page-header {
    background: var(--gradient-purple-orange); color: #fff;
    padding: 1.25rem 1.5rem; box-shadow: 0 4px 20px rgba(7,27,176,.2);
}
.page-body { padding: 1.25rem; }

.card {
    border: none; border-radius: 16px;
    box-shadow: var(--card-shadow); transition: all var(--transition-normal);
    background: #fff; overflow: hidden;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--card-shadow-hover); }
.card-header {
    background: var(--gradient-purple-orange); color: #fff;
    border: none; padding: 1rem 1.25rem; font-weight: 700;
}
.stat-card {
    border-radius: 16px; padding: 1.25rem; color: #fff;
    animation: fadeInUp .6s ease-out both;
}
.stat-card:nth-child(1) { animation-delay: .05s; background: linear-gradient(135deg,#071BB0,#4A7EF0); }
.stat-card:nth-child(2) { animation-delay: .1s; background: linear-gradient(135deg,#FF6B35,#FF8C5A); }
.stat-card:nth-child(3) { animation-delay: .15s; background: linear-gradient(135deg,#28a745,#5cb85c); }
.stat-card:nth-child(4) { animation-delay: .2s; background: linear-gradient(135deg,#6f42c1,#9b59b6); }
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.btn-primary {
    background: var(--gradient-purple-orange); border: none; color: #fff;
    padding: .65rem 1.5rem; border-radius: 12px; font-weight: 600;
    transition: all var(--transition-normal);
    box-shadow: 0 4px 15px rgba(7,27,176,.3);
}
.btn-primary:hover { transform: translateY(-2px); color: #fff; }

.form-control, .form-select {
    border: 2px solid #E8E4EC; border-radius: 12px; padding: .75rem 1rem;
    transition: all .25s ease;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary-purple);
    box-shadow: 0 0 0 4px rgba(7,27,176,.12);
}

.data-grid { width: 100%; border-collapse: collapse; }
.data-grid th, .data-grid td { padding: .85rem 1rem; border-bottom: 1px solid #eee; }
.data-grid th { background: #f3f0f8; font-weight: 700; }
.data-grid tbody tr { transition: background .2s; }
.data-grid tbody tr:hover { background: rgba(7,27,176,.04); }

.mobile-cards { display: none; }
.mobile-card {
    background: #fff; border-radius: 14px; padding: 1rem;
    margin-bottom: .75rem; box-shadow: var(--card-shadow);
    animation: fadeInUp .4s ease-out both;
}
.mobile-card .mc-row { display: flex; justify-content: space-between; padding: .35rem 0; border-bottom: 1px dashed #eee; }
.mobile-card .mc-row:last-child { border-bottom: none; }
.mobile-card .mc-label { color: #888; font-size: .85rem; }

.mobile-header {
    display: none; position: sticky; top: 0; z-index: 1035;
    background: var(--gradient-purple-orange); color: #fff;
    padding: .75rem 1rem; align-items: center; justify-content: space-between;
}
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 999; }

@media (max-width: 991px) {
    .app-sidebar { transform: translateX(100%); }
    .app-sidebar.open { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .main-content { margin-right: 0; }
    .mobile-header { display: flex; }
    .desktop-table-wrap { display: none; }
    .mobile-cards { display: block; }
}

.upload-zone {
    border: 2px dashed #c5bfe0; border-radius: 16px; padding: 2rem;
    text-align: center; cursor: pointer; transition: all .3s;
    background: linear-gradient(180deg,#faf9fc,#fff);
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary-orange);
    background: rgba(255,107,53,.05);
}
.upload-progress-wrap { margin-top: 1rem; display: none; }
.upload-progress-wrap.active { display: block; }
.upload-progress-bar {
    height: 10px; border-radius: 5px; background: #e9ecef; overflow: hidden;
}
.upload-progress-fill {
    height: 100%; background: var(--gradient-purple-orange);
    width: 0; transition: width .2s;
    border-radius: 5px;
}
.upload-file-list { margin-top: 1rem; }
.upload-file-item {
    display: flex; align-items: center; gap: .75rem;
    padding: .65rem .85rem; background: #f8f6fa; border-radius: 10px;
    margin-bottom: .5rem; animation: fadeInUp .3s ease;
}

.jalali-date-input,
.persian-date-picker { cursor: pointer; background: #fff; }

.table-warning { --bs-table-bg: rgba(255, 193, 7, 0.12); }
.mobile-card.border-warning { border: 2px solid #ffc107 !important; }
.nav-pills .nav-link.active { background: var(--gradient-purple-orange); }

.workflow-stepper { display: flex; flex-wrap: wrap; gap: .5rem; padding: 1rem; background: #fff; border-radius: 16px; box-shadow: var(--card-shadow); }
.wf-step { display: flex; align-items: flex-start; gap: .75rem; flex: 1 1 140px; min-width: 120px; position: relative; animation: fadeInUp .4s ease both; }
.wf-node {
    width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem; flex-shrink: 0; transition: all .3s;
}
.wf-step.pending .wf-node { background: #e9ecef; color: #888; }
.wf-step.active .wf-node { background: var(--gradient-purple-orange); color: #fff; box-shadow: 0 4px 16px rgba(7,27,176,.35); animation: pulse-glow 2s infinite; }
.wf-step.done .wf-node { background: #28a745; color: #fff; }
.wf-step.rejected .wf-node { background: #dc3545; color: #fff; }
.wf-title { font-weight: 600; font-size: .9rem; }
.wf-meta { font-size: .75rem; color: #888; margin-top: .15rem; }
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 53, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(255, 107, 53, 0); }
}

.entity-picker-display { cursor: pointer; background: #fff; }
.entity-picker-wrap .input-group-sm .btn { padding: .25rem .5rem; }
#entityPickerResults .list-group-item { cursor: pointer; border-radius: 8px; margin-bottom: .35rem; }
#entityPickerResults .list-group-item:hover { background: #f0f4ff; }
.batch-toolbar { display: none; }
.batch-toolbar.d-flex { display: flex !important; }
