:root {
    --pe-primary: #16a34a;
    --pe-primary-lt: #22c55e;
    --pe-primary-bg: #f0fdf4;
    --pe-accent: #0ea5e9;
    --pe-accent-lt: #38bdf8;
    --pe-warning: #f59e0b;
    --pe-danger: #ef4444;
    --pe-purple: #8b5cf6;
    --pe-dark: #0f172a;
    --pe-muted: #64748b;
    --pe-border: #e2e8f0;
    --pe-card-bg: #ffffff;
    --pe-body-bg: #f1f5f9;
    --pe-radius: 16px;
    --pe-radius-sm: 10px;
    --pe-shadow: 0 4px 24px rgba(15, 23, 42, .07);
    --pe-shadow-md: 0 8px 32px rgba(15, 23, 42, .12);
    --pe-transition: .25s cubic-bezier(.4, 0, .2, 1);
}

.pe-dashboard,
.pe-dashboard *,
.pe-dashboard *::before,
.pe-dashboard *::after {
    box-sizing: border-box;
}

.pe-dashboard {
    font-family: 'Vazirmatn', Tahoma, Arial, sans-serif;
    background: var(--pe-body-bg);
    color: var(--pe-dark);
    direction: rtl;
    font-size: 14px;
    min-height: 100vh;
}

.pe-dashboard table {
    border-collapse: collapse;
}

.pe-dashboard table th,
.pe-dashboard table td {
    border: 1px solid var(--pe-border);
}

.pe-ticket-thread {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px 0 12px;
}

.pe-ticket-bubble {
    background: #ffffff;
    border: 1px solid var(--pe-border);
    border-radius: 12px;
    padding: 10px 12px;
}

.pe-ticket-bubble.is-admin {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e3a8a;
}

.pe-ticket-meta {
    font-size: 11px;
    color: var(--pe-muted);
    margin-bottom: 6px;
    display: flex;
    gap: 6px;
    align-items: center;
}

.pe-ticket-text {
    line-height: 1.8;
    white-space: pre-wrap;
}

/* ===== Sidebar ===== */
.pe-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 260px;
    height: 100vh;
    background: var(--pe-dark);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform var(--pe-transition);
    transform: translateX(100%);
}

.pe-sidebar.open {
    transform: translateX(0);
}

.pe-sidebar-logo {
    padding: 28px 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.pe-sidebar-logo .logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--pe-primary), var(--pe-accent));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 10px;
}

.pe-sidebar-logo h5 {
    color: #fff;
    margin: 0;
    font-weight: 700;
    font-size: 16px;
}

.pe-sidebar-logo span {
    color: rgba(255, 255, 255, .45);
    font-size: 12px;
}

/* User Card in Sidebar */
.pe-sidebar-user {
    padding: 18px 24px;
    background: rgba(255, 255, 255, .04);
    margin: 16px 12px;
    border-radius: var(--pe-radius-sm);
    border: 1px solid rgba(255, 255, 255, .08);
}

.pe-sidebar-user .avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--pe-primary-lt), var(--pe-accent));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    font-size: 16px;
    flex-shrink: 0;
}

.pe-sidebar-user .user-name {
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pe-sidebar-user .user-badge {
    background: rgba(22, 163, 74, .25);
    color: var(--pe-primary-lt);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
}

/* Nav */
.pe-nav {
    padding: 8px 12px;
    flex: 1;
}

.pe-nav-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .3);
    padding: 12px 12px 6px;
}

.pe-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--pe-radius-sm);
    color: rgba(255, 255, 255, .65);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: all var(--pe-transition);
    margin-bottom: 2px;
    cursor: pointer;
}

.pe-nav-item:hover {
    background: rgba(255, 255, 255, .07);
    color: #fff;
    text-decoration: none;
}

.pe-nav-item.active {
    background: linear-gradient(90deg, rgba(22, 163, 74, .3), rgba(14, 165, 233, .15));
    color: var(--pe-primary-lt);
    border-right: 3px solid var(--pe-primary-lt);
}

.pe-nav-item .nav-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    background: rgba(255, 255, 255, .06);
    flex-shrink: 0;
}

.pe-nav-item.active .nav-icon {
    background: rgba(22, 163, 74, .25);
}

.pe-nav-item .badge-count {
    margin-right: auto;
    background: var(--pe-danger);
    color: #fff;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 20px;
    font-weight: 700;
}

/* Sidebar Footer */
.pe-sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

/* ===== Main Content ===== */
.pe-main {
    margin-right: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin var(--pe-transition);
}

/* ===== Topbar ===== */
.pe-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(241, 245, 249, .9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--pe-border);
    padding: 12px 28px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.pe-topbar .page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--pe-dark);
    margin: 0;
}

.pe-topbar .topbar-date {
    color: var(--pe-muted);
    font-size: 13px;
}

.pe-topbar-actions {
    margin-right: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.pe-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--pe-radius-sm);
    border: 1px solid var(--pe-border);
    background: var(--pe-card-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--pe-muted);
    cursor: pointer;
    transition: all var(--pe-transition);
    position: relative;
    font-size: 15px;
}

.pe-icon-btn:hover {
    background: var(--pe-primary-bg);
    color: var(--pe-primary);
    border-color: var(--pe-primary);
}

.pe-icon-btn .notif-dot {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 8px;
    height: 8px;
    background: var(--pe-danger);
    border-radius: 50%;
    border: 2px solid var(--pe-body-bg);
}

/* Hamburger for mobile */
.pe-hamburger {
    display: flex;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    background: var(--pe-card-bg);
    border: 1px solid var(--pe-border);
    border-radius: var(--pe-radius-sm);
    cursor: pointer;
    color: var(--pe-muted);
    font-size: 16px;
}

/* ===== Page Content ===== */
.pe-content {
    padding: 28px;
    flex: 1;
}

/* ===== Cards ===== */
.pe-card {
    background: var(--pe-card-bg);
    border-radius: var(--pe-radius);
    border: 1px solid var(--pe-border);
    box-shadow: var(--pe-shadow);
    padding: 24px;
    height: 100%;
}

.pe-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--pe-dark);
    margin-bottom: 4px;
}

.pe-card-sub {
    font-size: 12px;
    color: var(--pe-muted);
}

/* ===== KPI Cards ===== */
.pe-kpi {
    border-radius: var(--pe-radius);
    padding: 22px 20px;
    position: relative;
    overflow: hidden;
    border: none;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 130px;
    transition: transform var(--pe-transition), box-shadow var(--pe-transition);
}

.pe-kpi:hover {
    transform: translateY(-4px);
    box-shadow: var(--pe-shadow-md);
}

.pe-kpi::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: -20px;
    width: 90px;
    height: 90px;
    background: rgba(255, 255, 255, .12);
    border-radius: 50%;
}

.pe-kpi::before {
    content: '';
    position: absolute;
    bottom: 10px;
    left: 30px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, .08);
    border-radius: 50%;
}

.pe-kpi .kpi-label {
    font-size: 13px;
    font-weight: 600;
    opacity: .85;
}

.pe-kpi .kpi-number {
    font-size: 36px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -.02em;
}

.pe-kpi .kpi-desc {
    font-size: 11.5px;
    opacity: .75;
}

.pe-kpi .kpi-icon {
    position: absolute;
    top: 16px;
    left: 16px;
    font-size: 28px;
    opacity: .25;
}

/* ===== Status Summary ===== */
.pe-section-header-main h6 {
    font-size: 16px;
    font-weight: 800;
}

.pe-status-summary {
    padding: 20px 22px;
}

.pe-status-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.pe-status-item {
    background: #f8fafc;
    border: 1px solid var(--pe-border);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.pe-status-label {
    color: var(--pe-muted);
    font-size: 12px;
    font-weight: 600;
}

.pe-status-value {
    color: var(--pe-dark);
    font-size: 18px;
    font-weight: 800;
}

.pe-status-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pe-status-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    background: color-mix(in srgb, var(--chip-color) 18%, #ffffff);
    color: color-mix(in srgb, var(--chip-color) 80%, #111827);
    border: 1px solid color-mix(in srgb, var(--chip-color) 35%, #ffffff);
}

.pe-status-chip strong {
    font-weight: 800;
}

.pe-status-chip.is-empty {
    background: #f1f5f9;
    color: var(--pe-muted);
    border: 1px dashed var(--pe-border);
}

.pe-kpi-green { background: linear-gradient(135deg, #16a34a, #22c55e); color: #fff; }
.pe-kpi-blue { background: linear-gradient(135deg, #0369a1, #0ea5e9); color: #fff; }
.pe-kpi-amber { background: linear-gradient(135deg, #b45309, #f59e0b); color: #fff; }
.pe-kpi-purple { background: linear-gradient(135deg, #6d28d9, #8b5cf6); color: #fff; }

/* ===== Chart Card ===== */
.pe-chart-wrapper {
    position: relative;
    width: 100%;
    height: 280px;
}

.pe-chart-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 280px;
    color: var(--pe-muted);
    gap: 12px;
}

.pe-chart-placeholder i {
    font-size: 48px;
    opacity: .3;
}

.pe-chart-placeholder p {
    font-size: 13px;
    text-align: center;
}

/* ===== Status Badges ===== */
.pe-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.pe-badge-pending { background: #fef3c7; color: #92400e; }
.pe-badge-progress { background: #dbeafe; color: #1e40af; }
.pe-badge-offer { background: #f3e8ff; color: #6b21a8; }
.pe-badge-contracted { background: #dcfce7; color: #166534; }
.pe-badge-completed { background: #d1fae5; color: #065f46; }
.pe-badge-cancelled { background: #fee2e2; color: #991b1b; }
.pe-badge-signed { background: #cffafe; color: #164e63; }
.pe-badge-active { background: #dcfce7; color: #166534; }

/* ===== Table ===== */
.pe-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.pe-table th,
.pe-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--pe-border);
    text-align: right;
    vertical-align: middle;
}

.pe-table th {
    background: #f8fafc;
    color: var(--pe-muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.pe-table tbody tr:last-child td { border-bottom: none; }

.pe-table tbody tr:hover td { background: #fafcff; }

.pe-ticket-bubble.is-user {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #14532d;
    align-self: flex-end;
}

/* ===== Request Card (Mobile) ===== */
.pe-req-card {
    background: var(--pe-card-bg);
    border: 1px solid var(--pe-border);
    border-radius: var(--pe-radius-sm);
    padding: 16px;
    transition: box-shadow var(--pe-transition);
}

.pe-req-card:hover { box-shadow: var(--pe-shadow); }

/* ===== Contract Item ===== */
.pe-contract-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 0;
    border-bottom: 1px solid #f1f5f9;
}

.pe-contract-item:last-child { border-bottom: none; }

.pe-contract-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--pe-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.pe-contract-icon-active { background: #dcfce7; }
.pe-contract-icon-pending { background: #fef3c7; }
.pe-contract-icon-signed { background: #cffafe; }

/* ===== Progress Bar ===== */
.pe-progress {
    height: 6px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.pe-progress-bar {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--pe-primary), var(--pe-accent));
    transition: width .8s ease;
}

/* ===== Empty State ===== */
.pe-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--pe-muted);
}

.pe-empty i {
    font-size: 48px;
    opacity: .25;
    margin-bottom: 12px;
    display: block;
}

.pe-empty p { font-size: 13.5px; margin: 0; }

/* ===== Donut Chart ===== */
.pe-donut-wrapper {
    position: relative;
    width: 180px;
    height: 180px;
    margin: 0 auto;
}

.pe-donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.pe-donut-center .big-num {
    font-size: 32px;
    font-weight: 800;
    color: var(--pe-dark);
    line-height: 1;
}

.pe-donut-center .small-lbl {
    font-size: 11px;
    color: var(--pe-muted);
}

/* ===== Legend ===== */
.pe-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    margin-bottom: 8px;
}

.pe-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.pe-legend-count {
    margin-right: auto;
    font-weight: 700;
    color: var(--pe-dark);
}

/* ===== Welcome Banner ===== */
.pe-welcome {
    background: linear-gradient(120deg, #0f172a 0%, #1e3a5f 50%, #164e35 100%);
    border-radius: var(--pe-radius);
    padding: 58px 32px 28px;
    color: #fff;
    position: relative;
    overflow: hidden;
    margin-bottom: 28px;
}

.pe-welcome::before {
    content: '☀';
    position: absolute;
    font-size: 160px;
    right: -20px;
    top: -30px;
    opacity: .06;
    line-height: 1;
}

.pe-welcome h4 {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 6px;
}

.pe-welcome p {
    font-size: 13.5px;
    opacity: .75;
    margin: 0;
}

.pe-welcome-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 12px;
    color: rgba(255, 255, 255, .9);
    margin-bottom: 0;
    position: absolute;
    top: 16px;
    left: 16px;
}

/* ===== Overlay for mobile ===== */
.pe-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 1040;
}

.pe-overlay.show { display: block; }

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
    .pe-main { margin-right: 0; }

    .pe-content { padding: 20px 16px; }

    .pe-welcome { padding: 54px 20px 22px; }

    .pe-welcome-pill {
        top: 10px;
        left: 10px;
        font-size: 11px;
        padding: 5px 10px;
    }

    .pe-status-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .pe-status-list {
        grid-template-columns: 1fr;
    }

    .pe-kpi .kpi-number { font-size: 28px; }

    .pe-topbar { padding: 10px 16px; }

    .pe-topbar .page-title { font-size: 15px; }

    .pe-main-production-kpis .pe-kpi {
        min-height: 76px !important;
        padding: 10px 10px;
    }

    .pe-main-production-kpis .pe-kpi .kpi-label {
        font-size: 11px;
        line-height: 1.3;
    }

    .pe-main-production-kpis .pe-kpi .kpi-number {
        font-size: 16px !important;
        margin-top: 2px;
    }

    .pe-main-production-kpis .pe-kpi .kpi-desc {
        font-size: 10px;
        opacity: .9;
    }

    .pe-main-production-kpis .pe-kpi .kpi-icon {
        font-size: 16px;
        top: 8px;
        left: 8px;
    }
}

/* ===== Scrollbar ===== */
.pe-sidebar::-webkit-scrollbar { width: 4px; }
.pe-sidebar::-webkit-scrollbar-track { background: transparent; }
.pe-sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .15); border-radius: 4px; }

/* ===== Section Header ===== */
.pe-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.pe-section-header h6 {
    font-size: 15px;
    font-weight: 700;
    color: var(--pe-dark);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pe-section-header h6 .icon-wrap {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--pe-primary-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--pe-primary);
    font-size: 14px;
}

.pe-view-all {
    font-size: 12.5px;
    color: var(--pe-primary);
    text-decoration: none;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.pe-view-all:hover { text-decoration: underline; color: var(--pe-primary); }

/* ===== Alert Banner ===== */
.pe-alert-banner {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--pe-radius-sm);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #78350f;
    margin-bottom: 24px;
}

.pe-alert-banner i { color: var(--pe-warning); font-size: 16px; }

/* ===== Form ===== */
.pe-form-group {
    margin-bottom: 14px;
}

.pe-form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--pe-muted);
    margin-bottom: 6px;
}

.pe-form-input {
    width: 100%;
    border: 1px solid var(--pe-border);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    background: #fff;
    color: var(--pe-dark);
    transition: border-color var(--pe-transition), box-shadow var(--pe-transition);
}

.pe-form-input:focus {
    outline: none;
    border-color: var(--pe-primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}

.pe-form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.pe-btn {
    background: var(--pe-primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 18px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: transform var(--pe-transition), box-shadow var(--pe-transition);
}

.pe-btn:hover { transform: translateY(-1px); box-shadow: var(--pe-shadow); }

.pe-btn-secondary {
    background: #fff;
    color: var(--pe-primary);
    border: 1px solid rgba(14, 165, 233, 0.35);
}

.pe-btn-secondary:hover {
    box-shadow: var(--pe-shadow-sm);
    transform: translateY(-1px);
}

.pe-btn-sm {
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 8px;
}

.pe-action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pe-btn:disabled {
    opacity: .6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.pe-form-note {
    font-size: 12px;
    color: var(--pe-muted);
}

.pe-form-note.is-error { color: #b91c1c; }
.pe-form-note.is-success { color: #166534; }

/* ===== Tooltip badge ===== */
.pe-tip {
    font-size: 11px;
    background: #f1f5f9;
    color: var(--pe-muted);
    padding: 2px 8px;
    border-radius: 999px;
    margin-right: 6px;
}
