/* Cashback Attendance Management System — RTL design system */
:root {
  --brand: #0d9488; --brand-600: #0f766e; --brand-700: #115e59; --brand-50: #ecfdf9; --brand-100: #ccfbef;
  --navy: #0b1324; --navy-2: #111c33; --navy-3: #1b2a4a;
  --bg: #f3f5fa; --card: #ffffff; --text: #0f172a; --muted: #64748b; --line: #e6eaf2; --line-2: #f0f3f8;
  --ok: #16a34a; --ok-bg: #dcfce7; --warn: #d97706; --warn-bg: #fef3c7; --bad: #dc2626; --bad-bg: #fee2e2;
  --info: #2563eb; --info-bg: #dbeafe; --violet: #7c3aed; --violet-bg: #ede9fe; --gray-bg: #f1f5f9;
  --radius: 14px; --radius-sm: 10px; --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.06);
  --shadow-lg: 0 20px 50px rgba(2,6,23,.18); --sidebar: 268px;
  --font: 'Cairo', 'Segoe UI', Tahoma, system-ui, sans-serif;
}
[data-theme="dark"] {
  --bg: #0a1020; --card: #111a2e; --text: #e5eaf5; --muted: #8b98b4; --line: #1f2b45; --line-2: #18233a;
  --gray-bg: #1a2540; --brand-50: #0d2a2a; --brand-100: #12403d;
  --ok-bg: #0f2e1c; --warn-bg: #33250b; --bad-bg: #3a1414; --info-bg: #0f1f3d; --violet-bg: #221a3d;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14.5px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--brand-600); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; vertical-align: middle; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }
.mono { font-family: Consolas, 'Courier New', monospace; direction: ltr; unicode-bidi: embed; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0; width: var(--sidebar); z-index: 40;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%); color: #cbd5e1;
  display: flex; flex-direction: column; transition: transform .25s ease;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-logo { width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(135deg, #14b8a6, #0f766e); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px; box-shadow: 0 6px 18px rgba(20,184,166,.35); }
.brand-name { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.25; }
.brand-sub { font-size: 11px; color: #7f8db0; letter-spacing: .2px; }
.nav { flex: 1; overflow-y: auto; padding: 12px 12px 20px; }
.nav-section { font-size: 11px; color: #64749a; padding: 14px 12px 6px; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin: 2px 0; border-radius: 10px; color: #b6c2dc; font-weight: 500; transition: background .15s, color .15s; }
.nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav a.active { background: linear-gradient(90deg, rgba(20,184,166,.18), rgba(20,184,166,.06)); color: #fff; box-shadow: inset -3px 0 0 #14b8a6; }
.nav a.active svg { color: #2dd4bf; }
.sidebar-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.06); font-size: 12px; color: #7f8db0; }
.main { flex: 1; margin-inline-start: var(--sidebar); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: 66px; background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 24px; }
.topbar .title { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; position: relative; color: var(--text); }
.icon-btn:hover { background: var(--gray-bg); }
.icon-btn .dot { position: absolute; top: 6px; inset-inline-end: 6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; }
.menu-toggle { display: none; }
.search-box { position: relative; width: min(360px, 40vw); }
.search-box input { width: 100%; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--gray-bg); padding: 0 40px 0 12px; outline: none; }
.search-box input:focus { border-color: var(--brand); background: var(--card); box-shadow: 0 0 0 3px var(--brand-100); }
.search-box > svg { position: absolute; top: 11px; inset-inline-start: 12px; color: var(--muted); }
.dropdown { position: absolute; top: calc(100% + 8px); inset-inline-end: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); min-width: 280px; z-index: 50; overflow: hidden; }
.search-box .dropdown { inset-inline: 0; }
.dd-item { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line-2); cursor: pointer; color: var(--text); }
.dd-item:hover { background: var(--gray-bg); }
.dd-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; font-weight: 700; border-bottom: 1px solid var(--line); }
.notif-list { max-height: 420px; overflow-y: auto; width: min(380px, 92vw); }
.notif { padding: 12px 14px; border-bottom: 1px solid var(--line-2); display: flex; gap: 10px; }
.notif.unread { background: var(--brand-50); }
.notif .n-title { font-weight: 600; font-size: 13.5px; }
.notif .n-body { font-size: 12.5px; color: var(--muted); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); cursor: pointer; position: relative; }
.user-chip .meta { line-height: 1.2; }
.user-chip .meta b { font-size: 13px; display: block; }
.user-chip .meta span { font-size: 11px; color: var(--muted); }
.content { padding: 24px; max-width: 1600px; width: 100%; margin: 0 auto; }
.demo-banner { background: repeating-linear-gradient(45deg, #fef3c7, #fef3c7 12px, #fde68a 12px, #fde68a 24px); color: #78350f; text-align: center; font-weight: 700; padding: 6px; font-size: 13px; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 800; }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- cards / grid ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.card-h h3 { margin: 0; font-size: 15.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-b { padding: 18px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); margin-bottom: 18px; }
.g2 { grid-template-columns: 2fr 1fr; }
.g2e { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.kpi { padding: 16px 18px; display: flex; gap: 14px; align-items: center; position: relative; overflow: hidden; }
.kpi .ic { width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; flex-shrink: 0; }
.kpi .ic svg { width: 23px; height: 23px; }
.kpi .v { font-size: 26px; font-weight: 800; line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi .s { font-size: 11.5px; color: var(--muted); }
.kpi.clickable { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.kpi.clickable:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(16,24,40,.1); }
.c-brand { background: var(--brand-50); color: var(--brand-600); }
.c-ok { background: var(--ok-bg); color: var(--ok); }
.c-bad { background: var(--bad-bg); color: var(--bad); }
.c-warn { background: var(--warn-bg); color: var(--warn); }
.c-info { background: var(--info-bg); color: var(--info); }
.c-violet { background: var(--violet-bg); color: var(--violet); }
.c-gray { background: var(--gray-bg); color: var(--muted); }
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 230px; }
.tabs { display: inline-flex; background: var(--gray-bg); border-radius: 10px; padding: 3px; gap: 2px; }
.tabs button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.progress { height: 8px; background: var(--gray-bg); border-radius: 6px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, #14b8a6, #0f766e); border-radius: 6px; }

/* ---------- buttons / forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, box-shadow .15s, opacity .15s; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand-600); color: #fff; box-shadow: 0 4px 12px rgba(13,148,136,.25); }
.btn-primary:hover:not(:disabled) { background: var(--brand-700); }
.btn-light { background: var(--card); border-color: var(--line); color: var(--text); }
.btn-light:hover:not(:disabled) { background: var(--gray-bg); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--gray-bg); color: var(--text); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 34px; padding: 0; height: 34px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input { height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--card); outline: none; width: 100%; transition: border .15s, box-shadow .15s; }
textarea.input { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.filters .input { width: auto; min-width: 150px; }
.filters .grow { flex: 1; min-width: 200px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; user-select: none; }
.check input { accent-color: var(--brand-600); }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: separate; border-spacing: 0; }
.t th { position: sticky; top: 0; background: var(--gray-bg); color: var(--muted); font-weight: 700; font-size: 12.5px; text-align: start; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.t tbody tr:hover td { background: color-mix(in srgb, var(--brand-50) 55%, transparent); }
.t tr.clickable { cursor: pointer; }
.t tfoot td { font-weight: 700; background: var(--gray-bg); }
.person { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.person b { display: block; font-weight: 600; line-height: 1.3; }
.person span { font-size: 12px; color: var(--muted); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; flex-shrink: 0; object-fit: cover; background: #94a3b8; }
.avatar.lg { width: 84px; height: 84px; font-size: 28px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-bad { background: var(--bad-bg); color: var(--bad); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-info { background: var(--info-bg); color: var(--info); }
.b-violet { background: var(--violet-bg); color: var(--violet); }
.b-gray { background: var(--gray-bg); color: var(--muted); }
.b-brand { background: var(--brand-50); color: var(--brand-600); }
.empty { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty svg { width: 42px; height: 42px; color: #cbd5e1; margin-bottom: 8px; }
.empty b { display: block; color: var(--text); margin-bottom: 2px; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; gap: 10px; flex-wrap: wrap; }
.punch-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--gray-bg); direction: ltr; }
.chip.manual { background: var(--warn-bg); color: var(--warn); }

/* ---------- feed ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--line-2); }
.feed li:last-child { border-bottom: 0; }
.feed .when { margin-inline-start: auto; text-align: end; font-size: 12.5px; color: var(--muted); white-space: nowrap; }

/* ---------- modal / drawer / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(2,6,23,.5); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; animation: fade .15s; }
.modal { background: var(--card); border-radius: 16px; width: min(640px, 100%); box-shadow: var(--shadow-lg); animation: pop .18s ease-out; }
.modal.wide { width: min(920px, 100%); }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-h h3 { margin: 0; font-size: 17px; }
.modal-b { padding: 20px; }
.modal-f { display: flex; justify-content: flex-start; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--gray-bg); border-radius: 0 0 16px 16px; }
.drawer-overlay { justify-content: flex-start; padding: 0; align-items: stretch; }
.drawer { background: var(--card); width: min(520px, 100%); height: 100vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: slide .2s ease-out; }
.toasts { position: fixed; bottom: 20px; inset-inline-start: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center; min-width: 260px; max-width: 420px; animation: pop .2s; }
.toast.ok svg { color: #4ade80; } .toast.err { background: #7f1d1d; } .toast.warn svg { color: #fbbf24; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes slide { from { transform: translateX(-30px); opacity: 0; } }
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner.dark { border-color: var(--line); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: grid; place-items: center; padding: 60px; }
.alert { padding: 12px 14px; border-radius: 10px; display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.alert-warn { background: var(--warn-bg); color: #92400e; } .alert-bad { background: var(--bad-bg); color: #991b1b; }
.alert-ok { background: var(--ok-bg); color: #166534; } .alert-info { background: var(--info-bg); color: #1e40af; }
[data-theme="dark"] .alert-warn { color: #fcd34d; } [data-theme="dark"] .alert-bad { color: #fca5a5; } [data-theme="dark"] .alert-ok { color: #86efac; } [data-theme="dark"] .alert-info { color: #93c5fd; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; }
.stat-line { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.stat-line:last-child { border-bottom: 0; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: radial-gradient(circle at 20% 20%, rgba(45,212,191,.25), transparent 40%), radial-gradient(circle at 80% 70%, rgba(99,102,241,.25), transparent 45%), linear-gradient(160deg, #0b1324, #12224a); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art h2 { font-size: 34px; margin: 0 0 12px; line-height: 1.35; }
.login-art p { color: #a9b6d3; max-width: 460px; }
.login-feats { display: grid; gap: 14px; margin-top: 30px; }
.login-feats div { display: flex; gap: 12px; align-items: center; color: #dbe4f5; }
.login-feats svg { color: #2dd4bf; }
.login-form-wrap { display: grid; place-items: center; padding: 32px; background: var(--card); }
.login-form { width: min(400px, 100%); }
.login-form h1 { margin: 0 0 4px; font-size: 26px; }
.login-form .field { margin-bottom: 14px; }
.login-form .input { height: 46px; }
.login-form .btn { width: 100%; height: 46px; margin-top: 8px; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) { .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 1024px) {
  .sidebar { transform: translateX(100%); visibility: hidden; transition: transform .25s ease, visibility 0s .25s; }
  .app.nav-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-lg); transition: transform .25s ease; }
  .app.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(2,6,23,.45); z-index: 35; }
  .main { margin-inline-start: 0; }
  .menu-toggle { display: inline-grid; }
  .g2, .g2e { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .content { padding: 14px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .search-box { width: auto; flex: 1; }
  .topbar .title { display: none; }
  .user-chip .meta { display: none; }
  .user-chip { padding: 4px; }
  .form-grid, .g3 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px; gap: 10px; flex-direction: column; align-items: flex-start; }
  .kpi .v { font-size: 22px; }
  .kpi .ic { width: 38px; height: 38px; }
  .login-page { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .page-head h1 { font-size: 19px; }
  .filters .input { min-width: 0; flex: 1 1 140px; }
}
@media print {
  .sidebar, .topbar, .no-print, .filters, .toasts, .demo-banner { display: none !important; }
  .main { margin: 0; } .content { padding: 0; } .card { box-shadow: none; border: 0; }
  body { background: #fff; }
}
