:root {
    --bg: #f0f4f8;
    --surface: #ffffff;
    --text: #1a2332;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --border: #e2e8f0;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Tajawal', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    position: relative;
}

/* شعار Zero Waste — خلفية خفيفة لكل الصفحات */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image: url('../images/brand-watermark.png');
    background-repeat: no-repeat;
    background-position: center center;
    background-size: min(72vmin, 520px);
    opacity: 0.07;
}

@media (max-width: 768px) {
    body::before {
        background-size: min(88vw, 420px);
        opacity: 0.06;
    }
}

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

.app-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 14px 24px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    flex-wrap: wrap;
}

.app-logo {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.app-nav {
    display: flex;
    gap: 8px;
    flex: 1;
    flex-wrap: wrap;
}

.app-nav a {
    padding: 8px 14px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
}

.app-nav a.active,
.app-nav a:hover {
    background: #eff6ff;
    color: var(--primary);
}

.app-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.user-role {
    background: #eff6ff;
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
}

.app-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.app-footer {
    text-align: center;
    padding: 20px;
    color: var(--muted);
    font-size: 13px;
}

.page-title {
    margin: 0 0 8px;
    font-size: 28px;
}

.page-sub {
    color: var(--muted);
    margin: 0 0 24px;
}

.card {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card h3 {
    margin: 0 0 8px;
    font-size: 14px;
    color: var(--muted);
    font-weight: 500;
}

.stat-card .value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}

.btn {
    display: inline-block;
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 15px;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    text-decoration: none;
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.alert {
    padding: 14px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
}

.auth-card h1 {
    margin: 0 0 8px;
    font-size: 26px;
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
}

.field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
}

.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.94);
}

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

.table th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 14px;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}

.badge-employee { background: #dbeafe; color: #1e40af; }
.badge-worker { background: #f1f5f9; color: #475569; }
.badge-driver { background: #fef3c7; color: #92400e; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-terminated { background: #fee2e2; color: #991b1b; }
.badge-purchase { background: #dbeafe; color: #1e40af; }
.badge-sales { background: #d1fae5; color: #065f46; }
.badge-expense { background: #ffedd5; color: #9a3412; }

.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.35rem;
    height: 1.35rem;
    padding: 0 6px;
    margin-inline-start: 6px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    vertical-align: middle;
}

.app-nav a .nav-badge {
    margin-inline-start: 4px;
}

.app-nav a.active .nav-badge {
    background: #dc2626;
    color: #fff;
}

.task-notify-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #fef2f2;
    color: #991b1b;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}

.task-notify-pill:hover {
    background: #fee2e2;
}

.notifications-card {
    border-inline-start: 4px solid var(--primary, #2563eb);
}

.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 40px 20px;
}

.quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.quick-link {
    display: block;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s;
}

.quick-link:hover {
    border-color: var(--primary);
    text-decoration: none;
}

.quick-link strong {
    display: block;
    margin-bottom: 6px;
    color: var(--primary);
}

.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.filter-bar input,
.filter-bar select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
}

.filter-bar input {
    flex: 1;
    min-width: 200px;
}

.filter-bar .filter-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    font-size: 15px;
    white-space: nowrap;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 12px;
    color: var(--text);
}

.form-card {
    margin-bottom: 24px;
}

.form-section {
    border: none;
    margin: 0 0 24px;
    padding: 0 0 20px;
    border-bottom: 1px solid var(--border);
}

.form-section:last-of-type {
    border-bottom: none;
}

.form-section legend {
    font-size: 17px;
    font-weight: 700;
    padding: 0 0 12px;
    color: var(--primary);
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
}

.field-hint {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: 8px;
}

.person-avatar {
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--border);
}

.person-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.person-avatar__initials {
    font-weight: 700;
    color: var(--muted);
    user-select: none;
}

.person-avatar--sm {
    width: 36px;
    height: 36px;
    font-size: 12px;
}

.person-avatar--md {
    width: 56px;
    height: 56px;
    font-size: 16px;
}

.person-avatar--lg {
    width: 96px;
    height: 96px;
    font-size: 28px;
}

.person-profile-header__main {
    display: flex;
    align-items: center;
    gap: 20px;
}

.person-profile-header__main .page-title {
    margin-bottom: 4px;
}

.person-profile-header__main .page-sub {
    margin-bottom: 0;
}

.person-row-name {
    display: flex;
    align-items: center;
    gap: 10px;
}

.photo-upload-row {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.card-title {
    margin: 0 0 16px;
    font-size: 17px;
    color: var(--primary);
}

.detail-list {
    margin: 0;
    display: grid;
    gap: 10px;
}

.detail-list dt {
    font-size: 13px;
    color: var(--muted);
    font-weight: 500;
}

.detail-list dd {
    margin: 0;
    font-weight: 500;
}

.table-actions {
    white-space: nowrap;
    font-size: 14px;
}

.pagination {
    color: var(--muted);
    font-size: 14px;
}

.upload-form {
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.link-btn {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    padding: 0;
    text-decoration: underline;
}

.scan-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 32px 20px;
    text-align: center;
    background: #fafbfc;
    transition: border-color 0.15s, background 0.15s;
}

.scan-dropzone--active {
    border-color: var(--primary);
    background: #eff6ff;
}

.scan-dropzone__icon {
    font-size: 42px;
    margin-bottom: 8px;
}

.scan-dropzone__title {
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 6px;
}

.scan-dropzone__hint {
    color: var(--muted);
    font-size: 14px;
    margin: 0 0 16px;
}

.scan-dropzone__actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.scan-input-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

.scan-file-list {
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
    text-align: right;
    font-size: 14px;
    color: var(--text);
}

.scan-file-list li {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.vehicle-media-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    align-items: flex-start;
}

.vehicle-main-photo {
    display: block;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    max-width: 320px;
}

.vehicle-main-photo img {
    display: block;
    width: 100%;
    max-height: 220px;
    object-fit: cover;
}

.vehicle-doc-thumbs {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.vehicle-doc-thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 120px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    font-size: 13px;
    background: #fff;
}

.vehicle-doc-thumb img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
}

.vehicle-doc-pdf {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 80px;
    background: #fee2e2;
    color: #991b1b;
    border-radius: 6px;
    font-weight: 700;
}

.vehicle-upload-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.vehicle-upload-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    background: #fafafa;
}

.vehicle-upload-preview img {
    width: 100%;
    max-height: 140px;
    object-fit: cover;
    border-radius: 8px;
    margin-top: 8px;
}

.vehicle-doc-link {
    display: inline-block;
    margin-top: 8px;
    font-weight: 600;
}

.card-subtitle {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 12px;
}

.btn-link-danger {
    background: none;
    border: none;
    padding: 0;
    color: var(--danger);
    cursor: pointer;
    font: inherit;
    text-decoration: underline;
}

.fuel-chip-form {
    margin-top: 8px;
}

@media (max-width: 768px) {
    .app-header { flex-direction: column; align-items: flex-start; }
    .app-nav { width: 100%; }
}
