* { box-sizing: border-box; }
body {
    font-family: Vazirmatn, Tahoma, sans-serif;
    direction: rtl;
    text-align: right;
    background: #f4f5fb;
    margin: 0;
    color: #1f2333;
}
a { color: inherit; text-decoration: none; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.card {
    background: #fff;
    border: 1px solid #e6e8f0;
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 6px 24px rgba(30, 30, 60, .06);
    margin-bottom: 20px;
}
.card h3 { margin-top: 0; }
.login-wrap .card { max-width: 380px; width: 100%; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 14px; color: #555; }
input[type=text], input[type=password], input[type=file], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid #d8dbe6; border-radius: 8px; font-family: inherit; font-size: 14px;
}
.btn {
    display: inline-block; background: #4f46e5; color: #fff; border: none; padding: 10px 18px;
    border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 14px;
}
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.outline { background: #fff; color: #4f46e5; border: 1px solid #4f46e5; }
.btn.danger { background: #dc2626; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert.error { background: #fef2f2; color: #991b1b; }
.alert.success { background: #ecfdf5; color: #065f46; }
.muted { color: #888; font-size: 13px; }

.app-layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px; background: #1f2333; color: #fff; padding: 20px 16px; flex-shrink: 0;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.sidebar .brand { font-size: 16px; font-weight: 700; }
.logout-link { color: #f3a3a3; font-size: 13px; flex-shrink: 0; }
.sidebar-nav { display: flex; flex-direction: column; }
.sidebar-nav a { display: block; padding: 10px 12px; border-radius: 8px; color: #cbd0e0; margin-bottom: 4px; font-size: 14px; }
.sidebar-nav a.active, .sidebar-nav a:hover { background: #363b52; color: #fff; }
.main { flex: 1; padding: 28px; max-width: 1100px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.page-head h1 { font-size: 20px; margin: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px; border-bottom: 1px solid #eee; text-align: right; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; }
.badge.blue { background: #e6f1fb; color: #0c447c; }
.badge.amber { background: #faeeda; color: #854f0b; }
.badge.green { background: #eaf3de; color: #27500a; }
.profile-photo { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; background: #eee; flex-shrink: 0; }
.sso-btn { display: flex; align-items: center; gap: 10px; padding: 14px; border: 1px solid #e6e8f0; border-radius: 10px; margin-bottom: 10px; }
.sso-btn .icon { width: 34px; height: 34px; border-radius: 8px; background: #f1efe8; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* ===== موبایل ===== */
@media (max-width: 720px) {
    .app-layout { flex-direction: column; }
    .sidebar { width: 100%; padding: 14px 16px; position: sticky; top: 0; z-index: 10; }
    .sidebar-top { margin-bottom: 12px; }
    .sidebar-nav {
        flex-direction: row; overflow-x: auto; gap: 6px; margin: 0 -16px; padding: 0 16px 4px;
        -webkit-overflow-scrolling: touch;
    }
    .sidebar-nav a { white-space: nowrap; margin-bottom: 0; flex-shrink: 0; }
    .main { padding: 16px; max-width: 100%; }
    .page-head h1 { font-size: 18px; }
    .card { padding: 16px; }
    .grid { grid-template-columns: 1fr; gap: 12px; }

    /* جدول‌ها روی صفحه کوچک به‌صورت افقی اسکرول می‌شوند تا فشرده/به‌هم‌ریخته نشوند */
    .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
    .table-scroll table { min-width: 480px; }
    table { font-size: 13px; }
    th, td { padding: 8px 6px; }

    .btn, .btn.sm { padding: 10px 14px; font-size: 14px; } /* اندازه لمسی مناسب انگشت */
    input[type=text], input[type=password], input[type=file], select, textarea { font-size: 16px; } /* جلوگیری از زوم خودکار iOS */
}

@media (max-width: 420px) {
    .login-wrap .card { padding: 20px 16px; }
}
