/* وشى للأعمال — نظام التصميم (معتمد) */
:root {
  --plum: #3D0A3D;
  --plum-soft: rgba(255, 255, 255, 0.08);
  --plum-line: rgba(237, 201, 175, 0.18);
  --gold: #EDC9AF;
  --ivory: #F5EFE6;
  --brown: #7A5C46;
  --sand: #A8927A;
  --amber: #F2A007;
  --teal: #1B8A9C;
  --red: #9B2C2C;
  --card: #FFFFFF;
  --line: #E9DFD2;
  --ink: #3D0A3D;
  --amber-bg: #FCEBC6;
  --amber-ink: #8A5B00;
  --teal-bg: #D6ECEF;
  --red-bg: #F6E3E1;
  --neutral-bg: #EFE6DA;
  --radius: 16px;
  --radius-sm: 12px;
  --font-head: "Readex Pro", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --font-body: "IBM Plex Sans Arabic", "Readex Pro", system-ui, sans-serif;
  --nav-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--ivory);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3, .num { font-family: var(--font-head); }
.num { font-variant-numeric: tabular-nums; letter-spacing: 0; }
[hidden] { display: none !important; }

#app { max-width: 520px; margin: 0 auto; min-height: 100vh; position: relative; }
.screen { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 24px); }
.screen.no-nav { padding-bottom: calc(110px + var(--safe-b)); }
.pad { padding: 0 16px; }

/* ---------- الرأس البنفسجي ---------- */
.head {
  background: var(--plum);
  color: #fff;
  border-radius: 0 0 28px 28px;
  padding: 18px 20px 22px;
  position: relative;
  overflow: hidden;
}
.head-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand img.sym { height: 30px; width: auto; }
.brand img.word { height: 26px; width: auto; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--plum-line); background: transparent; color: var(--gold);
  cursor: pointer; position: relative; flex: none;
}
.icon-btn.light { border-color: var(--line); color: var(--plum); background: var(--card); }
.icon-btn .dot { position: absolute; top: 9px; inset-inline-end: 10px; width: 9px; height: 9px; border-radius: 50%; background: var(--amber); }
.icon-btn svg { width: 22px; height: 22px; }
.greet { margin-top: 14px; }
.greet small { color: var(--gold); opacity: .85; font-size: 13px; }
.greet h1 { margin: 2px 0 0; font-size: 26px; font-weight: 700; color: #fff; line-height: 1.3; }
.greet .roles { color: var(--gold); font-size: 13px; opacity: .9; }
.head-meta { color: var(--gold); font-size: 12.5px; opacity: .85; }
.head h1.title { margin: 10px 0 0; font-size: 22px; line-height: 1.4; color: #fff; }
.head .amount-big { color: var(--gold); font-family: var(--font-head); font-size: 26px; font-weight: 600; white-space: nowrap; }
.head .amount-big small { font-size: 13px; opacity: .8; margin-inline-start: 4px; }
.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.tile {
  background: var(--plum-soft); border-radius: 14px; padding: 12px 12px 10px;
  text-align: start; border: 0; color: #fff; cursor: pointer;
}
.tile .num { display: block; font-size: 24px; font-weight: 600; line-height: 1.2; }
.tile span { font-size: 12.5px; color: var(--gold); opacity: .9; }
.tile.gold .num { color: var(--gold); }
.tile.warn { background: rgba(155, 44, 44, .35); }

/* شريط المراحل */
.stages { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 18px; }
.stage { text-align: center; font-size: 11.5px; color: var(--gold); opacity: .55; }
.stage::before { content: ""; display: block; height: 4px; border-radius: 4px; background: rgba(237, 201, 175, .25); margin-bottom: 6px; }
.stage.done { opacity: .95; }
.stage.done::before { background: var(--gold); }
.stage.current { opacity: 1; color: #fff; font-weight: 600; }
.stage.current::before { background: var(--amber); }
.stage.stopped::before { background: #C46A6A; }

.bar { height: 7px; border-radius: 7px; background: #EDE4D8; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 7px; background: var(--plum); }
.head .bar { background: rgba(237, 201, 175, .2); }
.head .bar > i { background: var(--gold); }
.bar.over > i { background: var(--amber); }

/* ---------- العناوين والأقسام ---------- */
.section-title {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 24px 0 10px; font-family: var(--font-head); font-size: 18px; font-weight: 600;
}
.section-title h2 { margin: 0; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.section-title h2::before { content: "◆"; color: var(--gold); font-size: 11px; }
.section-title.amber h2::before { color: var(--amber); }
.section-title .aside { font-family: var(--font-body); font-size: 12.5px; color: var(--brown); font-weight: 400; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 16px 6px; }
.page-title h1 { margin: 0; font-size: 24px; }
.page-title .back-title { display: flex; align-items: center; gap: 12px; }

/* ---------- البطاقات ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.card.tap { cursor: pointer; }
.card.dashed { border-style: dashed; border-color: var(--sand); background: transparent; }
.card.flag-red { border-inline-end: 4px solid var(--red); }
.card.flag-amber { border-inline-end: 4px solid var(--amber); }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.card .meta { font-size: 12.5px; color: var(--brown); }
.card h3 { margin: 2px 0 0; font-size: 16.5px; font-weight: 600; line-height: 1.5; }
.card .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; }
.card .actions { margin-top: 14px; display: grid; gap: 8px; }
.amount { font-family: var(--font-head); font-weight: 600; font-size: 19px; white-space: nowrap; color: var(--plum); }
.amount small { font-size: 12px; color: var(--brown); font-weight: 400; margin-inline-start: 3px; font-family: var(--font-body); }
.amount.expected, .expected {
  color: var(--sand); border: 1.5px dashed var(--sand); border-radius: 10px; padding: 2px 8px;
}
.list .item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list .item:last-child { border-bottom: 0; padding-bottom: 0; }
.list .item:first-child { padding-top: 0; }
.list .item .grow { flex: 1; min-width: 0; }
.list .item .t { font-weight: 600; font-size: 15px; }
.list .item .s { font-size: 12.5px; color: var(--brown); }
.list .item .end { text-align: end; }
.thumb { width: 40px; height: 40px; border-radius: 12px; background: var(--ivory); display: grid; place-items: center; color: var(--brown); flex: none; }
.thumb.warn { background: var(--amber-bg); color: var(--amber-ink); }
.thumb svg { width: 20px; height: 20px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.kv label { display: block; font-size: 12px; color: var(--sand); }
.kv div { font-weight: 500; }
.kv .full { grid-column: 1 / -1; }

/* ---------- الوسوم ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap; line-height: 1.6;
}
.pill.amber { background: var(--amber-bg); color: var(--amber-ink); }
.pill.teal { background: var(--teal-bg); color: var(--teal); }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.neutral { background: var(--neutral-bg); color: var(--brown); }
.pill.plum { background: var(--plum); color: #fff; }
.pill.outline { border: 1px solid var(--sand); color: var(--brown); background: transparent; }
.tag-text { font-size: 12px; font-weight: 600; }
.tag-text.teal { color: var(--teal); }
.tag-text.amber { color: var(--amber-ink); }
.tag-text.red { color: var(--red); }

.note { border-radius: 14px; padding: 12px 14px; font-size: 13.5px; margin-bottom: 12px; }
.note.amber { background: var(--amber-bg); color: #6E4A00; }
.note.red { background: var(--red-bg); color: var(--red); }
.note.teal { background: var(--teal-bg); color: #10606C; }
.note b { font-weight: 600; }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-family: var(--font-head); font-weight: 600; font-size: 16px; cursor: pointer; width: 100%;
  text-decoration: none; transition: opacity .15s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 20px; height: 20px; }
.btn.primary { background: var(--plum); color: #fff; }
.btn.outline { background: transparent; border-color: var(--plum); color: var(--plum); }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn.teal { background: var(--teal-bg); color: var(--teal); }
.btn.ghost { background: transparent; color: var(--brown); min-height: 40px; font-size: 14px; font-family: var(--font-body); font-weight: 500; }
.btn.small { min-height: 38px; font-size: 14px; padding: 0 14px; width: auto; border-radius: 10px; }
.btn.muted { background: #D9CBBE; color: #fff; }
.link { background: none; border: 0; color: var(--brown); text-decoration: underline; text-underline-offset: 4px; cursor: pointer; font-size: 14px; padding: 4px; }
.link.teal { color: var(--teal); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.link svg { width: 18px; height: 18px; }

.bottom-bar {
  position: fixed; bottom: 0; inset-inline: 0; max-width: 520px; margin: 0 auto;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 14px 16px calc(14px + var(--safe-b)); z-index: 20;
}
.bottom-bar .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bottom-bar .grid.wide { grid-template-columns: 2fr 1fr; }
.bottom-bar .stack { display: grid; gap: 10px; }
.bottom-bar .center { text-align: center; margin-top: 8px; }
.bottom-bar .hint { text-align: center; font-size: 12.5px; color: var(--brown); margin-top: 8px; }

/* ---------- التنقل السفلي ---------- */
.nav {
  position: fixed; bottom: 0; inset-inline: 0; max-width: 520px; margin: 0 auto; z-index: 15;
  background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 8px 4px calc(8px + var(--safe-b)); height: calc(var(--nav-h) + var(--safe-b));
}
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--brown); font-size: 12px;
}
.nav a svg { width: 24px; height: 24px; }
.nav a.on { color: var(--plum); font-weight: 700; }

/* ---------- النماذج ---------- */
.field { margin-bottom: 16px; }
.field > label, .field > .label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; color: var(--plum); }
.field > label small, .field > .label small { color: var(--brown); font-weight: 400; }
.input, select.input, textarea.input {
  width: 100%; min-height: 54px; padding: 12px 16px; border-radius: 14px;
  border: 1px solid #DCCDBD; background: #FFFDFB; font-size: 16px; color: var(--plum);
  outline: none; transition: border-color .15s;
}
.input:focus { border-color: var(--plum); }
textarea.input { min-height: 90px; resize: vertical; line-height: 1.6; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--plum) 50%), linear-gradient(135deg, var(--plum) 50%, transparent 50%); background-position: 20px 24px, 26px 24px; background-size: 6px 6px; background-repeat: no-repeat; padding-inline-end: 16px; }
.input.ltr { direction: ltr; text-align: right; }
.money-input { position: relative; }
.money-input .input { font-family: var(--font-head); font-size: 30px; font-weight: 600; min-height: 76px; padding-inline-end: 64px; direction: ltr; text-align: right; }
.money-input .cur { position: absolute; inset-inline-end: 18px; top: 50%; transform: translateY(-50%); color: var(--brown); font-size: 15px; }
.hint { font-size: 12.5px; color: var(--brown); margin-top: 6px; }
.error-text { color: var(--red); font-size: 13px; margin-top: 6px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #E9DED0; border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; border-radius: 11px; min-height: 44px; font-size: 14.5px; color: var(--brown); cursor: pointer; font-family: var(--font-head); }
.seg button.on { background: var(--card); color: var(--plum); font-weight: 700; box-shadow: 0 1px 2px rgba(61,10,61,.08); }
.pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pick label {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 64px; padding: 8px;
  border: 1.5px dashed var(--sand); border-radius: 14px; cursor: pointer; font-size: 14.5px; color: var(--plum); text-align: center;
}
.pick label svg { width: 22px; height: 22px; }
.pick input { display: none; }
.files { margin-top: 10px; display: grid; gap: 8px; }
.file { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); font-size: 14px; }
.file .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .size { color: var(--brown); font-size: 12px; }
.file svg { width: 18px; height: 18px; color: var(--teal); flex: none; }
.file.uploading svg { color: var(--sand); }
.checks { display: grid; gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--plum); }
.check span small { display: block; color: var(--brown); font-size: 12px; }

/* ---------- التبويبات والفلاتر ---------- */
.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #E9DED0; border-radius: 14px; padding: 4px; gap: 4px; margin: 6px 0 16px; }
.tabs button { border: 0; background: transparent; border-radius: 11px; min-height: 42px; font-size: 14px; color: var(--brown); cursor: pointer; }
.tabs button.on { background: var(--card); color: var(--plum); font-weight: 700; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 8px 0 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-select { position: relative; flex: none; }
.chip-select select {
  appearance: none; border: 1px solid var(--sand); background: var(--card); color: var(--plum);
  border-radius: 999px; padding: 8px 16px 8px 30px; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.chip-select.on select { background: var(--plum); color: #fff; border-color: var(--plum); }
.chip-select::after { content: "▾"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 11px; pointer-events: none; color: inherit; }
.chip-select.on::after { color: #fff; }

/* ---------- السجل الزمني ---------- */
.timeline { position: relative; padding-inline-start: 22px; }
.timeline::before { content: ""; position: absolute; inset-inline-start: 6px; top: 8px; bottom: 8px; width: 1.5px; background: var(--line); }
.tl { position: relative; padding-bottom: 16px; }
.tl::before { content: "◆"; position: absolute; inset-inline-start: -22px; top: 0; color: var(--sand); font-size: 14px; line-height: 1.5; }
.tl.pending::before { color: var(--amber); }
.tl.good::before { color: var(--teal); }
.tl.bad::before { color: var(--red); }
.tl .t { font-weight: 600; font-size: 14.5px; }
.tl .s { font-size: 12px; color: var(--sand); }
.tl .d { font-size: 13px; color: var(--brown); margin-top: 2px; }

/* ---------- النوافذ السفلية ---------- */
.sheet-back { position: fixed; inset: 0; background: rgba(40, 8, 40, .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet {
  background: var(--ivory); width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto;
  border-radius: 24px 24px 0 0; padding: 10px 16px calc(20px + var(--safe-b)); animation: up .2s ease-out;
}
.sheet .grip { width: 44px; height: 5px; border-radius: 5px; background: #D8C9B8; margin: 0 auto 12px; }
.sheet h2 { font-size: 19px; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.sheet h2::before { content: "◆"; color: var(--gold); font-size: 11px; }
.sheet .sheet-actions { display: grid; gap: 10px; margin-top: 8px; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.toast {
  position: fixed; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); left: 50%; transform: translateX(-50%);
  background: var(--plum); color: #fff; padding: 12px 20px; border-radius: 14px; z-index: 80; font-size: 14px;
  max-width: calc(100% - 32px); text-align: center; animation: up .2s;
}
.toast.error { background: var(--red); }

.empty { text-align: center; color: var(--brown); font-size: 14px; padding: 24px 8px; }
.loading { display: grid; place-items: center; padding: 60px 0; color: var(--sand); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--plum); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.demo-tag { display: inline-block; font-size: 10.5px; padding: 0 6px; border-radius: 6px; background: #FBE3C2; color: #8A5B00; font-weight: 600; margin-inline-start: 6px; vertical-align: middle; }

/* ---------- شاشة الدخول ---------- */
.login { background: var(--plum); min-height: 100vh; padding: 48px 20px 28px; display: flex; flex-direction: column; align-items: center; position: relative; overflow: hidden; }
.login .wm { position: absolute; width: 280px; height: 280px; border: 46px solid rgba(255,255,255,.035); transform: rotate(45deg); bottom: 40px; inset-inline-end: -150px; pointer-events: none; }
.login .wm.two { width: 180px; height: 180px; border-width: 30px; bottom: -40px; inset-inline-end: -40px; }
.login .logo-sym { width: 80px; height: auto; margin-top: 12px; }
.login .logo-word { width: 180px; height: auto; margin-top: 18px; }
.login .rule { width: 56px; height: 1px; background: var(--gold); opacity: .7; margin: 20px 0 14px; }
.login .name { color: var(--gold); font-size: 20px; }
.login .sub { color: var(--gold); opacity: .75; font-size: 13.5px; margin-top: 8px; }
.login .box { background: var(--ivory); border-radius: 22px; padding: 26px 22px 20px; width: 100%; max-width: 400px; margin-top: 40px; position: relative; z-index: 1; }
.login .box h2 { margin: 0 0 16px; font-size: 24px; }
.login .box .field > label { color: var(--brown); font-weight: 400; font-size: 13.5px; }
.login .foot { color: var(--sand); font-size: 12px; margin-top: auto; padding-top: 28px; }

/* ---------- الطباعة (تصدير PDF بهوية وشى) ---------- */
.print-head { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; font-size: 12px; }
  #app { max-width: none; }
  .nav, .bottom-bar, .no-print, .icon-btn, .chips, .tabs { display: none !important; }
  .screen { padding: 0 !important; }
  .print-head { display: flex; align-items: center; justify-content: space-between; background: var(--plum); color: var(--gold); padding: 14px 18px; border-radius: 12px; margin-bottom: 14px; }
  .print-head img { height: 34px; }
  .print-head .t { font-family: var(--font-head); font-size: 18px; color: #fff; }
  .print-head .s { font-size: 11px; }
  .head { border-radius: 12px; }
  .card { break-inside: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@media (min-width: 521px) {
  body { background: #EDE5D9; }
  #app { background: var(--ivory); box-shadow: 0 0 0 1px var(--line); }
}
