/* ============================================================ */
/* FONT */
/* ============================================================ */
@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-RD-Regular.woff2') format('woff2');
    font-weight: normal;
    font-display: swap;
}

/* ============================================================ */
/* RESET & BASE */
/* ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background: #0a0e1a;
    min-height: 100vh;
    color: #e2e8f0;
    direction: rtl;
}

img {
    max-width: 100%;
    height: auto;
}

button {
    font-family: inherit;
}

input, select, textarea {
    font-family: inherit;
}

/* ============================================================ */
/* SIDEBAR */
/* ============================================================ */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    height: 100vh;
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    border-left: 1px solid rgba(59, 130, 246, 0.2);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    z-index: 999;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-logo {
    text-align: center;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(59, 130, 246, 0.15);
    margin-bottom: 15px;
}

.sidebar-logo img {
    max-width: 80px;
    max-height: 80px;
    border-radius: 12px;
    margin-bottom: 8px;
}

.sidebar-title {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: #e2e8f0;
}

.sidebar-lng-tank {
    width: 100%;
    margin: 0 0 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 10px;
}

.sidebar-lng-tank img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    object-fit: contain;
}

.sidebar-projects {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    margin-bottom: 10px;
}

.project-item {
    background: rgba(30, 41, 59, 0.4);
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 6px;
    border: 1px solid rgba(59, 130, 246, 0.1);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.project-item:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(59, 130, 246, 0.3);
}

.project-item.active {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.project-item .pname {
    color: #e2e8f0;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-item .pdate {
    font-size: 0.6rem;
    color: #64748b;
}

.project-item .pdelete {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.3s;
}

.project-item .pdelete:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.2);
}

.sidebar-footer {
    padding-top: 15px;
    border-top: 1px solid rgba(59, 130, 246, 0.15);
    margin-top: 10px;
}

/* ============================================================ */
/* MAIN CONTENT */
/* ============================================================ */
.main-content {
    margin-right: 280px;
    margin-left: 0;
    padding: 20px;
    min-height: 100vh;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

/* ============================================================ */
/* HEADER */
/* ============================================================ */
.header {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #3b82f6 100%);
    padding: 20px 30px;
    border-radius: 20px;
    margin-bottom: 20px;
    box-shadow: 0 10px 40px rgba(59, 130, 246, 0.3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.header h1 {
    font-size: 1.4rem;
    font-weight: 900;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-info {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.header-badge {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 0.82rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #e2e8f0;
}

.header-badge.live {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border-color: #10b981;
}

.header-badge.live::before {
    content: '●';
    margin-left: 5px;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.header-badge.pump {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(59, 130, 246, 0.2));
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.5);
    font-weight: 700;
    transition: all 0.3s;
}

.header-badge.pump:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* ============================================================ */
/* BUTTONS */
/* ============================================================ */
.btn {
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.3s;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary { background: #3b82f6; color: white; }
.btn-primary:hover { background: #2563eb; transform: translateY(-2px); }

.btn-success { background: #10b981; color: white; }
.btn-success:hover { background: #059669; transform: translateY(-2px); }

.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; transform: translateY(-2px); }

.btn-warning { background: #f59e0b; color: #0a0e1a; }
.btn-warning:hover { background: #d97706; transform: translateY(-2px); }

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.2); }

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

.btn-back {
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.3);
    color: #94a3b8;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.btn-back:hover {
    background: rgba(148, 163, 184, 0.1);
    color: #e2e8f0;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* ============================================================ */
/* WIZARD SECTIONS */
/* ============================================================ */
.wizard-section {
    margin-bottom: 20px;
    animation: fadeIn 0.4s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.wizard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    gap: 10px;
    flex-wrap: wrap;
}

/* ============================================================ */
/* IDLE BOX */
/* ============================================================ */
.idle-box {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.85), rgba(15, 23, 42, 0.9));
    border: 2px solid rgba(59, 130, 246, 0.25);
    border-radius: 20px;
    padding: 50px 30px;
    text-align: center;
    max-width: 700px;
    margin: 40px auto;
}

.idle-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.idle-box h2 {
    font-size: 1.6rem;
    color: #60a5fa;
    margin-bottom: 15px;
}

.idle-box p {
    color: #94a3b8;
    font-size: 1rem;
    margin-bottom: 25px;
    line-height: 1.8;
}

.idle-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}


/* ============================================================ */
/* PUMP SELECTOR — responsive 2x2 */
/* ============================================================ */
.pump-selector-grid {
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:14px;
    margin-top:14px;
}
.pump-selector-grid .pump-card { min-width:0; }
.pump-smart-info {
    margin-top:16px;
    display:flex;
    align-items:flex-start;
    gap:12px;
    padding:13px 15px;
    border:1px solid rgba(59,130,246,.25);
    border-right:3px solid #3b82f6;
    border-radius:10px;
    background:rgba(30,64,175,.08);
    color:#94a3b8;
    line-height:1.9;
    font-size:.76rem;
}
.pump-smart-info strong { display:block; color:#60a5fa; margin-bottom:2px; }
.pump-smart-info span { display:block; }
.pump-smart-info-icon {
    width:30px;height:30px;border-radius:8px;flex:0 0 30px;
    display:flex;align-items:center;justify-content:center;
    background:rgba(59,130,246,.14);color:#60a5fa;font-weight:900;
}
.pump-mismatch-overlay {
    position:fixed; inset:0; z-index:99999; display:flex; align-items:center; justify-content:center;
    padding:18px; background:rgba(2,6,23,.78); backdrop-filter:blur(5px);
}
.pump-mismatch-dialog {
    width:min(560px,100%); background:linear-gradient(145deg,#111c31,#0f172a);
    border:1px solid rgba(59,130,246,.35); border-radius:18px; padding:24px;
    box-shadow:0 24px 70px rgba(0,0,0,.45); direction:rtl;
}
.pump-mismatch-dialog h3 { margin:0 0 10px; color:#fbbf24; font-size:1.08rem; }
.pump-mismatch-dialog p { color:#cbd5e1; line-height:1.9; font-size:.84rem; margin:7px 0; }
.pump-mismatch-values { display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:14px 0; }
.pump-mismatch-value { padding:11px;border-radius:10px;background:rgba(30,41,59,.7);border:1px solid rgba(148,163,184,.12); }
.pump-mismatch-value small {display:block;color:#64748b;margin-bottom:4px;}
.pump-mismatch-value b {color:#e2e8f0;}
.pump-mismatch-actions { display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:18px; }
.pump-mismatch-actions button { border:0;border-radius:10px;padding:12px;font-family:inherit;cursor:pointer;font-weight:800; }
.pump-mismatch-smart { background:#2563eb;color:#fff; }
.pump-mismatch-back { background:rgba(51,65,85,.8);color:#e2e8f0;border:1px solid rgba(148,163,184,.2)!important; }
@media (max-width:700px) {
    .pump-selector-grid { grid-template-columns:1fr; gap:12px; }
    .pump-card { min-height:180px !important; }
    .pump-smart-info { font-size:.72rem; }
    .pump-mismatch-values, .pump-mismatch-actions { grid-template-columns:1fr; }
}

/* ============================================================ */
/* PUMP SELECTOR */
/* ============================================================ */
.pump-selector-box {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.85), rgba(15, 23, 42, 0.9));
    border: 2px solid rgba(59, 130, 246, 0.25);
    border-radius: 16px;
    padding: 22px 26px;
    margin-bottom: 20px;
}

.pump-selector-box h3 {
    color: #60a5fa;
    font-size: 1.1rem;
    margin-bottom: 6px;
}

.pump-group {
    margin-top: 20px;
}

.pump-group-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #e2e8f0;
    padding: 8px 14px;
    background: rgba(59, 130, 246, 0.1);
    border-right: 4px solid #3b82f6;
    border-radius: 8px;
    margin-bottom: 12px;
}

.pump-group-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.pump-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.85), rgba(15, 23, 42, 0.9));
    border: 2px solid rgba(59, 130, 246, 0.2);
    border-radius: 14px;
    padding: 16px 18px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.pump-card:hover {
    border-color: #3b82f6;
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.25);
}

.pump-card.active {
    border-color: #10b981;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(15, 23, 42, 0.9));
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
}

.pump-card.active::after {
    content: '✓';
    position: absolute;
    top: 10px;
    left: 12px;
    background: #10b981;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.pump-icon {
    font-size: 1.8rem;
    margin-bottom: 6px;
}

.pump-name {
    font-size: 0.95rem;
    font-weight: 800;
    color: #e2e8f0;
    margin-bottom: 4px;
}

.pump-tag {
    font-size: 0.7rem;
    color: #60a5fa;
    font-family: 'Courier New', monospace;
    direction: ltr;
    text-align: right;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.pump-fluid {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.pump-fluid span {
    background: rgba(59, 130, 246, 0.15);
    color: #94a3b8;
    font-size: 0.68rem;
    padding: 3px 9px;
    border-radius: 8px;
    font-weight: 600;
}

.pump-card.active .pump-fluid span {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.pump-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 8px;
}

.pump-badge.single {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

/* ============================================================ */
/* PUMP SPECS PREVIEW */
/* ============================================================ */
.pump-specs-preview {
    margin-bottom: 20px;
    padding: 16px 20px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 12px;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.preview-title {
    color: #10b981;
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

.preview-item {
    background: rgba(30, 41, 59, 0.6);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
}

.preview-item .label {
    color: #94a3b8;
    margin-bottom: 4px;
    font-size: 0.7rem;
}

.preview-item .value {
    color: #e2e8f0;
    font-weight: 700;
    direction: ltr;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    text-align: right;
}

/* ============================================================ */
/* UPLOAD SECTION */
/* ============================================================ */
.upload-section {
    background: rgba(30, 41, 59, 0.6);
    padding: 40px 30px;
    border-radius: 20px;
    margin-bottom: 20px;
    border: 2px dashed #3b82f6;
    text-align: center;
    transition: all 0.3s;
}

.upload-section.dragover {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 15px;
}

.upload-section h2 {
    color: #e2e8f0;
    margin-bottom: 10px;
    font-size: 1.4rem;
}

.upload-btn {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    padding: 14px 36px;
    border: none;
    border-radius: 10px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    margin-top: 15px;
    transition: all 0.3s;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(59, 130, 246, 0.4);
}

.file-input {
    display: none;
}

.file-status {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-top: 15px;
    padding: 10px 16px;
    background: rgba(30, 41, 59, 0.4);
    border-radius: 8px;
    display: inline-block;
}

/* ============================================================ */
/* FILE MANAGER */
/* ============================================================ */
.file-manager {
    background: rgba(15, 23, 42, 0.5);
    padding: 20px 24px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.file-manager-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.file-manager-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.file-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.file-item {
    background: rgba(30, 41, 59, 0.6);
    padding: 12px 16px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid rgba(59, 130, 246, 0.15);
    transition: all 0.3s;
    gap: 10px;
}

.file-item:hover {
    border-color: #3b82f6;
    background: rgba(30, 41, 59, 0.8);
}

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

.file-item .file-name {
    color: #e2e8f0;
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-item .file-info {
    font-size: 0.65rem;
    color: #64748b;
    margin-top: 4px;
}

.file-item-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.file-item .file-remove {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.file-item .file-remove:hover {
    background: rgba(239, 68, 68, 0.15);
    transform: scale(1.1);
}

.file-item .file-source {
    font-size: 0.65rem;
    padding: 2px 10px;
    border-radius: 10px;
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    white-space: nowrap;
}

.file-manager-footer {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* ============================================================ */
/* PROGRESS */
/* ============================================================ */
.progress-section {
    text-align: center;
    padding: 60px 20px;
}

.loading {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    border: 4px solid rgba(59, 130, 246, 0.2);
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loadingText {
    color: #94a3b8;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.progress-container {
    max-width: 500px;
    margin: 20px auto 0;
    padding: 0 20px;
}

.progress-bar-wrapper {
    width: 100%;
    height: 14px;
    background: rgba(30, 41, 59, 0.8);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(59, 130, 246, 0.3);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #3b82f6, #10b981, #3b82f6);
    background-size: 200% 100%;
    border-radius: 10px;
    transition: width 0.4s ease;
    animation: shimmer 2s infinite;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.6);
}

@keyframes shimmer {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    font-size: 0.85rem;
    color: #94a3b8;
}

#progressPercent {
    font-weight: 900;
    color: #60a5fa;
    font-size: 1.1rem;
    direction: ltr;
}

#progressStep {
    color: #94a3b8;
    font-size: 0.8rem;
    text-align: left;
}

/* ============================================================ */
/* TABS */
/* ============================================================ */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    background: rgba(30, 41, 59, 0.6);
    padding: 8px;
    border-radius: 15px;
}

.tab {
    padding: 10px 22px;
    background: transparent;
    border: 1px solid transparent;
    color: #94a3b8;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.tab:hover {
    background: rgba(59, 130, 246, 0.1);
    color: #e2e8f0;
}

.tab.active {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.4s; }

/* ============================================================ */
/* STATS CARDS */
/* ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stats-grid.six-cards {
    grid-template-columns: repeat(6, 1fr);
}

@media (max-width: 1400px) {
    .stats-grid.six-cards { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .stats-grid.six-cards { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.85), rgba(15, 23, 42, 0.9));
    padding: 0 0 14px 0;
    border-radius: 15px;
    border: 1px solid rgba(59, 130, 246, 0.2);
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #3b82f6, #10b981);
    z-index: 1;
}

.stat-card:hover {
    transform: translateY(-3px);
    border-color: #3b82f6;
}

.stat-card.success::before { background: linear-gradient(180deg, #10b981, #06b6d4); }
.stat-card.warning::before { background: linear-gradient(180deg, #f59e0b, #ef4444); }
.stat-card.danger::before { background: linear-gradient(180deg, #ef4444, #dc2626); }

.stat-label {
    font-size: 0.7rem;
    color: #e2e8f0;
    font-weight: 700;
    margin-bottom: 10px;
    padding: 9px 12px;
    background: rgba(59, 130, 246, 0.18);
    border-radius: 14px 14px 0 0;
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    line-height: 1.3;
}

.stat-card.success .stat-label { background: rgba(16, 185, 129, 0.18); }
.stat-card.warning .stat-label { background: rgba(245, 158, 11, 0.18); }
.stat-card.danger .stat-label { background: rgba(239, 68, 68, 0.18); }

.stat-value {
    font-size: 1.35rem;
    font-weight: 900;
    color: #60a5fa;
    direction: ltr;
    text-align: right;
    padding: 0 14px;
    line-height: 1.3;
}

.stat-unit {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-right: 4px;
    font-weight: 600;
}

.stat-trend {
    font-size: 0.68rem;
    margin-top: 6px;
    padding: 0 14px;
    color: #94a3b8;
    line-height: 1.6;
}

/* ============================================================ */
/* 🆕 CHARTS (با min() برای ریسپانسیو کامل) */
/* ============================================================ */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(450px, 100%), 1fr));
    gap: 18px;
    margin-bottom: 20px;
    min-width: 0;
    max-width: 100%;
}

.chart-container {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.8));
    padding: 20px 22px;
    border-radius: 15px;
    border: 1px solid rgba(59, 130, 246, 0.2);
    /* 🆕 جلوگیری از سرریز */
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.chart-container.full-width { grid-column: 1 / -1; }

.chart-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 14px;
    color: #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(59, 130, 246, 0.1);
    flex-wrap: wrap;
    gap: 8px;
}

.chart-wrapper {
    position: relative;
    height: 280px;
    /* 🆕 جلوگیری از سرریز canvas */
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.chart-wrapper.tall { height: 350px; }
.chart-wrapper.custom { height: 380px; }

/* ============================================================ */
/* 🆕 PERIODS TABLE (ریسپانسیو) */
/* ============================================================ */
.periods-table-container {
    max-height: 500px;
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
    border: 1px solid rgba(59, 130, 246, 0.15);
    background: rgba(15, 23, 42, 0.4);
    margin-bottom: 12px;
    /* 🆕 جلوگیری از سرریز */
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

#periodsTable {
    width: 100%;
    min-width: 1100px;
    border-collapse: collapse;
    font-size: 0.72rem;
}

#periodsTable thead th {
    background: rgba(59, 130, 246, 0.25);
    color: #e2e8f0;
    padding: 8px 8px;
    text-align: center;
    font-weight: 700;
    font-size: 0.72rem;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid rgba(59, 130, 246, 0.3);
}

#periodsTable tbody td {
    padding: 8px 8px;
    border-bottom: 1px solid rgba(59, 130, 246, 0.08);
    color: #cbd5e1;
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}

#periodsTable tbody tr:hover { background: rgba(59, 130, 246, 0.08); }
#periodsTable tbody tr:nth-child(even) { background: rgba(30, 41, 59, 0.2); }

#periodsTable tfoot td {
    padding: 12px;
    border-top: 2px solid rgba(59, 130, 246, 0.4);
    position: sticky;
    bottom: 0;
    background: #1e293b;
    z-index: 5;
    font-size: 0.82rem;
}

/* ============================================================ */
/* PAGINATION */
/* ============================================================ */
.periods-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    padding: 8px 0;
}

.page-btn {
    background: rgba(30, 41, 59, 0.6);
    color: #cbd5e1;
    border: 1px solid rgba(59, 130, 246, 0.25);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s;
    min-width: 36px;
}

.page-btn:hover:not(:disabled):not(.active) {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
}

.page-btn.active {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.page-dots { color: #64748b; padding: 0 4px; font-weight: bold; }

/* ============================================================ */
/* CUSTOM BUILDER */
/* ============================================================ */
.custom-builder {
    background: rgba(15, 23, 42, 0.5);
    padding: 20px 24px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.custom-builder h3 {
    margin-bottom: 15px;
    color: #60a5fa;
}

.custom-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 10px;
}

.custom-row label {
    font-size: 0.85rem;
    color: #94a3b8;
    min-width: 100px;
}

.custom-row select,
.custom-row input[type="text"],
.custom-row input[type="number"] {
    background: rgba(15, 23, 42, 0.8);
    color: #e2e8f0;
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 8px 15px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    flex: 1;
    min-width: 130px;
}

.custom-row .color-picker {
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    cursor: pointer;
    border-radius: 8px;
}

.param-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
    margin: 15px 0;
}

.param-item {
    background: rgba(30, 41, 59, 0.6);
    padding: 10px 16px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid rgba(59, 130, 246, 0.15);
    position: relative;
    transition: all 0.3s;
}

.param-item:hover {
    transform: translateX(-4px);
}

.param-item .remove-param {
    color: #ef4444;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 1.1rem;
    padding: 2px 6px;
}

/* ============================================================ */
/* INFO BOX */
/* ============================================================ */
.info-box {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-right-width: 4px;
    padding: 14px 20px;
    border-radius: 10px;
    margin-bottom: 15px;
    font-size: 0.88rem;
    color: #94a3b8;
    line-height: 1.8;
}

.info-box b { color: #e2e8f0; }

/* ============================================================ */
/* VIBRATION THRESHOLD */
/* ============================================================ */
.vib-threshold-box {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.8));
    padding: 18px 22px;
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.3);
    margin-bottom: 18px;
}

.vib-threshold-box h4 {
    color: #60a5fa;
    margin-bottom: 15px;
    font-size: 1rem;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(59, 130, 246, 0.15);
}

.threshold-grid {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 20px;
    align-items: end;
}

.threshold-group {
    background: rgba(15, 23, 42, 0.6);
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid rgba(59, 130, 246, 0.15);
}

.threshold-group-title {
    color: #94a3b8;
    font-size: 0.8rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.threshold-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.threshold-item label {
    color: #94a3b8;
    font-size: 0.78rem;
    min-width: 60px;
}

.threshold-item input[type="number"] {
    background: rgba(15, 23, 42, 0.9);
    color: #e2e8f0;
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 6px 10px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.85rem;
    width: 80px;
    text-align: center;
}

.threshold-unit { color: #64748b; font-size: 0.72rem; min-width: 40px; }

.threshold-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ============================================================ */
/* PUMP SPECS FULL */
/* ============================================================ */
.pump-specs-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 18px;
}

.pump-specs-box {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.8));
    border-radius: 14px;
    border: 1px solid rgba(59, 130, 246, 0.2);
    padding: 16px 20px;
}

.pump-specs-box h4 {
    color: #60a5fa;
    font-size: 0.95rem;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(59, 130, 246, 0.15);
}

.specs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.specs-table tr {
    border-bottom: 1px solid rgba(59, 130, 246, 0.08);
}

.specs-table tr:last-child { border-bottom: none; }

.specs-table td {
    padding: 7px 4px;
    vertical-align: middle;
}

.specs-table td:first-child {
    color: #94a3b8;
    font-size: 0.75rem;
    width: 45%;
}

.specs-table td:last-child {
    color: #e2e8f0;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    direction: ltr;
    text-align: left;
    font-size: 0.82rem;
}

.specs-table td.rtl-value {
    font-family: inherit;
    direction: rtl;
    text-align: left;
}

.eng-calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.eng-calc-item {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 10px;
    padding: 12px 14px;
    border: 1px solid rgba(59, 130, 246, 0.15);
    text-align: center;
}

.eng-calc-item .label {
    font-size: 0.68rem;
    color: #94a3b8;
    margin-bottom: 6px;
}

.eng-calc-item .value {
    font-size: 1.15rem;
    font-weight: 800;
    color: #60a5fa;
    direction: ltr;
}

.eng-calc-item .unit {
    font-size: 0.65rem;
    color: #64748b;
    margin-right: 3px;
}

/* ============================================================ */
/* DATA TABLE */
/* ============================================================ */
.data-table-container {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.8));
    padding: 20px 22px;
    border-radius: 15px;
    border: 1px solid rgba(59, 130, 246, 0.2);
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

th, td {
    padding: 8px 12px;
    text-align: right;
    border-bottom: 1px solid rgba(59, 130, 246, 0.12);
    white-space: nowrap;
}

th {
    background: rgba(59, 130, 246, 0.2);
    font-weight: 700;
    color: #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 10;
}

td { color: #cbd5e1; }
tr:hover { background: rgba(59, 130, 246, 0.06); }

/* ============================================================ */
/* BADGES */
/* ============================================================ */
.badge {
    display: inline-block;
    padding: 2px 12px;
    border-radius: 12px;
    font-size: 0.65rem;
    font-weight: 700;
}

.badge-success { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.badge-danger { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.badge-info { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }

/* ============================================================ */
/* MODAL */
/* ============================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
    padding: 20px;
}

.modal-overlay.active { display: flex; }

.modal {
    background: #1e293b;
    padding: 30px 35px;
    border-radius: 20px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid rgba(59, 130, 246, 0.3);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal h3 {
    color: #e2e8f0;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.modal .modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 15px;
}

/* ============================================================ */
/* USER MENU */
/* ============================================================ */
.user-menu {
    position: relative;
    display: inline-block;
}

.user-dropdown.is-open { display: block !important; }
.user-dropdown { pointer-events: auto; }
.user-menu, #userMenuBtn { pointer-events: auto; }

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 240px;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.98));
    border: 2px solid rgba(59, 130, 246, 0.3);
    border-radius: 12px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
    z-index: 10000;
    overflow: hidden;
    animation: dropdownFade 0.2s;
}

@keyframes dropdownFade {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-dropdown-header {
    padding: 14px 16px;
    background: rgba(59, 130, 246, 0.1);
    border-bottom: 1px solid rgba(59, 130, 246, 0.2);
    line-height: 1.6;
}

.user-dropdown-item {
    display: block;
    padding: 11px 16px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s;
    cursor: pointer;
    border-bottom: 1px solid rgba(59, 130, 246, 0.05);
}

.user-dropdown-item:hover {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    padding-right: 20px;
}

.user-dropdown-item.danger {
    color: #fca5a5;
    border-bottom: none;
}

.user-dropdown-item.danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* ============================================================ */
/* ADMIN PANEL */
/* ============================================================ */
.admin-panel-modal {
    max-width: 950px !important;
    max-height: 90vh !important;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.admin-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
}

.admin-panel-header h3 {
    color: #fff;
    font-size: 1.2rem;
    font-weight: 800;
    margin: 0;
}

.admin-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.admin-close-btn:hover {
    background: rgba(239, 68, 68, 0.5);
    transform: scale(1.1);
}

.admin-tabs {
    display: flex;
    background: rgba(15, 23, 42, 0.6);
    border-bottom: 1px solid rgba(59, 130, 246, 0.2);
    padding: 0 15px;
    gap: 4px;
    overflow-x: auto;
}

.admin-tab {
    padding: 12px 18px;
    background: transparent;
    border: none;
    color: #94a3b8;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}

.admin-tab:hover { color: #e2e8f0; background: rgba(59, 130, 246, 0.08); }
.admin-tab.active { color: #60a5fa; border-bottom-color: #3b82f6; }

.admin-tab-content {
    display: none;
    padding: 22px 25px;
    overflow-y: auto;
    flex: 1;
    max-height: 60vh;
}

.admin-tab-content.active { display: block; }

.admin-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 10px;
}

.admin-section-header h4 {
    color: #60a5fa;
    font-size: 1rem;
    margin: 0;
}

/* Add User Form */
.add-user-form {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.add-user-form h5 {
    color: #10b981;
    font-size: 0.95rem;
    margin-bottom: 15px;
}

.admin-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 15px;
}

.admin-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.admin-form-group label {
    color: #94a3b8;
    font-size: 0.78rem;
    font-weight: 600;
}

.admin-form-group input,
.admin-form-group select {
    background: rgba(15, 23, 42, 0.9);
    color: #e2e8f0;
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 9px 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
}

.admin-form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 12px;
}

/* Users List */
.users-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.user-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-right: 4px solid #3b82f6;
    border-radius: 10px;
    padding: 14px 18px;
    transition: all 0.3s;
}

.user-card.inactive {
    opacity: 0.55;
    border-right-color: #64748b;
}

.user-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 10px;
    flex-wrap: wrap;
}

.user-card-name {
    color: #e2e8f0;
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.user-card-username {
    color: #64748b;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    direction: ltr;
    text-align: right;
    margin-top: 3px;
}

.user-card-role {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.user-badge {
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: 700;
}

.user-badge.self { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.user-badge.admin { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.user-badge.inactive { background: rgba(239, 68, 68, 0.2); color: #ef4444; }

.user-card-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    padding-top: 10px;
    border-top: 1px dashed rgba(59, 130, 246, 0.15);
}

.role-select {
    background: rgba(15, 23, 42, 0.9);
    color: #e2e8f0;
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 5px 10px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.75rem;
    cursor: pointer;
}

.btn-mini {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #60a5fa;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-mini:hover { transform: scale(1.1); }
.btn-mini.btn-reset:hover { background: rgba(245, 158, 11, 0.3); color: #f59e0b; }
.btn-mini.btn-delete:hover { background: rgba(239, 68, 68, 0.3); color: #ef4444; }

/* Settings */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.settings-item {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 10px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-item label {
    color: #e2e8f0;
    font-size: 0.85rem;
    font-weight: 700;
}

.settings-item input,
.settings-item select {
    background: rgba(15, 23, 42, 0.9);
    color: #e2e8f0;
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 9px 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
}

/* Logs */
.logs-list {
    max-height: 450px;
    overflow-y: auto;
    border-radius: 10px;
    border: 1px solid rgba(59, 130, 246, 0.15);
}

.logs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.logs-table th {
    background: rgba(59, 130, 246, 0.2);
    color: #e2e8f0;
    padding: 10px 12px;
    text-align: right;
    position: sticky;
    top: 0;
    z-index: 5;
    font-weight: 700;
}

.logs-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(59, 130, 246, 0.08);
    color: #cbd5e1;
}

.logs-table tr.log-success { border-right: 3px solid #10b981; }
.logs-table tr.log-failed { border-right: 3px solid #ef4444; }

/* Security Actions */
.security-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
}

.security-action-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 12px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.security-action-card.danger {
    border-color: rgba(239, 68, 68, 0.4);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), rgba(15, 23, 42, 0.9));
}

.sa-header {
    color: #e2e8f0;
    font-weight: 800;
    font-size: 0.9rem;
}

.security-action-card.danger .sa-header { color: #fca5a5; }

.sa-desc {
    color: #94a3b8;
    font-size: 0.75rem;
    line-height: 1.7;
    flex: 1;
}

/* ============================================================ */
/* FOOTER */
/* ============================================================ */
.site-footer {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.95));
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 20px;
    padding: 25px 30px 15px;
    margin-top: 30px;
    margin-bottom: 20px;
}

.footer-content {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(59, 130, 246, 0.15);
}

.footer-section {
    text-align: center;
    padding: 0 10px;
    position: relative;
}

.footer-section:not(:last-child)::after {
    content: '';
    position: absolute;
    left: -12px;
    top: 20%;
    height: 60%;
    width: 1px;
    background: linear-gradient(180deg, transparent, rgba(59, 130, 246, 0.3), transparent);
}

.footer-logo { font-size: 2rem; margin-bottom: 6px; }

.footer-logo-img {
    max-width: 55px;
    max-height: 55px;
    margin-bottom: 8px;
    border-radius: 10px;
}

.footer-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #e2e8f0;
    margin-bottom: 3px;
}

.footer-subtitle {
    font-size: 0.8rem;
    color: #60a5fa;
    font-weight: 700;
    letter-spacing: 1px;
}

.footer-heading {
    font-size: 0.82rem;
    font-weight: 700;
    color: #60a5fa;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px dashed rgba(59, 130, 246, 0.2);
    display: inline-block;
}

.footer-text {
    font-size: 0.78rem;
    color: #94a3b8;
    line-height: 1.8;
}

.footer-text b { color: #e2e8f0; font-weight: 700; }

.footer-bottom {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding-top: 15px;
    font-size: 0.72rem;
    color: #64748b;
    flex-wrap: wrap;
}

.footer-separator { color: #3b82f6; font-weight: 900; }
#footerDate { color: #60a5fa; font-weight: 600; }

/* ============================================================ */
/* PUMP FILTER */
/* ============================================================ */
#pumpFilterContainer {
    margin-bottom: 15px;
}

.pump-filter {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.8));
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.2);
    flex-wrap: wrap;
}

.filter-label {
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 600;
}

.filter-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.filter-btn {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #94a3b8;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    color: #e2e8f0;
}

.filter-btn.active {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

/* ============================================================ */
/* SIDEBAR BACKDROP */
/* ============================================================ */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* دکمه فلش لبه سایدبار */
.sidebar-close-btn {
    position: absolute;
    top: 50%;
    left: -20px;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border: 3px solid #0a0e1a;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.5);
    transition: all 0.3s;
    z-index: 1000;
}

.sidebar-close-btn:hover {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 25px rgba(59, 130, 246, 0.7);
}

.sidebar-close-btn::before {
    content: '❯';
    display: block;
}

@media (max-width: 1024px) {
    .sidebar-close-btn {
        display: flex;
    }
}

/* ============================================================ */
/* SIDEBAR PROGRESS OVERLAY */
/* ============================================================ */
.sidebar-progress-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 14, 26, 0.92);
    backdrop-filter: blur(8px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s;
}

.sidebar-progress-content {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.98));
    border: 2px solid rgba(59, 130, 246, 0.3);
    border-radius: 20px;
    padding: 40px 50px;
    text-align: center;
    min-width: 360px;
    max-width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(59, 130, 246, 0.15);
    animation: fadeIn 0.3s;
}

.sidebar-progress-spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
    border: 4px solid rgba(59, 130, 246, 0.2);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.sidebar-progress-title {
    color: #60a5fa;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.sidebar-progress-message {
    color: #94a3b8;
    font-size: 0.85rem;
    margin-bottom: 20px;
    min-height: 20px;
    direction: rtl;
}

.sidebar-progress-bar-wrapper {
    width: 100%;
    height: 12px;
    background: rgba(30, 41, 59, 0.8);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(59, 130, 246, 0.3);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.sidebar-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #3b82f6, #10b981, #3b82f6);
    background-size: 200% 100%;
    border-radius: 10px;
    transition: width 0.4s ease;
    animation: shimmer 2s infinite;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.6);
}

.sidebar-progress-percent {
    margin-top: 12px;
    color: #10b981;
    font-size: 1.3rem;
    font-weight: 900;
    direction: ltr;
}

/* ============================================================ */
/* UTILITIES */
/* ============================================================ */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: #64748b; }

/* ============================================================ */
/* SCROLLBAR */
/* ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(30, 41, 59, 0.3); border-radius: 8px; }
::-webkit-scrollbar-thumb { background: rgba(59, 130, 246, 0.4); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(59, 130, 246, 0.6); }

/* ============================================================ */
/* RESPONSIVE — TABLET (1024px) */
/* ============================================================ */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(100%);
        width: 290px;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-right: 0; margin-left: 0; padding: 15px; }
    #sidebarToggle { display: inline-block !important; }

    .header h1 { font-size: 1.1rem; }
    .header { padding: 15px 18px; }

    .charts-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .chart-container {
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
    }

    .pump-specs-container { grid-template-columns: 1fr; }
    .stats-grid.six-cards { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================================ */
/* RESPONSIVE — MOBILE (768px) */
/* ============================================================ */
@media (max-width: 768px) {
    body { font-size: 14px; }

    .main-content {
        padding: 10px;
    }

    .container {
        max-width: 100%;
    }

    /* Header */
    .header {
        padding: 12px 14px;
        border-radius: 14px;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .header h1 {
        font-size: 0.95rem;
        line-height: 1.4;
        text-align: center;
    }

    .header-info {
        justify-content: center;
        gap: 6px;
    }

    .header-badge {
        padding: 4px 10px;
        font-size: 0.7rem;
        border-radius: 8px;
    }

    .header-info .btn {
        padding: 6px 10px;
        font-size: 0.72rem;
    }

    /* Pump Selector */
    .pump-selector-box { padding: 16px 14px; }
    .pump-group-grid { grid-template-columns: 1fr; gap: 10px; }
    .pump-card { padding: 12px 14px; }

    /* Upload Section */
    .upload-section { padding: 25px 18px; }
    .upload-icon { font-size: 3rem; }
    .upload-section h2 { font-size: 1.1rem; }
    .upload-btn {
        padding: 12px 24px;
        font-size: 0.95rem;
        width: 100%;
    }

    /* File Manager */
    .file-manager { padding: 15px 14px; }
    .file-manager-header {
        flex-direction: column;
        align-items: stretch;
    }
    .file-list { grid-template-columns: 1fr; }
    .file-item { padding: 10px 12px; }
    .file-manager-footer {
        flex-direction: column;
    }
    .file-manager-footer .btn { width: 100%; }

    /* Tabs */
    .tabs {
        gap: 4px;
        padding: 6px;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    .tab {
        padding: 8px 14px;
        font-size: 0.75rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Stats */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
    }
    .stats-grid.six-cards {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .stat-card { padding: 0 0 10px 0; }
    .stat-value { font-size: 1rem; padding: 0 10px; }
    .stat-label {
        font-size: 0.6rem;
        padding: 6px 8px;
        margin-bottom: 6px;
        min-height: auto;
    }
    .stat-trend { font-size: 0.6rem; padding: 0 10px; }

    /* 🆕 Charts — فیت کامل در موبایل */
    .charts-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
        min-width: 0;
        max-width: 100%;
    }

    .chart-container {
        padding: 14px 12px;
        border-radius: 12px;
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
        box-sizing: border-box;
    }

    .chart-title {
        font-size: 0.85rem;
        margin-bottom: 10px;
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .chart-wrapper {
        height: 240px;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }
    .chart-wrapper.tall { height: 280px; }
    .chart-wrapper.custom { height: 300px; }

    /* 🆕 Periods Table — اسکرول افقی در موبایل */
    .periods-table-container {
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #periodsTable {
        font-size: 0.65rem;
        min-width: 900px;
    }

    #periodsTable thead th,
    #periodsTable tbody td,
    #periodsTable tfoot td {
        padding: 6px 4px;
    }

    /* Pump Specs Preview */
    .preview-grid { grid-template-columns: repeat(2, 1fr); }
    .preview-item { font-size: 0.7rem; }

    /* Pump Specs Full */
    .pump-specs-container { grid-template-columns: 1fr; }
    .specs-table { font-size: 0.72rem; }
    .specs-table td { padding: 5px 3px; }

    /* Threshold */
    .threshold-grid { grid-template-columns: 1fr; }
    .threshold-actions { flex-direction: row; }
    .threshold-actions .btn { flex: 1; }

    /* Custom Builder */
    .custom-row {
        flex-direction: column;
        align-items: stretch;
    }
    .custom-row label {
        min-width: auto;
        font-size: 0.78rem;
    }
    .custom-row select,
    .custom-row input {
        min-width: auto;
        width: 100%;
    }

    /* Modal */
    .modal {
        padding: 20px 18px;
        width: 100%;
        border-radius: 16px;
        max-height: 95vh;
    }
    .modal h3 { font-size: 1.1rem; }

    /* Admin Panel */
    .admin-panel-modal { max-width: 100% !important; }
    .admin-panel-header { padding: 15px 18px; }
    .admin-panel-header h3 { font-size: 1rem; }
    .admin-tab { font-size: 0.72rem; padding: 10px 10px; }
    .admin-tab-content { padding: 15px; }
    .admin-form-grid { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .security-actions { grid-template-columns: 1fr; }
    .user-card-header { flex-direction: column; }

    /* Pagination */
    .page-btn {
        padding: 5px 9px;
        font-size: 0.72rem;
        min-width: 30px;
    }

    /* Data Table */
    .data-table-container { padding: 14px; }
    table { font-size: 0.68rem; }
    th, td { padding: 6px 8px; }

    /* Footer */
    .site-footer {
        padding: 18px 14px 12px;
        border-radius: 14px;
    }
    .footer-content {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    .footer-section:not(:last-child)::after { display: none; }
    .footer-section:not(:last-child) {
        padding-bottom: 12px;
        border-bottom: 1px dashed rgba(59, 130, 246, 0.15);
    }
    .footer-logo { font-size: 1.5rem; }
    .footer-title { font-size: 0.8rem; }
    .footer-text { font-size: 0.72rem; }

    /* Filter */
    .pump-filter {
        flex-direction: column;
        align-items: stretch;
        padding: 10px 12px;
    }
    .filter-buttons { justify-content: center; }

    /* Idle Box */
    .idle-box {
        padding: 30px 20px;
        margin: 20px auto;
    }
    .idle-icon { font-size: 3.5rem; }
    .idle-box h2 { font-size: 1.2rem; }
    .idle-box p { font-size: 0.85rem; }
    .idle-actions { flex-direction: column; }
    .idle-actions .btn { width: 100%; }
}

/* ============================================================ */
/* RESPONSIVE — SMALL MOBILE (480px) */
/* ============================================================ */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
    }
    .stats-grid.six-cards {
        grid-template-columns: 1fr !important;
    }

    .stat-value { font-size: 0.95rem; }

    .header-badge { font-size: 0.65rem; }

    .btn {
        font-size: 0.75rem;
        padding: 6px 12px;
    }
    .btn-lg {
        padding: 12px 20px;
        font-size: 0.9rem;
    }

    .chart-container {
        padding: 12px 10px;
    }

    .chart-wrapper { height: 220px; }
    .chart-wrapper.tall { height: 250px; }
    .chart-wrapper.custom { height: 280px; }

    .chart-title { font-size: 0.78rem; }

    #periodsTable {
        min-width: 800px;
        font-size: 0.6rem;
    }
    #periodsTable thead th,
    #periodsTable tbody td,
    #periodsTable tfoot td {
        padding: 5px 3px;
    }

    .sidebar-progress-content {
        padding: 30px 25px;
        min-width: auto;
        width: 90%;
    }
    .sidebar-progress-spinner {
        width: 50px;
        height: 50px;
    }
    .sidebar-progress-title { font-size: 1rem; }
}

/* ============================================================ */
/* COMPARISON TABLE */
/* ============================================================ */
.comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    margin-top: 10px;
}

.comparison-table thead th {
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
    color: #fff;
    padding: 12px 10px;
    text-align: center;
    font-weight: 700;
    font-size: 0.75rem;
    border-bottom: 2px solid rgba(59, 130, 246, 0.5);
}

.comparison-table tbody td {
    padding: 10px 8px;
    text-align: center;
    border-bottom: 1px solid rgba(59, 130, 246, 0.1);
    color: #cbd5e1;
    font-size: 0.78rem;
}

.comparison-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.08);
}

.comparison-table tbody tr:nth-child(even) {
    background: rgba(30, 41, 59, 0.2);
}

@media (max-width: 768px) {
    .comparison-table {
        font-size: 0.65rem;
        min-width: 800px;
    }
    .comparison-table thead th,
    .comparison-table tbody td {
        padding: 6px 4px;
    }
}

/* ============================================================ */
/* 🆕 COMPARISON TABLE (جدول مقایسه فایل‌ها) */
/* ============================================================ */
.comparison-table {
    width: 100%;
    min-width: 1000px;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.comparison-table thead th {
    background: rgba(59, 130, 246, 0.25);
    color: #e2e8f0;
    padding: 10px 8px;
    text-align: center;
    font-weight: 700;
    font-size: 0.72rem;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid rgba(59, 130, 246, 0.3);
    white-space: nowrap;
}

.comparison-table tbody td {
    padding: 8px 6px;
    border-bottom: 1px solid rgba(59, 130, 246, 0.08);
    color: #cbd5e1;
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}

.comparison-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.08);
}

.comparison-table tbody tr:nth-child(even) {
    background: rgba(30, 41, 59, 0.2);
}

.comparison-table tfoot td {
    padding: 12px 8px;
    border-top: 2px solid rgba(59, 130, 246, 0.4);
    font-size: 0.82rem;
    position: sticky;
    bottom: 0;
    background: #1e293b;
    z-index: 5;
}

/* موبایل */
@media (max-width: 768px) {
    .comparison-table {
        min-width: 900px;
        font-size: 0.68rem;
    }
    .comparison-table thead th,
    .comparison-table tbody td,
    .comparison-table tfoot td {
        padding: 6px 4px;
    }
}

@media (max-width: 480px) {
    .comparison-table {
        min-width: 800px;
        font-size: 0.62rem;
    }
}

/* ============================================================ */
/* 🆕 CHART TOGGLES (Checkbox های زیر نمودار) */
/* ============================================================ */
.chart-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: center;
    margin-top: 12px;
    padding: 10px 14px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: 10px;
    direction: rtl;
}

.toggle-label {
    font-size: 0.78rem;
    color: #60a5fa;
    font-weight: 700;
    margin-left: 4px;
    white-space: nowrap;
}

.toggle-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 0.75rem;
    color: #cbd5e1;
    padding: 4px 10px;
    border-radius: 6px;
    transition: all 0.2s;
    user-select: none;
    white-space: nowrap;
}

.toggle-item:hover {
    background: rgba(59, 130, 246, 0.1);
    color: #e2e8f0;
}

.toggle-item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(59, 130, 246, 0.5);
    border-radius: 4px;
    background: rgba(15, 23, 42, 0.8);
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
    flex-shrink: 0;
}

.toggle-item input[type="checkbox"]:hover {
    border-color: #3b82f6;
}

.toggle-item input[type="checkbox"]:checked {
    background: #3b82f6;
    border-color: #3b82f6;
}

.toggle-item input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    line-height: 1;
}

.toggle-item input[type="checkbox"]:checked + span {
    color: #60a5fa;
    font-weight: 700;
}

/* موبایل */
@media (max-width: 768px) {
    .chart-toggles {
        padding: 8px 10px;
        gap: 6px 10px;
    }
    .toggle-label {
        width: 100%;
        font-size: 0.72rem;
        margin-bottom: 4px;
    }
    .toggle-item {
        font-size: 0.68rem;
        padding: 3px 8px;
    }
}

/* ============================================================ */
/* 🆕 DATE RANGE PICKER */
/* ============================================================ */
.date-range-picker-container {
    margin-top: 12px;
}

.date-range-picker {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.drp-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
}

.drp-row-secondary {
    padding-top: 10px;
    border-top: 1px dashed rgba(59, 130, 246, 0.15);
    align-items: center;
    justify-content: space-between;
}

.drp-label {
    font-size: 0.82rem;
    color: #60a5fa;
    font-weight: 700;
    white-space: nowrap;
    padding-top: 8px;
}

.drp-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 200px;
    flex: 1;
}

.drp-field label {
    font-size: 0.72rem;
    color: #94a3b8;
    font-weight: 600;
}

.drp-input {
    background: rgba(15, 23, 42, 0.9);
    color: #e2e8f0;
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 8px 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    text-align: center;
    direction: ltr;
    transition: border-color 0.2s;
}

.drp-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.drp-display {
    min-height: 18px;
    font-size: 0.68rem;
    color: #94a3b8;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    direction: rtl;
}

.drp-display-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.drp-display-item b {
    color: #60a5fa;
    font-family: 'Courier New', monospace;
}

.drp-btn {
    align-self: flex-end;
    padding: 8px 16px;
    font-size: 0.82rem;
    white-space: nowrap;
    margin-top: 18px;
}

.drp-hint {
    font-size: 0.72rem;
    color: #64748b;
    line-height: 1.5;
}

/* موبایل */
@media (max-width: 768px) {
    .drp-row {
        flex-direction: column;
        align-items: stretch;
    }
    .drp-label {
        padding-top: 0;
    }
    .drp-field {
        min-width: auto;
    }
    .drp-btn {
        align-self: stretch;
        margin-top: 0;
    }
    .drp-row-secondary {
        flex-direction: column;
        align-items: stretch;
    }
    .drp-hint {
        text-align: center;
    }
}

/* ============================================================ */
/* 🆕 CHART CONTROLS (Date Range + Zoom) */
/* ============================================================ */
.chart-controls {
    margin-top: 14px;
    padding: 14px 16px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    direction: rtl;
}

.chart-controls-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.control-label {
    font-size: 0.82rem;
    color: #60a5fa;
    font-weight: 700;
}

.date-input-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #cbd5e1;
}

.date-input-group > span {
    color: #94a3b8;
    font-weight: 600;
    white-space: nowrap;
}

.date-input {
    background: rgba(15, 23, 42, 0.8);
    color: #e2e8f0;
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 7px 12px;
    border-radius: 7px;
    font-family: inherit;
    font-size: 0.82rem;
    direction: ltr;
    text-align: right;
    min-width: 170px;
    transition: all 0.2s;
}

.date-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.date-input::placeholder {
    color: #475569;
    font-size: 0.72rem;
}

.date-display {
    background: rgba(16, 185, 129, 0.08);
    color: #10b981;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    border-right: 3px solid #10b981;
    display: none;
    margin-right: 4px;
    direction: rtl;
}

.chart-controls-hint {
    font-size: 0.72rem;
    color: #64748b;
    padding-top: 6px;
    border-top: 1px dashed rgba(59, 130, 246, 0.12);
    margin-top: 4px;
    text-align: center;
}

/* موبایل */
@media (max-width: 768px) {
    .chart-controls {
        padding: 10px 12px;
        gap: 8px;
    }
    .chart-controls-row {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    .date-input-group {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }
    .date-input-group > span {
        font-size: 0.72rem;
    }
    .date-input {
        width: 100%;
        min-width: auto;
    }
    .date-display {
        width: 100%;
        margin-right: 0;
    }
    .chart-controls-row .btn {
        width: 100%;
    }
    .toggle-item {
        justify-content: center;
    }
}

/* ============================================================
   GUIDE TAB
   ============================================================ */
.guide-intro{
    grid-column:1/-1;
    width:100%;
    box-sizing:border-box;
    display:grid;
    grid-template-columns:86px minmax(0,1fr);
    align-items:center;
    gap:18px;
    direction:ltr;
    min-height:145px;
}
.guide-intro-icon{
    width:78px;
    height:78px;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:14px;
    background:rgba(37,99,235,.10);
    color:#60a5fa;
}
.guide-intro-icon svg{
    width:58px;
    height:58px;
    fill:none;
    stroke:currentColor;
    stroke-width:3;
    stroke-linecap:round;
    stroke-linejoin:round;
}
.guide-intro-content{
    direction:rtl;
    text-align:right;
    min-width:0;
}
.guide-intro-content h3{
    margin:0 0 10px;
    color:#cbd5e1;
    font-size:1.05rem;
    line-height:1.7;
}
.guide-intro-content p{
    margin:5px 0;
    line-height:1.9;
}
.guide-intro-note{
    color:#94a3b8;
    font-size:.8rem;
}
.guide-grid{display:grid;grid-template-columns:1fr 1fr;gap:15px;}
.guide-grid .full-width{grid-column:1/-1;}
.guide-table-wrap{overflow:auto;}
.guide-table td,.guide-table th{vertical-align:top;line-height:1.8;}
.formula-list{display:grid;gap:9px;}
.formula-card{background:rgba(15,23,42,.55);border:1px solid rgba(59,130,246,.14);border-radius:10px;padding:12px;}
.formula-card b{display:block;color:#60a5fa;margin-bottom:7px;}
.formula-card code{display:block;direction:ltr;text-align:left;font-family:Vazirmatn,monospace;color:#e2e8f0;background:rgba(2,6,23,.5);padding:9px;border-radius:7px;white-space:normal;}
.guide-steps{margin:0;padding-right:22px;line-height:2.1;color:#cbd5e1;}
.guide-reference-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:10px;}
.guide-reference-grid>div{background:rgba(15,23,42,.5);border-radius:9px;padding:10px 12px;}
.guide-reference-grid span{display:block;font-size:.68rem;color:#64748b;margin-bottom:4px;}
.guide-reference-grid b{display:block;color:#e2e8f0;font-size:.82rem;}
@media(max-width:900px){.guide-grid{grid-template-columns:1fr;}.guide-grid .full-width{grid-column:auto;}}

/* اصلاح نمایش راهنمای تاریخ و کارت‌های تحلیل مهندسی */
.drp-format-hint{display:flex;align-items:center;justify-content:center;gap:8px;direction:rtl;font-size:.64rem;color:#64748b;white-space:nowrap;}
.drp-format-hint b{color:#60a5fa;font-weight:800;}
.analysis-metric{background:rgba(30,41,59,.45);padding:10px 12px;border-radius:9px;border:1px solid rgba(148,163,184,.10);display:flex;flex-direction:column;gap:4px;}
.analysis-metric span{font-size:.70rem;color:#94a3b8;}
.analysis-metric b{font-size:1.02rem;color:#e2e8f0;font-weight:900;}
.analysis-metric small{font-size:.67rem;color:#64748b;line-height:1.6;}
.analysis-metric strong{font-size:.72rem;margin-top:2px;}
.muted-label{font-size:.68rem;color:#94a3b8;margin-bottom:4px;}


.drp-format-hint { display:flex; align-items:center; justify-content:center; gap:8px; direction:rtl; flex-wrap:wrap; }
.drp-format-hint .drp-or { display:inline-flex; align-items:center; justify-content:center; padding:0 6px; min-width:24px; font-weight:700; color:#60a5fa; white-space:nowrap; }


/* ============================================================
   AI PUMP ASSISTANT — V5.14.1
   ============================================================ */
.sidebar-ai-button-wrap { padding: 10px 12px 4px; }
.sidebar-ai-button {
    width: 100%; border: 1px solid rgba(56,189,248,.35); border-radius: 12px;
    padding: 11px 12px; display:flex; align-items:center; gap:9px; cursor:pointer;
    background: linear-gradient(135deg, rgba(14,116,144,.25), rgba(37,99,235,.18));
    color:#e2e8f0; font-family:inherit; font-weight:700; transition:.2s;
}
.sidebar-ai-button:hover { transform:translateY(-1px); border-color:rgba(56,189,248,.75); background:linear-gradient(135deg, rgba(14,116,144,.38), rgba(37,99,235,.28)); }
.sidebar-ai-icon { font-size:1.15rem; }
.ai-tab-button { border-color:rgba(56,189,248,.28); }
.ai-assistant-shell { display:flex; flex-direction:column; gap:14px; min-height:680px; }
.ai-assistant-header { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:18px 20px; border-radius:16px; background:linear-gradient(135deg, rgba(15,23,42,.95), rgba(14,116,144,.22)); border:1px solid rgba(56,189,248,.22); }
.ai-assistant-title { font-size:1.25rem; font-weight:800; color:#f8fafc; }
.ai-assistant-subtitle { color:#94a3b8; font-size:.82rem; margin-top:5px; }
.ai-context-bar { display:flex; flex-wrap:wrap; gap:9px; padding:10px 12px; border:1px solid rgba(148,163,184,.16); border-radius:12px; background:rgba(15,23,42,.5); color:#cbd5e1; font-size:.78rem; }
.ai-context-bar span { padding:5px 9px; border-radius:999px; background:rgba(51,65,85,.45); }
.ai-chat { flex:1; min-height:390px; max-height:58vh; overflow:auto; padding:18px; border:1px solid rgba(148,163,184,.16); border-radius:16px; background:rgba(2,6,23,.35); }
.ai-welcome { max-width:680px; margin:50px auto; text-align:center; color:#cbd5e1; }
.ai-welcome-icon { font-size:3rem; margin-bottom:10px; }
.ai-welcome h3 { margin:0 0 10px; color:#f8fafc; }
.ai-welcome p { line-height:1.9; margin:7px 0; }
.ai-welcome .muted { color:#64748b; font-size:.82rem; }
.ai-message { display:flex; gap:9px; margin:0 0 14px; align-items:flex-start; }
.ai-message.user { flex-direction:row-reverse; }
.ai-avatar { width:34px; height:34px; flex:0 0 34px; display:grid; place-items:center; border-radius:50%; background:rgba(51,65,85,.55); }
.ai-bubble { max-width:min(82%, 900px); padding:12px 15px; border-radius:14px; line-height:1.9; font-size:.9rem; overflow-wrap:anywhere; }
.ai-message.assistant .ai-bubble { background:rgba(30,41,59,.85); color:#e2e8f0; border-top-right-radius:4px; }
.ai-message.user .ai-bubble { background:rgba(30,64,175,.38); color:#f8fafc; border-top-left-radius:4px; }
.ai-code { direction:ltr; text-align:left; white-space:pre-wrap; overflow:auto; padding:10px; border-radius:9px; background:#020617; color:#cbd5e1; margin:8px 0 0; }
.ai-suggestions { display:flex; flex-wrap:wrap; gap:8px; }
.ai-suggestions button { border:1px solid rgba(56,189,248,.2); background:rgba(15,23,42,.6); color:#cbd5e1; border-radius:10px; padding:8px 11px; cursor:pointer; font-family:inherit; font-size:.78rem; }
.ai-suggestions button:hover { border-color:rgba(56,189,248,.55); color:#fff; }
.ai-composer { display:flex; gap:10px; align-items:stretch; }
.ai-composer textarea { flex:1; resize:vertical; min-height:52px; max-height:180px; padding:12px 14px; border-radius:12px; border:1px solid rgba(148,163,184,.22); background:rgba(15,23,42,.85); color:#f8fafc; font-family:inherit; line-height:1.8; outline:none; }
.ai-composer textarea:focus { border-color:rgba(56,189,248,.65); box-shadow:0 0 0 3px rgba(56,189,248,.08); }
.ai-send-btn { min-width:112px; }
.ai-disclaimer { color:#64748b; font-size:.72rem; line-height:1.7; text-align:center; }
@media (max-width: 700px) {
    .ai-assistant-header { flex-direction:column; align-items:stretch; }
    .ai-composer { flex-direction:column; }
    .ai-send-btn { width:100%; }
    .ai-bubble { max-width:88%; }
}

.ai-metrics{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:8px}
.ai-metric{padding:9px 10px;border:1px solid rgba(56,189,248,.14);border-radius:11px;background:rgba(15,23,42,.55);min-width:0}
.ai-metric span{display:block;color:#64748b;font-size:.68rem;margin-bottom:4px}.ai-metric b{font-size:.78rem;color:#e2e8f0}
.ai-feedback{display:flex;gap:6px;margin-top:9px;padding-top:8px;border-top:1px solid rgba(148,163,184,.10)}
.ai-feedback button{border:0;background:transparent;color:#64748b;cursor:pointer;font-family:inherit;font-size:.68rem}.ai-feedback button:hover{color:#e2e8f0}.ai-feedback-done{font-size:.68rem;color:#4ade80}
@media(max-width:1100px){.ai-metrics{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(max-width:650px){.ai-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}}

/* ============================================================
   V5.14.3 — AI Usage / Privacy Admin
   ============================================================ */
.ai-privacy-note{padding:12px 14px;border:1px solid rgba(59,130,246,.25);background:rgba(30,64,175,.12);border-radius:10px;color:#cbd5e1;margin-bottom:14px;line-height:1.8}
.ai-budget-card{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;padding:14px;border-radius:12px;border:1px solid rgba(148,163,184,.18);background:rgba(15,23,42,.55)}
.ai-budget-card>div{display:flex;flex-direction:column;gap:5px}.ai-budget-card span{font-size:.78rem;color:#94a3b8}.ai-budget-card strong{font-size:1.1rem;color:#f8fafc}.ai-budget-card.warning{border-color:rgba(245,158,11,.45)}.ai-budget-card.danger{border-color:rgba(239,68,68,.55)}.ai-budget-card.success{border-color:rgba(16,185,129,.35)}
.ai-budget-progress{height:9px;background:#1e293b;border-radius:99px;overflow:hidden;margin:10px 0 18px}.ai-budget-progress>div{height:100%;background:#60a5fa;border-radius:99px;transition:width .3s}.ai-usage-stats{display:grid;grid-template-columns:repeat(6,1fr);gap:10px}.ai-usage-stats>div{padding:12px;border-radius:10px;background:rgba(30,41,59,.55);display:flex;flex-direction:column;gap:5px}.ai-usage-stats span{font-size:.75rem;color:#94a3b8}.ai-usage-stats b{color:#f8fafc}.admin-table{width:100%;border-collapse:collapse}.admin-table th,.admin-table td{padding:9px;border-bottom:1px solid rgba(148,163,184,.12);text-align:right}.admin-table th{color:#94a3b8;font-size:.8rem}.admin-table td{color:#e2e8f0}.table-responsive{overflow:auto}.admin-loading,.admin-error{padding:18px;color:#cbd5e1}
@media(max-width:900px){.ai-budget-card{grid-template-columns:repeat(2,1fr)}.ai-usage-stats{grid-template-columns:repeat(2,1fr)}}


/* V5.14.3 AI admin pricing */
.ai-admin-settings-card{margin-top:22px;padding:18px;border:1px solid rgba(96,165,250,.25);border-radius:14px;background:rgba(15,23,42,.55)}
.ai-admin-settings-card h4{color:#60a5fa;margin:0 0 8px}.ai-admin-settings-card h5{color:#cbd5e1;margin:18px 0 10px}.settings-help{color:#94a3b8;font-size:.82rem;line-height:1.8;margin:6px 0 12px}.ai-admin-settings-card input[type=number],.ai-admin-settings-card input[type=text],.ai-admin-settings-card select{direction:ltr;text-align:left}

/* ============================================================
   V5.15.0 — Engineering AI workspace
   ============================================================ */
.ai-header-actions{display:flex;gap:8px;flex-wrap:wrap}
.ai-workspace{display:grid;grid-template-columns:270px minmax(0,1fr);gap:12px;min-height:680px}
.ai-conversations-panel{border:1px solid rgba(148,163,184,.16);border-radius:16px;background:rgba(2,6,23,.30);overflow:hidden;display:flex;flex-direction:column}
.ai-panel-title{display:flex;justify-content:space-between;align-items:center;padding:13px 14px;border-bottom:1px solid rgba(148,163,184,.12);color:#e2e8f0;font-weight:800}
.ai-icon-btn{border:0;background:transparent;color:#94a3b8;cursor:pointer;padding:5px;border-radius:7px}.ai-icon-btn:hover{background:rgba(239,68,68,.12);color:#fca5a5}
.ai-conversation-list{overflow:auto;padding:8px}
.ai-conversation-item{width:100%;text-align:right;border:1px solid transparent;background:transparent;color:#cbd5e1;padding:10px;border-radius:10px;cursor:pointer;font-family:inherit;margin-bottom:5px}
.ai-conversation-item:hover{background:rgba(51,65,85,.32);border-color:rgba(148,163,184,.12)}
.ai-conversation-item.active{background:rgba(14,116,144,.18);border-color:rgba(56,189,248,.32)}
.ai-conv-title{display:block;font-weight:700;font-size:.8rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ai-conv-meta{display:block;color:#64748b;font-size:.65rem;margin-top:5px}
.ai-empty-history{padding:20px 10px;color:#64748b;font-size:.75rem;text-align:center;line-height:1.8}
.ai-main-panel{min-width:0;display:flex;flex-direction:column;gap:10px}
.ai-bubble-wrap{max-width:min(88%,1000px);min-width:0}.ai-message-actions{display:flex;gap:7px;align-items:center;margin-top:9px;padding-top:7px;border-top:1px solid rgba(148,163,184,.10)}
.ai-message-actions button{border:0;background:transparent;color:#64748b;cursor:pointer;font-family:inherit;font-size:.66rem}.ai-message-actions button:hover{color:#e2e8f0}.ai-message-actions .ai-delete-turn{margin-right:auto;color:#94a3b8}.ai-message-actions .ai-delete-turn:hover{color:#fca5a5}
.ai-sources{margin-top:10px;padding-top:9px;border-top:1px solid rgba(56,189,248,.14);display:flex;flex-direction:column;gap:5px}.ai-sources b{font-size:.7rem;color:#7dd3fc}.ai-sources a{font-size:.7rem;color:#93c5fd;text-decoration:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ai-sources a:hover{text-decoration:underline;color:#bae6fd}
.ai-web-control{display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap;padding:8px 11px;border:1px solid rgba(56,189,248,.14);border-radius:10px;background:rgba(15,23,42,.38);color:#94a3b8;font-size:.72rem}.ai-web-control label{color:#cbd5e1;cursor:pointer}.ai-web-control input{vertical-align:middle;margin-left:5px}
@media(max-width:900px){.ai-workspace{grid-template-columns:1fr}.ai-conversations-panel{max-height:190px}.ai-conversation-list{display:flex;gap:6px;overflow:auto}.ai-conversation-item{min-width:210px}.ai-bubble-wrap{max-width:92%}}

/* V5.17 Digital Twin health card */
.ai-health-card{display:none;margin:8px 0 12px}.ai-health{border:1px solid rgba(148,163,184,.22);border-radius:12px;padding:12px 14px;background:rgba(15,23,42,.72)}.ai-health.healthy{border-color:rgba(16,185,129,.45)}.ai-health.warning{border-color:rgba(245,158,11,.5)}.ai-health.critical{border-color:rgba(239,68,68,.55)}.ai-health-head{font-size:.95rem}.ai-health-summary{margin-top:7px;color:#cbd5e1;font-size:.82rem;line-height:1.8}.ai-health-evidence{margin:7px 0 0;padding-right:18px;color:#94a3b8;font-size:.76rem;line-height:1.8}

.ai-admin-enable-banner{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:14px 16px;margin:10px 0 18px;border:1px solid rgba(56,189,248,.28);border-radius:12px;background:rgba(15,23,42,.45)}
.ai-enable-toggle{display:flex;align-items:center;gap:10px;font-weight:700;white-space:nowrap}
.ai-disabled-panel{min-height:360px;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;border:1px solid rgba(148,163,184,.18);border-radius:16px;background:rgba(15,23,42,.65);color:#cbd5e1;padding:40px}
.ai-disabled-panel h3{margin:14px 0 8px;color:#e2e8f0}
.ai-disabled-panel p{color:#94a3b8}
