/* ===== نظام الحضور والانصراف ===== */
:root {
    --primary: #1e3a5f; --primary-2: #0f766e; --bg: #f1f5f9; --card: #fff; --border: #e2e8f0;
    --text: #1e293b; --muted: #64748b; --green: #16a34a; --amber: #d97706; --red: #dc2626; --blue: #2563eb;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', Tahoma, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--blue); }

/* الشريط العلوي */
.topbar { background: var(--primary); color: #fff; display: flex; align-items: center; gap: 16px; padding: 0 20px; min-height: 58px; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 16px; white-space: nowrap; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a { color: #cbd5e1; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 600; white-space: nowrap; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: rgba(255,255,255,.16); color: #fff; }
.user { display: flex; gap: 10px; align-items: center; color: #cbd5e1; }
.user a { text-decoration: none; font-size: 18px; }
.nav-toggle { display: none; background: none; border: none; color: #fff; font-size: 22px; cursor: pointer; margin-inline-start: auto; }
@media (max-width: 860px) {
    .nav-toggle { display: block; }
    .nav, .user { display: none; width: 100%; }
    .nav-open .nav { display: flex; flex-direction: column; padding-bottom: 8px; }
    .nav-open .user { display: flex; padding-bottom: 12px; }
}

.container { max-width: 1200px; margin: 0 auto; padding: 20px 16px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }

/* عناصر عامة */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { font-size: 20px; margin: 0; color: var(--primary); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.card h2 { font-size: 16px; margin: 0 0 12px; color: var(--primary); }
.muted { color: var(--muted); font-size: 12.5px; }
.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 600; }
.flash.success { background: #dcfce7; color: #166534; }
.flash.error { background: #fee2e2; color: #991b1b; }
.warn-bar { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-weight: 600; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: none; border-radius: 8px; padding: 8px 14px; font-weight: 700; font-size: 13.5px; cursor: pointer; text-decoration: none; font-family: inherit; background: #e2e8f0; color: #1e293b; }
.btn:hover { filter: brightness(.95); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
input[type=text], input[type=number], input[type=time], input[type=date], input[type=month], input[type=password], input[type=search], input[type=tel], select, textarea {
    padding: 8px 10px; border: 1.5px solid #cbd5e1; border-radius: 7px; font-size: 14px; font-family: inherit; background: #fff; max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; }
.grid .full { grid-column: 1 / -1; }
.field label { display: block; font-weight: 700; font-size: 13px; margin-bottom: 5px; color: #334155; }
.field input, .field select, .field textarea { width: 100%; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.6; }
.checks { display: flex; gap: 18px; flex-wrap: wrap; }
.checks label, .days label { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; cursor: pointer; }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.days label { padding: 5px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-weight: 500; }

/* جداول */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; background: #fff; }
.table th { background: #f8fafc; text-align: right; font-size: 12.5px; color: #475569; padding: 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table .num { text-align: center; font-variant-numeric: tabular-nums; }
.table tr.row-muted td { background: #f8fafc; color: #94a3b8; }
.table tr.row-absent td { background: #fef2f2; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.pill.ok { background: #dcfce7; color: #166534; }
.pill.info { background: #dbeafe; color: #1e40af; }
.pill.warn { background: #fef3c7; color: #92400e; }
.pill.bad { background: #fee2e2; color: #991b1b; }
.pill.gray { background: #f1f5f9; color: #475569; }
.pill.purple { background: #ede9fe; color: #5b21b6; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; }
.stat .lbl { font-size: 12px; color: var(--muted); }
.stat .val { font-size: 26px; font-weight: 800; color: var(--primary); }
.stat.green .val { color: var(--green); } .stat.amber .val { color: var(--amber); } .stat.red .val { color: var(--red); } .stat.blue .val { color: var(--blue); }

details.fix summary { cursor: pointer; color: var(--blue); font-size: 13px; }
details.fix form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }

/* صفحة الدخول */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: linear-gradient(160deg, var(--primary), var(--primary-2)); }
.auth .box { background: #fff; border-radius: 18px; padding: 28px 24px; width: 100%; max-width: 380px; box-shadow: 0 24px 60px rgba(0,0,0,.25); }
.auth h1 { text-align: center; font-size: 20px; color: var(--primary); margin: 0 0 18px; }
.auth .field { margin-bottom: 12px; }
.auth .btn { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }

@media print { .topbar, .toolbar, .no-print, .footer { display: none !important; } .card { border: none; } }
