
/* ===== ألوان حاسبة الاستئذان 1:1 — مأخوذة من mew-main/style.css =====
   الفاتح: :root في style.css (السطور 1–14) + القيم الثابتة في المكوّنات.
   الداكن: @media (prefers-color-scheme: dark) في style.css (السطور 639–665). */
:root{
  --p:#0758b7; --p-dark:#063f82; --p-ink:#0758b7; --p-soft:#eaf4ff; --p-line:#c9dff6; --on-p:#ffffff; --sel:#0758b7;
  --bg:#f4f9ff; --bg-grad:linear-gradient(180deg,#eef7ff 0,#fff 430px);
  --surface:#ffffff; --raised:#ffffff; --field:#fbfdff; --field-line:#cbd9e8; --track:#eef2f7;
  --text:#12233b; --muted:#617188; --quiet:#617188; --line:#dbe6f2; --divider:#edf2f7;
  --g:#138a52; --g-ink:#08693d; --g-soft:#e9f8f0; --g-line:#b9e6ce;
  --a:#795910; --a-text:#6b6045; --a-soft:#fffaf0; --a-line:#f0dfb3;
  --r:#cf3f36; --r-ink:#a92720; --r-soft:#fff0ee; --r-line:#f3c4bf;
  --shadow:0 10px 30px rgba(18,54,93,.08); --shadow-sm:0 2px 7px rgba(18,54,93,.10);
  --btn-shadow:0 8px 18px rgba(7,88,183,.22); --focus:rgba(7,88,183,.15);
  --handle:#d4dce8; --scrim:rgba(8,25,46,.42); --ring-track:#eef2f7;
}
html[data-theme="dark"]{
  color-scheme:dark;
  --p:#4CAEEB; --p-dark:#58B9F2; --p-ink:#4CAEEB; --p-soft:#18344A; --p-line:#2A4055; --on-p:#0A1521; --sel:#58B9F2;
  --bg:#0A1521; --bg-grad:#0A1521;
  --surface:#122234; --raised:#172B40; --field:#0F1D2C; --field-line:#2A4055; --track:#253647;
  --text:#F4F8FC; --muted:#BBCAD9; --quiet:#8499AD; --line:#2A4055; --divider:#2A4055;
  --g:#4DD297; --g-ink:#4DD297; --g-soft:#172B40; --g-line:#4DD297;
  --a:#FFAA69; --a-text:#BBCAD9; --a-soft:#0F1F2F; --a-line:#FFAA69;
  --r:#F06A6A; --r-ink:#F06A6A; --r-soft:#0F1F2F; --r-line:#F06A6A;
  --shadow:0 10px 30px rgb(2 8 15 / 34%); --shadow-sm:0 2px 7px rgb(2 8 15 / 34%);
  --btn-shadow:0 8px 18px rgb(2 8 15 / 34%); --focus:#58B9F2;
  --handle:#8499AD; --scrim:rgb(2 8 15 / 34%); --ring-track:#253647;
}
*{box-sizing:border-box;margin:0;padding:0;-webkit-tap-highlight-color:transparent}
html{background:var(--bg)}
body{font-family:Tahoma,Arial,sans-serif;background:var(--bg-grad);color:var(--text);
  min-width:320px;min-height:100dvh;overflow-x:hidden;padding-bottom:calc(28px + env(safe-area-inset-bottom));-webkit-text-size-adjust:100%}
button,input{font:inherit;color:inherit}
button{cursor:pointer}
.num{font-variant-numeric:tabular-nums;direction:ltr;unicode-bidi:isolate;display:inline-block}
.num.rg,.rg{direction:rtl;unicode-bidi:isolate}
.dt{unicode-bidi:isolate;white-space:nowrap}
.wrap{max-width:520px;margin:0 auto;padding:0 16px}

/* ===== Header ===== */
.hdr{padding:calc(14px + env(safe-area-inset-top)) 0 14px}
.hdr-row{display:flex;align-items:center;gap:12px}
.mark{width:52px;height:52px;border-radius:16px;flex-shrink:0;display:grid;place-items:center;color:var(--on-p);
  background:linear-gradient(145deg,var(--p),var(--p-dark));box-shadow:var(--btn-shadow)}
.mark svg{width:32px;height:32px}
.brand{flex:1;min-width:0}
.brand h1{font-size:22px;font-weight:700;line-height:1.3;letter-spacing:-.2px;color:var(--text)}
.brand p{font-size:13.5px;color:var(--muted);margin-top:1px}
.icon-btn{width:40px;height:40px;border-radius:12px;border:1px solid var(--line);background:var(--surface);
  display:grid;place-items:center;color:var(--p);flex-shrink:0}
.icon-btn:focus-visible{outline:3px solid var(--focus);outline-offset:2px}
.icon-btn svg{width:20px;height:20px}
.proto-flag{display:flex;align-items:center;gap:8px;margin-top:12px;padding:8px 12px;border-radius:12px;
  background:var(--a-soft);border:1px solid var(--a-line);color:var(--a-text);font-size:12.5px;font-weight:500;line-height:1.6}
.proto-flag b,.proto-flag svg{color:var(--a);font-weight:700}

/* ===== Tabs (نفس mode-options في حاسبة الاستئذان) ===== */
.tabs{position:relative;display:grid;grid-template-columns:1fr 1fr;padding:4px;border-radius:13px;background:var(--track);margin:4px 0 14px}
.tabs button{position:relative;z-index:1;border:0;background:none;padding:11px 6px;border-radius:10px;
  font-size:15px;font-weight:700;color:var(--muted);display:flex;align-items:center;justify-content:center;gap:7px}
.tabs button svg{width:18px;height:18px}
.tabs button[aria-selected="true"]{color:var(--text)}
.tabs button[aria-selected="true"] svg{color:var(--p)}
.tabs button:focus-visible{outline:3px solid var(--focus);outline-offset:1px}
.tabs .pill{position:absolute;top:4px;bottom:4px;width:calc(50% - 4px);right:4px;border-radius:10px;background:var(--raised);
  box-shadow:var(--shadow-sm);transition:transform .25s cubic-bezier(.3,.7,.2,1)}
.tabs[data-active="monthly"] .pill{transform:translateX(-100%)}
html[data-theme="dark"] .tabs .pill{box-shadow:inset 0 0 0 1px var(--sel),var(--shadow-sm)}

/* ===== Cards ===== */
.card{background:var(--surface);border:1px solid var(--line);border-radius:18px;padding:16px;box-shadow:var(--shadow);margin-bottom:12px}
.card-h{display:flex;align-items:center;gap:10px;margin-bottom:12px}
.card-h .ic{width:34px;height:34px;border-radius:10px;background:var(--p-soft);color:var(--p);display:grid;place-items:center;flex-shrink:0}
.card-h .ic svg{width:18px;height:18px}
.card-h h2{font-size:15.5px;font-weight:700;color:var(--text)}
.card-h small{display:block;font-size:12px;color:var(--quiet);font-weight:400;margin-top:1px}
.card-h .tag{margin-inline-start:auto}
.tag{font-size:11px;font-weight:700;padding:3px 8px;border-radius:999px;white-space:nowrap}
.tag.demo{background:var(--a-soft);color:var(--a);border:1px solid var(--a-line)}
.tag.ok{background:var(--g-soft);color:var(--g-ink);border:1px solid var(--g-line)}
.tag.save{background:var(--p-soft);color:var(--p);border:1px solid var(--p-line)}

/* ===== حقول (نفس .field input) ===== */
.dur{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.dur.one{grid-template-columns:minmax(0,1fr)}
.fld{min-width:0}
.fld label{display:block;font-size:.9rem;color:var(--muted);font-weight:700;margin-bottom:7px}
.stp{display:flex;align-items:stretch;height:52px;border:1px solid var(--field-line);border-radius:11px;background:var(--field);overflow:hidden;transition:border-color .15s,box-shadow .15s}
.stp:focus-within{border-color:var(--sel);box-shadow:0 0 0 3px var(--focus)}
.fld.err .stp{border-color:var(--r);box-shadow:none}
.stp button{width:44px;border:0;background:none;color:var(--p);font-size:22px;font-weight:500;flex-shrink:0;display:grid;place-items:center}
.stp button:active{background:var(--p-soft)}
.stp input{flex:1;min-width:0;width:100%;border:0;background:none;text-align:center;font-size:20px;font-weight:700;outline:none;color:var(--text);
  font-variant-numeric:tabular-nums;direction:ltr}
.stp input::placeholder{color:var(--muted);opacity:.5;font-weight:500}
.fld .msg{font-size:12px;color:var(--r-ink);margin-top:5px;min-height:18px;line-height:18px;font-weight:600}

/* chips (نفس segmented-control) */
.chips{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-bottom:12px}
.chip{border:1px solid var(--line);background:transparent;border-radius:12px;padding:9px 4px;text-align:center;color:var(--muted);transition:.15s ease}
.chip b{display:block;font-size:14px;font-weight:700}
.chip span{display:block;font-size:12px;margin-top:1px;opacity:.85}
.chip[aria-pressed="true"]{border-color:var(--sel);background:var(--p);color:var(--on-p);box-shadow:inset 0 0 0 1px var(--sel)}
.sched-note{font-size:12.5px;line-height:1.6;color:var(--a);background:var(--a-soft);border:1px solid var(--a-line);border-radius:10px;padding:6px 10px;margin:-4px 0 12px}
.sched-note[hidden]{display:none}
.chip:focus-visible{outline:3px solid var(--focus);outline-offset:2px}

.salary .stp input{font-size:19px}
.unit-lbl{display:grid;place-items:center;padding:0 12px;font-size:13px;color:var(--muted);font-weight:700;border-inline-end:1px solid var(--field-line)}

/* ===== Result: annual ===== */
.res{border-radius:18px;padding:16px;border:1px solid var(--p-line);background:linear-gradient(180deg,var(--p-soft),var(--surface) 70%);box-shadow:var(--shadow);margin-bottom:12px}
.hero{text-align:center;padding:6px 4px 14px}
.hero .cap{font-size:13.5px;font-weight:700;color:var(--muted)}
.hero .big{display:block;font-size:56px;font-weight:700;line-height:1.1;margin-top:4px;color:var(--text);letter-spacing:-.5px}
.hero .big.wait{font-size:40px;color:var(--muted)}
.hero .of{font-size:15px;font-weight:700;color:var(--muted);margin-top:2px}
.hero .of.wait{font-size:13px;color:var(--a)}
.meter{position:relative;height:8px;border-radius:99px;background:var(--ring-track);margin:12px auto 0;max-width:260px;overflow:hidden}
.meter i{position:absolute;top:0;bottom:0;inset-inline-start:0;width:0;border-radius:99px;background:var(--p);transition:width .4s ease}
.meter i.hi{opacity:.3}
.pair{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.part{background:var(--surface);border:1px solid var(--line);border-radius:13px;padding:11px 12px;text-align:center;min-width:0}
.part .t{font-size:13px;font-weight:700;color:var(--muted)}
.part .v{font-size:30px;font-weight:700;line-height:1.2;margin-top:4px;color:var(--text)}
.part .s{font-size:12.5px;color:var(--muted);font-weight:500}
.part.pending .v{font-size:14px;color:var(--a);line-height:1.6;margin-top:8px}
.part.pending .s{display:none}
.drop{margin-top:10px;background:var(--surface);border:1px solid var(--line);border-radius:13px;padding:12px}
.drop[hidden]{display:none}
.drop .dh{font-size:13px;font-weight:700;color:var(--muted);text-align:center}
.drop .dv{display:block;text-align:center;font-size:24px;font-weight:700;color:var(--p);margin:4px 0 10px;line-height:1.35}
.drop .dv.long{white-space:normal;font-size:19px;line-height:1.5}
.drop dl{display:grid;border-top:1px solid var(--divider)}
.drop dl div{display:flex;justify-content:space-between;align-items:baseline;gap:10px;padding:8px 2px;border-bottom:1px solid var(--divider);font-size:13.5px}
.drop dl div:last-child{border-bottom:0}
.drop dt{color:var(--muted)}
.drop dd{font-weight:700;color:var(--text);text-align:end}
.drop dd.down{color:var(--r-ink)}
#aRes[data-state="partial"] .state-banner{display:none}
.drop .dn{display:flex;justify-content:center;align-items:baseline;gap:8px;flex-wrap:wrap;font-size:14px;color:var(--muted);padding-top:10px;border-top:1px solid var(--divider)}
.drop .dn b{font-size:20px;color:var(--text)}
.drop .dn b.down{color:var(--r-ink)}
.lvl-btn{display:flex;align-items:center;justify-content:center;gap:6px;margin:12px auto 0;border:0;background:none;color:var(--p);font-size:13.5px;font-weight:700;padding:6px 10px}
.lvl-btn svg{width:16px;height:16px}
.lv-h{font-size:14px;font-weight:700;margin:6px 0 8px;color:var(--text)}
.lv-h small{font-weight:500;color:var(--muted);font-size:12.5px}
.slabs+.lv-h{margin-top:16px}
.drop .hint{margin-top:8px;font-size:12.5px;line-height:1.7;color:var(--a);background:var(--a-soft);border:1px solid var(--a-line);border-radius:10px;padding:7px 10px}

.slabs{list-style:none;display:grid;gap:6px;margin-top:4px}
.slabs li{display:flex;align-items:center;gap:10px;padding:9px 12px;border-radius:12px;border:1px solid var(--line);background:var(--field);font-size:13.5px;color:var(--text)}
.slabs li .rng{flex:1}
.slabs li .sc{font-weight:700;white-space:nowrap}
.slabs li.on{border-color:var(--sel);background:var(--p-soft);box-shadow:inset -3px 0 0 var(--p)}
.slabs li.on .sc{color:var(--p)}
.slabs li .dot{width:8px;height:8px;border-radius:50%;background:var(--line)}
.slabs li.on .dot{background:var(--p)}

/* ===== Result: monthly ===== */
.money{text-align:center;padding:4px 0 2px}
.money .cap{font-size:12.5px;color:var(--muted);font-weight:500}
.money .amt{font-size:40px;font-weight:700;line-height:1.2;margin-top:2px;color:var(--text)}
.money .amt small{font-size:16px;font-weight:600;color:var(--muted);margin-inline-start:4px}
.money .words{font-size:14px;color:var(--p);font-weight:700;margin-top:2px;min-height:22px}
.kpis{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:14px}
.kpi{background:var(--surface);border:1px solid var(--line);border-radius:13px;padding:10px 12px}
.kpi .t{font-size:12px;color:var(--muted)}
.kpi .v{font-size:17px;font-weight:700;margin-top:2px;color:var(--text)}
.prog{margin-top:12px;background:var(--surface);border:1px solid var(--line);border-radius:13px;padding:11px 12px}
.prog .row{display:flex;justify-content:space-between;flex-wrap:wrap;gap:2px 10px;font-size:12.5px;color:var(--muted);line-height:1.6}
.prog .row b{color:var(--text);font-size:14px}
.bar{height:8px;border-radius:99px;background:var(--ring-track);margin-top:8px;overflow:hidden}
.bar i{display:block;height:100%;width:0;border-radius:99px;background:var(--g);transition:width .4s ease}
.method{margin-top:12px}
.method summary{list-style:none;display:flex;align-items:center;gap:8px;font-size:13.5px;font-weight:700;color:var(--p);padding:6px 2px;cursor:pointer}
.method summary::-webkit-details-marker{display:none}
.method summary svg{width:16px;height:16px;transition:transform .2s}
.method[open] summary svg{transform:rotate(180deg)}
.steps{list-style:none;counter-reset:s;display:grid;gap:6px;margin-top:6px}
.steps li{counter-increment:s;display:flex;gap:10px;font-size:13px;line-height:1.7;background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:8px 10px;color:var(--text)}
.steps li::before{content:counter(s);width:22px;height:22px;border-radius:7px;background:var(--p-soft);color:var(--p);font-size:12px;font-weight:700;display:grid;place-items:center;flex-shrink:0;margin-top:2px}

/* states */
.res[data-state="empty"] .dimmable,.res[data-state="error"] .dimmable{opacity:.35;filter:saturate(.3)}
.state-banner{display:none;align-items:center;gap:8px;font-size:13px;font-weight:700;padding:9px 12px;border-radius:12px;margin-bottom:12px;line-height:1.6}
.res[data-state="empty"] .state-banner{display:flex;background:var(--surface);border:1px dashed var(--field-line);color:var(--muted)}
.res[data-state="error"] .state-banner{display:flex;background:var(--r-soft);border:1px solid var(--r-line);color:var(--r-ink)}
.res[data-state="partial"] .state-banner{display:flex;background:var(--a-soft);border:1px solid var(--a-line);color:var(--a)}
.state-banner svg{width:18px;height:18px;flex-shrink:0}

/* زر إعادة الضبط (نفس secondary-button) */
.reset{width:100%;min-height:50px;border:1px solid var(--p);background:var(--raised);color:var(--p);border-radius:13px;padding:12px;font-size:14.5px;font-weight:700;display:flex;align-items:center;justify-content:center;gap:8px}
.reset:active{background:var(--p-soft)}
.reset svg{width:17px;height:17px}
.disclaimer{font-size:12px;color:var(--quiet);line-height:1.8;text-align:center;margin:12px 6px 0}

.panel[hidden]{display:none}


footer{text-align:center;color:var(--muted);font-size:12px;line-height:1.9;margin-top:20px}
footer b{color:var(--text)}

/* ===== Sheet (نفس work-settings-dialog) ===== */
.sheet{position:fixed;inset:0;z-index:50;display:none}
.sheet.open{display:block}
.sheet .scrim{position:absolute;inset:0;background:var(--scrim);animation:fade .2s}
.sheet .body{position:absolute;left:0;right:0;bottom:0;max-height:86vh;overflow:auto;background:var(--raised);color:var(--text);border-radius:24px 24px 0 0;
  box-shadow:0 -10px 40px rgba(8,25,46,.15);padding:10px 18px calc(22px + env(safe-area-inset-bottom));animation:up .25s cubic-bezier(.3,.7,.2,1);max-width:600px;margin:0 auto}
html[data-theme="dark"] .sheet .body{box-shadow:0 -10px 40px var(--scrim)}
.handle{width:36px;height:4px;border-radius:4px;background:var(--handle);margin:0 auto 12px}
.sheet h3{font-size:17px;margin-bottom:10px;display:flex;justify-content:space-between;align-items:center}
.sheet h3 .close-btn{border:1px solid var(--p-line);background:var(--p-soft);color:var(--p);min-height:36px;padding:6px 16px;border-radius:999px;font-size:14px;font-weight:700;flex-shrink:0}
.sheet h3 .close-btn:active{background:var(--p);color:var(--on-p)}
.rule{display:flex;gap:10px;align-items:flex-start;padding:10px 0;border-bottom:1px solid var(--divider);font-size:13.5px;line-height:1.7}
.rule:last-child{border-bottom:0}
.rule .tag{margin-top:2px}
@keyframes up{from{transform:translateY(100%)}}
@keyframes fade{from{opacity:0}}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
@media (max-width:350px){
  .hero .big{font-size:48px}.part .v{font-size:26px}.drop .dv{font-size:21px}
  .stp button{width:38px}.brand h1{font-size:20px}.money .amt{font-size:34px}
}

.slab-row{margin-top:6px}
body.sheet-open{overflow:hidden}
/* Four-digit annual hours must remain fully visible on 320px screens. */
@media (max-width:350px){.stp input.wide-value{font-size:17px}}
