/* ============================ TOKENS ============================ */
:root{
  --ink:#15181F; --ink-soft:#2A2F3A;
  --bg:#ECEFF3; --surface:#F6F8FB; --card:#FFFFFF; --line:#E2E7EE;
  --muted:#7C8696; --text:#1B2230;
  --accent:#F5820B; --accent-d:#D96E00;
  --green:#138A5E; --green-bg:#E4F5EC;
  --amber:#C07A00; --amber-bg:#FCF0DA;
  --radius:18px; --radius-sm:12px;
  --shadow:0 10px 30px -12px rgba(20,30,50,.18);
  --shadow-sm:0 4px 14px -6px rgba(20,30,50,.16);
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0}
body{font-family:'Tajawal',system-ui,sans-serif;background:var(--bg);color:var(--text);
  font-size:16px;line-height:1.5;min-height:100vh;min-height:100dvh;-webkit-font-smoothing:antialiased;
  padding-bottom:env(safe-area-inset-bottom)}
button{font-family:inherit;cursor:pointer;border:0;background:none}
input,select,textarea{font-family:inherit;font-size:16px}
.num{font-variant-numeric:tabular-nums;letter-spacing:.2px}
.hidden{display:none!important}

/* ============================ LOGIN ============================ */
#login{position:relative;min-height:100dvh;display:flex;flex-direction:column;align-items:center;justify-content:center;
  padding:28px 24px;overflow:hidden;color:#fff}
#login .login-bg{position:absolute;inset:0;z-index:0;background:#0A0B0F url('images/login-car.jpg') center/cover no-repeat}
#login .login-bg::after{content:'';position:absolute;inset:0;
  background:radial-gradient(120% 80% at 70% 30%, rgba(225,25,45,.22), transparent 55%),
    linear-gradient(180deg, rgba(8,9,13,.55) 0%, rgba(8,9,13,.86) 58%, rgba(8,9,13,.97) 100%)}
#login .login-inner{position:relative;z-index:2;width:100%;max-width:380px;display:flex;flex-direction:column;align-items:center}
.login-logo-wrap{width:124px;height:124px;border-radius:50%;display:grid;place-items:center;margin-bottom:18px;
  background:rgba(255,255,255,.04);
  box-shadow:0 0 0 1px rgba(255,255,255,.14), 0 0 42px -6px rgba(225,25,45,.55), 0 18px 44px -14px rgba(0,0,0,.85)}
.login-logo{width:112px;height:112px;border-radius:50%;object-fit:cover;display:block}
#login h1{font-size:24px;font-weight:800;margin:0 0 3px;text-align:center;text-shadow:0 2px 14px rgba(0,0,0,.7)}
#login .sub{color:#C2C9D6;font-size:13.5px;margin-bottom:24px;text-align:center;letter-spacing:.3px}
.login-card{width:100%;background:rgba(18,20,26,.55);border:1px solid rgba(255,255,255,.10);border-radius:22px;padding:22px;
  backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);box-shadow:0 24px 60px -20px rgba(0,0,0,.85)}
.field{margin-bottom:14px}
.field label{display:block;font-size:13px;color:#AEB6C4;margin-bottom:7px;font-weight:600}
.field input{width:100%;padding:14px 15px;border-radius:13px;border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.06);color:#fff;outline:none;transition:.15s}
.field input::placeholder{color:#7A8392}
.field input:focus{border-color:#E11D2A;background:rgba(255,255,255,.09);box-shadow:0 0 0 3px rgba(225,25,45,.18)}
.btn-primary{width:100%;padding:15px;border-radius:13px;font-weight:800;font-size:16px;color:#fff;letter-spacing:.5px;
  background:linear-gradient(160deg,#E81F2F,#A50C16);box-shadow:0 14px 30px -10px rgba(225,25,45,.6);transition:transform .1s,filter .15s}
.btn-primary:active{transform:scale(.985)}
.btn-primary:disabled{filter:grayscale(.4) brightness(.85);cursor:default}
#loginErr{color:#FF9A8B;font-size:13.5px;margin-top:12px;min-height:18px;text-align:center}
.demo-hint{margin-top:14px;text-align:center;font-size:12.5px;color:#8A93A4;border-top:1px solid rgba(255,255,255,.08);padding-top:13px}
.demo-hint b{color:#D7DEEA}
.login-lang{position:absolute;top:calc(16px + env(safe-area-inset-top));inset-inline-end:18px;z-index:3;
  background:rgba(255,255,255,.10);color:#fff;font-weight:800;font-size:13px;padding:8px 13px;border-radius:11px;
  backdrop-filter:blur(6px)}
/* ============================ APP SHELL ============================ */
#app{display:none;flex-direction:column;min-height:100dvh}
.topbar{position:sticky;top:0;z-index:20;display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:calc(14px + env(safe-area-inset-top)) 18px 14px;background:var(--ink);color:#fff}
.topbar .t-left{display:flex;align-items:center;gap:11px;min-width:0}
.topbar .t-right{display:flex;align-items:center;gap:9px;flex:0 0 auto}
.topbar .logo{width:38px;height:38px;border-radius:11px;display:grid;place-items:center;
  background:linear-gradient(160deg,var(--accent),var(--accent-d));flex:0 0 auto}
.topbar .logo svg{width:21px;height:21px;stroke:#fff;fill:none;stroke-width:2}
.topbar .ttl{font-weight:800;font-size:16px;line-height:1.15;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.topbar .ttl small{display:block;font-weight:500;font-size:11.5px;color:#94A0B2}
.icon-btn{width:38px;height:38px;border-radius:11px;display:grid;place-items:center;background:rgba(255,255,255,.08);color:#fff}
.icon-btn svg{width:19px;height:19px;stroke:currentColor;fill:none;stroke-width:2}
.icon-btn.lang{font-weight:800;font-size:13.5px;width:42px}

.scene{flex:1;padding:18px 16px 120px;max-width:560px;margin:0 auto;width:100%}
.scene-head{display:flex;align-items:flex-end;justify-content:space-between;margin:2px 2px 16px}
.scene-head h2{font-size:21px;font-weight:800;margin:0}
.scene-head .cnt{font-size:13px;color:var(--muted)}

.sum-row{display:flex;gap:10px;margin-bottom:14px}
.sum{flex:1;background:var(--card);border:1px solid var(--line);border-radius:var(--radius-sm);
  padding:12px 13px;box-shadow:var(--shadow-sm)}
.sum .lbl{font-size:12px;color:var(--muted)}
.sum .val{font-size:18px;font-weight:800;margin-top:2px}
.sum .val.a{color:var(--amber)}

/* search */
.searchbar{display:flex;align-items:center;gap:8px;background:var(--card);border:1px solid var(--line);
  border-radius:14px;padding:0 12px;margin-bottom:14px;box-shadow:var(--shadow-sm)}
.searchbar svg{width:18px;height:18px;stroke:var(--muted);fill:none;stroke-width:2;flex:0 0 auto}
.searchbar input{flex:1;border:0;background:none;outline:none;padding:13px 0;color:var(--text)}
.searchbar .clr{width:26px;height:26px;border-radius:8px;display:none;place-items:center;background:var(--surface);color:var(--muted)}
.searchbar .clr svg{width:13px;height:13px;stroke-width:2.4}
.searchbar.has .clr{display:grid}

/* cards */
.card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow-sm);padding:15px;margin-bottom:11px}
.fact-card{cursor:pointer;transition:transform .08s}
.fact-card:active{transform:scale(.99)}
.fc-top{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}
.fc-name{font-weight:700;font-size:16.5px;line-height:1.2}
.fc-car{color:var(--muted);font-size:13.5px;margin-top:3px}
.badge{font-size:12px;font-weight:700;padding:5px 11px;border-radius:999px;white-space:nowrap;flex:0 0 auto}
.badge.paid{color:var(--green);background:var(--green-bg)}
.badge.pend{color:var(--amber);background:var(--amber-bg)}
.fc-bot{display:flex;align-items:center;justify-content:space-between;margin-top:12px;padding-top:11px;border-top:1px dashed var(--line)}
.fc-total{font-weight:800;font-size:17px}
.fc-total small{font-weight:500;font-size:12px;color:var(--muted)}
.fc-reste{font-size:13px;color:var(--amber);font-weight:700}
.fc-date{font-size:12px;color:var(--muted)}
.card-print{width:34px;height:34px;border-radius:10px;display:grid;place-items:center;background:var(--surface);color:var(--ink);border:1px solid var(--line)}
.card-print svg{width:17px;height:17px;stroke:currentColor;fill:none;stroke-width:1.9}

.line-card{display:flex;align-items:center;justify-content:space-between;gap:12px}
.lc-l{min-width:0}
.lc-name{font-weight:700;font-size:16px}
.lc-time{font-size:12.5px;color:var(--muted);margin-top:3px;display:flex;align-items:center;gap:5px}
.lc-time svg{width:13px;height:13px;stroke:currentColor;fill:none;stroke-width:2}
.lc-amt{font-weight:800;font-size:17px;white-space:nowrap}
.lc-del{width:34px;height:34px;border-radius:10px;display:grid;place-items:center;background:#FBE9E7;color:#D7402F;flex:0 0 auto}
.lc-del svg{width:16px;height:16px;stroke:currentColor;fill:none;stroke-width:2}

.empty{text-align:center;color:var(--muted);padding:50px 20px}
.empty svg{width:46px;height:46px;stroke:var(--muted);fill:none;stroke-width:1.6;opacity:.6;margin-bottom:12px}
.empty p{margin:0;font-size:14.5px}

.add-form{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow-sm);padding:15px;margin-bottom:18px}
.add-form .row{display:flex;gap:10px}
.inp{width:100%;padding:13px 14px;border-radius:12px;border:1px solid var(--line);background:var(--surface);color:var(--text);outline:none;transition:.15s}
.inp:focus{border-color:var(--accent);background:#fff}
.inp.amt{flex:0 0 38%}
.add-btn{width:100%;margin-top:11px;padding:13px;border-radius:12px;font-weight:700;color:#fff;background:var(--ink);transition:transform .1s}
.add-btn:active{transform:scale(.99)}

/* bottom nav */
.nav{position:fixed;left:0;right:0;bottom:0;z-index:30;padding:0 16px calc(14px + env(safe-area-inset-bottom));pointer-events:none}
.nav-inner{max-width:560px;margin:0 auto;background:var(--ink);border-radius:22px;display:flex;align-items:center;padding:7px;
  box-shadow:0 18px 40px -12px rgba(20,30,50,.45);pointer-events:auto}
.nav-btn{flex:1;display:flex;flex-direction:column;align-items:center;gap:3px;padding:9px 4px;border-radius:16px;color:#8A93A4;font-size:11.5px;font-weight:600;transition:.18s}
.nav-btn svg{width:21px;height:21px;stroke:currentColor;fill:none;stroke-width:2}
.nav-btn.active{color:#fff;background:rgba(255,255,255,.10)}
.nav-btn.fab{flex:0 0 auto;width:54px;height:54px;margin:0 4px;border-radius:18px;
  background:linear-gradient(160deg,var(--accent),var(--accent-d));color:#fff;justify-content:center;
  box-shadow:0 10px 22px -8px rgba(245,130,11,.7)}
.nav-btn.fab svg{width:25px;height:25px;stroke-width:2.4}

/* sheet */
.sheet-wrap{position:fixed;inset:0;z-index:50;display:none}
.sheet-wrap.open{display:block}
.sheet-bg{position:absolute;inset:0;background:rgba(15,18,25,.55);backdrop-filter:blur(2px);opacity:0;transition:opacity .25s}
.sheet-wrap.open .sheet-bg{opacity:1}
.sheet{position:absolute;left:0;right:0;bottom:0;background:var(--bg);border-radius:24px 24px 0 0;max-height:94dvh;
  display:flex;flex-direction:column;transform:translateY(100%);transition:transform .3s cubic-bezier(.3,.9,.3,1);max-width:560px;margin:0 auto}
.sheet-wrap.open .sheet{transform:translateY(0)}
.sheet-head{padding:16px 18px 12px;border-bottom:1px solid var(--line);background:var(--bg);border-radius:24px 24px 0 0;flex:0 0 auto}
.sheet-head .grip{width:42px;height:5px;border-radius:3px;background:#CBD3DE;margin:0 auto 12px}
.sheet-head .sh-top{display:flex;align-items:center;justify-content:space-between}
.sheet-head h3{margin:0;font-size:18px;font-weight:800}
.sheet-head .x{width:34px;height:34px;border-radius:10px;display:grid;place-items:center;background:var(--surface);color:var(--muted)}
.sheet-head .x svg{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:2.2}
.steps{display:flex;align-items:center;gap:6px;margin-top:14px}
.step{flex:1;display:flex;flex-direction:column;gap:6px}
.step .bar{height:5px;border-radius:3px;background:var(--line);transition:.25s}
.step.done .bar,.step.active .bar{background:var(--accent)}
.step .nm{font-size:11px;color:var(--muted);font-weight:600;text-align:center}
.step.active .nm{color:var(--accent)}
.sheet-body{overflow-y:auto;-webkit-overflow-scrolling:touch;padding:18px;flex:1}
.pane{display:none;animation:fade .25s}
.pane.show{display:block}
@keyframes fade{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.lbl{display:block;font-size:13.5px;font-weight:600;color:var(--ink-soft);margin:0 0 7px}
.lbl .opt{color:var(--muted);font-weight:400;font-size:12px}
.field-b{margin-bottom:15px}
.field-b .inp{box-shadow:var(--shadow-sm)}
.two{display:flex;gap:11px}.two>div{flex:1}
.items-list{margin-bottom:8px}
.item-row{display:flex;gap:9px;margin-bottom:9px;align-items:center}
.item-row .desc{flex:1}.item-row .price{flex:0 0 32%}
.item-row .rm{width:42px;height:46px;flex:0 0 auto;border-radius:12px;display:grid;place-items:center;background:#FBE9E7;color:#D7402F}
.item-row .rm svg{width:17px;height:17px;stroke:currentColor;fill:none;stroke-width:2.2}
.add-item{width:100%;padding:12px;border-radius:12px;border:1.5px dashed var(--accent);color:var(--accent-d);font-weight:700;
  background:rgba(245,130,11,.05);display:flex;align-items:center;justify-content:center;gap:7px}
.add-item svg{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:2.4}
.pay-box{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:16px;box-shadow:var(--shadow-sm);margin-top:6px}
.total-line{display:flex;align-items:center;justify-content:space-between;padding-bottom:14px;margin-bottom:14px;border-bottom:1px dashed var(--line)}
.total-line .l{color:var(--muted);font-size:14px}
.total-line .v{font-size:26px;font-weight:800}
.total-line .v small{font-size:13px;font-weight:600;color:var(--muted)}
.pay-grid{display:flex;gap:11px;margin-bottom:14px}.pay-grid>div{flex:1}
.reste-line{display:flex;align-items:center;justify-content:space-between;padding:13px 14px;border-radius:13px;font-weight:700;transition:.2s}
.reste-line.ok{background:var(--green-bg);color:var(--green)}
.reste-line.due{background:var(--amber-bg);color:var(--amber)}
.reste-line .v{font-size:19px;font-weight:800}
.status-pill{margin-top:13px;text-align:center;font-weight:800;font-size:15px;padding:11px;border-radius:13px}
.status-pill.paid{background:var(--green-bg);color:var(--green)}
.status-pill.pend{background:var(--amber-bg);color:var(--amber)}
.sheet-foot{flex:0 0 auto;display:flex;gap:11px;padding:14px 18px calc(16px + env(safe-area-inset-bottom));border-top:1px solid var(--line);background:var(--bg)}
.btn-ghost{flex:0 0 38%;padding:15px;border-radius:13px;font-weight:700;color:var(--ink);background:var(--surface);border:1px solid var(--line)}
.btn-next{flex:1;padding:15px;border-radius:13px;font-weight:700;color:#fff;
  background:linear-gradient(160deg,var(--accent),var(--accent-d));box-shadow:0 10px 22px -10px rgba(245,130,11,.55);transition:transform .1s}
.btn-next:active{transform:scale(.99)}
.btn-next:disabled{filter:grayscale(.5) brightness(.85)}
/* print sheet */
.print-opts{padding:18px;display:flex;flex-direction:column;gap:12px}
.print-opts .opt-btn{display:flex;align-items:center;gap:13px;padding:16px;border-radius:14px;border:1px solid var(--line);
  background:var(--card);box-shadow:var(--shadow-sm);font-weight:700;font-size:15.5px;color:var(--text)}
.print-opts .opt-btn .ic{width:40px;height:40px;border-radius:11px;display:grid;place-items:center;flex:0 0 auto}
.print-opts .opt-btn .ic svg{width:21px;height:21px;stroke:#fff;fill:none;stroke-width:2}
.print-opts .opt-btn .ic.t{background:var(--ink)} .print-opts .opt-btn .ic.p{background:var(--accent)}
/* autocomplete */
.ac-wrap{position:relative}
.ac-list{position:absolute;top:100%;left:0;right:0;z-index:8;background:var(--card);border:1px solid var(--line);
  border-radius:12px;box-shadow:var(--shadow);margin-top:5px;max-height:212px;overflow-y:auto;display:none}
.ac-list.show{display:block}
.ac-item{padding:11px 13px;font-size:15px;cursor:pointer;border-bottom:1px solid var(--line)}
.ac-item:last-child{border-bottom:0}
.ac-item:active,.ac-item.hl{background:var(--surface)}
.ac-item b{color:var(--accent-d)}
/* detail view */
.dhead{display:flex;align-items:center;gap:10px;margin-bottom:16px}
.dhead .nm{font-weight:800;font-size:19px}
.dsec{margin-bottom:16px}
.dsec h4{font-size:12.5px;font-weight:700;color:var(--muted);margin:0 0 9px}
.dcard{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow-sm);padding:2px 15px}
.dkv{display:flex;justify-content:space-between;gap:12px;padding:11px 0;border-bottom:1px solid var(--line)}
.dkv:last-child{border-bottom:0}
.dkv .k{color:var(--muted);font-size:14px}
.dkv .v{font-weight:600;text-align:end}
.ditems{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow-sm);overflow:hidden}
.ditem{display:flex;justify-content:space-between;gap:12px;padding:12px 15px;border-bottom:1px solid var(--line)}
.ditem .p{font-weight:700;white-space:nowrap}
.dtotal{display:flex;justify-content:space-between;padding:14px 15px;background:var(--surface);font-weight:800;font-size:17px}
.dpay-reste{color:var(--amber)}
.dh-actions{display:flex;gap:8px}
/* dashboard */
.icon-btn.on{color:var(--accent)}
.seg{display:flex;background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:4px;margin-bottom:14px}
.seg button{flex:1;padding:9px;border-radius:9px;font-weight:700;font-size:13.5px;color:var(--muted)}
.seg button.on{background:var(--ink);color:#fff}
.kpi-hero{background:linear-gradient(160deg,var(--ink),#242A38);color:#fff;border-radius:var(--radius);padding:18px;box-shadow:var(--shadow);margin-bottom:12px}
.kpi-hero .lbl{color:#9AA6B8;font-size:13px}
.kpi-hero .val{font-size:32px;font-weight:800;margin-top:4px}
.kpi-hero .val small{font-size:15px;font-weight:600;color:#9AA6B8}
.kpi-hero .val.neg{color:#FF9A8B}
.kpi-grid{display:grid;grid-template-columns:1fr 1fr;gap:11px;margin-bottom:12px}
.kpi{background:var(--card);border:1px solid var(--line);border-radius:var(--radius-sm);padding:14px;box-shadow:var(--shadow-sm)}
.kpi .ic{width:34px;height:34px;border-radius:10px;display:grid;place-items:center;margin-bottom:9px}
.kpi .ic svg{width:18px;height:18px;stroke:#fff;fill:none;stroke-width:2}
.kpi .lbl{font-size:12.5px;color:var(--muted)}
.kpi .val{font-size:18px;font-weight:800;margin-top:2px}
.chart-card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:15px;box-shadow:var(--shadow-sm)}
.chart-card h4{margin:0 0 12px;font-size:13px;color:var(--muted);font-weight:700}
.bars{display:flex;align-items:flex-end;gap:7px;height:110px}
.bars .b{flex:1;display:flex;flex-direction:column;align-items:center;gap:6px;height:100%;justify-content:flex-end}
.bars .b .bar{width:100%;background:linear-gradient(180deg,var(--accent),var(--accent-d));border-radius:6px 6px 0 0;min-height:3px;transition:height .3s}
.bars .b .dy{font-size:10.5px;color:var(--muted)}

#toast{position:fixed;left:50%;bottom:104px;transform:translateX(-50%) translateY(20px);background:var(--ink);color:#fff;
  padding:12px 20px;border-radius:13px;font-weight:600;font-size:14px;z-index:80;opacity:0;pointer-events:none;transition:.25s;box-shadow:var(--shadow);max-width:90%}
#toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
#toast.err{background:#C0392B}
.spin{width:18px;height:18px;border:2.4px solid rgba(255,255,255,.4);border-top-color:#fff;border-radius:50%;animation:rot .7s linear infinite;display:inline-block;vertical-align:-3px}
@keyframes rot{to{transform:rotate(360deg)}}
.full-load{position:fixed;inset:0;display:grid;place-items:center;background:var(--bg);z-index:90}
.full-load .spin{width:34px;height:34px;border-color:rgba(245,130,11,.25);border-top-color:var(--accent)}
