@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/Vazirmatn-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #eef3ff;
    --text: #101828;
    --muted: #667085;
    --border: rgba(16, 24, 40, 0.08);
    --primary: #2f6bff;
    --primary-dark: #204ccc;
    --success: #19a974;
    --danger: #e5484d;
    --warning: #e19b2c;
    --shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
    --radius: 24px;
}

* {
    box-sizing: border-box;
}

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

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background: linear-gradient(180deg, #f8faff 0%, #eef2ff 100%);
    color: var(--text);
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 290px 1fr;
    max-width: 100%;
    overflow-x: clip;
    align-items: stretch;
}

.sidebar {
    background: rgba(11, 20, 46, 0.95);
    color: #fff;
    padding: 28px 18px;
    position: sticky;
    top: 0;
    min-height: 100vh;
    height: auto;
    align-self: stretch;
    transition: transform 0.35s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.brand-mark {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #5d89ff, #7b61ff);
    font-weight: 700;
    box-shadow: 0 12px 24px rgba(123, 97, 255, 0.35);
}

.brand span,
.topbar-user span,
.topbar-title p,
.card p,
.page-head p,
.empty-state,
.stat-card small {
    color: var(--muted);
}

.brand span {
    display: block;
    color: rgba(255, 255, 255, 0.68);
    margin-top: 4px;
    font-size: 0.92rem;
}

.menu {
    display: grid;
    gap: 10px;
}

.menu-link {
    position: relative;
    padding: 14px 16px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
    transition: background 0.25s ease, transform 0.25s ease, color 0.25s ease;
}

.menu-link::before {
    content: '';
    position: absolute;
    inset-inline-start: 10px;
    width: 4px;
    border-radius: 999px;
    inset-block: 0;
    background: linear-gradient(180deg, #7c9bff, #4b73ff);
    transform: scaleY(0.25);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
    z-index: 0;
}

.menu-icon,
.menu-text {
    position: relative;
    z-index: 1;
}

.menu-icon {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 22px;
}

.menu-icon svg {
    width: 20px;
    height: 20px;
    display: block;
}

.menu-text {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-link:hover,
.menu-link.active {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(-4px);
}

.menu-link:hover::before,
.menu-link.active::before {
    transform: scaleY(1);
    opacity: 1;
}

.menu-link.danger:hover {
    background: rgba(229, 72, 77, 0.14);
}

.main-area {
    padding: 26px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

.topbar {
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 24px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
    min-width: 0;
    min-height: 56px;
}

.topbar h1,
.page-head h2,
.card-head h3 {
    margin: 0;
}

.topbar-title,
.topbar-user {
    min-width: 0;
}

.topbar-title {
    display: flex;
    align-items: center;
}

.topbar-title p {
    margin: 0;
    font-size: 0.92rem;
}

.topbar-user strong,
.topbar-user span {
    overflow-wrap: anywhere;
}

.topbar-user {
    display: flex;
    align-items: center;
}

.topbar-user strong {
    font-size: 0.92rem;
    font-weight: 700;
}

.hamburger {
    display: none;
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 14px;
    background: var(--surface-soft);
    cursor: pointer;
}

.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    margin: 5px auto;
    transition: transform 0.25s ease;
}

.content,
.auth-shell {
    display: grid;
    gap: 22px;
    min-width: 0;
}

.content {
    flex: 1;
}

.content > *,
.content-grid > *,
.profile-grid > *,
.stats-grid > * {
    min-width: 0;
}

.page-head,
.card,
.stat-card,
.login-card,
.form-card {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.page-head,
.card {
    padding: 22px;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.badge {
    display: inline-flex;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(47, 107, 255, 0.1);
    color: var(--primary);
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.stats-grid,
.content-grid {
    display: grid;
    gap: 22px;
}

.stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.content-grid {
    grid-template-columns: 1.15fr 1fr;
}

.dashboard-content-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
}

.chart-box {
    position: relative;
    min-height: 340px;
    height: 340px;
    overflow: hidden;
}

.chart-box canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.profile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-card {
    padding: 24px;
    display: grid;
    gap: 8px;
}

.stat-card strong {
    font-size: 1.9rem;
    color: var(--primary-dark);
}

.card-head,
.toolbar,
.toolbar-form,
.action-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.card-head,
.toolbar {
    justify-content: space-between;
    margin-bottom: 18px;
}

.toolbar-form {
    width: 100%;
}

.toolbar-form-search {
    gap: 10px;
}

.toolbar-form input,
.toolbar-form select {
    flex: 1;
}

.search-field {
    position: relative;
    flex: 1;
    min-width: 0;
}

.search-field input {
    width: 100%;
    padding-inline: 44px 16px;
    height: 48px;
    border: 1px solid rgba(102, 112, 133, 0.18);
    border-radius: 16px;
    background: linear-gradient(180deg, #ffffff, #f8faff);
    box-shadow: inset 0 1px 2px rgba(16, 24, 40, 0.04);
}

.search-field input:focus {
    border-color: rgba(47, 107, 255, 0.55);
    box-shadow: 0 0 0 4px rgba(47, 107, 255, 0.12);
}

.search-field-icon {
    position: absolute;
    inset-inline-start: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--muted);
    pointer-events: none;
}

.search-field-icon svg {
    width: 18px;
    height: 18px;
    display: block;
}

.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

.no-min-table {
    min-width: 0;
}

.table-responsive-tight {
    overflow: visible;
}

.table-compact th,
.table-compact td {
    padding: 11px 10px;
}

.table-compact {
    table-layout: fixed;
}

.compact-head {
    margin-bottom: 18px;
}

.wrap-actions {
    flex-wrap: wrap;
}

.table th,
.table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    text-align: right;
    vertical-align: middle;
}

.table th {
    color: var(--muted);
    font-weight: 500;
    background: rgba(238, 243, 255, 0.7);
}

.empty-state {
    text-align: center;
    padding: 18px 0;
}

.btn {
    border: 0;
    cursor: pointer;
    border-radius: 16px;
    padding: 12px 16px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #7b61ff);
    color: #fff;
    box-shadow: 0 14px 24px rgba(47, 107, 255, 0.24);
}

.btn-secondary {
    background: #101828;
    color: #fff;
}

.btn-light {
    background: var(--surface-soft);
    color: var(--text);
}

.btn-danger {
    background: rgba(229, 72, 77, 0.12);
    color: var(--danger);
}

.btn-block {
    width: 100%;
}

.form-grid,
.filter-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.filter-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.form-span-2 {
    grid-column: 1 / -1;
}

.form-group {
    display: grid;
    gap: 8px;
}

.form-group label {
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    border: 1px solid rgba(102, 112, 133, 0.18);
    border-radius: 16px;
    padding: 14px 16px;
    background: #fff;
    outline: 0;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.picker-button {
    width: 100%;
    border: 1px solid rgba(102, 112, 133, 0.18);
    border-radius: 16px;
    padding: 14px 16px;
    background: #fff;
    text-align: right;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: rgba(47, 107, 255, 0.55);
    box-shadow: 0 0 0 4px rgba(47, 107, 255, 0.12);
}

.form-actions {
    display: flex;
    align-items: end;
}

.summary-box {
    padding: 20px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(47, 107, 255, 0.08), rgba(123, 97, 255, 0.08));
    display: grid;
    gap: 6px;
}

.summary-box strong {
    color: var(--primary-dark);
    font-size: 1.6rem;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.44);
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    overscroll-behavior: contain;
}

.modal-card {
    width: min(560px, 100%);
    max-height: 88vh;
    overflow: auto;
    background: #fff;
    border-radius: 24px;
    padding: 20px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2);
}

.modal-card-compact {
    width: min(430px, 100%);
    padding: 16px;
}

.date-picker-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr 0.9fr;
    gap: 10px;
    align-items: end;
}

.date-picker-grid .form-group {
    gap: 6px;
}

.date-picker-grid select {
    min-width: 0;
    padding: 12px 14px;
}

.employee-picker-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.employee-picker-item {
    width: 100%;
    border: 1px solid rgba(102, 112, 133, 0.16);
    border-radius: 18px;
    padding: 14px 16px;
    background: #fff;
    text-align: right;
    cursor: pointer;
}

.employee-picker-item:hover {
    border-color: rgba(47, 107, 255, 0.28);
    background: rgba(47, 107, 255, 0.03);
}

.sidebar-backdrop {
    display: none;
}

.employee-picker-item strong,
.employee-picker-item span {
    display: block;
}

.employee-picker-item span {
    color: var(--muted);
    margin-top: 6px;
}

.timeline {
    display: grid;
    gap: 14px;
}

.timeline-item {
    padding: 16px;
    border-radius: 18px;
    background: var(--surface-soft);
}

.timeline-item p,
.timeline-item span {
    margin: 6px 0 0;
}

.auth-shell {
    min-height: 100vh;
    place-items: center;
    padding: 28px;
}

.login-card {
    width: min(1100px, 100%);
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    overflow: hidden;
    align-items: stretch;
}

.login-panel,
.form-card {
    padding: 42px;
}

.form-card {
    display: grid;
    gap: 18px;
    align-content: start;
}

.form-card .btn {
    margin-top: 6px;
}

.login-panel {
    background: linear-gradient(135deg, rgba(47, 107, 255, 0.98), rgba(123, 97, 255, 0.95));
    color: #fff;
}

.login-panel p,
.login-meta {
    color: rgba(255, 255, 255, 0.82);
}

.login-meta {
    display: grid;
    gap: 14px;
    margin-top: 26px;
}

.toast-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 60;
    display: grid;
    gap: 10px;
}

.toast {
    min-width: 260px;
    padding: 14px 16px;
    border-radius: 18px;
    color: #fff;
    box-shadow: var(--shadow);
    animation: slideIn 0.35s ease;
}

.toast.success { background: linear-gradient(135deg, #1fb987, #0f9960); }
.toast.error { background: linear-gradient(135deg, #ef5a60, #c53030); }
.toast.info { background: linear-gradient(135deg, #4f7cff, #3451d1); }

.site-footer {
    display: flex;
    justify-content: center;
    padding: 4px 0 2px;
}

.footer-credit {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(244, 246, 248, 0.96);
    border: 1px solid rgba(16, 24, 40, 0.08);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
    color: #374151;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.footer-credit:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
}

.footer-credit-text {
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}

.footer-credit-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 62px;
    padding: 5px 11px;
    border-radius: 999px;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    direction: ltr;
    background: linear-gradient(135deg, #6e72ff, #4b57db);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.reveal-card {
    opacity: 0;
    transform: translateY(22px);
    animation: fadeUp 0.7s ease forwards;
}

.reveal-card:nth-child(2) { animation-delay: 0.08s; }
.reveal-card:nth-child(3) { animation-delay: 0.12s; }
.reveal-card:nth-child(4) { animation-delay: 0.16s; }

@keyframes fadeUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(-12px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .content-grid,
    .dashboard-content-grid,
    .profile-grid,
    .filter-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 960px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: auto;
        z-index: 50;
        width: min(84vw, 320px);
        max-width: 320px;
        padding: 18px 14px;
        transform: translate3d(calc(100% + 20px), 0, 0);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        box-shadow: -20px 0 40px rgba(15, 23, 42, 0.18);
        border-radius: 24px 0 0 24px;
        height: auto;
    }

    .sidebar.open {
        transform: translate3d(0, 0, 0);
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .brand {
        margin-bottom: 18px;
    }

    .brand-mark {
        width: 44px;
        height: 44px;
        border-radius: 14px;
    }

    .menu {
        gap: 8px;
    }

    .menu-link {
        padding: 12px 14px;
        min-height: 48px;
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.26);
        border: 0;
        padding: 0;
        z-index: 45;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    .sidebar-backdrop.visible {
        opacity: 1;
        pointer-events: auto;
    }

    .hamburger {
        display: inline-block;
    }

    .main-area {
        padding: 18px;
        width: 100%;
    }

    .page-head {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-form,
    .action-row {
        flex-wrap: wrap;
    }

    .login-card {
        grid-template-columns: 1fr;
    }

    body.menu-open {
        overflow: hidden;
    }
}

@media (max-width: 640px) {
    .stats-grid,
    .form-grid,
    .filter-grid {
        grid-template-columns: 1fr;
    }

    .page-head,
    .card,
    .stat-card,
    .login-panel,
    .form-card {
        padding: 18px;
    }

    .topbar {
        padding: 10px 12px;
    }

    .sidebar {
        width: calc(100vw - 56px);
        max-width: calc(100vw - 56px);
        border-radius: 20px 0 0 20px;
    }

    .topbar-user {
        justify-content: flex-end;
    }

    .card-head,
    .action-row,
    .form-actions {
        flex-wrap: wrap;
    }

    .toolbar-form-search {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-form-search .btn {
        width: 100%;
    }

    .table.mobile-stack-table,
    .table.mobile-stack-table thead,
    .table.mobile-stack-table tbody,
    .table.mobile-stack-table tr,
    .table.mobile-stack-table th,
    .table.mobile-stack-table td {
        display: block;
        width: 100%;
    }

    .table.mobile-stack-table {
        min-width: 0;
    }

    .table.mobile-stack-table thead {
        display: none;
    }

    .table.mobile-stack-table tr {
        border: 1px solid var(--border);
        border-radius: 18px;
        padding: 10px 12px;
        margin-bottom: 12px;
        background: #fff;
    }

    .table.mobile-stack-table td {
        text-align: right;
        border: 0;
        padding: 8px 0;
    }

    .table.mobile-stack-table td::before {
        content: attr(data-label);
        display: block;
        color: var(--muted);
        font-size: 0.82rem;
        margin-bottom: 4px;
    }

    .chart-box {
        min-height: 240px;
        height: 240px;
    }

    .footer-credit {
        gap: 6px;
        padding: 4px 8px;
    }

    .footer-credit-text,
    .footer-credit-badge {
        font-size: 0.74rem;
    }

    .modal-card {
        width: 100%;
        max-height: 92vh;
        padding: 16px;
        border-radius: 20px;
    }

    .date-picker-grid {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 8px;
    }

    .date-picker-grid label {
        font-size: 0.82rem;
    }

    .date-picker-grid select {
        padding: 11px 10px;
    }
}
