:root {
    --navy: #0f2744;
    --navy-2: #16365a;
    --teal: #0f766e;
    --teal-2: #0d9488;
    --gold: #c9a227;
    --bg: #f3f5f8;
    --card: #ffffff;
    --text: #122033;
    --muted: #5b6b7f;
    --line: #e5eaf1;
    --present: #047857;
    --late: #b45309;
    --absent: #b91c1c;
    --weekend: #be123c;
    --leave: #0369a1;
    --shadow: 0 14px 40px rgba(15, 39, 68, 0.08);
    --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Tajawal", "Segoe UI", Tahoma, sans-serif;
    overflow-x: hidden; /* لمنع التمرير الأفقي الزائد في الصفحة */
}

a { color: inherit; text-decoration: none; }

.app-shell {
    min-height: 100vh;
}

.topbar {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 70%, #0b3b4d 100%);
    color: #fff;
    padding: 14px 0;
    position: sticky;
    top: 0;
    z-index: 40;
    box-shadow: 0 8px 24px rgba(15, 39, 68, 0.2);
}

/* 
  تعديل: جعل عرض الصفحة والشريط العلوي 100% 
  بدلاً من الحد الأقصى 1200 بكسل
*/
.topbar-inner,
.page {
    width: 100%;
    padding: 0 16px;
    margin: 0 auto;
}

.page.page-full {
    width: 100%;
    max-width: none;
}

body:has(.page-full) .topbar-inner {
    width: 100%;
    max-width: none;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    font-size: 1.05rem;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.16);
}

.top-meta {
    text-align: center;
}

.top-clock {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 1px;
}

.top-date {
    opacity: .8;
    font-size: .85rem;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
}

.nav-link {
    color: #fff;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(255,255,255,.08);
}

.nav-link:hover { background: rgba(255,255,255,.16); }

/* تعديل: تقليل المسافات العلوية والسفلية لاستغلال المساحة */
.page { padding: 16px 0 24px; }

.page-title {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 16px;
}

.page-title h1 {
    margin: 0 0 4px;
    font-size: 1.7rem;
}

.page-title p {
    margin: 0;
    color: var(--muted);
}

.grid {
    display: grid;
    gap: 16px;
}

.copy-grid {
    grid-template-columns: 1.2fr 1.2fr 180px auto;
    gap: 14px;
    align-items: end;
}

.stats {
    grid-template-columns: repeat(4, 1fr);
}

.layout {
    grid-template-columns: 1.4fr .9fr;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-body { padding: 16px; }

.stat-card {
    padding: 18px 20px;
    color: #fff;
    min-height: 118px;
}

.stat-card h3 {
    margin: 0;
    font-size: 2rem;
}

.stat-card span {
    display: block;
    opacity: .9;
    margin-top: 4px;
}

.bg-present { background: linear-gradient(135deg, #047857, #0f766e); }
.bg-late { background: linear-gradient(135deg, #d97706, #b45309); }
.bg-absent { background: linear-gradient(135deg, #dc2626, #9f1239); }
.bg-hours { background: linear-gradient(135deg, #1d4ed8, #0f2744); }
.bg-leave { background: linear-gradient(135deg, #0284c7, #0369a1); }

.hero-time {
    text-align: center;
    padding: 12px 0 8px;
}

.hero-time .clock {
    font-size: 2.4rem;
    font-weight: 800;
    color: var(--navy);
}

.hero-time small {
    color: var(--muted);
}

.action-btn {
    width: 100%;
    padding: 14px 18px;
    border-radius: 14px;
    font-size: 1.05rem;
    color: #fff;
}

.btn-checkin { background: linear-gradient(135deg, var(--teal), #115e59); }
.btn-checkout { background: linear-gradient(135deg, #b91c1c, #9f1239); }
.btn-break { background: linear-gradient(135deg, #d97706, #b45309); }
.btn-excel { background: linear-gradient(135deg, #15803d, #166534); color: #fff; }
.btn-navy { background: var(--navy); color: #fff; }
.btn-ghost {
    background: #eef3f8;
    color: var(--navy);
}

.btn {
    padding: 10px 16px;
    border-radius: 12px;
}

.alert {
    border-radius: 14px;
    padding: 12px 14px;
    margin: 12px 0;
    font-weight: 700;
}

.alert-ok { background: #ecfdf5; color: #065f46; }
.alert-warn { background: #fffbeb; color: #92400e; }
.alert-info { background: #eff6ff; color: #1e3a8a; }
.alert-error { background: #fef2f2; color: #991b1b; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 12px;
    align-items: end;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
    color: var(--navy);
}

input, select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    background: #fff;
}

.table-wrap {
    overflow: auto;
    border-radius: 14px;
    border: 1px solid var(--line);
}

table.report {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

table.report th {
    background: #111827;
    color: #fff;
    padding: 12px 10px;
    font-weight: 800;
    text-align: center;
    white-space: nowrap;
}

table.report td {
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid var(--line);
}

.row-weekend { background: #fce4ec; }
.row-late { background: #fef3c7; }
.row-absent { background: #fecaca; }
.row-leave { background: #dceeff; }
.row-alt { background: #f8fafc; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .82rem;
    font-weight: 800;
}

.badge-present { background: #d1fae5; color: #065f46; }
.badge-late { background: #fde68a; color: #92400e; }
.badge-absent { background: #fecaca; color: #991b1b; }
.badge-weekend { background: #fce7f3; color: #9f1239; }
.badge-leave { background: #dbeafe; color: #1e40af; }
.badge-muted { background: #e5e7eb; color: #374151; }
.badge-holiday { background: #fde68a; color: #92400e; }
.row-holiday { background: #fde68a; }

html[lang="en"], html[lang="en"] body {
    font-family: Inter, "Segoe UI", sans-serif;
}

.brand-logo {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    object-fit: cover;
    background: #fff;
}

.nav-link {
    position: relative;
}
.nav-link.active {
    background: rgba(255,255,255,.22);
}
.nav-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-inline-start: 4px;
}

.dropdown { position: relative; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-end: 0;
    width: 280px;
    background: #fff;
    color: var(--text);
    border-radius: 14px;
    box-shadow: var(--shadow);
    overflow: hidden;
    z-index: 50;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item {
    display: block;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    font-size: .9rem;
}
.dropdown-item strong { display: block; }
.dropdown-item.unread { background: #f0fdfa; }
.dropdown-empty { padding: 14px; color: var(--muted); }

.check-line {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0;
    font-weight: 700;
}
.check-line input { width: auto; }

.inline-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}
.inline-actions input { width: 140px; padding: 8px; }

textarea { margin-bottom: 8px; }

.sheet-card {
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.sheet-card .card-body {
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    padding: 16px;
    flex-grow: 1;
}

/* 
  تعديل: جعل حاوية الجدول تملأ الشاشة بالكامل عمودياً 
  وتغيير أقصى ارتفاع ليكون ديناميكياً مع الشاشة 
*/
.sheet-wrap {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: auto;
    height: calc(100vh - 120px); /* يأخذ كامل ارتفاع الشاشة مع ترك مساحة صغيرة للرأسيات */
    max-height: calc(100vh - 120px);
    border: 1px solid #94a3b8;
    border-radius: 10px;
    background: #fff;
    -webkit-overflow-scrolling: touch;
}
.sheet-table {
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    width: 100%;
    min-width: 100%;
    font-size: 12px;
}
.sheet-table th,
.sheet-table td {
    box-sizing: border-box;
    border-bottom: 1px solid #64748b;
    border-inline-end: 1px solid #64748b;
    text-align: center;
    vertical-align: middle;
    padding: 0 2px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.sheet-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #0f2744;
    color: #fff;
    font-weight: 800;
    height: 48px;
    line-height: 1.15;
}
.sheet-table .name-col {
    position: sticky;
    inset-inline-start: 0;
    z-index: 4;
    background: #0f2744;
    color: #fff;
    text-align: start;
    padding-inline: 10px;
    font-weight: 800;
    width: 240px;
    min-width: 240px;
}
.sheet-table thead .name-col {
    z-index: 6;
    background: #0b1c31;
}
.sheet-table tbody .name-col {
    background: #f8fafc;
    color: var(--navy);
    z-index: 5;
    box-shadow: 4px 0 8px rgba(15,39,68,.08);
}
.sheet-table tbody tr:nth-child(even) .name-col {
    background: #eef2f7;
}
.sheet-table .cell-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
    font-weight: 800;
    line-height: 36px;
    height: 36px;
}
.sheet-table th.col-weekend { background: #6b1d3a; }
.sheet-table th.col-holiday { background: #7a4f0b; }
.cell-present { background: #dcfce7; color: #166534; }
.cell-late { background: #fef3c7; color: #92400e; }
.cell-absent { background: #fee2e2; color: #991b1b; }
.cell-weekend { background: #fce7f3; color: #9f1239; }
.cell-holiday { background: #fde68a; color: #92400e; }
.cell-leave { background: #dbeafe; color: #1e40af; }
.cell-leave .cell-text {
    white-space: nowrap;
    font-size: 10px;
}
.cell-future { background: #f8fafc; color: #94a3b8; }
.day-sub { display: block; font-size: 9px; opacity: .85; font-weight: 600; line-height: 1.2; }
.rank-card { position: relative; }
.rank-card.gold { outline: 2px solid #fbbf24; }

.section-title {
    margin: 0 0 14px;
    font-size: 1.15rem;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,.1);
    padding: 6px 10px;
    border-radius: 999px;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gold);
    color: #111;
    display: grid;
    place-items: center;
    font-weight: 800;
}

.filters {
    display: grid;
    grid-template-columns: 180px 1fr 180px 180px auto;
    gap: 10px;
    align-items: end;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

@media (max-width: 980px) {
    .stats, .layout, .form-grid, .filters, .copy-grid {
        grid-template-columns: 1fr 1fr;
    }
    .top-meta { display: none; }
}

@media (max-width: 640px) {
    .stats, .layout, .form-grid, .filters, .page-title, .pw-grid, .copy-grid {
        grid-template-columns: 1fr;
        display: grid;
    }
    .topbar-inner { flex-wrap: wrap; }
    .hero-time .clock { font-size: 1.8rem; }
}