/* فاتورتي — mobile-first styles. Same palette as the portal (tokens.css). */
:root {
  --primary: #0F4C81; --primary-700: #0B3A63; --primary-100: #E8F1F9; --secondary: #1A6E5C;
  --ink: #1B1F23; --ink-2: #3D444B; --ink-3: #6A737D; --bg: #F4F6F9; --surface: #FFFFFF; --border: #DEE2E6;
  --success: #1A7F37; --success-tint: #E6F4EA; --warning: #9A6700; --warning-tint: #FFF8E1; --danger: #B42318; --danger-tint: #FEF1F0;
  --radius: 14px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 2px 8px rgba(15,23,42,.06);
  --font: "IBM Plex Sans Arabic", "Noto Naskh Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
html[dir="ltr"] { --font: "Inter", "Segoe UI", system-ui, sans-serif; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.55; min-height: 100vh; padding-bottom: calc(72px + var(--safe-bottom)); -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
h1 { font-size: 1.35rem; margin: 0 0 12px; }
h2 { font-size: 1.1rem; margin: 18px 0 10px; }
p { margin: 0 0 10px; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; unicode-bidi: isolate; }
.muted { color: var(--ink-3); }
.small { font-size: .875rem; }
[hidden] { display: none !important; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); background: var(--primary); color: #fff; }
.topbar-brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; flex: 1; min-width: 0; }
.topbar-brand span { display: flex; flex-direction: column; line-height: 1.2; }
.topbar-brand small { opacity: .8; font-size: .75rem; }
.topbar-btn { color: #fff; text-decoration: none; font-size: 1.4rem; padding: 4px 8px; }
.net { font-size: .75rem; background: var(--warning-tint); color: var(--warning); border-radius: 999px; padding: 2px 10px; }

main { padding: 16px; max-width: 640px; margin: 0 auto; outline: none; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.hero { background: linear-gradient(135deg, var(--primary), var(--primary-700)); color: #fff; }
.hero p { opacity: .9; }

.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.action { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 104px; border: 0; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); text-decoration: none; color: var(--ink); font-weight: 600; text-align: center; padding: 12px; cursor: pointer; }
.action .ico { font-size: 1.9rem; line-height: 1; }
.action.primary { background: var(--primary); color: #fff; }
.action.wide { grid-column: 1 / -1; min-height: 72px; flex-direction: row; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 18px; border-radius: 12px; border: 1px solid transparent; font-weight: 700; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--primary); border-color: var(--border); }
.btn-danger { background: var(--danger-tint); color: var(--danger); border-color: #F0A39C; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: .875rem; font-weight: 600; color: var(--ink-2); }
.input { width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid #B6BCC4; border-radius: 12px; background: #fff; }
.input:focus { outline: 2px solid #1F7DCC; outline-offset: 1px; border-color: #1F7DCC; }
textarea.input { min-height: 96px; }
.hint { font-size: .8rem; color: var(--ink-3); }
.ok-text { color: var(--success); font-size: .875rem; }
.err-text { color: var(--danger); font-size: .875rem; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #E9ECF1; border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.segmented button { border: 0; background: transparent; border-radius: 9px; min-height: 40px; font-weight: 600; font-size: .875rem; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: #fff; color: var(--primary); box-shadow: var(--shadow); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 8px 14px; font-size: .875rem; cursor: pointer; }
.chip b { color: var(--primary); }

.line { display: grid; grid-template-columns: 1fr 1.4fr 44px; gap: 6px; align-items: center; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px dashed var(--border); }
.line > .input:first-child { grid-column: 1 / -1; }
.line .input { min-height: 44px; padding: 8px; }
.line .num { text-align: end; }
.line .remove { border: 0; background: var(--danger-tint); color: var(--danger); border-radius: 10px; min-height: 44px; cursor: pointer; }
.total { display: flex; justify-content: space-between; align-items: baseline; font-size: 1.35rem; font-weight: 800; padding: 12px 0; border-top: 2px solid var(--ink); margin-top: 8px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list a { text-decoration: none; color: inherit; display: flex; justify-content: space-between; gap: 10px; width: 100%; }
.list .amount { font-weight: 700; white-space: nowrap; unicode-bidi: isolate; }

.badge { display: inline-block; border-radius: 999px; padding: 1px 10px; font-size: .75rem; font-weight: 700; }
.badge-success { background: var(--success-tint); color: var(--success); }
.badge-danger { background: var(--danger-tint); color: var(--danger); }
.badge-warning { background: var(--warning-tint); color: var(--warning); }
.badge-info { background: var(--primary-100); color: var(--primary); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.stat { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.stat span { display: block; font-size: .8rem; color: var(--ink-3); }
.stat strong { font-size: 1.25rem; unicode-bidi: isolate; }

.qr-box { text-align: center; }
.qr-box svg { width: min(260px, 70vw); height: auto; background: #fff; padding: 8px; border-radius: 12px; }
.result { border-radius: var(--radius); padding: 16px; margin-bottom: 14px; border: 2px solid; }
.result h2 { margin: 0 0 4px; }
.result-success { background: var(--success-tint); border-color: #6FCF97; color: var(--success); }
.result-warning { background: var(--warning-tint); border-color: #E0B341; color: var(--warning); }
.result-danger { background: var(--danger-tint); border-color: #F0A39C; color: var(--danger); }
dl.kv { margin: 0; display: grid; gap: 10px; }
dl.kv dt { font-size: .75rem; color: var(--ink-3); font-weight: 600; }
dl.kv dd { margin: 0; font-weight: 600; }

.scanner { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 1 / 1; margin-bottom: 14px; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.85); border-radius: 16px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }

.banner { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: var(--warning-tint); color: var(--warning); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-weight: 600; }
.alert { border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.alert-danger { background: var(--danger-tint); color: var(--danger); }
.alert-success { background: var(--success-tint); color: var(--success); }
.alert ul { margin: 0; padding-inline-start: 18px; }

.tabbar { position: fixed; bottom: 0; inset-inline: 0; z-index: 10; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #fff; border-top: 1px solid var(--border); padding-bottom: var(--safe-bottom); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; color: var(--ink-3); text-decoration: none; font-size: .72rem; font-weight: 600; }
.tabbar a .ico { font-size: 1.35rem; line-height: 1.1; }
.tabbar a[aria-current="page"] { color: var(--primary); }

.toast { position: fixed; bottom: calc(84px + var(--safe-bottom)); inset-inline: 16px; z-index: 20; background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 16px; text-align: center; box-shadow: var(--shadow); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--primary-100); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 24px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
@media print { .topbar, .tabbar, .no-print { display: none !important; } body { background: #fff; padding: 0; } .card { box-shadow: none; } }
.result-info { background: #EAF2FB; border-color: #8DB6E2; color: #0B5394; }
.test-banner { background: var(--warning-tint); color: var(--warning); border: 2px dashed #E0B341; border-radius: 12px; padding: 8px 12px; font-weight: 700; margin: 0 0 12px; }
