:root {
  --navy: #002448;
  --navy-2: #032a5a;
  --blue: #0a4fa8;
  --blue-2: #1565c0;
  --sky: #3eb6f5;
  --gold: #e6b422;
  --gold-d: #8a6a10;
  --bg: #eef3f8;
  --card: #ffffff;
  --text: #10233a;
  --muted: #5d738a;
  --line: #d5e2ee;
  --danger: #d32f2f;
  --danger-bg: #fdecee;
  --ok: #1b8a45;
  --ok-bg: #e7f6ec;
  --warn: #c47a00;
  --warn-bg: #fff6e4;
  --purple: #7b1fa2;
  --purple-bg: #f3e8fb;
  --shadow: 0 10px 32px rgba(3, 42, 90, .08);
  --r: 22px;
  --tap: 48px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Cairo", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}
a { color: var(--blue); text-decoration: none; }
img { max-width: 100%; }
button, input, select, textarea { font-family: inherit; font-size: 1rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.ico { display: block; flex-shrink: 0; }
.ib {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; flex-shrink: 0;
}
.ib-blue { background: #e3f2fd; color: #1565c0; }
.ib-pink { background: #fce4ec; color: #c2185b; }
.ib-green { background: #e8f5e9; color: #2e7d32; }
.ib-red { background: #ffebee; color: #c62828; }
.ib-purple { background: #f3e5f5; color: #7b1fa2; }
.ib-gold { background: #fff8e1; color: #b28704; }
.ib-teal { background: #e0f7fa; color: #00838f; }
.ib-orange { background: #fff3e0; color: #ef6c00; }
.ib-navy { background: #e8eef7; color: #032a5a; }
.ib-gray { background: #eceff1; color: #546e7a; }

.app-shell { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 10px 28px rgba(2, 34, 72, .28);
}
.topbar-inner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px 12px; max-width: 1240px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; }
.brand img {
  width: 50px; height: 50px; border-radius: 50%; background: #fff;
  object-fit: cover; box-shadow: 0 0 0 2px rgba(255,255,255,.4);
}
.brand small { display: block; font-weight: 500; opacity: .88; font-size: 12px; }
.search-box { flex: 1; min-width: 240px; }
.search-box form { display: flex; background: #fff; border-radius: 999px; overflow: hidden; box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.search-box input {
  flex: 1; border: 0; padding: 11px 18px; min-height: 46px; outline: none; color: var(--text);
}
.search-box button {
  border: 0; background: var(--gold); color: #1a1403; font-weight: 800;
  padding: 0 20px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0;
  display: grid; place-items: center; background: rgba(255,255,255,.12); color: #fff;
  position: relative; cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,.22); }
.badge {
  position: absolute; top: 2px; left: 2px; background: #ff3d57; color: #fff;
  border-radius: 99px; font-size: 10px; min-width: 18px; height: 18px;
  display: grid; place-items: center; font-weight: 800;
}
.userchip {
  display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.12);
  border-radius: 999px; padding: 4px 10px 4px 4px; color: #fff; font-weight: 700; font-size: 13px;
}
.nav-bar { background: var(--blue); }
.nav {
  display: flex; gap: 2px; overflow-x: auto; padding: 0 8px;
  max-width: 1240px; margin: 0 auto; width: 100%; scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: #d6e8ff; white-space: nowrap; padding: 13px 14px;
  font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; gap: 6px;
  position: relative;
}
.nav a.active, .nav a:hover { color: #fff; background: rgba(255,255,255,.12); }
.nav a.active::after {
  content: ""; position: absolute; right: 12px; left: 12px; bottom: 0;
  height: 3px; background: var(--gold); border-radius: 3px 3px 0 0;
}
.wrap { width: min(1240px, calc(100% - 24px)); margin: 18px auto 100px; }
.page-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.page-title { margin: 0; font-size: 1.45rem; display: flex; align-items: center; gap: 10px; }
.sec-title { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; margin: 0 0 12px; }
.grid { display: grid; gap: 12px; }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 20px;
}
.stat {
  text-align: right; display: flex; align-items: center; gap: 12px; padding: 16px;
}
.stat .ib { width: 48px; height: 48px; border-radius: 14px; }
.stat b { display: block; font-size: 1.45rem; color: var(--navy-2); line-height: 1.2; }
.stat span { color: var(--muted); font-size: 13px; font-weight: 700; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 16px; border-radius: 14px; border: 0;
  font-weight: 800; cursor: pointer; text-align: center;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #083f86; }
.btn-gold { background: var(--gold); color: #1a1403; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: #fff; color: var(--blue); border: 1.5px solid #c5d8ea; }
.btn-soft { background: #e3f2fd; color: var(--blue-2); border: 0; }
.btn-lg { min-height: 54px; font-size: 1.05rem; padding: 12px 18px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 800;
}
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-danger { background: var(--danger-bg); color: var(--danger); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-purple { background: var(--purple-bg); color: var(--purple); }
.pill-blue { background: #e3f2fd; color: var(--blue); }
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: #fff;
}
.item:hover { border-color: #b9d2ea; box-shadow: var(--shadow); }
.item h3 { margin: 0 0 4px; font-size: 1rem; }
.muted { color: var(--muted); font-size: 13px; }
.flash {
  padding: 12px 14px; border-radius: 14px; margin-bottom: 12px; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
}
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-error, .errors { background: var(--danger-bg); color: var(--danger); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }
.flash-info { background: #e3f2fd; color: var(--blue); }
.flash-purple { background: var(--purple-bg); color: var(--purple); }
.errors ul { margin: 8px 0 0; padding-right: 18px; }
label { font-weight: 700; margin: 12px 0 6px; display: flex; align-items: center; gap: 8px; }
.lab-ico { width: 28px; height: 28px; border-radius: 8px; }
.field {
  width: 100%; min-height: var(--tap); border: 1.5px solid var(--line);
  border-radius: 12px; padding: 10px 12px; background: #fff;
}
.field:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(10,79,168,.12); }
.field.bad { border-color: var(--danger); background: #fff8f8; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.hint.ok { color: var(--ok); font-weight: 700; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 8px; border-bottom: 1px solid var(--line); text-align: right; }
th { color: var(--muted); font-weight: 800; background: #f7fbfe; }
.table-wrap { overflow: auto; border-radius: 14px; border: 1px solid var(--line); }

.profile-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  margin-bottom: 8px; padding-bottom: 12px; border-bottom: 1px solid #eef3f8;
}
.profile-name { margin: 0; font-size: 1.55rem; font-weight: 800; color: var(--navy-2); }

.prow {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid #eef3f8;
}
.prow:last-of-type { border-bottom: 0; }
.prow-r { display: flex; align-items: center; gap: 10px; min-width: 0; }
.prow-lab { font-weight: 700; color: var(--muted); }
.prow-v { font-weight: 800; text-align: left; color: var(--text); }

.kv {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid #eef3f8;
}
.kv:last-child { border-bottom: 0; }

.banner {
  display: flex; align-items: center; gap: 10px;
  margin-top: 14px; padding: 12px 14px; border-radius: 14px; font-weight: 800;
}
.banner .dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.banner-purple { background: var(--purple-bg); color: var(--purple); }
.banner-purple .dot { background: var(--purple); }
.banner-warn { background: var(--warn-bg); color: var(--warn); }
.banner-warn .dot { background: var(--warn); }
.banner-error { background: var(--danger-bg); color: var(--danger); }
.banner-error .dot { background: var(--danger); }
.banner-info { background: #e3f2fd; color: var(--blue); }
.banner-info .dot { background: var(--blue); }

.auth-page {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 20% 10%, #4fc3f7 0, transparent 40%),
    linear-gradient(180deg, #0a4fa8 0%, #022248 100%);
  display: grid; place-items: center; padding: 20px;
}
.auth-card {
  width: min(440px, 100%); background: #fff; border-radius: 28px; padding: 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,.22);
}
.auth-logo { width: 128px; height: 128px; object-fit: contain; display: block; margin: 0 auto 8px; }
.tabs { display: flex; background: #eef6fc; border-radius: 14px; padding: 4px; margin: 12px 0; }
.tabs a, .tabs button {
  flex: 1; border: 0; background: transparent; min-height: 42px; border-radius: 12px;
  font-weight: 800; color: var(--muted); cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px;
}
.tabs .on { background: #fff; color: var(--blue); box-shadow: var(--shadow); }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; background: #fff;
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom)); z-index: 40;
}
.bottom-nav a {
  color: var(--muted); font-size: 11px; font-weight: 800; text-align: center;
  padding: 4px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.bottom-nav a.active { color: var(--blue); }
.bottom-nav .ib { width: 28px; height: 28px; border-radius: 9px; }

.sticky-bar {
  position: sticky; top: 78px; z-index: 20;
  background: linear-gradient(90deg, #032a5a, #0a4fa8); color: #fff;
  border-radius: 16px; padding: 12px 16px;
  display: flex; justify-content: space-between; gap: 10px; font-weight: 800; margin-bottom: 14px;
}
.money-words { font-size: 13px; color: var(--gold-d); font-weight: 700; }
.map-box { height: 240px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); margin-top: 8px; }
.hero-cust { text-align: center; padding: 8px 0 10px; }
.hero-cust img { width: 112px; height: 112px; object-fit: contain; }
.code-big { font-size: 2.1rem; letter-spacing: .35em; text-align: center; font-weight: 900; color: var(--navy-2); }
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; }
.filters a, .filters span {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 14px;
  white-space: nowrap; color: var(--text); font-weight: 700; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
}
.filters .on { background: var(--blue); color: #fff; border-color: var(--blue); }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; display: grid; place-items: center; gap: 8px; }
.empty-t { font-weight: 800; color: var(--text); }
.confirm-box { background: #fff8e1; border: 1px solid #ffe082; padding: 16px; border-radius: 16px; }
.seg { display: flex; gap: 6px; overflow-x: auto; margin: 14px 0; }
.seg a, .seg button {
  border: 0; background: #eef3f8; color: var(--muted); border-radius: 12px;
  padding: 8px 14px; font-weight: 800; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.seg .on { background: var(--blue); color: #fff; }
.panel { display: none; }
.panel.on { display: block; }
.qr-box { display: grid; place-items: center; padding: 12px; }
.meter {
  height: 10px; background: #e3eef8; border-radius: 99px; overflow: hidden; margin: 4px 0 10px;
}
.meter > i { display: block; height: 100%; background: linear-gradient(90deg, #39b6f5, #0a4fa8); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.toolbar .field { min-width: 160px; }
@media (max-width: 860px) {
  .g-4 { grid-template-columns: repeat(2, 1fr); }
  .g-3 { grid-template-columns: 1fr 1fr; }
  .nav-bar { display: none; }
  .userchip span:last-child { display: none; }
  .search-box { flex: 1 1 100%; order: 5; }
}
@media (max-width: 640px) {
  .g-2, .g-3 { grid-template-columns: 1fr; }
  .prow { align-items: flex-start; }
  .prow-v { max-width: 58%; }
}
@media (min-width: 861px) {
  .bottom-nav { display: none; }
}
@media print {
  .topbar, .bottom-nav, .no-print, .pwa-install { display: none !important; }
  .wrap { margin: 0; width: 100%; }
}

.pwa-install {
  position: fixed;
  right: 12px;
  left: 12px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 80;
  background: #fff;
  color: var(--text);
  border-radius: 18px;
  box-shadow: 0 14px 40px rgba(3, 42, 90, .24);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 520px;
  margin: 0 auto;
}
.pwa-install[hidden] { display: none !important; }
.pwa-install img { width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0; }
.pwa-install-txt { flex: 1; min-width: 0; }
.pwa-install-txt b { display: block; font-size: 14px; }
.pwa-install-txt span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.pwa-install .btn { min-height: 42px; padding: 8px 14px; flex-shrink: 0; }
.pwa-x {
  border: 0; background: #eef3f8; width: 36px; height: 36px; border-radius: 50%;
  font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); flex-shrink: 0;
}
body.auth-page .pwa-install { bottom: 16px; }
@media (max-width: 860px) {
  .pwa-install { bottom: calc(70px + env(safe-area-inset-bottom)); }
  body.auth-page .pwa-install { bottom: 16px; }
}
