/* LIMO ERP — one stylesheet. Arabic, right-to-left. Calm surfaces and roomy rows: people read these screens all day,
   so contrast is kept for what matters (figures, states, the one main action) and everything else stays quiet. */
:root {
  --ground: #eef1f5;
  --surface: #ffffff;
  --ink: #16202e;
  --muted: #46536a;
  --line: #e1e6ed;
  --line-soft: #eef1f5;
  --petrol: #0f2440;          /* the main colour: navy */
  --petrol-deep: #0b1b31;
  --petrol-tint: #e8eef7;
  --navy-2: #15335a;
  --link: #2b5a94;
  --gold: #c9a24a;
  --night: #0f2440;
  --amber: #a35a06;
  --amber-bg: #fdf0d9;
  --amber-mark: #c9a24a;
  --ok: #1f7a4d;
  --ok-bg: #e4f3ea;
  --bad: #b42318;
  --bad-bg: #fbe5e2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 36, 64, .05);
  --font: "Noto Sans Arabic", "Segoe UI", Tahoma, "Geeza Pro", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 17px; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--ground); line-height: 1.7; -webkit-font-smoothing: antialiased; }
h1 { font-size: 1.6rem; margin: 0; font-weight: 600; line-height: 1.4; }
h2 { font-size: 1.06rem; margin: 0 0 .7rem; font-weight: 600; }
p { margin: 0 0 .8rem; }
a { color: var(--link); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.boot { padding: 3rem; text-align: center; color: var(--muted); }
:focus-visible { outline: 2px solid var(--petrol); outline-offset: 2px; }

/* ---------------------------------------------------------------- buttons and fields */
.btn { font: inherit; font-weight: 600; padding: .5rem 1.1rem; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block; line-height: 1.5; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--petrol); border-color: var(--petrol); color: #fff; }
.btn.primary:hover { background: var(--petrol-deep); border-color: var(--petrol-deep); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--link); }
.btn.quiet:hover { background: var(--line-soft); }
.btn.small { padding: .18rem .6rem; font-size: .88rem; }
.btn.wide { width: 100%; padding: .6rem; }
.btn:disabled { opacity: .5; cursor: default; }

input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .5rem .7rem; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--petrol-tint); outline-offset: 0; border-color: var(--petrol); }
input:disabled, select:disabled { background: var(--ground); color: var(--muted); }
input[type="checkbox"] { width: auto; margin-inline-end: .5rem; }
.field { display: block; margin-bottom: .85rem; }
.field > span { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.field small { display: block; color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.check { display: flex; align-items: center; margin-bottom: .85rem; }
.field-error, .form-error { color: var(--bad); font-size: .9rem; margin: .3rem 0 .8rem; }
.stack { max-width: 30rem; }
.stack.narrow { max-width: 24rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }

/* ---------------------------------------------------------------- sign-in */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background: var(--night); }
.gate-card { width: min(26rem, 100%); background: var(--surface); border-radius: 10px; padding: 2rem;
  border: 1px solid var(--line); border-top: 4px solid var(--gold); border-radius: 14px; box-shadow: 0 10px 30px rgba(15, 36, 64, .08); }
.gate-brand { margin-bottom: 1.4rem; }
.gate-brand strong { display: block; font-size: 1.5rem; letter-spacing: .02em; }
.gate-brand span { color: var(--muted); font-size: .9rem; }
.gate-card h1 { font-size: 1.15rem; margin-bottom: 1rem; }
.gate-alt { margin: 1.2rem 0 0; font-size: .9rem; color: var(--muted); }
.companies { display: grid; gap: .5rem; }
.company { font: inherit; text-align: start; padding: .75rem 1rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.company:hover { border-color: var(--petrol); }
.company span { color: var(--muted); font-size: .88rem; }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 17rem 1fr; min-height: 100vh; }
.side { background: var(--night); color: #c9d4e3; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: .75rem; align-items: center; padding: 1.15rem 1.25rem 1rem; }
.brand .logo { width: 2.4rem; height: 2.4rem; border-radius: 10px; background: var(--gold); color: var(--night); display: grid; place-items: center; font-weight: 700; font-size: 1.2rem; flex: none; }
.brand strong { display: block; color: #fff; font-size: 1.08rem; font-weight: 600; letter-spacing: .02em; }
.brand span { font-size: .8rem; color: #93a4bd; }
.side nav { padding: .25rem .75rem 1rem; flex: 1; overflow-y: auto; }
.side nav a, .side nav .nav-group { display: flex; align-items: center; gap: .7rem; width: 100%; padding: .55rem .75rem; border-radius: 9px; color: #c9d4e3;
  text-decoration: none; font: inherit; font-weight: 500; background: none; border: 0; cursor: pointer; text-align: start; }
.side nav a:hover, .side nav .nav-group:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side nav a.current { background: var(--navy-2); color: #fff; box-shadow: inset -3px 0 0 var(--gold); }
.side nav .nav-group { color: #9fb0c8; margin-top: .3rem; }
.side nav .nav-group .label { flex: 1; }
.side nav .nav-group .chev { transition: transform .15s; opacity: .7; }
.side nav .nav-group[aria-expanded="true"] .chev { transform: rotate(-90deg); }
.side nav .nav-group.has-current { color: #fff; }
.side nav .sub a { padding-inline-start: 2.6rem; font-size: .95rem; }
.side nav .count { background: var(--gold); color: var(--night); font-weight: 700; font-size: .75rem; border-radius: 99px; padding: 0 .5rem; line-height: 1.5; }
.side .foot { padding: .8rem 1.25rem; border-top: 1px solid rgba(255, 255, 255, .08); font-size: .78rem; color: #7f91ab; }
.icon { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .7rem 2rem; position: sticky; top: 0; z-index: 5; }
.crumb { color: var(--muted); font-size: .92rem; }
.crumb strong { color: var(--ink); font-weight: 600; }
.top-tools { display: flex; gap: .6rem; align-items: center; }
.icon-btn { width: 2.4rem; height: 2.4rem; border: 1px solid var(--line); border-radius: 10px; display: grid; place-items: center; color: var(--muted);
  background: var(--surface); position: relative; cursor: pointer; text-decoration: none; }
.icon-btn:hover { border-color: var(--muted); color: var(--ink); }
.icon-btn .dot { position: absolute; top: -.35rem; inset-inline-end: -.35rem; background: var(--bad); color: #fff; font-size: .7rem; font-weight: 700; border-radius: 99px; padding: 0 .4rem; line-height: 1.6; }
.me { display: flex; gap: .6rem; align-items: center; border: 1px solid var(--line); border-radius: 99px; padding: .2rem .9rem .2rem .3rem; font-size: .92rem; font-weight: 500; }
.me .avatar { width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--night); color: #fff; display: grid; place-items: center; font-size: .85rem; }
.me a { font-size: .85rem; }
.main { min-width: 0; }
.page { padding: 1.6rem 2rem 4rem; max-width: 80rem; }
.page-head .sub { margin: .1rem 0 0; color: var(--muted); font-size: .95rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.head-tools { display: flex; gap: .5rem; align-items: end; flex-wrap: wrap; }
.head-tools .field { margin: 0; }
.block { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.25rem 1.5rem; margin-top: 1.1rem; box-shadow: var(--shadow); }
.block > .grid { border: 0; box-shadow: none; border-radius: 0; }
.block > .grid th { background: transparent; }
.block > .grid th:first-child, .block > .grid td:first-child { padding-inline-start: 0; }
.block > .grid th:last-child, .block > .grid td:last-child { padding-inline-end: 0; }

/* ---------------------------------------------------------------- tables */
.grid { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.grid th { text-align: start; font-size: .84rem; font-weight: 600; color: var(--muted); padding: .7rem 1rem; border-bottom: 1px solid var(--line); background: #f8fafb; white-space: nowrap; }
.grid td { padding: .7rem 1rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid td:first-child, .grid td a, .grid td .badge { white-space: nowrap; }
.grid tfoot td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 0; padding: .55rem .8rem; }
.grid .num { font-variant-numeric: tabular-nums; direction: ltr; text-align: end; white-space: nowrap; }
.grid .code { color: var(--muted); text-align: start; }
.grid .end { text-align: end; }
.grid tr.group td { font-weight: 700; background: #f7f9fa; }
.grid.clickable tbody tr { cursor: pointer; }
.grid tbody tr:hover td { background: #fafbfc; }
.grid.clickable tbody tr:hover td, .grid.clickable tbody tr:focus-visible td { background: var(--petrol-tint); }
.indent-1 { padding-inline-start: 1.2rem; }
.indent-2 { padding-inline-start: 2.4rem; }
.indent-3 { padding-inline-start: 3.6rem; }
.indent-4 { padding-inline-start: 4.8rem; }
.row-actions { display: flex; gap: .35rem; justify-content: flex-end; white-space: nowrap; }

.tabs { display: flex; gap: .3rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.tabs button { font: inherit; background: none; border: 0; border-bottom: 3px solid transparent; padding: .55rem 1rem; cursor: pointer; color: var(--muted); margin-bottom: -1px; }
.tabs button.current { color: var(--ink); font-weight: 600; border-bottom-color: var(--gold); }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-top: 1rem; color: var(--muted); font-size: .9rem; }

.badge { display: inline-block; font-size: .8rem; font-weight: 600; padding: .1rem .65rem; border-radius: 99px; background: var(--line-soft); color: var(--muted); margin-inline-start: .35rem; white-space: nowrap; }
td > .badge:first-child, h1 .badge, h2 .badge { margin-inline-start: 0; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--amber-bg); color: var(--amber); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.state { padding: .5rem .8rem; border-radius: var(--radius); background: var(--line-soft); font-weight: 600; margin: .6rem 0; display: inline-block; }
.state.ok { background: var(--ok-bg); color: var(--ok); }
.steps { margin: 0 0 1.25rem; padding-inline-start: 1.4rem; display: grid; gap: .45rem; }
.state.warn { background: var(--amber-bg); color: var(--amber); }
.state.bad { background: var(--bad-bg); color: var(--bad); }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; padding: 3rem 1.5rem; text-align: center; color: var(--muted); }
.empty .actions { justify-content: center; }
.empty p { max-width: 34rem; margin-inline: auto; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); font-size: .9rem; }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.facts.wide { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1.1rem 1.5rem; box-shadow: var(--shadow); gap: .45rem 1.5rem; }
.secret { font-size: 1.15rem; font-weight: 700; letter-spacing: .08em; background: var(--ground); padding: .6rem .8rem; border-radius: var(--radius); text-align: center; }

/* ---------------------------------------------------------------- the entry sheet */
.entry-head { display: grid; grid-template-columns: 11rem 1fr; gap: 1rem; }
.sheet td { padding: .3rem .4rem; }
.sheet thead th:nth-child(3), .sheet thead th:nth-child(4) { text-align: end; }
.entry .sheet td input { border-color: transparent; background: transparent; border-radius: 3px; padding: .35rem .45rem; }
.entry .sheet td input:hover { border-color: var(--line); }
.entry .sheet td input:focus { background: var(--surface); border-color: var(--petrol); }
.entry .sheet .amount { text-align: end; font-variant-numeric: tabular-nums; width: 9.5rem; }
.entry .sheet tbody td { border-bottom: 1px solid var(--line); }
.entry .sheet tbody td + td { border-inline-start: 1px solid var(--line-soft); }
.entry-foot { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: .7rem; }

/* ---------------------------------------------------------------- dialogs */
dialog { border: 0; padding: 0; color: var(--ink); font-family: var(--font); }
dialog::backdrop { background: rgba(19, 33, 43, .45); }
dialog.confirm { border-radius: 10px; width: min(30rem, calc(100vw - 2rem)); box-shadow: 0 18px 48px rgba(19, 33, 43, .3); }
dialog.confirm form { padding: 1.4rem 1.5rem; }
dialog.confirm h2 { font-size: 1.15rem; margin-bottom: .7rem; }
.confirm-text { color: var(--muted); }
dialog.drawer { margin: 0; margin-inline-start: auto; height: 100vh; max-height: 100vh; width: min(28rem, 100vw); box-shadow: 0 0 40px rgba(19, 33, 43, .3); }
dialog.drawer header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
dialog.drawer header h2 { margin: 0; }
.drawer-body { padding: 1.25rem; overflow-y: auto; }

#toasts { position: fixed; bottom: 1.2rem; inset-inline-start: 1.2rem; display: grid; gap: .5rem; z-index: 50; max-width: min(26rem, calc(100vw - 2.4rem)); }
.toast { background: #24343f; color: #fff; padding: .7rem 1rem; border-radius: var(--radius); box-shadow: 0 8px 24px rgba(19, 33, 43, .25); border-inline-start: 4px solid var(--ok); }
.toast.error { border-inline-start-color: #e2685f; }

/* ---------------------------------------------------------------- home */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.kpi { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 1rem 1.25rem 1.1rem; text-decoration: none; color: var(--ink); }
.kpi:hover { border-color: #c5cedb; }
.kpis.three { grid-template-columns: repeat(3, 1fr); margin: 1rem 0; }
.block-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .6rem; }
.block-head h2 { margin: 0; }
.kpi .label { display: flex; gap: .5rem; align-items: center; color: var(--muted); font-size: .92rem; font-weight: 500; }
.kpi .figure { font-size: 1.9rem; font-weight: 600; line-height: 1.5; font-variant-numeric: tabular-nums; }
.kpi .figure small { font-size: .9rem; color: var(--muted); font-weight: 500; }
.kpi .note { color: var(--muted); font-size: .88rem; }
.kpi.attention { border-color: #ecd49a; background: linear-gradient(#fffaf0, #fff 60%); }
.kpi.attention .label { color: var(--amber); }
.kpi.quiet .figure { color: #9aa5b5; }
.meter { display: flex; height: .45rem; border-radius: 99px; overflow: hidden; margin: .4rem 0 .5rem; background: var(--line-soft); }
.meter span { display: block; }
.legend { display: flex; gap: .9rem; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.legend i { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; margin-inline-end: .3rem; }
.fill-rent { background: #2b5a94; } .fill-salary { background: #7a5ab5; } .fill-free { background: #1f7a4d; }
.board { display: grid; grid-template-columns: 1.55fr 1fr; gap: 1rem; margin-top: 1rem; align-items: start; }
.board .stack-cards { display: grid; gap: 1rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.25rem; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; display: flex; gap: .55rem; align-items: center; }
.card-head a, .card-head span { font-size: .88rem; font-weight: 500; text-decoration: none; color: var(--link); }
.todo { display: flex; align-items: center; gap: .9rem; padding: .8rem 1.25rem; border-bottom: 1px solid var(--line-soft); }
.todo:last-child { border-bottom: 0; }
.todo .mark { width: 2.25rem; height: 2.25rem; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--petrol-tint); color: var(--link); }
.todo .mark.warn { background: var(--amber-bg); color: var(--amber); }
.todo .mark.bad { background: var(--bad-bg); color: var(--bad); }
.todo .what { flex: 1; min-width: 0; }
.todo .what strong { display: block; font-weight: 600; }
.todo .what span { color: var(--muted); font-size: .88rem; }
.todo .amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.card .grid { border: 0; border-radius: 0; box-shadow: none; }
.calm { display: flex; gap: .6rem; align-items: center; padding: .9rem 1.25rem; margin: 0; color: var(--ok); font-weight: 500; }

@media (prefers-reduced-motion: no-preference) {
  dialog.confirm[open] { animation: rise .14s ease-out; }
  @keyframes rise { from { opacity: 0; transform: translateY(8px); } }
}
.grid input.amount { width: 7rem; text-align: end; }

/* Readability: nothing in the interface is set smaller than about 15px, and secondary text is not thin. */
.grid td, .todo .what span, .kpi .note { font-weight: 450; }
.grid th { font-size: .9rem; font-weight: 600; }
.todo .what span, .kpi .note, .crumb, .field small, .brand span, .side .foot { font-size: .93rem; }
.badge { font-size: .86rem; }
.shell { grid-template-columns: 16rem 1fr; }

/* ---------------------------------------------------------------- phone and small tablet
   The menu leaves the page and slides in from the side when asked for; tables scroll sideways inside their card. */
.menu-btn, .menu-shade { display: none; }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(17rem, 82vw); height: 100dvh; z-index: 60;
    transform: translateX(100%); transition: transform .18s ease-out; }
  .shell.menu-open .side { transform: none; box-shadow: 0 0 40px rgba(8, 16, 30, .45); }
  .shell.menu-open .menu-shade { display: block; position: fixed; inset: 0; background: rgba(8, 16, 30, .45); z-index: 55; border: 0; }
  .menu-btn { display: grid; }
  .topbar { padding: .6rem 1rem; gap: .6rem; }
  .topbar .crumb { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .me { font-size: 0; gap: 0; padding: .2rem; }
  .page { padding: 1rem; }
  .page-head { align-items: stretch; }
  .page-head h1 { font-size: 1.45rem; }
  .kpis { grid-template-columns: 1fr 1fr; gap: .7rem; }
  .board { grid-template-columns: 1fr; }
  .entry-head { grid-template-columns: 1fr; }
  .grid { display: block; overflow-x: auto; white-space: nowrap; }
  .tabs { overflow-x: auto; white-space: nowrap; }
  dialog.confirm { width: calc(100vw - 2rem); max-width: 26rem; }
}
@media (max-width: 420px) {
  .kpis, .kpis.three { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- paper */
.signatures, .print-head { display: none; }
dialog.drawer[open] { display: flex; flex-direction: column; }
.drawer-body { flex: 1; }
@media print {
  .side, .topbar, .no-print, .page-head .head-tools, .row-actions, #toasts, .tabs { display: none !important; }
  .shell { display: block; }
  body { background: #fff; font-size: 12pt; }
  .page { padding: 0; max-width: none; }
  .block, .grid, .card, .facts.wide { box-shadow: none; break-inside: avoid; }
  input, select { border: 0; padding: 0; background: none; appearance: none; }
  a { color: inherit; text-decoration: none; }
  .print-head { display: block; font-weight: 700; font-size: 14pt; border-bottom: 2px solid #000; padding-bottom: .4rem; margin-bottom: 1rem; }
  .signatures { display: flex; justify-content: space-between; margin-top: 3rem; padding: 0 2rem; }
  .signatures span { border-top: 1px solid #000; padding-top: .4rem; min-width: 12rem; text-align: center; }
}

.perms { border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .9rem .2rem; margin: 0 0 .9rem; }
.perms legend { font-weight: 600; padding: 0 .4rem; }
.perms .check { margin-bottom: .45rem; }
.grid select { min-width: 15rem; }

.level { display: flex; gap: .6rem; align-items: center; margin-bottom: .6rem; counter-increment: level; }
.level .n::before { content: counter(level) '.'; font-weight: 700; }
.stack { counter-reset: level; }
.head-tools > select { width: auto; min-width: 11rem; }
