:root {
  --bg: #f4f2ee; --panel: #ffffff; --ink: #1d2327; --muted: #69727a; --line: #e2ded6;
  --brand: #0f5c4d; --brand-ink: #ffffff; --brand-soft: #e3efeb;
  --ok: #1d7a46; --ok-soft: #e2f3e8; --warn: #9a6400; --warn-soft: #fbf0d9;
  --bad: #b3261e; --bad-soft: #fbe5e3; --info: #2a5d9f; --info-soft: #e5eef9;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  font-family: "Noto Sans Arabic", "Segoe UI", Tahoma, "Geeza Pro", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.55; }
a { color: var(--brand); }
h1 { font-size: 1.35rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }

.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--brand); color: var(--brand-ink); padding: 1.25rem 1rem; position: sticky; top: 0; height: 100vh; overflow: auto; }
.side .who { font-size: .85rem; opacity: .85; margin-bottom: 1.25rem; border-bottom: 1px solid rgba(255,255,255,.2); padding-bottom: 1rem; }
.side .who strong { display: block; font-size: 1rem; opacity: 1; }
.side .badge-role { display: inline-block; margin-top: .35rem; background: rgba(255,255,255,.18); border-radius: 99px; padding: 0 .6rem; font-size: .75rem; }
.nav { display: flex; flex-direction: column; gap: .2rem; }
.nav button { all: unset; cursor: pointer; padding: .55rem .75rem; border-radius: 8px; font-size: .95rem; }
.nav button:hover { background: rgba(255,255,255,.1); }
.nav button[aria-current="page"] { background: #fff; color: var(--brand); font-weight: 600; }
.nav button:focus-visible { outline: 2px solid #fff; }
.side .logout { margin-top: 1.5rem; width: 100%; background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4); }
main { padding: 1.5rem 2rem 3rem; max-width: 1200px; width: 100%; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: .82rem; }
.kpi .value { font-size: 1.45rem; font-weight: 700; margin-top: .15rem; }
.kpi.pos .value { color: var(--ok); } .kpi.neg .value { color: var(--bad); }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: start; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; background: #faf9f6; }
tr.clickable { cursor: pointer; } tr.clickable:hover td { background: #faf9f6; }
.table-wrap { overflow-x: auto; }

form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .8rem; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }
input, select, textarea { width: 100%; font: inherit; padding: .55rem .65rem; border: 1px solid #cfc9bd; border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: .8rem; }
.check { display: flex; align-items: center; gap: .5rem; color: var(--ink); font-size: .95rem; }
.check input { width: auto; }

button, .btn { font: inherit; cursor: pointer; border-radius: 8px; padding: .5rem 1rem; border: 1px solid var(--brand); background: var(--brand); color: #fff; text-decoration: none; display: inline-block; }
button.secondary, .btn.secondary { background: #fff; color: var(--brand); }
button.danger { background: var(--bad); border-color: var(--bad); }
button.ok { background: var(--ok); border-color: var(--ok); }
button.small { padding: .25rem .6rem; font-size: .85rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.toolbar > div { min-width: 140px; }

.status { display: inline-block; padding: .05rem .6rem; border-radius: 99px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.status.draft, .status.recorded, .status.pending { background: #eceae4; color: #555; }
.status.submitted { background: var(--info-soft); color: var(--info); }
.status.approved, .status.verified { background: var(--ok-soft); color: var(--ok); }
.status.rejected { background: var(--bad-soft); color: var(--bad); }

.notice { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.info { background: var(--info-soft); color: var(--info); }

.bar { height: 8px; background: var(--brand-soft); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); }

#toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .6rem 1.1rem; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20; }
#toast.show { opacity: 1; } #toast.bad { background: var(--bad); }

.dialog-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; z-index: 10; overflow: auto; }
.dialog { background: var(--panel); border-radius: var(--radius); width: min(980px, 100%); padding: 1.25rem; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.dialog header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(400px, 100%); }
.login-card .brand { color: var(--brand); font-weight: 700; font-size: 1.2rem; margin-bottom: 1rem; }

.empty { color: var(--muted); padding: 1rem 0; text-align: center; }
.files { display: flex; flex-direction: column; gap: .4rem; }
.file-item { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px; }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: .75rem; }
  .side .who { margin-bottom: .5rem; padding-bottom: .5rem; }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav button { white-space: nowrap; }
  .side .logout { margin-top: .5rem; width: auto; }
  main { padding: 1rem; }
}
