@font-face {
    font-family: 'Vazir';
    src: url('fonts/Vazir.woff2') format('woff2');
    font-weight: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazir';
    src: url('fonts/Vazir-Bold.woff2') format('woff2');
    font-weight: bold;
    font-display: swap;
}

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.08);
    --radius: 8px;
    --radius-lg: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Vazir', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    direction: rtl;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

/* ─── Header ─── */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.site-header .inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.site-header .logo {
    font-size: 1rem;
    font-weight: bold;
    color: var(--text);
}
.site-header .logo small {
    font-weight: normal;
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: block;
}
.site-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}
.site-nav a {
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: all 0.2s;
    white-space: nowrap;
}
.site-nav a:hover,
.site-nav a.active {
    background: #f1f5f9;
    color: var(--primary);
    text-decoration: none;
}
.site-nav .user-badge {
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 0.4rem 0.75rem;
    border-right: 1px solid var(--border);
    margin-right: 0.25rem;
}

/* ─── Container ─── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    width: 100%;
}

/* ─── Card ─── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}
.card-title {
    font-size: 1.15rem;
    font-weight: bold;
    margin-bottom: 1rem;
    color: var(--text);
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-family: inherit;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.5;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #057a53; color: #fff; }

.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover { background: #b45309; color: #fff; }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; color: #fff; }

.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: #f8fafc; border-color: #cbd5e1; }

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-lg { padding: 0.65rem 1.25rem; font-size: 1rem; }
.btn-block { width: 100%; }

/* ─── Forms ─── */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.35rem;
}
.form-control,
.form-select {
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
    line-height: 1.5;
}
.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-control::placeholder { color: #94a3b8; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ─── Table ─── */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
table th, table td {
    padding: 0.65rem 0.75rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    white-space: nowrap;
}
table tbody tr:hover { background: #f8fafc; }

/* ─── Pagination ─── */
.pagination {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 1rem;
}
.pagination a,
.pagination span {
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--text);
    text-decoration: none;
    transition: all 0.15s;
}
.pagination a:hover { background: #f1f5f9; }
.pagination .active a,
.pagination .active span {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ─── Alert ─── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}
.alert-info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.alert-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.alert-error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

/* ─── Grid ─── */
.row { display: flex; flex-wrap: wrap; margin: 0 -0.5rem; }
.row > * { padding: 0 0.5rem; }
.col-12 { width: 100%; }
.col-6 { width: 50%; }
.col-4 { width: 33.33333%; }
.col-3 { width: 25%; }
@media (min-width: 768px) {
    .col-md-2 { width: 16.66667%; }
    .col-md-3 { width: 25%; }
    .col-md-4 { width: 33.33333%; }
    .col-md-5 { width: 41.66667%; }
    .col-md-6 { width: 50%; }
    .col-md-7 { width: 58.33333%; }
    .col-md-8 { width: 66.66667%; }
    .col-md-9 { width: 75%; }
    .col-md-10 { width: 83.33333%; }
}
@media (max-width: 767px) {
    .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10 { width: 100%; }
}

/* ─── Utilities ─── */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-muted { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.font-bold { font-weight: bold; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mr-1 { margin-left: 0.25rem; }
.ml-1 { margin-right: 0.25rem; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.my-3 { margin-top: 1rem; margin-bottom: 1rem; }
.my-4 { margin-top: 1.5rem; margin-bottom: 1.5rem; }
.my-5 { margin-top: 2rem; margin-bottom: 2rem; }
.d-flex { display: flex; }
.d-inline { display: inline; }
.d-inline-block { display: inline-block; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.w-full { width: 100%; }
.w-auto { width: auto; }

/* ─── Dashboard Cards ─── */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}
.dash-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1rem;
    text-align: center;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}
.dash-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}
.dash-card .icon {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    display: block;
}
.dash-card .label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}
.dash-card .btn { width: 100%; }

/* ─── Welcome Section ─── */
.welcome-box {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
}
.welcome-box h2 { font-size: 1.2rem; margin: 0; }
.welcome-box .role { font-size: 0.85rem; opacity: 0.85; margin-top: 0.25rem; }

/* ─── Footer ─── */
.site-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 1rem 0;
    text-align: center;
    margin-top: auto;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ─── Modal ─── */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    justify-content: center;
    align-items: flex-start;
    padding-top: 3rem;
}
.modal.show { display: flex; }
.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: calc(100% - 2rem);
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.modal-header h5 { font-size: 1rem; font-weight: bold; }
.modal-close { background: none; border: none; font-size: 1.25rem; cursor: pointer; color: var(--text-secondary); padding: 0.25rem; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: 0.75rem 1.25rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 0.5rem; }

/* ─── Scan Preview ─── */
.scan-preview { max-width: 100%; height: auto; border-radius: var(--radius); margin-top: 0.5rem; box-shadow: var(--shadow); }

/* ─── Login Page ─── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}
.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}
.login-box h2 {
    text-align: center;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}
.login-box .subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

/* ─── Letter Number ─── */
.letter-num {
    font-weight: bold;
    color: var(--primary);
}
.letter-num-lg {
    font-size: 1.15rem;
    font-weight: bold;
    color: var(--primary);
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .site-header .inner { flex-direction: column; align-items: stretch; text-align: center; }
    .site-nav { justify-content: center; }
    .dash-grid { grid-template-columns: repeat(2, 1fr); }
    .card { padding: 1rem; }
    .login-box { margin: 1rem; padding: 1.5rem; }
    .modal-content { margin: 1rem; }
    table { font-size: 0.8rem; }
    table th, table td { padding: 0.45rem 0.5rem; }
}
@media (max-width: 480px) {
    .dash-grid { grid-template-columns: 1fr; }
}
