* { box-sizing: border-box; }
body {
    font-family: Tahoma, "Vazirmatn", sans-serif;
    direction: rtl;
    background: #f4f6f9;
    margin: 0;
    color: #263238;
}
a { color: #1565c0; text-decoration: none; }
.container { max-width: 1100px; margin: 0 auto; padding: 16px; }

/* ---------------------------------------------------------------
   چیدمان اصلی: ساید‌بار (راست، چون RTL) + محتوای اصلی
   --------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: #1e293b;
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-brand {
    padding: 18px 20px;
    font-weight: bold;
    font-size: 15px;
    border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-nav { flex: 1 1 auto; display: flex; flex-direction: column; padding: 10px 0; }
.sidebar-nav a {
    color: #cbd5e1;
    padding: 11px 20px;
    font-size: 14px;
    text-decoration: none;
    border-right: 3px solid transparent;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav a.active { background: rgba(255,255,255,.1); color: #fff; border-right-color: #1565c0; }
.sidebar-section-title {
    padding: 14px 20px 4px; font-size: 11px; color: #64748b; text-transform: uppercase;
}
.sidebar-user {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,.12);
    font-size: 13px;
    color: #cbd5e1;
}
.sidebar-user .btn { width: 100%; margin-top: 8px; }

.main-content { flex: 1 1 auto; min-width: 0; }
.main-content .container { max-width: 1200px; }

.mobile-topbar {
    display: none;
    position: sticky; top: 0; z-index: 900;
    background: #1e293b; color: #fff;
    padding: 12px 16px;
    align-items: center; justify-content: space-between;
}
.mobile-topbar button {
    background: transparent; border: none; color: #fff; font-size: 20px; cursor: pointer;
}
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 999;
}

@media (max-width: 900px) {
    .app-shell { display: block; }
    .mobile-topbar { display: flex; }
    .sidebar {
        position: fixed; top: 0; right: 0; height: 100vh; z-index: 1000;
        transform: translateX(100%);
        transition: transform .25s ease;
        box-shadow: -4px 0 16px rgba(0,0,0,.25);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
}

/* ---------------------------------------------------------------
   کارت‌ها و جداول
   --------------------------------------------------------------- */
.card {
    background: #fff;
    border-radius: 10px;
    padding: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    margin-bottom: 16px;
}
/* هر کارتی که جدول یا محتوای عریض دارد، به‌جای بهم‌ریختن صفحه، به‌صورت افقی اسکرول شود */
.card { overflow-x: auto; }

.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 800px) { .grid-4, .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px) { .grid[style] { grid-template-columns: 1fr !important; } }
@media (max-width: 480px) { .grid-4, .grid-3 { grid-template-columns: 1fr !important; } }

.stat { text-align: center; }
.stat .num { font-size: 28px; font-weight: bold; color: #1e293b; }
.stat .label { color: #64748b; font-size: 13px; }
table { width: 100%; border-collapse: collapse; background: #fff; min-width: 480px; }
th, td { padding: 10px 8px; border-bottom: 1px solid #eee; text-align: right; font-size: 14px; white-space: nowrap; }
th { background: #f1f5f9; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; color: #fff; font-size: 12px; }
.btn {
    display: inline-block; padding: 8px 16px; border-radius: 6px; border: none;
    background: #1565c0; color: #fff; cursor: pointer; font-size: 14px;
}
.btn:hover { background: #0d47a1; }
.btn-secondary { background: #64748b; }
.btn-danger { background: #e53935; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
input, select, textarea {
    width: 100%; padding: 9px; border: 1px solid #cbd5e1; border-radius: 6px;
    font-family: inherit; margin-top: 4px; margin-bottom: 12px; font-size: 14px;
}
label { font-weight: bold; font-size: 13px; color: #334155; }
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; font-size: 14px; }
.alert-error { background: #fdecea; color: #b71c1c; border: 1px solid #f5c6cb; }
.alert-success { background: #e8f5e9; color: #1b5e20; border: 1px solid #c8e6c9; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters select, .filters input { width: auto; margin: 0; min-width: 0; }
@media (max-width: 600px) {
    .filters select, .filters input { flex: 1 1 100%; }
}
.timeline { border-right: 3px solid #e2e8f0; padding-right: 16px; margin-right: 6px; }
.timeline-item { position: relative; margin-bottom: 18px; }
.timeline-item::before {
    content: ''; position: absolute; right: -22px; top: 4px; width: 10px; height: 10px;
    border-radius: 50%; background: #1565c0;
}
.small-muted { color: #94a3b8; font-size: 12px; }

/* ---------------------------------------------------------------
   تقویم انتخاب تاریخ شمسی
   --------------------------------------------------------------- */
.jalali-picker { position: relative; display: inline-block; }
.jalali-display { width: 140px; cursor: pointer; background: #fff; margin: 0; }
.jalali-popup {
    position: absolute; z-index: 9999;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.2); padding: 10px; width: 240px;
}
.jalali-popup-header { display: flex; justify-content: space-between; align-items: center; font-weight: bold; margin-bottom: 8px; }
.jalali-popup-header button { background: #f1f5f9; border: none; border-radius: 4px; width: 26px; height: 26px; cursor: pointer; font-size: 16px; }
.jalali-popup-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11px; color: #94a3b8; margin-bottom: 4px; }
.jalali-popup-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.jalali-day {
    background: none; border: none; padding: 6px 0; border-radius: 4px; cursor: pointer; font-size: 13px;
}
.jalali-day:hover { background: #1565c0; color: #fff; }
.jalali-popup-footer { display: flex; justify-content: space-between; margin-top: 8px; border-top: 1px solid #eee; padding-top: 8px; }
.jalali-popup-footer button {
    background: none; border: none; color: #1565c0; cursor: pointer; font-size: 12px; padding: 4px 8px;
}
.jalali-popup-footer button:hover { text-decoration: underline; }
.login-box {
    max-width: 380px; margin: 80px auto; background: #fff; padding: 30px;
    border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,.08);
}
@media (max-width: 480px) {
    .login-box { margin: 30px auto; padding: 20px; }
    .container { padding: 12px; }
}

