:root {
    --primary: #5c6cff;
    --primary-dark: #2c3e50;
    --accent: #ff9ecd;
    --background: #f7f9ff;
    --surface: #ffffff;
    --text: #1f2544;
    --text-muted: #68718f;
    --border: rgba(127, 140, 141, 0.15);
    --success: #00b894;
    --error: #ff5f6d;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Vazir', Tahoma, sans-serif;
    background: radial-gradient(circle at top left, #fff7fe 0%, #f0f6ff 55%, var(--background) 100%);
    color: var(--text);
}

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

.navbar {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 50%, #2c3e50 100%);
    color: #fff;
    padding: 18px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.navbar .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 20px;
    position: relative;
}

.navbar .brand::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 40px;
    background: linear-gradient(180deg, #e74c3c 0%, #c0392b 100%);
    border-radius: 2px;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.4);
}

.navbar .links {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.navbar .links a,
.navbar .links form button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.08);
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    font-family: 'Vazir', Tahoma, sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
}

.navbar .links a:hover,
.navbar .links form button:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.3);
    transform: translateY(-1px);
}

.navbar .links a[aria-current="page"] {
    background: rgba(52, 152, 219, 0.8);
    border-color: rgba(52, 152, 219, 0.8);
    font-weight: 600;
}

.navbar .links a[aria-current="page"]:hover {
    background: rgba(52, 152, 219, 1);
    border-color: rgba(52, 152, 219, 1);
}

.page {
    padding: 32px 16px 48px;
    display: flex;
    justify-content: center;
}

.container {
    width: min(1080px, 100%);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.card {
    background: var(--surface);
    border-radius: 20px;
    padding: 28px;
    box-shadow: 0 20px 40px rgba(44, 62, 80, 0.12);
    border: 1px solid var(--border);
}

.card-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
}

.card-header h1,
.card-header h2,
.card-header h3 {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
}

.card-header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
}

.alert {
    padding: 14px 16px;
    border-radius: 14px;
    font-size: 15px;
    margin-bottom: 18px;
}

.alert-success {
    background: rgba(0, 184, 148, 0.12);
    color: var(--success);
    border: 1px solid rgba(0, 184, 148, 0.35);
}

.alert-error {
    background: rgba(255, 95, 109, 0.1);
    color: var(--error);
    border: 1px solid rgba(255, 95, 109, 0.35);
}

.form-grid {
    display: grid;
    gap: 18px;
}

@media (min-width: 720px) {
    .form-grid.two {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-field label {
    font-weight: 600;
    color: var(--text);
    font-size: 15px;
}

.form-field small {
    color: var(--text-muted);
    font-size: 12px;
}

.input-control,
select,
textarea {
    border-radius: 14px;
    border: 1px solid rgba(44, 62, 80, 0.25);
    padding: 12px 14px;
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: rgba(255,255,255,0.9);
    color: var(--text);
}

.input-control:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #7f8c8d;
    box-shadow: 0 0 0 3px rgba(127, 140, 141, 0.2);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

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

.btn {
    border: none;
    border-radius: 30px;
    padding: 12px 22px;
    font-size: 15px;
    font-weight: 600;
    font-family: 'Vazir', Tahoma, sans-serif;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.navbar .links a.logout-link {
    background: rgba(231, 76, 60, 0.8);
    border-color: rgba(231, 76, 60, 0.8);
}

.navbar .links a.logout-link:hover {
    background: rgba(231, 76, 60, 1);
    border-color: rgba(231, 76, 60, 1);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

.btn-primary {
    background: linear-gradient(135deg, #7f8c8d 0%, #5d6d7e 100%);
    color: #fff;
    box-shadow: 0 12px 25px rgba(127, 140, 141, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 32px rgba(127, 140, 141, 0.30);
}

.btn-secondary {
    background: rgba(44, 62, 80, 0.1);
    color: var(--primary-dark);
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 16px;
    border: 1px solid rgba(44, 62, 80, 0.12);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
    direction: rtl;
}

th, td {
    text-align: right;
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid rgba(44, 62, 80, 0.08);
}

th {
    background: rgba(44, 62, 80, 0.08);
    color: var(--text);
    font-weight: 600;
}

tr:hover td {
    background: rgba(44, 62, 80, 0.04);
}

.table-empty {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.filters label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(44, 62, 80, 0.12);
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 600;
}

.stat-grid {
    display: grid;
    gap: 18px;
}

@media (min-width: 720px) {
    .stat-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.stat-card {
    background: linear-gradient(160deg, rgba(255,255,255,0.95), rgba(240,245,255,0.95));
    border-radius: 18px;
    padding: 22px;
    border: 1px solid rgba(44, 62, 80, 0.12);
    box-shadow: 0 16px 32px rgba(44, 62, 80, 0.15);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-card h3 {
    margin: 0;
    font-size: 16px;
    color: var(--text-muted);
}

.stat-card strong {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-dark);
}

.muted {
    color: var(--text-muted);
    font-size: 13px;
}

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
}

.login-card {
    width: min(420px, 100%);
    background: var(--surface);
    border-radius: 24px;
    padding: 36px 32px;
    box-shadow: 0 24px 48px rgba(44, 62, 80, 0.16);
    border: 1px solid var(--border);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: relative;
    overflow: hidden;
}

.login-card h1 {
    margin: 0;
    font-size: 24px;
}

.login-card p {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.8;
}

.login-card.is-loading {
    filter: saturate(0.8);
}

.login-card.is-loading::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.85), rgba(240, 245, 255, 0.9));
    backdrop-filter: blur(4px);
    z-index: 2;
}

.loading-indicator {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    background: linear-gradient(160deg, rgba(255,255,255,0.2), rgba(44, 62, 80, 0.12));
    z-index: 3;
    color: var(--primary-dark);
    font-weight: 600;
}

.login-card.is-loading .loading-indicator {
    display: flex;
}

.loading-spinner {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 3px solid rgba(44, 62, 80, 0.25);
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
}

.loading-text {
    font-size: 15px;
}

.btn.is-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.btn.is-loading::after {
    content: '';
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #fff;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0); }
    to { transform: rotate(360deg); }
}

.navbar .links form {
    margin: 0;
}

.navbar .links form button {
    border: none;
}

.persian-datepicker {
    position: absolute;
    z-index: 9999;
    background: var(--surface);
    border-radius: 18px;
    box-shadow: 0 24px 48px rgba(15, 31, 95, 0.18);
    border: 1px solid rgba(44, 62, 80, 0.15);
    padding: 16px;
    min-width: 260px;
    direction: rtl;
}

.persian-datepicker header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.persian-datepicker header button {
    border: none;
    background: rgba(44, 62, 80, 0.12);
    color: var(--primary-dark);
    border-radius: 50%;
    width: 34px;
    height: 34px;
    font-size: 18px;
    cursor: pointer;
}

.persian-datepicker header button:hover {
    background: rgba(44, 62, 80, 0.22);
}

.persian-datepicker header span {
    font-weight: 600;
}

.persian-datepicker table {
    width: 100%;
    border-collapse: collapse;
    min-width: 0;
}

.persian-datepicker th {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    padding: 6px 0;
}

.persian-datepicker td {
    text-align: center;
    padding: 6px 0;
}

.persian-datepicker td button {
    border: none;
    background: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
}

.persian-datepicker td button:hover {
    background: rgba(44, 62, 80, 0.15);
}

.persian-datepicker td button.active {
    background: linear-gradient(120deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 6px 16px rgba(44, 62, 80, 0.25);
}

.persian-datepicker td button:disabled {
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 600px) {
    .navbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .navbar .links {
        width: 100%;
    }

    .form-actions {
        justify-content: stretch;
    }

    .form-actions .btn {
        flex: 1 1 auto;
        justify-content: center;
    }
}
