@font-face { font-family: "Plex"; src: url("/fonts/IBMPlexSansArabic-Regular.ttf"); font-weight: 400; }
@font-face { font-family: "Plex"; src: url("/fonts/IBMPlexSansArabic-Medium.ttf"); font-weight: 500; }
@font-face { font-family: "Plex"; src: url("/fonts/IBMPlexSansArabic-SemiBold.ttf"); font-weight: 600; }
@font-face { font-family: "Plex"; src: url("/fonts/IBMPlexSansArabic-Bold.ttf"); font-weight: 700; }

:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --ink: #16140f;
  --ink-2: #4a463d;
  --ink-3: #8a8478;
  --rule: #e7e2d7;
  --sand: #a8834a;
  --sand-wash: #f5eee1;
  --ok: #2f7a4f; --ok-wash: #e6f2ea;
  --warn: #9a6b12; --warn-wash: #fbf1dc;
  --bad: #a3322a; --bad-wash: #f8e5e3;
  --info: #335f8a; --info-wash: #e5eef7;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Plex", system-ui, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.6; }
a { color: inherit; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.num { font-variant-numeric: tabular-nums; }

/* shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: #15130f; color: #e9e4d8; padding: 22px 16px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; border-bottom: 1px solid #2c2820; margin-bottom: 12px; }
.side .brand img { height: 24px; filter: invert(1); }
.side .brand span { font-size: 12px; color: #a59f90; }
.side a { text-decoration: none; padding: 9px 12px; border-radius: 8px; color: #cfc9bb; display: flex; justify-content: space-between; }
.side a:hover { background: #221f19; color: #fff; }
.side a.on { background: #2a261e; color: #fff; box-shadow: inset -3px 0 0 var(--sand); }
.side .grow { flex: 1; }
.side .foot { font-size: 11px; color: #7d776a; padding: 8px 12px; }
main { padding: 26px 34px 60px; max-width: 1240px; width: 100%; }

/* headings */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.top h1 { font-size: 22px; font-weight: 600; margin: 0; }
.top .sub { color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.crumbs { font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.crumbs a { text-decoration: none; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }

/* panels */
.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.panel.flush { padding: 0; }
.panel.flush h2 { padding: 16px 20px 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.cols { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; display: block; }
.stat .k { font-size: 12px; color: var(--ink-3); }
.stat .v { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; font-weight: 500; color: var(--ink-3); margin-inline-start: 4px; }
.stat .h { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.stat.bad { border-color: #ecc8c4; background: linear-gradient(0deg, #fff, #fff 60%, var(--bad-wash)); }
.stat.bad .v { color: var(--bad); }

/* tables */
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: start; font-weight: 500; font-size: 12px; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--rule); background: #fbfaf7; }
table.t td { padding: 11px 14px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.link { cursor: pointer; }
table.t tr.link:hover td { background: #fbf8f2; }
table.t td.n, table.t th.n { text-align: left; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t .muted { color: var(--ink-3); font-size: 12px; }
.empty { color: var(--ink-3); padding: 18px 20px; font-size: 13px; }

/* badges */
.b { display: inline-block; font-size: 11.5px; font-weight: 500; padding: 2px 9px; border-radius: 99px; background: #eeebe4; color: var(--ink-2); white-space: nowrap; }
.b.paid, .b.active, .b.signed, .b.sent-doc { background: var(--ok-wash); color: var(--ok); }
.b.overdue, .b.cancelled { background: var(--bad-wash); color: var(--bad); }
.b.open, .b.sent { background: var(--info-wash); color: var(--info); }
.b.partial { background: var(--warn-wash); color: var(--warn); }
.b.draft { background: #eeebe4; color: var(--ink-2); }

/* buttons */
.btn { font: inherit; font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--rule); background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #cfc7b6; }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #2b2820; }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

/* forms */
label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; font-weight: 500; }
input, select, textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid #ddd6c8; border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid #d9c49f; border-color: var(--sand); }
textarea { min-height: 90px; line-height: 1.8; }
textarea.code { min-height: 70vh; font-size: 14px; line-height: 1.9; }
.f { margin-bottom: 14px; }
.fr { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
fieldset { border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px 16px 2px; margin: 0 0 16px; }
legend { font-size: 12px; color: var(--ink-3); padding: 0 6px; }

.items { width: 100%; border-collapse: collapse; }
.items th { font-size: 12px; color: var(--ink-3); font-weight: 500; text-align: start; padding: 0 6px 6px; }
.items td { padding: 4px 6px; vertical-align: top; }
.items .qty { width: 80px; } .items .price { width: 130px; } .items .tot { width: 120px; text-align: left; padding-top: 12px; }
.items .x { width: 36px; }
.sum { display: flex; justify-content: flex-end; gap: 16px; font-size: 16px; font-weight: 600; padding: 12px 6px 0; border-top: 1px solid var(--rule); margin-top: 8px; }

/* key-values */
dl.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--ink-3); }
dl.kv dd { margin: 0; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--ok-wash); color: var(--ok); font-size: 13px; }
.flash.error { background: var(--bad-wash); color: var(--bad); }
.big { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.feed { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.feed li { padding: 8px 0; border-bottom: 1px solid var(--rule); display: flex; justify-content: space-between; gap: 10px; }
.feed li:last-child { border-bottom: 0; }
.feed time { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.callout { background: var(--sand-wash); border: 1px solid #ead9bb; border-radius: var(--radius); padding: 12px 16px; font-size: 13px; margin-bottom: 18px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
iframe.preview { width: 100%; height: 80vh; border: 1px solid var(--rule); border-radius: var(--radius); background: #fff; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .stats, .grid2, .grid3, .cols, .split { grid-template-columns: 1fr; }
  main { padding: 18px 16px; }
}

.side-out { font: inherit; background: none; border: 0; color: #8f897c; padding: 9px 12px; cursor: pointer; text-align: start; width: 100%; }
.side-out:hover { color: #fff; }
