/* Al-Saher — one interface for phone, tablet and desktop.
   Phone (<720): top bar + bottom tabs, details open full screen, forms rise as bottom sheets.
   Tablet (720–1099): icon rail, list and detail side by side from 960.
   Desktop (≥1100): full sidebar with groups, list + detail panes, forms as centred dialogs. */

@font-face { font-family: Plex; src: url(fonts/plex-arabic-400.woff2) format('woff2'); font-weight: 400; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: Plex; src: url(fonts/plex-arabic-500.woff2) format('woff2'); font-weight: 500; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: Plex; src: url(fonts/plex-arabic-600.woff2) format('woff2'); font-weight: 600; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: Plex; src: url(fonts/plex-arabic-700.woff2) format('woff2'); font-weight: 700; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: Plex; src: url(fonts/plex-latin-400.woff2) format('woff2'); font-weight: 400 500; font-display: swap; unicode-range: U+0000-00FF, U+2010-2044; }
@font-face { font-family: Plex; src: url(fonts/plex-latin-600.woff2) format('woff2'); font-weight: 600 700; font-display: swap; unicode-range: U+0000-00FF, U+2010-2044; }

:root {
  --night: #0A1A20;
  --night-2: #10272F;
  --brand: #2EA9CB;
  --brand-ink: #137391;
  --brand-soft: #E3F4F8;
  --teal: #1FB5A2;
  --bg: #F2F7F8;
  --surface: #FFFFFF;
  --surface-2: #F7FAFB;
  --line: #DDE7EA;
  --line-strong: #C6D5DA;
  --text: #0E2228;
  --muted: #5A7078;
  --faint: #8BA0A7;
  --ok: #17845A; --ok-soft: #E2F4EB;
  --warn: #A86A00; --warn-soft: #FBF0DA;
  --bad: #C63A2F; --bad-soft: #FBE7E5;
  --info: #2E6FCB; --info-soft: #E5EEFB;
  --grey-soft: #EDF1F3;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(10, 26, 32, .06), 0 4px 16px rgba(10, 26, 32, .06);
  --shadow-lg: 0 12px 48px rgba(10, 26, 32, .22);
  --side-w: 0px;
  --top-h: 60px;
  --tab-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #0A1A20; --surface: #10262E; --surface-2: #0D2027; --line: #1D3A44; --line-strong: #2A4C57;
  --text: #E4F0F2; --muted: #93AAB1; --faint: #6B858D; --brand-ink: #5CC6E3; --brand-soft: #123844;
  --ok: #4FC891; --ok-soft: #0F3427; --warn: #E9B44C; --warn-soft: #3A2C0C; --bad: #F07A70; --bad-soft: #3D1714;
  --info: #7FAEF0; --info-soft: #14284A; --grey-soft: #1A3039;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 12px 48px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Plex, 'Segoe UI', Tahoma, sans-serif; font-size: 15px; line-height: 1.55;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-ink); text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 600; }
.num, .ltr { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ----- The Omani rial sign (U+20C4), painted from the Central Bank outline in the text colour. */
.rial { display: inline-block; height: .68em; aspect-ratio: 741.36 / 415.06; background: currentColor; flex: none;
  -webkit-mask: url(rial.svg) center / contain no-repeat; mask: url(rial.svg) center / contain no-repeat; margin-inline-end: .28em; vertical-align: baseline; }
.money { direction: ltr; unicode-bidi: isolate; white-space: nowrap; font-variant-numeric: tabular-nums; display: inline-flex; align-items: baseline; }
.money.neg { color: var(--bad); }
@media (forced-colors: active) { .rial { background: CanvasText; } }

/* ===== Shell ===== */
.shell { min-height: 100%; display: flex; }
.side { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: calc(var(--top-h) + var(--safe-top)); padding: var(--safe-top) 16px 0;
  display: flex; align-items: center; gap: 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar h1 { font-size: 19px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .back { margin-inline-start: -8px; }
.view { flex: 1; padding: 4px 16px calc(var(--tab-h) + var(--safe-bottom) + 24px); }

.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30; height: calc(var(--tab-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom); display: flex; background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 11.5px; font-weight: 500; position: relative; }
.tabbar a svg.i { width: 22px; height: 22px; }
.tabbar a.on { color: var(--brand-ink); }
.tabbar a.on::before { content: ''; position: absolute; top: 0; width: 36px; height: 3px; border-radius: 0 0 3px 3px; background: var(--brand); }

.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand .mark { width: 38px; height: 38px; border-radius: 11px; background: #fff; display: grid; place-items: center; flex: none; overflow: hidden; }
.brand .mark img { width: 34px; height: 34px; object-fit: contain; }
.brand b { font-size: 16px; font-weight: 700; display: block; }
.brand small { font-size: 11.5px; color: #8FB3BD; display: block; }

.side nav { display: flex; flex-direction: column; gap: 2px; }
.side .group { font-size: 11.5px; color: #6E929C; padding: 14px 12px 4px; font-weight: 500; }
.side a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: #C6DADF; font-weight: 500; font-size: 14.5px; }
.side a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side a.on { background: rgba(46, 169, 203, .18); color: #fff; }
.side a.on svg.i { color: var(--brand); }
.side .me { margin-top: auto; padding: 12px; border-top: 1px solid rgba(255, 255, 255, .08); display: flex; align-items: center; gap: 10px; color: #C6DADF; }
.side .me .who { flex: 1; min-width: 0; }
.side .me b { display: block; color: #fff; font-weight: 500; font-size: 14px; }
.side .me small { color: #7F9FA8; font-size: 12px; }

@media (min-width: 720px) {
  :root { --side-w: 88px; }
  .tabbar { display: none; }
  .view { padding: 4px 24px 40px; }
  .topbar { padding-inline: 24px; }
  .side { display: flex; flex-direction: column; position: fixed; inset-block: 0; inset-inline-start: 0; width: var(--side-w);
    background: var(--night); padding: calc(14px + var(--safe-top)) 10px 10px; z-index: 40; overflow-y: auto; }
  .main { margin-inline-start: var(--side-w); }
  .side .brand { justify-content: center; margin-bottom: 10px; }
  .side .brand .txt, .side .group, .side .me .who { display: none; }
  .side a { flex-direction: column; gap: 3px; font-size: 11px; padding: 9px 4px; text-align: center; }
  .side a svg.i { width: 22px; height: 22px; }
  .side .me { justify-content: center; padding: 10px 0 0; }
}
@media (min-width: 1100px) {
  :root { --side-w: 252px; }
  .side { padding-inline: 14px; }
  .side .brand { justify-content: flex-start; padding: 2px 6px 8px; }
  .side .brand .txt, .side .group, .side .me .who { display: block; }
  .side a { flex-direction: row; font-size: 14.5px; padding: 9px 12px; text-align: start; gap: 12px; }
  .side a svg.i { width: 20px; height: 20px; }
  .side .me { justify-content: flex-start; padding: 12px 6px 4px; }
  .view { padding: 4px 32px 48px; }
  .topbar { padding-inline: 32px; }
}

/* List + detail side by side when there is room. */
.split { display: grid; gap: 20px; align-items: start; grid-template-columns: minmax(0, 1fr); }
.split > * { min-width: 0; }
@media (min-width: 960px) {
  .split.has-detail { grid-template-columns: minmax(320px, 400px) 1fr; }
  .split.has-detail > .pane-list { position: sticky; top: calc(var(--top-h) + 8px); max-height: calc(100vh - var(--top-h) - 24px); overflow-y: auto; padding-inline-end: 4px; }
  .split.has-detail > .pane-list .row .extra { display: none; }
}
@media (max-width: 959px) { .split.has-detail > .pane-list { display: none; } }
.pane-detail { min-width: 0; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); font-weight: 500; font-size: 14.5px;
  white-space: nowrap; transition: background .15s, border-color .15s, transform .1s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.primary { background: var(--brand-ink); border-color: var(--brand-ink); color: #fff; }
.btn.primary:hover { background: color-mix(in srgb, var(--brand-ink) 88%, #000); }
:root[data-theme='dark'] .btn.primary { background: var(--brand); border-color: var(--brand); color: var(--night); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--grey-soft); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13.5px; }
.btn.block { width: 100%; }
.icon-btn { width: 42px; height: 42px; display: inline-grid; place-items: center; border-radius: 12px; border: 0; background: transparent; color: var(--text); flex: none; }
.icon-btn:hover { background: var(--grey-soft); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fab { position: fixed; inset-inline-end: 18px; bottom: calc(var(--tab-h) + var(--safe-bottom) + 18px); z-index: 25; width: 56px; height: 56px;
  border-radius: 18px; border: 0; background: var(--brand-ink); color: #fff; display: grid; place-items: center; box-shadow: var(--shadow-lg); }
.fab svg.i { width: 26px; height: 26px; }
:root[data-theme='dark'] .fab { background: var(--brand); color: var(--night); }
@media (min-width: 720px) { .fab { display: none; } }
.wide-only { display: none !important; }
@media (min-width: 720px) { .wide-only { display: inline-flex !important; } .phone-only { display: none !important; } }

/* ===== Cards, sections ===== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card.pad { padding: 16px; }
.section { margin-top: 18px; }
.section > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.section > header h2 { font-size: 15.5px; }
.section > header .muted { font-size: 13px; }
.grid { display: grid; gap: 12px; }
.grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .grid.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.grid.two { grid-template-columns: 1fr; }
@media (min-width: 1100px) { .grid.two { grid-template-columns: 1fr 1fr; align-items: start; } }

.kpi { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi .label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.kpi .hint { font-size: 12.5px; color: var(--faint); }
.kpi.accent { background: var(--night); border-color: var(--night); color: #fff; }
.kpi.accent .label { color: #8FB3BD; }
.kpi.accent .hint { color: #6E929C; }
a.kpi:hover { border-color: var(--line-strong); }

/* ===== Lists ===== */
.toolbar { display: flex; gap: 8px; align-items: center; margin: 4px 0 12px; flex-wrap: wrap; }
.search { flex: 1; min-width: 180px; position: relative; }
.search input { width: 100%; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 42px 0 14px; }
.search svg.i { position: absolute; inset-inline-start: 13px; top: 12px; color: var(--faint); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin: 0 -16px 12px; padding-inline: 16px; }
@media (min-width: 720px) { .chips { margin-inline: 0; padding-inline: 0; flex-wrap: wrap; } }
.chips::-webkit-scrollbar { display: none; }
.chip { height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); white-space: nowrap; font-size: 13.5px; color: var(--muted); font-weight: 500; flex: none; }
.chip.on { background: var(--text); border-color: var(--text); color: var(--surface); }
.chip .n { opacity: .65; margin-inline-start: 4px; }

.rows { display: flex; flex-direction: column; }
.rows.card { overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); color: inherit; min-height: 64px; }
.row:last-child { border-bottom: 0; }
a.row:hover, button.row:hover { background: var(--surface-2); }
.row.on { background: var(--brand-soft); box-shadow: inset -3px 0 0 var(--brand); }
button.row { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: start; }
.row .main-col { flex: 1; min-width: 0; }
.row .title { font-weight: 500; display: flex; align-items: center; gap: 8px; min-width: 0; }
.row .title > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-size: 13px; color: var(--muted); display: flex; gap: 6px 12px; flex-wrap: wrap; margin-top: 2px; }
.row .end { text-align: end; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.row .end .money { font-weight: 600; }
.row .thumb { width: 48px; height: 48px; border-radius: 10px; background: var(--grey-soft); object-fit: cover; flex: none; display: grid; place-items: center; color: var(--faint); }
.row .extra { font-size: 13px; color: var(--muted); flex: none; width: 140px; }
@media (max-width: 899px) { .row .extra { display: none; } }
.more { display: flex; justify-content: center; padding: 12px; }

.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 15px; flex: none;
  background: var(--brand-soft); color: var(--brand-ink); }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--grey-soft); color: var(--muted); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand-ink); }
.badge.plain::before { display: none; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty svg.i { width: 40px; height: 40px; color: var(--faint); margin: 0 auto 10px; stroke-width: 1.4; }
.empty b { display: block; color: var(--text); font-weight: 500; margin-bottom: 4px; }
.loading { padding: 40px; display: grid; place-items: center; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { height: 64px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, transparent, var(--grey-soft), transparent) 0 0 / 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ===== Detail ===== */
.detail-head { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 4px; }
.detail-head .titles { flex: 1; min-width: 200px; }
.detail-head h2 { font-size: 21px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.detail-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; display: flex; gap: 6px 14px; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.facts > div { background: var(--surface); padding: 12px 14px; }
.facts dt { font-size: 12.5px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.facts dd .money { font-weight: 600; }
.note { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; }

table.lines { width: 100%; border-collapse: collapse; font-size: 14px; }
table.lines th { text-align: start; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
table.lines td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.lines tr:last-child td { border-bottom: 0; }
table.lines .n { text-align: end; white-space: nowrap; }
.totals { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-top: 1px solid var(--line); background: var(--surface-2); }
.totals > div { display: flex; justify-content: space-between; font-size: 14px; }
.totals > div.grand { font-size: 16px; font-weight: 600; padding-top: 6px; border-top: 1px dashed var(--line-strong); }
.progress { height: 8px; border-radius: 99px; background: var(--grey-soft); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }

.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline .t { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.timeline .t:last-child { border-bottom: 0; }
.timeline .t .body { flex: 1; min-width: 0; }
.timeline .t .meta { font-size: 12.5px; color: var(--faint); margin-top: 2px; }
.timeline .t img { margin-top: 8px; border-radius: 10px; max-height: 260px; object-fit: cover; cursor: zoom-in; }
.dot { width: 34px; height: 34px; border-radius: 50%; background: var(--grey-soft); display: grid; place-items: center; color: var(--muted); flex: none; }
.dot svg.i { width: 17px; height: 17px; }

/* Stage board for customers */
.stages { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.stages button { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 8px; text-align: center; }
.stages button b { display: block; font-size: 19px; font-weight: 600; }
.stages button span { font-size: 12px; color: var(--muted); }
.stages button.on { border-color: var(--brand); background: var(--brand-soft); }

/* Product grid */
.pgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 720px) { .pgrid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); } }
.pcard { display: flex; flex-direction: column; overflow: hidden; color: inherit; }
.pcard .img { aspect-ratio: 4 / 3; background: var(--grey-soft); display: grid; place-items: center; color: var(--faint); }
.pcard .img img { width: 100%; height: 100%; object-fit: cover; }
.pcard .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.pcard .name { font-weight: 500; font-size: 14px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.8em; }
.pcard .foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; gap: 6px; }
.pcard.off { opacity: .55; }
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.view-toggle button { border: 0; background: none; width: 42px; height: 42px; display: grid; place-items: center; color: var(--muted); }
.view-toggle button.on { background: var(--grey-soft); color: var(--text); }

/* Bar chart */
.bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; align-items: end; height: 170px; padding: 14px 14px 0; }
.bars .m { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bars .pair i { width: min(16px, 40%); border-radius: 4px 4px 0 0; background: var(--ok); min-height: 2px; }
.bars .pair i.out { background: var(--bad); opacity: .75; }
.bars .m span { font-size: 11.5px; color: var(--muted); padding-bottom: 8px; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); padding: 10px 14px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }

/* ===== Forms ===== */
.form { display: grid; gap: 14px; }
.form .cols { display: grid; gap: 14px; }
@media (min-width: 560px) { .form .cols { grid-template-columns: 1fr 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 13.5px; font-weight: 500; color: var(--muted); }
.field > label .req { color: var(--bad); }
.field .hint { font-size: 12.5px; color: var(--faint); }
.field .err { font-size: 12.5px; color: var(--bad); }
.input, select.input, textarea.input { width: 100%; height: 46px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); padding: 0 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea.input { height: auto; min-height: 92px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.field.bad .input { border-color: var(--bad); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .input { padding-inline-start: 42px; }
.input-wrap .affix { position: absolute; inset-inline-start: 13px; color: var(--muted); display: flex; pointer-events: none; }
.input-wrap .affix .rial { height: 11px; margin: 0; }
.input.num { text-align: left; direction: ltr; }
.seg { display: flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg button { flex: 1; border: 0; background: none; min-height: 44px; padding: 0 8px; font-size: 13.5px; font-weight: 500; color: var(--muted); border-inline-end: 1px solid var(--line); }
.seg button:last-child { border-inline-end: 0; }
.seg button.on { background: var(--text); color: var(--surface); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 46px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); }
.switch input { width: 44px; height: 26px; appearance: none; border-radius: 99px; background: var(--line-strong); position: relative; transition: background .15s; margin: 0; flex: none; }
.switch input::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: inset-inline-start .15s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { inset-inline-start: 21px; }

.picker { width: 100%; min-height: 46px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); padding: 0 12px; text-align: start; }
.picker .val { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker .val.placeholder { color: var(--faint); }

.phone { display: flex; gap: 8px; }
.phone select { width: 118px; flex: none; padding: 0 8px; direction: ltr; }
.phone .input { flex: 1; direction: ltr; text-align: left; letter-spacing: .04em; }
.phone-hint { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--faint); }
.phone-hint.done { color: var(--ok); }
.flag { width: 20px; height: 14px; border-radius: 2px; flex: none; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }

.photo-field { display: flex; gap: 12px; align-items: center; }
.photo-field .preview { width: 84px; height: 84px; border-radius: 12px; background: var(--grey-soft); object-fit: cover; display: grid; place-items: center; color: var(--faint); flex: none; overflow: hidden; }
.photo-field .preview img { width: 100%; height: 100%; object-fit: cover; }

/* Line items editor */
.items { display: flex; flex-direction: column; gap: 8px; }
.item { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.item .name { grid-column: 1 / -1; display: flex; gap: 8px; }
.item .name .input { flex: 1; }
.item .nums { display: grid; grid-template-columns: 90px 1fr; gap: 8px; }
.item .line-total { align-self: center; font-weight: 600; min-width: 90px; text-align: end; }
@media (min-width: 720px) {
  .item { grid-template-columns: 1fr 90px 150px 110px 42px; align-items: center; }
  .item .name { grid-column: auto; }
  .item .nums { display: contents; }
}
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.icon-btn.pick { border: 1px solid var(--line-strong); background: var(--surface); flex: none; }

/* A package inside a sale: its price on top, its parts underneath */
.bundle { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--brand); border-radius: 12px; background: var(--brand-soft); }
.bundle-head { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.bundle-head > .input { grid-column: 1 / -1; grid-row: 2; }
.bundle-tag { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13.5px; color: var(--brand-ink); }
.bundle-tag svg { width: 16px; height: 16px; }
.bundle-head > .input-wrap { grid-row: 3; }
.bundle-head > .icon-btn { grid-row: 1; grid-column: 2; }
.parts { display: flex; flex-direction: column; gap: 6px; }
.part { display: grid; grid-template-columns: auto 1fr 56px auto; gap: 8px; align-items: center; padding-inline-start: 10px; border-inline-start: 2px solid var(--line-strong); }
.bundle .part .input { background: var(--surface); }
.bundle .add-part { align-self: flex-start; }
.bundle-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--warn-soft); font-size: 13.5px; }
.bundle-hint[hidden] { display: none; }
@media (min-width: 720px) {
  .bundle-head { grid-template-columns: auto 1fr 170px 42px; }
  .bundle-head > .input, .bundle-head > .input-wrap, .bundle-head > .icon-btn { grid-row: auto; grid-column: auto; }
  .part { grid-template-columns: auto 1fr 90px 42px; margin-inline-start: 24px; }
}
table.lines tr.ln-bundle td { font-weight: 600; }
table.lines tr.ln-bundle td svg { width: 15px; height: 15px; vertical-align: -2px; color: var(--brand); }
table.lines tr.ln-part td { padding-top: 5px; padding-bottom: 5px; font-size: 13px; color: var(--muted); }
table.lines td.part-name { padding-inline-start: 30px; }
table.lines td.part-name::before { content: '— '; color: var(--faint); }
.sum-box { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.sum-box > div { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.sum-box > div.grand { font-weight: 600; font-size: 16px; }

/* ===== Sheets & dialogs ===== */
.scrim { position: fixed; inset: 0; z-index: 80; background: rgba(6, 18, 22, .48); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease-out; }
.sheet { width: 100%; max-height: 92vh; background: var(--surface); border-radius: 20px 20px 0 0; display: flex; flex-direction: column; animation: rise .24s cubic-bezier(.2, .8, .2, 1); padding-bottom: var(--safe-bottom); }
.sheet > header { display: flex; align-items: center; gap: 8px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.sheet > header h3 { flex: 1; font-size: 17px; }
.sheet > .body { padding: 16px; overflow-y: auto; flex: 1; }
.sheet > footer { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.sheet > footer .btn { flex: 1; }
.sheet .grabber { width: 40px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: 8px auto 0; }
@media (min-width: 720px) {
  .scrim { align-items: center; padding: 24px; }
  .sheet { max-width: 560px; border-radius: 18px; max-height: 88vh; box-shadow: var(--shadow-lg); animation: pop .2s ease-out; padding-bottom: 0; }
  .sheet.wide { max-width: 860px; }
  .sheet .grabber { display: none; }
  .sheet > footer { justify-content: flex-end; }
  .sheet > footer .btn { flex: none; min-width: 120px; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: .4; } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
.menu-list { display: flex; flex-direction: column; }
.menu-list a, .menu-list button { display: flex; align-items: center; gap: 14px; padding: 14px 6px; border: 0; background: none; border-bottom: 1px solid var(--line); color: var(--text); font-weight: 500; text-align: start; width: 100%; }
.menu-list a:last-child, .menu-list button:last-child { border-bottom: 0; }
.menu-list .ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); }
.menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.menu-grid a { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 6px; border-radius: 14px; border: 1px solid var(--line); color: var(--text); font-size: 13px; font-weight: 500; text-align: center; }
.menu-grid a .ico { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); }

.toasts { position: fixed; z-index: 120; inset-inline: 0; bottom: calc(var(--tab-h) + var(--safe-bottom) + 16px); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
@media (min-width: 720px) { .toasts { bottom: 24px; } }
.toast { background: var(--night); color: #fff; padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14px; animation: rise .2s ease-out; max-width: 480px; }
.toast.bad { background: var(--bad); }
.lightbox { position: fixed; inset: 0; z-index: 130; background: rgba(0,0,0,.9); display: grid; place-items: center; padding: 16px; }
.lightbox img { max-height: 100%; max-width: 100%; border-radius: 8px; }

/* ===== Auth screens ===== */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px calc(24px + var(--safe-bottom)); background:
  radial-gradient(120% 80% at 100% 0%, #13404D 0%, transparent 60%), radial-gradient(90% 70% at 0% 100%, #0E3A3A 0%, transparent 55%), var(--night); }
.gate .box { width: 100%; max-width: 400px; background: var(--surface); border-radius: 22px; padding: 28px 22px 22px; box-shadow: var(--shadow-lg); }
.gate .logo { width: 84px; height: 84px; margin: 0 auto 10px; border-radius: 22px; background: #fff; display: grid; place-items: center; box-shadow: 0 0 0 1px var(--line); }
.gate .logo img { width: 74px; }
.gate h1 { text-align: center; font-size: 21px; }
.gate p.lead { text-align: center; color: var(--muted); margin: 6px 0 20px; font-size: 14px; }
.gate .server-line { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 16px; font-size: 12.5px; color: var(--muted); }
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13.5px; background: var(--bad-soft); color: var(--bad); }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.offline-bar { position: fixed; top: var(--safe-top); inset-inline: 0; z-index: 140; background: var(--warn); color: #fff; text-align: center; font-size: 13px; padding: 6px; }

/* ===== Print (invoices) ===== */
.print-only { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; color: #000; font-size: 12.5px; }
  .side, .tabbar, .topbar, .fab, .toasts, .no-print, .pane-list { display: none !important; }
  .main { margin: 0 !important; }
  .view { padding: 0 !important; }
  .split { display: block !important; }
  .print-only { display: block; }
  .card { border-color: #bbb; }
}
.doc { background: #fff; color: #10232a; border-radius: var(--radius); border: 1px solid var(--line); padding: 28px; }
.doc .doc-head { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 18px; border-bottom: 2px solid #10232a; }
.doc .doc-head img { width: 76px; }
.doc .doc-title { font-size: 22px; font-weight: 700; white-space: nowrap; }
.doc .doc-table { overflow-x: auto; margin-inline: -4px; }
.doc .doc-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 18px 0; font-size: 13.5px; }
.doc .doc-meta b { display: block; font-size: 12px; color: #5A7078; font-weight: 500; }
.doc table.lines th { background: #F2F7F8; color: #10232a; }
.doc .doc-foot { margin-top: 22px; font-size: 12.5px; color: #44595f; white-space: pre-wrap; border-top: 1px solid #DDE7EA; padding-top: 12px; }
@media (max-width: 719px) {
  .doc { padding: 16px; }
  .doc .doc-meta { grid-template-columns: 1fr; }
  .doc .doc-head { flex-direction: column-reverse; gap: 12px; }
  .doc .doc-head > div:last-child { text-align: start !important; }
  .doc table.lines { font-size: 13px; }
  .doc table.lines th, .doc table.lines td { padding: 8px 6px; }
  .doc .totals { min-width: 0; }
}
@media print { .doc { border: 0; padding: 0; } }
