/* Receipt Book — styled after the family's carbon receipt book:
   maroon cover, white voucher sheets, blue-ink entries, a perforated tear line. */

@font-face { font-family: Plex; font-weight: 400; font-display: swap; src: url(/fonts/plex-arabic-400.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: Plex; font-weight: 600; font-display: swap; src: url(/fonts/plex-arabic-600.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: Plex; font-weight: 700; font-display: swap; src: url(/fonts/plex-arabic-700.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: Plex; font-weight: 400; font-display: swap; src: url(/fonts/plex-latin-400.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Plex; font-weight: 600; font-display: swap; src: url(/fonts/plex-latin-600.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Plex; font-weight: 700; font-display: swap; src: url(/fonts/plex-latin-700.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --cover: #7a1f3d;        /* receipt book cover */
  --cover-deep: #5e1530;
  --maroon: #952949;       /* logo maroon */
  --paper: #ffffff;
  --carbon: #f7ecf0;       /* pink carbon-copy tint */
  --desk: #ece6e8;
  --ink: #1f3a93;          /* blue pen */
  --graphite: #1e1b1c;
  --muted: #6b6266;
  --rule: #c9bcc1;
  --stamp: #c62828;
  --whatsapp: #128c4a;
  --radius-sheet: 6px;
  --radius-ctl: 10px;
  --shadow-sheet: 0 1px 0 rgba(60, 10, 25, .08), 0 10px 28px -12px rgba(60, 10, 25, .35);
  --font: Plex, "Segoe UI", system-ui, -apple-system, Tahoma, Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  color: var(--graphite);
  background: var(--desk);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--ink); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #e9a8bd; outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.ink { color: var(--ink); }
.muted { color: var(--muted); }
.ar { font-family: var(--font); direction: rtl; unicode-bidi: isolate; }

/* ------------------------------------------------------------ top bar & navigation */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--cover);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  display: flex; align-items: center; gap: 12px;
}
.topbar img { height: 34px; width: auto; border-radius: 3px; display: block; }
.topbar h1 { font-size: 19px; font-weight: 600; margin: 0; flex: 1; letter-spacing: .1px; }
.topbar .who { font-size: 14px; opacity: .8; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--paper);
  border-top: 1px solid #e2d6da;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 4px 4px calc(env(safe-area-inset-bottom) + 4px);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0 4px; text-decoration: none; color: var(--muted); font-size: 12.5px; font-weight: 600;
  border-radius: 10px;
}
.tabs a svg { width: 24px; height: 24px; }
.tabs a[aria-current="page"] { color: var(--cover); }
.tabs a[aria-current="page"] svg { stroke-width: 2.3; }

main { max-width: 760px; margin: 0 auto; padding: 16px 12px calc(env(safe-area-inset-bottom) + 96px); }

@media (min-width: 900px) {
  .tabs { position: sticky; top: 0; bottom: auto; max-width: 760px; margin: 12px auto 0; border: 1px solid #e2d6da; border-radius: 14px; padding: 4px; }
  .tabs a { flex-direction: row; justify-content: center; gap: 8px; font-size: 15px; padding: 10px 0; }
  .tabs a svg { width: 20px; height: 20px; }
  main { padding-bottom: 48px; }
}

/* ------------------------------------------------------------ the voucher sheet (new receipt) */
.book { background: var(--cover); border-radius: 14px; padding: 10px; }
@media (max-width: 520px) { .book { margin: -16px -12px 0; border-radius: 0; padding: 10px 8px 14px; } }

.sheet {
  background: var(--paper);
  border-radius: var(--radius-sheet);
  box-shadow: var(--shadow-sheet);
  position: relative;
}
.stub {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px 14px;
  background: var(--carbon);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
}
.stub .no { font-size: 15px; color: var(--muted); }
.stub .no b { color: #b0173c; font-size: 22px; font-weight: 700; margin-left: 6px; }
.datepick {
  position: relative; display: inline-flex; align-items: baseline; gap: 6px; cursor: pointer;
  padding: 4px 10px; border-radius: 8px; border: 1.5px dashed #d5bfc8; background: var(--paper);
}
.datepick .muted { font-size: 14px; }
.datepick b { color: var(--ink); font-weight: 600; font-size: 16.5px; white-space: nowrap; }
.datepick input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; cursor: pointer; }
.datepick:focus-within { outline: 3px solid #e9a8bd; outline-offset: 1px; }
/* the perforation */
.perf {
  height: 14px; position: relative;
  background:
    radial-gradient(circle at 7px 7px, var(--cover) 4px, transparent 4.5px) 0 0 / 16px 14px repeat-x;
}
.perf::after { content: ""; position: absolute; left: 0; right: 0; top: 6px; border-top: 1.5px dashed #d9c3cb; }
@media (max-width: 520px) { .perf { background-size: 14px 14px; } }

.vhead { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; padding: 8px 16px 2px; }
.vhead .en { font-weight: 700; font-size: 17px; line-height: 1.2; }
.vhead .arn { font-weight: 700; font-size: 18px; line-height: 1.2; text-align: right; direction: rtl; }
.vhead img { height: 40px; width: auto; display: block; }
.vtitle { text-align: center; padding: 4px 0 6px; }
.vtitle .ar { font-weight: 700; font-size: 20px; line-height: 1.2; display: block; }
.vtitle .en { font-weight: 700; font-size: 13px; letter-spacing: .6px; border-bottom: 1.5px solid var(--graphite); padding-bottom: 1px; }

.vbody { padding: 4px 16px 18px; }
.field { padding: 12px 0 2px; position: relative; }
.field > .lbl { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 15px; color: var(--graphite); }
.field > .lbl .ar { color: var(--muted); font-size: 15px; }
.line {
  width: 100%; border: 0; border-bottom: 2px dotted #6f6669; border-radius: 0;
  background: transparent; padding: 6px 2px 5px; font-size: 19px; font-weight: 600; color: var(--ink);
  outline: none; min-height: 42px;
}
.line::placeholder { color: #b4a9ad; font-weight: 400; }
.line:focus { border-bottom-color: var(--ink); border-bottom-style: solid; background: linear-gradient(transparent 70%, rgba(31, 58, 147, .05)); }
.line.rtl { direction: rtl; }
.line.small { font-size: 17px; min-height: 38px; }
.hint { font-size: 14px; color: var(--muted); margin-top: 6px; min-height: 0; }
.hint b { color: var(--graphite); font-weight: 600; }
.err { color: var(--stamp); font-size: 14px; margin-top: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* amount boxes: BD | Fils */
.amount { display: grid; grid-template-columns: 1.7fr 1fr; border: 2px solid var(--graphite); background: #f1f2f4; margin-top: 6px; }
.amount label { display: block; padding: 4px 10px 0; font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; }
.amount .cell + .cell { border-left: 2px solid var(--graphite); }
.amount input {
  width: 100%; border: 0; background: transparent; outline: none; text-align: center;
  font-size: 32px; font-weight: 700; color: var(--ink); padding: 0 6px 6px; font-variant-numeric: tabular-nums;
}
.amount input::placeholder { color: #c0b8bb; }
.amount:focus-within { box-shadow: 0 0 0 3px #e9a8bd; }
.words { font-size: 14.5px; color: var(--ink); margin-top: 8px; line-height: 1.5; }
.words .ar { display: block; text-align: right; }

/* suggestions under "Received from" */
.suggest {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 10;
  background: var(--paper); border: 1px solid #d9cdd1; border-radius: 10px; margin-top: 4px;
  box-shadow: 0 14px 30px -12px rgba(40, 10, 20, .35); max-height: 300px; overflow: auto; padding: 4px;
}
.suggest button {
  display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 8px; cursor: pointer;
}
.suggest button:hover, .suggest button.active { background: var(--carbon); }
.suggest .s-name { font-weight: 600; }
.suggest .s-meta { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.suggest .s-new { color: var(--cover); font-weight: 600; }

/* chips: units and payment method */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  border: 1.5px solid #cdbec4; background: var(--paper); border-radius: 999px; padding: 7px 14px; font-size: 15.5px;
  font-weight: 600; cursor: pointer; color: var(--graphite); display: inline-flex; gap: 8px; align-items: center;
}
.chip small { font-weight: 400; color: var(--muted); font-size: 13.5px; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip[aria-pressed="true"] small { color: #d6dcf3; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.seg .chip { justify-content: center; padding: 9px 4px; border-radius: 10px; font-size: 15px; }
@media (max-width: 400px) { .seg { grid-template-columns: repeat(2, 1fr); } }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: var(--radius-ctl); padding: 13px 18px; font-weight: 600; font-size: 17px; cursor: pointer;
  background: var(--cover); color: #fff; text-decoration: none; min-height: 50px;
}
.btn:hover { background: var(--cover-deep); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btn.big { font-size: 18.5px; min-height: 58px; }
.btn.ghost { background: var(--paper); color: var(--graphite); border: 1.5px solid #d3c5ca; }
.btn.ghost:hover { background: var(--carbon); }
.btn.wa { background: var(--whatsapp); }
.btn.wa:hover { background: #0e7a40; }
.btn.danger { background: none; color: var(--stamp); border: 0; min-height: 44px; }
.btn.link { background: none; color: var(--ink); padding: 8px 4px; min-height: 0; }
.btn svg { width: 22px; height: 22px; flex: none; }
.issue-bar { margin-top: 18px; }

/* ------------------------------------------------------------ issued receipt */
.issued { animation: none; }
.tear { animation: tear .55s cubic-bezier(.2, .7, .3, 1) both; transform-origin: 30% 0; }
@keyframes tear {
  0% { transform: translateY(-14px) rotate(-1.4deg); opacity: 0; }
  60% { transform: translateY(2px) rotate(.3deg); opacity: 1; }
  100% { transform: none; }
}
@media (prefers-reduced-motion: reduce) { .tear { animation: none; } }

.summary { padding: 16px; }
.summary .top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.summary .rno { font-size: 15px; color: var(--muted); }
.summary .rno b { color: #b0173c; font-size: 22px; margin-left: 4px; }
.summary .amt { font-size: 34px; font-weight: 700; color: var(--ink); margin: 6px 0 0; line-height: 1.15; }
.summary .amt small { font-size: 17px; font-weight: 600; color: var(--muted); margin-right: 6px; }
.summary .who { font-size: 19px; font-weight: 600; margin-top: 2px; }
.summary .for { color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--carbon); color: var(--cover); white-space: nowrap; }
.pill.ok { background: #e3f3e8; color: #17663a; }
.pill.void { background: #fde7e7; color: var(--stamp); }
.voucher-img { display: block; width: 100%; height: auto; border-radius: 4px; background: #fff; cursor: zoom-in; }
.voucher-wrap { padding: 0 10px 10px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.actions .wide { grid-column: 1 / -1; }
.actions .btn { font-size: 16px; padding: 12px 10px; gap: 6px; }
.actions .btn.wa { font-size: 17.5px; min-height: 56px; }
.after { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; flex-wrap: wrap; gap: 6px; }

/* ------------------------------------------------------------ lists (receipts, customers, units) */
.page-head { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; }
.page-head h2 { font-size: 24px; margin: 0; flex: 1; font-weight: 700; }
.search {
  width: 100%; border: 1.5px solid #d6c9ce; border-radius: 12px; background: var(--paper); padding: 12px 14px; font-size: 17px; outline: none;
}
.search:focus { border-color: var(--ink); }
.month { margin-top: 20px; }
.month-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px 8px; }
.month-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.month-head .tot { font-weight: 700; color: var(--ink); }
.month-head .cnt { font-size: 13.5px; color: var(--muted); display: block; text-align: right; font-weight: 400; }
.list { background: var(--paper); border-radius: 12px; overflow: hidden; box-shadow: 0 1px 0 rgba(60, 10, 25, .06); }
.list > * + * { border-top: 1px solid #efe6e9; }
.rrow {
  display: grid; grid-template-columns: 64px 1fr auto; align-items: center;
  text-decoration: none; color: inherit; min-height: 64px;
}
.rrow .rn {
  align-self: stretch; display: flex; align-items: center; justify-content: center;
  color: #b0173c; font-weight: 700; font-size: 15px; border-right: 2px dashed #e6d7dc; background: #fcf7f9;
}
.rrow .rm { padding: 10px 12px; min-width: 0; }
.rrow .rm .n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rrow .rm .b { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rrow .ra { padding: 0 14px 0 4px; text-align: right; font-weight: 700; color: var(--ink); white-space: nowrap; }
.rrow .ra small { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; }
.rrow.is-void .n, .rrow.is-void .ra { text-decoration: line-through; color: #a99ca1; }
.rrow:hover { background: #fdf9fa; }

.crow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-decoration: none; color: inherit; cursor: pointer; background: none; border: 0; width: 100%; text-align: left; }
.crow:hover { background: #fdf9fa; }
.crow .main { flex: 1; min-width: 0; }
.crow .t { font-weight: 600; }
.crow .s { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crow .r { text-align: right; font-weight: 700; color: var(--ink); white-space: nowrap; }
.crow .r small { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; }
.tag { display: inline-block; font-size: 13px; padding: 1px 8px; border-radius: 6px; background: #eef1fb; color: var(--ink); margin-right: 4px; font-weight: 600; }

.empty { text-align: center; padding: 36px 18px; color: var(--muted); }
.empty b { display: block; color: var(--graphite); font-size: 18px; margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

/* ------------------------------------------------------------ forms on plain pages (settings, editors) */
.card { background: var(--paper); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 4px; font-size: 18px; }
.card p.sub { margin: 0 0 10px; color: var(--muted); font-size: 14.5px; }
.f { display: block; margin-top: 12px; }
.f > span { display: block; font-size: 14.5px; color: var(--muted); margin-bottom: 4px; }
.box {
  width: 100%; border: 1.5px solid #d6c9ce; border-radius: 10px; background: #fff; padding: 11px 12px; font-size: 17px; outline: none;
}
.box:focus { border-color: var(--ink); }
textarea.box { min-height: 86px; resize: vertical; line-height: 1.4; }
select.box { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #6b6266 50%), linear-gradient(135deg, #6b6266 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.row-btns { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.row-btns .btn { flex: 1; }

.sigbox { border: 1.5px dashed #c9b8be; border-radius: 10px; background: #fff; position: relative; }
.sigbox canvas { display: block; width: 100%; height: 190px; cursor: crosshair; }
.sigbox .base { position: absolute; left: 16px; right: 16px; bottom: 40px; border-top: 1.5px dotted #9a8e92; pointer-events: none; }
.sigbox .x { position: absolute; left: 14px; bottom: 44px; color: #b4a9ad; font-size: 22px; pointer-events: none; }
.sig-current { max-height: 80px; max-width: 100%; display: block; margin: 8px 0; }
.logo-current { height: 56px; width: auto; display: block; margin: 8px 0; border-radius: 4px; }

/* ------------------------------------------------------------ bottom sheet dialog */
.scrim { position: fixed; inset: 0; background: rgba(30, 8, 16, .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.dialog {
  background: var(--desk); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto;
  border-radius: 18px 18px 0 0; padding: 8px 14px calc(env(safe-area-inset-bottom) + 18px);
  animation: up .22s ease-out;
}
.dialog .grab { width: 44px; height: 5px; border-radius: 3px; background: #cbbfc3; margin: 4px auto 10px; }
.dialog h2 { margin: 2px 2px 10px; font-size: 21px; }
@keyframes up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (min-width: 700px) { .scrim { align-items: center; } .dialog { border-radius: 18px; } }
@media (prefers-reduced-motion: reduce) { .dialog { animation: none; } }

.zoom { position: fixed; inset: 0; background: rgba(20, 6, 12, .92); z-index: 60; overflow: auto; display: flex; align-items: center; justify-content: center; padding: 10px; }
.zoom img { width: 100%; max-width: 1400px; height: auto; background: #fff; }
@media (max-width: 700px) and (orientation: portrait) { .zoom img { width: 220%; max-width: none; } .zoom { justify-content: flex-start; } }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px); transform: translateX(-50%);
  background: var(--graphite); color: #fff; padding: 11px 18px; border-radius: 12px; z-index: 70; font-size: 15.5px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .5); max-width: calc(100% - 32px);
}

/* ------------------------------------------------------------ login */
.login-body { background: var(--cover); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login { width: 100%; max-width: 380px; }
.login .sheet { padding: 0 0 22px; overflow: hidden; }
.login .logo { display: block; width: 168px; height: auto; margin: 26px auto 10px; border-radius: 4px; }
.login h1 { text-align: center; font-size: 21px; margin: 6px 0 0; }
.login h1 .ar { display: block; font-size: 18px; color: var(--muted); font-weight: 600; }
.login form { padding: 8px 22px 0; }
.login .btn { margin-top: 22px; }
.login .err { text-align: center; margin-top: 12px; }

/* ------------------------------------------------------------ public receipt page */
.pub { max-width: 920px; margin: 0 auto; padding: 16px 12px 40px; }
.pub-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.pub-head img { height: 46px; width: auto; border-radius: 3px; }
.pub-head .t { font-weight: 700; font-size: 19px; line-height: 1.25; }
.pub-head .t .ar { display: block; font-weight: 600; font-size: 16px; color: var(--muted); text-align: left; }
.pub .actions .btn { flex-direction: column; gap: 0; line-height: 1.2; padding: 10px 12px; }
.pub .actions .btn .ar { font-size: 14px; font-weight: 400; opacity: .9; }
.pub .note { text-align: center; margin-top: 14px; color: var(--muted); font-size: 15px; }
