:root {
  --bg: #f1f6f5; --card: #ffffff; --ink: #14201f; --muted: #627371; --line: #dde8e6;
  --brand: #0f766e; --brand-2: #14b8a6; --brand-soft: #dff4f1;
  --amber: #b45309; --amber-soft: #fff1d6; --green: #047857; --green-soft: #d8f5e8;
  --red: #dc2626; --red-soft: #fde8e8; --field: #f6faf9;
  --shadow: 0 1px 2px rgba(10, 60, 55, .06), 0 6px 20px rgba(10, 60, 55, .07);
  --r: 18px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
:root:not([data-theme="light"]) { color-scheme: light dark; }
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1615; --card: #162221; --ink: #e8f2f0; --muted: #94aaa6; --line: #243634;
    --brand: #2dd4bf; --brand-2: #14b8a6; --brand-soft: #123532;
    --amber: #fbbf24; --amber-soft: #3a2d10; --green: #34d399; --green-soft: #12332a; --red: #f87171; --red-soft: #3a1b1b; --field: #101b1a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", system-ui, -apple-system, sans-serif; font-size: 16px; line-height: 1.55; min-height: 100vh; overscroll-behavior-y: contain; }
body.lock { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px calc(110px + var(--safe-b)); }

.hero { background: linear-gradient(135deg, #0f766e, #14b8a6); color: #fff; padding: calc(16px + var(--safe-t)) 0 22px; border-radius: 0 0 28px 28px; }
.hero .wrap { padding-bottom: 0; }
.hero-top { display: flex; align-items: center; justify-content: space-between; }
.hero h1 { margin: 0; font-size: 26px; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.hero .bell { width: 36px; height: 36px; border-radius: 12px; background: rgba(255, 255, 255, .2); display: grid; place-items: center; font-size: 20px; }
.hero p { margin: 8px 0 10px; opacity: .92; font-size: 14.5px; }
.icon-btn { width: 42px; height: 42px; border-radius: 13px; background: rgba(255, 255, 255, .18); font-size: 19px; display: grid; place-items: center; }
.wa-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 99px; background: rgba(255, 255, 255, .18); color: #fff; font-size: 13px; }
.wa-pill i { width: 9px; height: 9px; border-radius: 50%; background: #9ca3af; }
.wa-pill.ok i { background: #4ade80; box-shadow: 0 0 0 3px rgba(74, 222, 128, .3); }
.wa-pill.warn i { background: #fbbf24; } .wa-pill.bad i { background: #f87171; }

.tabs { display: flex; gap: 8px; margin: 16px 0 12px; overflow-x: auto; }
.tabs button { flex: 1; min-width: max-content; padding: 10px 12px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); color: var(--muted); font-weight: 600; font-size: 14.5px; border: 2px solid transparent; }
.tabs button em { font-style: normal; margin-inline-start: 6px; background: var(--line); border-radius: 99px; padding: 1px 8px; font-size: 12.5px; }
.tabs button.on { color: var(--brand); border-color: var(--brand); } .tabs button.on em { background: var(--brand-soft); }

.list { display: grid; gap: 12px; }
.card { background: var(--card); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); border-inline-start: 6px solid var(--brand-2); }
.card.soon { border-inline-start-color: #f59e0b; } .card.late { border-inline-start-color: var(--red); } .card.done { border-inline-start-color: var(--line); opacity: .8; }
.card .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.amt { font-size: 28px; font-weight: 800; letter-spacing: .3px; direction: ltr; }
.due { text-align: end; line-height: 1.3; } .due b { display: block; font-size: 16px; } .due small { color: var(--muted); font-size: 12.5px; }
.card.soon .due b { color: var(--amber); } .card.late .due b { color: var(--red); }
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 4px; color: var(--muted); font-size: 14.5px; } .meta b { color: var(--ink); }
.rem { margin-top: 8px; padding: 7px 10px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); font-size: 13.5px; font-weight: 600; }
.errline { margin-top: 6px; color: var(--red); font-size: 13px; }
.foot { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 10px; } .sp { flex: 1; }
.chip { font-size: 12.5px; padding: 3px 10px; border-radius: 99px; background: var(--line); color: var(--muted); }
.chip.ok { background: var(--green-soft); color: var(--green); } .chip.warn { background: var(--amber-soft); color: var(--amber); } .chip.bad { background: var(--red-soft); color: var(--red); }
.mini { padding: 7px 11px; border-radius: 11px; background: var(--field); border: 1px solid var(--line); font-size: 13.5px; }
.mini.ok { background: var(--green-soft); color: var(--green); border-color: transparent; font-weight: 600; } .mini.bad { color: var(--red); }
.empty { text-align: center; color: var(--muted); padding: 50px 10px; line-height: 2; }

.fab { position: fixed; inset-inline-start: 20px; bottom: calc(22px + var(--safe-b)); width: 62px; height: 62px; border-radius: 22px; background: linear-gradient(135deg, #0f766e, #14b8a6); color: #fff; font-size: 32px; box-shadow: 0 8px 24px rgba(15, 118, 110, .45); z-index: 20; }
.fab:active { transform: scale(.94); }

.sheet-bg { position: fixed; inset: 0; background: rgba(5, 20, 18, .5); display: flex; align-items: flex-end; justify-content: center; z-index: 50; opacity: 0; transition: opacity .18s; }
.sheet-bg.on { opacity: 1; }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--card); border-radius: 26px 26px 0 0; padding: 10px 18px calc(22px + var(--safe-b)); transform: translateY(30px); transition: transform .2s; }
.sheet-bg.on .sheet { transform: none; }
@media (min-width: 640px) { .sheet-bg { align-items: center; } .sheet { border-radius: 26px; } }
.grab { width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: 4px auto 10px; }
.sheet h2 { margin: 4px 0 12px; font-size: 20px; }
.sect { margin: 16px 0 8px; font-weight: 700; color: var(--brand); font-size: 15px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; } .grid .full { grid-column: 1 / -1; }
label { display: block; font-size: 13.5px; color: var(--muted); font-weight: 600; }
input, select { display: block; width: 100%; margin-top: 4px; padding: 12px 12px; border-radius: 13px; border: 1.5px solid var(--line); background: var(--field); color: var(--ink); font-size: 16px; min-height: 48px; }
input:focus, select:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft); }
.quick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; font-size: 13px; color: var(--muted); }
.quick button { padding: 6px 12px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); font-size: 13px; font-weight: 600; }
.seg { display: flex; background: var(--field); border: 1.5px solid var(--line); border-radius: 14px; padding: 3px; gap: 3px; margin-bottom: 10px; }
.seg button { flex: 1; padding: 10px 6px; border-radius: 11px; color: var(--muted); font-weight: 600; font-size: 14.5px; }
.seg button.on { background: var(--brand); color: #fff; }
.hint { color: var(--muted); font-size: 13.5px; margin: 6px 0; }
.err { color: var(--red); font-size: 14px; min-height: 20px; margin-top: 8px; }
.actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; } .actions .btn { flex: 1; }
.btn { padding: 13px 16px; border-radius: 14px; background: var(--field); border: 1.5px solid var(--line); font-weight: 700; min-height: 48px; }
.btn.pri { background: linear-gradient(135deg, #0f766e, #14b8a6); color: #fff; border-color: transparent; } .btn.bad { color: var(--red); } .btn:disabled { opacity: .55; }
.wa { padding: 12px 14px; border-radius: 14px; display: grid; gap: 2px; font-size: 14.5px; }
.wa.ok { background: var(--green-soft); color: var(--green); } .wa.warn { background: var(--amber-soft); color: var(--amber); } .wa.bad { background: var(--red-soft); color: var(--red); }
.qr { display: block; width: 260px; max-width: 80%; margin: 14px auto 4px; border-radius: 14px; background: #fff; padding: 8px; }

.login { max-width: 360px; margin: 0 auto; padding: calc(70px + var(--safe-t)) 24px 24px; text-align: center; }
.login .logo { font-size: 56px; } .login h1 { margin: 6px 0 2px; } .login p { color: var(--muted); margin: 0 0 18px; }
.login input { text-align: center; margin-bottom: 10px; } .login .btn { width: 100%; }

#toast { position: fixed; inset-inline: 16px; bottom: calc(96px + var(--safe-b)); margin: 0 auto; max-width: 420px; background: #14201f; color: #fff; padding: 12px 16px; border-radius: 14px; text-align: center; font-size: 14.5px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 80; }
#toast.on { opacity: 1; }

/* v2: header buttons, multi-recipient chips, delivery chips, import preview */
.hbtns { display: flex; gap: 8px; }
label small { font-weight: 400; opacity: .8; }
.tgs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tg { font-size: 12.5px; padding: 3px 10px; border-radius: 99px; background: var(--field); border: 1px solid var(--line); color: var(--muted); }
.tg.sent { background: var(--green-soft); color: var(--green); border-color: transparent; } .tg.failed { background: var(--red-soft); color: var(--red); border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; min-height: 30px; align-items: center; }
.rc { display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 12px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); font-weight: 600; font-size: 14px; }
.rc button { width: 22px; height: 22px; border-radius: 50%; background: rgba(0, 0, 0, .1); font-size: 11px; }
.addrow { display: flex; gap: 8px; align-items: center; } .addrow input, .addrow select { margin-top: 0; flex: 1; } .addrow .hint { flex: 1; margin: 0; }
.filebtn { display: flex; align-items: center; justify-content: center; cursor: pointer; text-align: center; color: var(--ink); font-size: 16px; }
.sumrow { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 8px; }
.prev { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; font-size: 13.5px; }
.prev li { padding: 7px 12px; border-bottom: 1px solid var(--line); } .prev li:last-child { border-bottom: 0; }
.prev li.bad { background: var(--red-soft); color: var(--red); } .prev li.dup { background: var(--amber-soft); color: var(--amber); } .prev em { font-style: normal; }
input[hidden] { display: none !important; }

/* statistics */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 4px; }
.kpi { background: var(--field); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: grid; gap: 1px; }
.kpi small { color: var(--muted); font-size: 12.5px; font-weight: 600; } .kpi b { font-size: 21px; direction: ltr; text-align: end; } .kpi span { color: var(--muted); font-size: 12.5px; }
.kpi.big { grid-column: 1 / -1; background: var(--brand-soft); border-color: transparent; } .kpi.big b { font-size: 28px; color: var(--brand); }
.kpi.bad { background: var(--red-soft); border-color: transparent; } .kpi.bad b { color: var(--red); }
.brow { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.bl { display: flex; gap: 8px; align-items: baseline; font-weight: 600; } .bl em { font-style: normal; color: var(--muted); font-size: 12.5px; }
.bar { grid-column: 1; height: 9px; border-radius: 99px; background: var(--line); overflow: hidden; align-self: center; } .bar i { display: block; height: 100%; background: linear-gradient(90deg, #14b8a6, #0f766e); border-radius: 99px; }
.bv { grid-column: 2; grid-row: 1 / span 2; text-align: end; display: grid; line-height: 1.25; } .bv b { direction: ltr; } .bv small { color: var(--muted); font-size: 12px; }
