/* Visual language shared with the revenue dashboard: deep emerald stage, paper sheets, gold hairlines, Amiri headings. */
:root {
  --ink: #22291f; --emerald-900: #0c2f24; --emerald-700: #12432f; --emerald-500: #1f6f4a; --gold-500: #c9962c; --gold-300: #e7c877;
  --paper: #faf7ef; --paper-line: #e4ddc9; --sage: #dce3d5; --stone: #7d8577; --cream: #f4efe0;
  --ok: #1f6f4a; --ok-bg: #dce8d9; --bad: #a4432a; --bad-bg: #f3dfd8; --warn: #8a6410; --warn-bg: #f6ebcf; --info: #3f5866; --info-bg: #e0e8ec; --mute-bg: #efeadb;
  --card-shadow: 0 14px 30px -16px rgba(0,0,0,.45), 0 0 0 1px rgba(201,150,44,.14);
  --head-grad: linear-gradient(135deg, #0c2f24, #12432f 60%, #0e3a29);
  --gold-grad: linear-gradient(160deg, #e7c877, #c9962c);
  --serif: 'Amiri', 'Traditional Arabic', Georgia, serif; --sans: 'Tajawal', 'Segoe UI', Tahoma, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; min-height: 100vh; color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.6;
  background: radial-gradient(circle at 15% 10%, #143b2b 0%, transparent 45%), radial-gradient(circle at 85% 90%, #143b2b 0%, transparent 45%), #0a1f17;
  background-attachment: fixed;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.3; font-family: var(--serif); }
h1 { font-size: 1.6rem; color: var(--cream); } h2 { font-size: 1.2rem; color: var(--emerald-900); } h3 { font-size: 1.05rem; color: var(--emerald-900); }
a { color: var(--emerald-500); }
::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: rgba(201,150,44,.4); border-radius: 10px; }

#busy { position: fixed; inset-inline: 0; top: 0; height: 3px; background: linear-gradient(90deg, transparent, var(--gold-300), transparent); background-size: 40% 100%; background-repeat: no-repeat; opacity: 0; z-index: 99; animation: slide 1s linear infinite; }
#busy.on { opacity: 1; }
@keyframes slide { from { background-position: -40% 0; } to { background-position: 140% 0; } }

#toasts { position: fixed; z-index: 120; inset-inline: 0; bottom: 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: var(--head-grad); color: var(--cream); padding: 11px 18px; border-radius: 12px; box-shadow: 0 20px 40px -18px rgba(0,0,0,.6), 0 0 0 1px rgba(201,150,44,.35); max-width: 560px; pointer-events: auto; }
.toast.err { background: linear-gradient(135deg, #7d2f1c, #a4432a); }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 262px minmax(0, 1fr); gap: 20px; padding: 22px; min-height: 100vh; max-width: 1700px; margin: 0 auto; }
.side { background: var(--head-grad); color: #cfe0d6; border-radius: 16px; padding: 18px 12px; position: sticky; top: 22px; height: calc(100vh - 44px); overflow-y: auto; box-shadow: 0 20px 40px -18px rgba(0,0,0,.5), 0 0 0 1px rgba(201,150,44,.15); }
.side::after { content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 5px; background: linear-gradient(90deg, var(--gold-500), var(--gold-300), var(--gold-500)); }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 16px; color: var(--cream); font-family: var(--serif); font-weight: 700; font-size: 1.15rem; }
.brand i { width: 42px; height: 42px; border-radius: 10px; background: var(--gold-grad); display: grid; place-items: center; font-style: normal; color: var(--emerald-900); font-family: var(--serif); font-weight: 700; font-size: 1.15rem; flex: none; }
.nav-sec { font-size: .72rem; letter-spacing: .08em; color: var(--gold-300); opacity: .8; padding: 16px 10px 4px; font-weight: 700; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 9px; color: #cfe0d6; text-decoration: none; font-weight: 500; transition: background .2s, transform .15s; }
.nav a:hover { background: rgba(231,200,119,.12); transform: translateX(-2px); }
[dir="ltr"] .nav a:hover { transform: translateX(2px); }
.nav a.on { background: var(--gold-grad); color: var(--emerald-900); font-weight: 800; }
.nav a span.ic { width: 20px; text-align: center; }
.main { min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.top { display: flex; align-items: center; gap: 10px; padding: 14px 24px; background: var(--head-grad); border-radius: 16px; position: sticky; top: 22px; z-index: 5; color: var(--cream); box-shadow: 0 20px 40px -18px rgba(0,0,0,.5), 0 0 0 1px rgba(201,150,44,.15); }
.top::after { content: ""; position: absolute; inset-inline: 16px; bottom: 0; height: 3px; border-radius: 3px; background: linear-gradient(90deg, var(--gold-500), var(--gold-300), var(--gold-500)); }
.top .grow { flex: 1; }
.top .muted { color: #c9d6ca; }
.top .btn { background: rgba(255,255,255,.05); border: 1px solid rgba(231,200,119,.35); color: var(--gold-300); }
.top .btn:hover { background: rgba(231,200,119,.14); }
.menu-btn { display: none; }
.view { width: 100%; padding-bottom: 40px; }
.page-h { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-h .grow { flex: 1; } .page-h .muted { color: #a9bdb0; } .page-h h2 { color: var(--cream); }

/* ---------- paper components ---------- */
.card, .stat, .slip { background: var(--paper); border-radius: 16px; box-shadow: var(--card-shadow); position: relative; }
.card { padding: 22px 24px; margin-bottom: 20px; overflow: hidden; }
.card::before { content: ""; position: absolute; inset: 0; pointer-events: none; background-image: repeating-linear-gradient(0deg, rgba(15,61,46,.03) 0, rgba(15,61,46,.03) 1px, transparent 1px, transparent 34px); }
.card > * { position: relative; }
.card > h2, .card > h3 { margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { border-radius: 14px; padding: 18px 20px; overflow: hidden; }
.stat::after { content: ""; position: absolute; inset-inline-end: 0; top: 0; bottom: 0; width: 4px; background: var(--gold-500); }
.stat b { display: block; font-family: var(--serif); font-size: 1.9rem; line-height: 1.15; color: var(--emerald-900); direction: ltr; text-align: start; }
[dir="rtl"] .stat b { text-align: right; }
.stat span { color: #7a8371; font-size: .8rem; font-weight: 700; letter-spacing: .3px; }
.stat.ok::after { background: var(--emerald-500); } .stat.bad::after { background: var(--bad); } .stat.warn::after { background: var(--gold-500); } .stat.info::after { background: #3f5866; }
.stat.bad b { color: var(--bad); } .stat.ok b { color: var(--ok); }

.btn { border: 1px solid var(--paper-line); background: #fff; padding: 9px 16px; border-radius: 9px; cursor: pointer; font-weight: 700; font-size: .9rem; color: var(--emerald-900); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; transition: background .2s, transform .15s, box-shadow .2s; }
.btn:hover { background: var(--sage); transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: wait; transform: none; }
.btn.primary { background: var(--head-grad); border-color: var(--emerald-700); color: var(--gold-300); box-shadow: 0 8px 18px -10px rgba(12,47,36,.7); }
.btn.primary:hover { filter: brightness(1.12); background: var(--head-grad); }
.btn.danger { background: linear-gradient(135deg, #7d2f1c, #a4432a); border-color: #7d2f1c; color: #fff; }
.btn.ok { background: linear-gradient(135deg, #12432f, #1f6f4a); border-color: #12432f; color: #fff; }
.btn.sm { padding: 4px 11px; font-size: .8rem; } .btn.big { padding: 20px 34px; font-size: 1.3rem; border-radius: 16px; font-family: var(--serif); }
.page-h .btn:not(.primary):not(.danger):not(.ok), .tabs + .page-h .btn { background: rgba(255,255,255,.05); border-color: rgba(231,200,119,.35); color: var(--gold-300); }
.page-h .btn:not(.primary):not(.danger):not(.ok):hover { background: rgba(231,200,119,.14); }
.page-h .btn.primary { background: var(--gold-grad); color: var(--emerald-900); border-color: var(--gold-500); }

.row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.row.center { align-items: center; }
.fld { display: flex; flex-direction: column; gap: 5px; min-width: 150px; flex: 1; }
.fld label { font-size: .8rem; color: #5a6353; font-weight: 700; }
input, select, textarea { background: #fff; border: 1px solid var(--paper-line); border-radius: 10px; padding: 9px 12px; width: 100%; font-family: var(--sans); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold-500); box-shadow: 0 0 0 3px rgba(201,150,44,.18); }
input[readonly] { background: var(--mute-bg); }
.chk { display: flex; gap: 8px; align-items: center; cursor: pointer; } .chk input { width: auto; accent-color: var(--emerald-500); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.sec-t { grid-column: 1 / -1; font-family: var(--serif); font-size: 1.05rem; font-weight: 700; color: var(--emerald-900); border-bottom: 2px solid var(--gold-300); padding-bottom: 4px; margin-top: 8px; }

.tbl-wrap { overflow: auto; max-height: 68vh; border: 1px solid var(--paper-line); border-radius: 12px; background: #fff; }
.tbl { border-collapse: collapse; width: 100%; font-size: .9rem; }
.tbl th, .tbl td { padding: 9px 12px; border-bottom: 1px solid var(--paper-line); text-align: start; white-space: nowrap; }
.tbl th { background: var(--sage); color: var(--emerald-900); position: sticky; top: 0; font-weight: 800; z-index: 1; }
.tbl tbody tr:nth-child(even) td { background: rgba(250,247,239,.6); }
.tbl tr:hover td { background: rgba(201,150,44,.09) !important; }
.tbl td.n, .tbl th.n { text-align: end; font-variant-numeric: tabular-nums; direction: ltr; }
.tbl td.wrap { white-space: normal; min-width: 200px; }
.tbl input.cell { padding: 4px 6px; width: 86px; text-align: end; direction: ltr; border-radius: 7px; }
.tbl tfoot td { font-weight: 800; background: var(--sage); color: var(--emerald-900); }
.empty { padding: 28px; text-align: center; color: var(--stone); }
.badge { display: inline-block; padding: 2px 11px; border-radius: 99px; font-size: .76rem; font-weight: 800; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.info { background: var(--info-bg); color: var(--info); } .badge.mute { background: var(--mute-bg); color: var(--stone); }
.top .badge.info { background: rgba(231,200,119,.18); color: var(--gold-300); }

.tabs { display: flex; gap: 6px; background: rgba(255,255,255,.06); padding: 5px; border-radius: 12px; margin-bottom: 16px; flex-wrap: wrap; width: fit-content; max-width: 100%; }
.tabs button { border: 0; background: none; padding: 8px 16px; cursor: pointer; border-radius: 8px; color: #cfe0d6; font-weight: 700; }
.tabs button:hover { background: rgba(231,200,119,.1); }
.tabs button.on { background: var(--gold-grad); color: var(--emerald-900); }
.note { background: var(--info-bg); color: var(--info); padding: 12px 16px; border-radius: 12px; margin-bottom: 14px; border: 1px solid rgba(63,88,102,.15); }
.note.warn { background: var(--warn-bg); color: var(--warn); border-color: rgba(201,150,44,.35); } .note.bad { background: var(--bad-bg); color: var(--bad); border-color: rgba(164,67,42,.3); }
.muted { color: var(--stone); } .nowrap { white-space: nowrap; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 12px; }

/* ---------- modal ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(5,16,11,.72); backdrop-filter: blur(3px); z-index: 60; display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal { background: var(--paper); border-radius: 18px; width: min(580px, 100%); max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 30px 60px -20px rgba(0,0,0,.6), 0 0 0 1px rgba(201,150,44,.2); overflow: hidden; }
.modal.wide { width: min(1000px, 100%); }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; background: var(--head-grad); color: var(--cream); position: relative; }
.modal-h::after { content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 4px; background: linear-gradient(90deg, var(--gold-500), var(--gold-300), var(--gold-500)); }
.modal-h h3 { color: var(--cream); font-size: 1.2rem; }
.modal-h .x { border: 0; background: none; font-size: 1.7rem; cursor: pointer; line-height: 1; color: var(--gold-300); }
.modal-b { padding: 20px 22px; overflow-y: auto; }
.modal-f { padding: 14px 22px; border-top: 1px solid var(--paper-line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; background: rgba(220,227,213,.35); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: start center; padding: 56px 16px; }
.login { width: min(480px, 100%); padding: 0; border-radius: 18px; box-shadow: 0 30px 60px -20px rgba(0,0,0,.55), 0 0 0 1px rgba(201,150,44,.15); }
.login .head { background: var(--head-grad); color: var(--cream); padding: 32px 36px 28px; display: flex; align-items: center; gap: 16px; position: relative; }
.login .head::after { content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 5px; background: linear-gradient(90deg, var(--gold-500), var(--gold-300), var(--gold-500)); }
.login .head .brand-mark { width: 52px; height: 52px; border-radius: 12px; background: var(--gold-grad); display: grid; place-items: center; font-family: var(--serif); font-weight: 700; font-size: 1.5rem; color: var(--emerald-900); flex: none; }
.login .head .brand-name { font-family: var(--serif); font-size: 1.4rem; font-weight: 700; }
.login .head .brand-sub { font-size: .78rem; color: #c9d6ca; margin-top: 2px; letter-spacing: .4px; }
.login .login-body { padding: 30px 36px 32px; }
.login .login-body .sub { color: #6b7364; font-size: .9rem; margin: 0 0 22px; line-height: 1.8; }
.login .fld { margin-bottom: 14px; }
.login .btn.primary { width: 100%; justify-content: center; padding: 12px; font-size: 1rem; }

/* ---------- punch ---------- */
.punch { text-align: center; padding: 30px 16px; }
.clock { font-family: var(--serif); font-size: 3.6rem; font-weight: 700; font-variant-numeric: tabular-nums; direction: ltr; color: var(--emerald-900); line-height: 1.1; }
.punch .btn.big { min-width: 280px; margin: 16px 0; justify-content: center; }
.punch-list { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; direction: ltr; }
.punch-list span { background: var(--sage); padding: 5px 14px; border-radius: 99px; font-variant-numeric: tabular-nums; color: var(--emerald-900); font-weight: 700; }
.qr-box { display: grid; place-items: center; padding: 14px; text-align: center; }
.qr-code { font-family: var(--serif); font-size: 3.8rem; letter-spacing: .2em; font-weight: 700; direction: ltr; color: var(--emerald-900); }

/* ---------- payslip + print ---------- */
.slip { padding: 22px; box-shadow: none; border: 1px solid var(--paper-line); background: #fff; }
.slip h2 { text-align: center; margin-bottom: 4px; }
.slip .sub { text-align: center; color: var(--stone); margin-bottom: 14px; }
.slip table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.slip th, .slip td { border: 1px solid var(--paper-line); padding: 7px 12px; text-align: start; }
.slip th { background: var(--sage); color: var(--emerald-900); }
.slip td.n { text-align: end; direction: ltr; font-variant-numeric: tabular-nums; }
.slip .net { font-size: 1.25rem; font-weight: 800; background: var(--head-grad); color: var(--gold-300); }
@media print {
  html, body { background: #fff !important; }
  body * { visibility: hidden; }
  .printable, .printable * { visibility: visible; }
  .printable { position: absolute; inset: 0 0 auto 0; border: 0; }
  .backdrop { background: none; position: static; backdrop-filter: none; }
}

@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; padding: 14px; gap: 14px; }
  .side { position: fixed; inset-block: 14px; inset-inline-start: 14px; width: 270px; height: auto; z-index: 40; transform: translateX(120%); transition: transform .22s; }
  [dir="ltr"] .side { transform: translateX(-120%); }
  .side.open { transform: none !important; }
  .menu-btn { display: inline-flex; }
  .top { top: 14px; padding: 12px 16px; }
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) { .g2, .g3, .g4 { grid-template-columns: 1fr 1fr; } .clock { font-size: 2.8rem; } .punch .btn.big { min-width: 100%; } .card { padding: 16px; } .login .head, .login .login-body { padding-inline: 22px; } }
