:root{
  --brand:#0f766e;
  --brand-2:#0d9488;
  --brand-dark:#0b4f4a;
  --ink:#0f172a;
  --muted:#64748b;
  --line:#e2e8f0;
  --bg:#eef2f7;
  --card:#ffffff;
  --ok:#0f766e;
  --warn:#b45309;
  --warn-bg:#fef3c7;
  --ok-bg:#ccfbf1;
  --danger:#b91c1c;
  --radius:18px;
}

*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0}
body{
  font-family:"Segoe UI","Noto Kufi Arabic",Tahoma,"Cairo",system-ui,-apple-system,sans-serif;
  background:var(--bg);
  color:var(--ink);
  min-height:100vh;
  -webkit-font-smoothing:antialiased;
}
.hidden{display:none !important}
button{font-family:inherit}

/* ============ شاشة الدخول ============ */
#loginScreen{
  min-height:100vh;
  display:flex;
  flex-direction:column;
  align-items:center;
  padding:28px 22px 22px;
  background:
    radial-gradient(120% 60% at 50% 0%, #d9f2ee 0%, rgba(217,242,238,0) 60%),
    var(--bg);
}

.login-top{text-align:center;margin-top:26px}
.brandmark{
  width:64px;height:64px;margin:0 auto 14px;
  border-radius:20px;
  background:linear-gradient(140deg,var(--brand-2),var(--brand-dark));
  color:#fff;display:grid;place-items:center;
  box-shadow:0 10px 24px -8px rgba(15,118,110,.55);
}
.brandmark svg{width:32px;height:32px}
.login-top h1{margin:0;font-size:26px;letter-spacing:-.3px}
.login-top .sub{margin:8px 0 0;color:var(--muted);font-size:14px}

.login-card{
  width:100%;max-width:360px;
  margin-top:26px;
  background:var(--card);
  border:1px solid var(--line);
  border-radius:24px;
  padding:20px 18px 16px;
  box-shadow:0 18px 40px -28px rgba(15,23,42,.45);
}
.lbl{display:block;font-size:13px;color:var(--muted);margin-bottom:10px;text-align:center}

.code-boxes{display:flex;gap:14px;justify-content:center;direction:ltr}
.code-box{
  width:54px;height:62px;border-radius:15px;
  border:1.5px solid var(--line);
  background:#f8fafc;
  display:grid;place-items:center;
  font-size:25px;font-weight:700;
  color:var(--ink);
  transition:border-color .15s, background .15s, transform .12s;
}
.code-box.filled{border-color:var(--brand);background:#f0fdfa}
.code-box.active{border-color:var(--brand);box-shadow:0 0 0 3px rgba(15,118,110,.14)}


.err{min-height:18px;margin:10px 0 4px;text-align:center;font-size:13px;color:var(--danger);font-weight:600}
.shake{animation:shake .32s}
@keyframes shake{
  0%,100%{transform:translateX(0)}
  25%{transform:translateX(-7px)}
  75%{transform:translateX(7px)}
}

.keypad{
  display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-top:6px;
  direction:ltr;
}
.keypad button{
  height:56px;border-radius:16px;border:1px solid var(--line);
  background:#f8fafc;color:var(--ink);
  font-size:22px;font-weight:600;
  cursor:pointer;transition:transform .08s, background .15s;
}
.keypad button:active{transform:scale(.96);background:#eef2f7}
.keypad .ghost{font-size:19px;color:var(--muted)}
.keypad .go{
  background:linear-gradient(140deg,var(--brand-2),var(--brand));
  border-color:transparent;color:#fff;font-size:16px;font-weight:700;
}

.demo-hint{
  margin-top:16px;padding-top:14px;border-top:1px dashed var(--line);
  font-size:12px;color:var(--muted);text-align:center;line-height:1.7;
}
.tag{
  display:inline-block;background:var(--warn-bg);color:var(--warn);
  border-radius:999px;padding:2px 8px;font-size:11px;font-weight:700;margin-inline-end:4px;
}
.login-foot{margin-top:auto;padding-top:22px;font-size:11.5px;color:#94a3b8;text-align:center}

/* ============ الشاشة الرئيسية ============ */
#appScreen{min-height:100vh;padding-bottom:28px}

.app-head{
  background:linear-gradient(160deg,var(--brand-2) 0%,var(--brand) 55%,var(--brand-dark) 100%);
  color:#fff;
  padding:calc(18px + env(safe-area-inset-top)) 18px 22px;
  border-radius:0 0 26px 26px;
  box-shadow:0 14px 30px -22px rgba(11,79,74,.9);
}
.head-row{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
.hello{margin:0;font-size:15px;opacity:.9}
.hello span{font-weight:700;opacity:1}
.area{
  margin:6px 0 0;font-size:12.5px;
  display:inline-block;
  background:rgba(255,255,255,.16);
  padding:4px 10px;border-radius:999px;
}
.logout{
  width:40px;height:40px;border-radius:12px;flex:none;
  background:rgba(255,255,255,.14);border:0;color:#fff;
  display:grid;place-items:center;cursor:pointer;
}
.logout svg{width:20px;height:20px}

.hero-card{
  margin-top:16px;
  background:rgba(255,255,255,.13);
  border:1px solid rgba(255,255,255,.18);
  border-radius:var(--radius);
  padding:14px 16px 16px;
}
.hero-lbl{margin:0;font-size:12.5px;opacity:.85}
.hero-num{margin:6px 0 10px;font-size:31px;font-weight:800;letter-spacing:-.5px}
.hero-num small{font-size:14px;font-weight:600;opacity:.85}
.bar{height:8px;border-radius:999px;background:rgba(255,255,255,.22);overflow:hidden}
.bar i{display:block;height:100%;width:0;border-radius:999px;background:#fff;transition:width .6s ease}
.hero-sub{margin:9px 0 0;font-size:12px;opacity:.9}

.content{padding:16px 16px 0}

.stats{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.stat{
  background:var(--card);border:1px solid var(--line);border-radius:14px;
  padding:12px 8px;text-align:center;
}
.stat-num{margin:0;font-size:18px;font-weight:800}
.stat-lbl{margin:4px 0 0;font-size:11.5px;color:var(--muted)}

.section-head{display:flex;align-items:center;gap:8px;margin:20px 2px 10px}
.section-head h2{margin:0;font-size:15.5px}
.count{
  background:#e2e8f0;color:#475569;border-radius:999px;
  font-size:11.5px;font-weight:700;padding:2px 9px;
}

.sales{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:9px}
.sale{
  background:var(--card);border:1px solid var(--line);border-radius:14px;
  padding:12px 14px;
}
.sale-top{display:flex;justify-content:space-between;align-items:baseline;gap:10px}
.client{font-size:14px;font-weight:700}
.amount{font-size:14.5px;font-weight:800;color:var(--brand-dark);white-space:nowrap}
.sale-bot{display:flex;justify-content:space-between;align-items:center;gap:10px;margin-top:6px}
.product{font-size:12px;color:var(--muted)}
.meta{display:flex;align-items:center;gap:8px}
.date{font-size:11.5px;color:#94a3b8}
.chip{
  font-size:10.5px;font-weight:700;border-radius:999px;padding:3px 8px;white-space:nowrap;
}
.chip.ok{background:var(--ok-bg);color:var(--ok)}
.chip.late{background:var(--warn-bg);color:var(--warn)}

.sheet-note{
  display:flex;gap:10px;align-items:flex-start;
  margin-top:16px;padding:12px 14px;
  background:#f1f5f9;border:1px solid var(--line);border-radius:14px;
  font-size:12px;
}
.sheet-note svg{width:18px;height:18px;color:var(--brand);flex:none;margin-top:1px}
.sheet-note p{margin:0;line-height:1.7}
.muted{color:var(--muted)}
.small{font-size:11.5px}

.actions{display:flex;flex-direction:column;gap:9px;margin-top:16px}
.btn-line{
  width:100%;padding:13px;border-radius:14px;cursor:pointer;
  background:#fff;border:1px solid var(--line);color:var(--brand-dark);
  font-size:13.5px;font-weight:700;
}
.btn-line:active{background:#f8fafc}
.btn-solid{
  width:100%;padding:14px;border-radius:14px;border:0;cursor:pointer;
  background:linear-gradient(140deg,var(--brand-2),var(--brand));
  color:#fff;font-size:14px;font-weight:700;margin-top:14px;
}
.foot-note{text-align:center;font-size:11px;color:#94a3b8;margin:14px 0 0;line-height:1.7}

/* ============ المودال ============ */
.overlay{
  position:fixed;inset:0;background:rgba(15,23,42,.45);
  display:flex;align-items:flex-end;justify-content:center;
  z-index:50;
}
.sheet{
  width:100%;max-width:420px;
  background:#fff;border-radius:24px 24px 0 0;
  padding:10px 18px calc(22px + env(safe-area-inset-bottom));
  animation:up .22s ease;
  max-height:88vh;overflow:auto;
}
@keyframes up{from{transform:translateY(24px);opacity:.6}to{transform:translateY(0);opacity:1}}
.sheet-grab{width:38px;height:4px;border-radius:999px;background:#e2e8f0;margin:2px auto 12px}
.sheet h3{margin:0 0 6px;font-size:16px}

.checks{list-style:none;margin:14px 0 10px;padding:0;display:flex;flex-direction:column;gap:9px}
.check{
  display:flex;gap:10px;align-items:flex-start;
  border:1px solid var(--line);border-radius:13px;padding:11px 12px;font-size:12.5px;line-height:1.65;
}
.check .ic{
  width:20px;height:20px;border-radius:50%;flex:none;display:grid;place-items:center;
  font-size:12px;font-weight:800;color:#fff;
}
.check.pass .ic{background:var(--ok)}
.check.block{background:#f8fafc}
.check.block .ic{background:#64748b;font-size:11px}
.res-tag{font-style:normal;font-weight:800}
.check.pass .res-tag{color:var(--ok)}
.check.block .res-tag{color:#475569}
.check .ic svg{display:block}
.check b{display:block;font-size:12.5px}
.check span{color:var(--muted);font-size:11.5px}

.steps{margin:10px 0 6px;padding-inline-start:18px;font-size:13px;line-height:2;color:#334155}

/* ============ إضافات النسخة ١ ============ */

.login-card.busy .keypad button{opacity:.5;pointer-events:none}
.keypad .go:disabled{opacity:.7;cursor:default}
.keypad .go.loading{font-size:0}
.keypad .go.loading::after{
  content:"";display:block;width:18px;height:18px;margin:0 auto;
  border:2.5px solid rgba(255,255,255,.45);border-top-color:#fff;border-radius:50%;
  animation:spin .7s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}

.boot{
  position:fixed;inset:0;z-index:60;background:var(--bg);
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px;
}
.boot.hidden{display:none}
.brandmark.small{width:48px;height:48px;border-radius:15px;margin:0}
.brandmark.small svg{width:24px;height:24px}
.boot-bar{width:120px;height:4px;border-radius:999px;background:#dbe3ec;overflow:hidden}
.boot-bar i{display:block;height:100%;width:40%;border-radius:999px;background:var(--brand);animation:slide 1.1s ease-in-out infinite}
@keyframes slide{0%{transform:translateX(120%)}100%{transform:translateX(-260%)}}

.screen.hidden{display:none !important}

.demo-hint .demo-line{margin:0;line-height:1.6}
.demo-hint .demo-codes{
  margin:6px 0 0;direction:ltr;font-weight:700;font-size:11.5px;color:#475569;
  letter-spacing:.4px;font-variant-numeric:tabular-nums;
}

/* ============ v1: choice screen and the two views ============ */
.head-name{flex:1;min-width:0}
.icon-btn{
  width:40px;height:40px;border-radius:12px;flex:none;
  background:rgba(255,255,255,.14);border:0;color:#fff;
  display:grid;place-items:center;cursor:pointer;
}
.icon-btn svg{width:20px;height:20px}
.icon-btn:active{background:rgba(255,255,255,.24)}

.choose-title{margin:2px 2px 4px;font-size:19px}
.choose-sub{margin:0 2px 16px;font-size:12.5px;color:var(--muted)}

.choice-card{
  width:100%;display:flex;align-items:center;gap:12px;
  background:var(--card);border:1px solid var(--line);border-radius:18px;
  padding:16px 14px;margin-bottom:10px;cursor:pointer;text-align:start;
  box-shadow:0 10px 24px -22px rgba(15,23,42,.5);
  transition:transform .1s, border-color .15s;
}
.choice-card:active{transform:scale(.985);border-color:#cbd5e1}
.choice-ic{
  width:44px;height:44px;border-radius:14px;flex:none;display:grid;place-items:center;
  background:#ccfbf1;color:var(--brand-dark);
}
.choice-ic.alt{background:#e0e7ff;color:#3730a3}
.choice-ic svg{width:22px;height:22px}
.choice-txt{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}
.choice-txt b{font-size:15px}
.choice-txt span{font-size:12px;color:var(--muted);line-height:1.5}
.choice-arrow{font-size:22px;color:#94a3b8;line-height:1}

/* stock */
.stock{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px}
.stock li{
  background:var(--card);border:1px solid var(--line);border-radius:13px;
  padding:11px 13px;display:flex;align-items:center;gap:10px;
}
.stock .s-name{flex:1;min-width:0;font-size:13.5px;font-weight:700}
.stock .s-units{font-size:12px;color:var(--muted);white-space:nowrap}
.chip.out{background:#fee2e2;color:#b91c1c}

/* chart */
.chart{
  display:flex;align-items:flex-end;gap:5px;height:132px;
  background:var(--card);border:1px solid var(--line);border-radius:14px;
  padding:12px 10px 8px;
}
.chart .col{flex:1;display:flex;flex-direction:column;justify-content:flex-end;align-items:center;gap:6px;height:100%}
.chart .bar-v{
  width:100%;border-radius:6px 6px 3px 3px;
  background:linear-gradient(180deg,var(--brand-2),var(--brand));
  min-height:4px;transition:height .5s ease;
}
.chart .bar-v.low{background:linear-gradient(180deg,#fbbf24,#d97706)}
.chart .col-lbl{font-size:9.5px;color:#94a3b8;font-weight:600}

/* month list */
.months{list-style:none;margin:10px 0 0;padding:0;display:flex;flex-direction:column;gap:6px}
.months li{
  display:flex;align-items:center;gap:10px;
  background:var(--card);border:1px solid var(--line);border-radius:11px;
  padding:9px 12px;font-size:12.5px;
}
.months .m-lbl{width:34px;color:var(--muted);font-weight:700}
.months .m-val{flex:1;font-weight:700}
.months .m-pct{font-size:11.5px;font-weight:700;color:var(--brand-dark)}
.months .m-pct.below{color:var(--warn)}

/* ============ v1.1 — YTD filters ============ */
.filter-bar{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:16px 0 0}
.filter-btn{
  display:flex;align-items:center;gap:9px;cursor:pointer;text-align:left;
  background:var(--card);border:1px solid var(--line);border-radius:14px;
  padding:10px 11px;color:var(--ink);font-family:inherit;
}
.filter-btn.on{border-color:var(--brand);background:#f0fdfa;box-shadow:0 0 0 3px rgba(15,118,110,.08)}
.fb-ic{width:30px;height:30px;border-radius:10px;background:#f1f5f9;display:grid;place-items:center;color:var(--brand);flex:none}
.filter-btn.on .fb-ic{background:#ccfbf1}
.fb-ic svg{width:16px;height:16px}
.fb-txt{display:flex;flex-direction:column;min-width:0;text-align:left}
.fb-lbl{font-size:10px;color:var(--muted);font-weight:700;text-transform:uppercase;letter-spacing:.5px}
.fb-txt b{font-size:12.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

.active-filters{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:10px}
.af-row{display:flex;gap:6px;flex-wrap:wrap;flex:1;min-width:0}
.af-chip{
  display:inline-flex;align-items:center;gap:6px;font-family:inherit;
  background:var(--brand);color:#fff;border:0;border-radius:999px;
  font-size:11.5px;font-weight:700;padding:5px 9px 5px 10px;cursor:pointer;
  max-width:100%;
}
.af-chip span.x{font-size:13px;line-height:1;opacity:.85}
.af-clear{
  background:none;border:0;color:var(--brand-dark);font-family:inherit;
  font-size:12px;font-weight:700;cursor:pointer;padding:4px 2px;text-decoration:underline;
}
.filter-note{margin:8px 2px 0;font-size:11.5px;color:var(--warn)}

.quick-row{display:flex;gap:7px;flex-wrap:wrap;margin:12px 0 0}
.q-chip{
  background:#f1f5f9;border:1px solid var(--line);color:#334155;font-family:inherit;
  border-radius:999px;font-size:12px;font-weight:700;padding:7px 12px;cursor:pointer;
}
.q-chip:active{background:#e2e8f0}
.range-row{display:flex;align-items:center;gap:7px;margin-top:10px}
.range-lbl{font-size:11.5px;color:var(--muted);font-weight:700}
.range-row select{
  flex:1;min-width:0;padding:8px 6px;border-radius:10px;border:1px solid var(--line);
  background:#fff;font-size:12.5px;font-family:inherit;color:var(--ink);
}
.range-dash{color:var(--muted);font-size:12px}
.chip-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:7px;margin-top:12px}
.m-chip{
  padding:9px 4px;border-radius:11px;border:1px solid var(--line);background:#fff;
  font-size:12px;font-weight:700;color:#334155;cursor:pointer;font-family:inherit;
}
.m-chip.on{background:var(--brand);border-color:var(--brand);color:#fff}
.pick-list{list-style:none;margin:12px 0 0;padding:0;display:flex;flex-direction:column;gap:7px}
.pick-list li label{
  display:flex;align-items:center;gap:10px;
  border:1px solid var(--line);border-radius:12px;padding:11px 12px;font-size:13px;cursor:pointer;
}
.pick-list li.on label{border-color:var(--brand);background:#f0fdfa}
.pick-list input{accent-color:var(--brand);width:17px;height:17px;margin:0}
.sheet-actions{display:grid;grid-template-columns:1fr 1.3fr;gap:9px;margin-top:16px}
.sheet-actions .btn-solid{margin-top:0}
.products{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:6px}
.products li{
  display:flex;align-items:center;gap:10px;
  background:var(--card);border:1px solid var(--line);border-radius:11px;
  padding:9px 12px;font-size:12.5px;
}
.products .p-name{flex:1;min-width:0;display:flex;flex-direction:column;gap:1px;font-weight:700}
.products .p-name b{font-weight:700;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.products .p-val{font-weight:800;color:var(--brand-dark);white-space:nowrap}
.products .p-share{font-size:11px;color:var(--muted);width:40px;text-align:right}

/* ============ v1.2 — roles, hierarchy, growth ============ */
.scope-bar{display:flex;align-items:center;gap:8px;margin:10px 0 0}
.role-badge{
  background:#0f766e;color:#fff;border-radius:999px;
  font-size:11px;font-weight:800;letter-spacing:.02em;
  padding:5px 10px;white-space:nowrap;
}
.scope-pick{
  flex:1;display:flex;align-items:center;gap:8px;
  background:rgba(255,255,255,.16);border:1px solid rgba(255,255,255,.28);
  border-radius:12px;padding:6px 10px;min-width:0;
}
.scope-pick .sp-lbl{font-size:10.5px;font-weight:700;opacity:.8;color:#e6fffb;white-space:nowrap}
.scope-pick select{
  flex:1;min-width:0;background:transparent;border:0;color:#fff;
  font-family:inherit;font-size:12.5px;font-weight:700;padding:2px 0;
}
.scope-pick select option{color:#0f172a}

.area-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:6px}
.area-row{
  display:flex;align-items:center;gap:8px;cursor:pointer;
  background:var(--card);border:1px solid var(--line);border-radius:11px;
  padding:10px 12px;font-size:12.5px;
}
.area-row:active{border-color:var(--brand)}
.area-row .a-name{font-weight:700;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.area-row .a-meta{font-size:10.5px;color:var(--muted);white-space:nowrap}
.area-row .a-val{font-weight:800;color:var(--brand-dark);white-space:nowrap}
.area-row .a-pct{font-size:11.5px;font-weight:700;color:var(--brand-dark);width:38px;text-align:right}
.area-row .a-pct.below{color:var(--warn)}
.area-row .a-growth{font-size:11px;font-weight:700;width:46px;text-align:right}

.products .p-growth,.months .m-growth{font-size:11px;font-weight:700;width:46px;text-align:right}
.stat-num.up,.a-growth.up,.p-growth.up,.m-growth.up{color:#15803d}
.stat-num.down,.a-growth.down,.p-growth.down,.m-growth.down{color:#b91c1c}
.stat-num.flat,.a-growth.flat,.p-growth.flat,.m-growth.flat{color:var(--muted)}
.stock-note{margin:8px 2px 0;font-size:11.5px}
#ytdScreen .stats{grid-template-columns:repeat(4,1fr);gap:8px}
#ytdScreen .stat{padding:10px 5px}
#ytdScreen .stat-num{font-size:15px}
#ytdScreen .stat-lbl{font-size:10.5px}
.products .p-units{font-style:normal;font-weight:600;font-size:10.5px;color:var(--muted);white-space:nowrap}

/* ============ v1.3 — branches ============ */
.branch-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:6px}
.branch-list li{
  display:grid;grid-template-columns:1fr auto;gap:2px 10px;align-items:center;
  background:var(--card);border:1px solid var(--line);border-radius:11px;padding:9px 12px;
}
.b-name{font-weight:700;font-size:12.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.b-tag{
  font-style:normal;font-size:9.5px;font-weight:800;letter-spacing:.03em;text-transform:uppercase;
  background:#ecfeff;color:#0e7490;border:1px solid #a5f3fc;border-radius:6px;padding:1px 5px;margin-left:6px;
  vertical-align:middle;
}
.b-meta{grid-column:1;font-size:10.5px;color:var(--muted)}
.b-val{grid-column:2;grid-row:1 / span 2;font-weight:800;color:var(--brand-dark);font-size:12.5px}
.branch-note{margin:0 0 8px;font-size:11px}
.stock .s-branch{display:block;font-style:normal;font-size:10.5px;color:var(--muted);font-weight:600}
