/* CHM – Chinese Markets  |  red / black / white theme matching the design mock-ups */
:root{
  --red:#e1151b; --red-dark:#b90f14; --red-soft:#fdecec; --black:#111; --ink:#1c1c1c; --muted:#6b6b6b;
  --line:#d9d9d9; --bg:#ffffff; --bg-soft:#f6f6f6; --ok:#1f8f3a; --warn:#c77a00; --info:#1d5fb3; --yellow:#f7c300;
  --radius:22px; --shadow:0 2px 10px rgba(0,0,0,.08); --font:"Segoe UI","Noto Naskh Arabic","Tahoma",Arial,sans-serif;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0;background:var(--bg);color:var(--ink);font-family:var(--font);font-size:15px;line-height:1.5}
html[dir=ltr] body{font-size:14.5px}
a{color:var(--red);text-decoration:none} a:hover{text-decoration:underline}
button,input,select,textarea{font:inherit;color:inherit}
h1,h2,h3,h4{margin:0 0 .5rem;font-weight:700}
.app{min-height:100vh;display:flex;flex-direction:column}

/* ---------- header ---------- */
.topbar{display:flex;align-items:center;justify-content:space-between;gap:1rem;padding:.8rem 2rem .4rem;max-width:1400px;width:100%;margin:0 auto}
.brand{display:flex;align-items:center;gap:.6rem}
.logo{height:64px;width:auto}
.brand-text{display:flex;flex-direction:column;line-height:1.15;text-align:left}
html[dir=rtl] .brand-text{text-align:left}
.brand-en{font-weight:800;letter-spacing:.5px;color:var(--black);font-size:1.05rem}
.brand-ar{font-weight:800;color:var(--red);font-size:1.2rem}
.topbar-mid{flex:1;text-align:center}
.topbar-side{display:flex;align-items:center;gap:.8rem;flex-wrap:wrap;justify-content:flex-end}
.redbar{height:10px;background:var(--red);margin:0 2rem;max-width:1336px;margin-inline:auto;width:calc(100% - 4rem)}
.lang-switch{font-size:.85rem}
.lang-switch b{font-weight:800;letter-spacing:.5px;color:var(--black);display:block;font-size:1rem}
.lang-switch a{margin-inline-end:.8rem;color:var(--red);font-weight:600}
.lang-switch a.active{text-decoration:underline}
.user-chip{font-weight:600}
.user-chip small{color:var(--muted);font-weight:400;display:block}

/* ---------- sections drawer (opens on demand; RTL = slides from the right, LTR = from the left) ---------- */
.sidebar:empty{display:none}
.sb-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.38);z-index:40;animation:fade .15s}
.sb-panel{position:fixed;top:0;bottom:0;inset-inline-start:0;width:300px;max-width:88vw;background:#fff;z-index:41;overflow-y:auto;padding:.9rem .9rem 2rem;box-shadow:4px 0 24px rgba(0,0,0,.25);animation:slide .18s ease-out}
html[dir=rtl] .sb-panel{box-shadow:-4px 0 24px rgba(0,0,0,.25)}
@keyframes fade{from{opacity:0}to{opacity:1}}
@keyframes slide{from{transform:translateX(var(--sb-from,-20px));opacity:0}to{transform:none;opacity:1}}
html[dir=rtl] .sb-panel{--sb-from:20px}
.sb-head{display:flex;align-items:center;gap:.5rem;margin-bottom:.8rem;padding-bottom:.6rem;border-bottom:3px solid var(--red)}
.sb-home{flex:1;display:block;background:var(--black);color:#fff;border-radius:999px;padding:.4rem .9rem;font-weight:700;text-align:center}
.sb-home.current{background:#fff;color:var(--red);box-shadow:inset 0 0 0 2px var(--red)}
.sb-home:hover{text-decoration:none;color:#fff}
.sb-toggle{border:0;background:#eee;color:#333;border-radius:50%;width:34px;height:34px;font-size:1rem;cursor:pointer;flex:none}
.sb-toggle:hover{background:var(--red);color:#fff}
.sb-groups{display:flex;flex-direction:column;gap:.7rem}
.sb-group-title{color:var(--red);font-weight:800;font-size:.95rem;margin:0 .3rem .25rem;letter-spacing:.2px}
.sb-item{display:block;padding:.36rem .9rem;border-radius:10px;color:var(--ink);margin:.12rem 0;border:1px solid transparent;font-size:.93rem}
.sb-item:hover{background:var(--red-soft);text-decoration:none;color:var(--red)}
.sb-item.current{background:var(--red);color:#fff;font-weight:700}
.sb-pill{margin-inline-end:.3rem;background:var(--black);color:#fff}
.sb-pill:hover{background:#000}
@media print{.sidebar{display:none!important}}

/* ---------- nav ---------- */
.subnav{display:flex;flex-wrap:wrap;gap:.6rem;padding:.9rem 2rem .3rem;max-width:1400px;width:100%;margin:0 auto;align-items:center}
.subnav .spacer{flex:1}
.pill{display:inline-flex;align-items:center;gap:.35rem;border:0;border-radius:999px;padding:.38rem 1.1rem;background:var(--red);color:#fff;font-weight:600;cursor:pointer;white-space:nowrap;box-shadow:var(--shadow);text-decoration:none;line-height:1.4}
.pill:hover{background:var(--red-dark);text-decoration:none;color:#fff}
.pill.black{background:var(--black)} .pill.black:hover{background:#000}
.pill.gray{background:#eee;color:var(--ink);box-shadow:none} .pill.gray:hover{background:#e0e0e0}
.pill.outline{background:#fff;color:var(--red);border:2px solid var(--red);box-shadow:none}
.pill.ok{background:var(--ok)} .pill.warn{background:var(--warn)} .pill.info{background:var(--info)}
.pill.ok,.pill.warn,.pill.info,.pill.red{color:#fff}
.pill.busy{opacity:.6;pointer-events:none}
.pill.sm{padding:.22rem .8rem;font-size:.85rem}
.pill.xs{padding:.1rem .6rem;font-size:.78rem}
.pill[disabled]{opacity:.5;cursor:not-allowed}
.pill.active{outline:3px solid rgba(0,0,0,.25)}
/* current section in the top navigation: white pill with a red border + a red marker underneath */
.subnav .pill.current{background:#fff;color:var(--red);box-shadow:inset 0 0 0 2px var(--red);position:relative;font-weight:800}
.subnav .pill.current::after{content:"";position:absolute;left:50%;bottom:-7px;width:14px;height:4px;margin-left:-7px;border-radius:2px;background:var(--red)}
.subnav .pill.current:hover{background:#fff;color:var(--red)}

/* ---------- layout ---------- */
.view{flex:1;padding:1rem 2rem 2rem;max-width:1400px;width:100%;margin:0 auto;min-width:0;overflow-x:hidden}
.footer{text-align:center;color:var(--muted);font-size:.8rem;padding:1rem}
.row{display:flex;gap:1rem;flex-wrap:wrap;align-items:center}
.row.between{justify-content:space-between}
.row.end{justify-content:flex-end}
.col{display:flex;flex-direction:column;gap:.6rem}
.grid{display:grid;gap:1rem}
.grid.c2{grid-template-columns:repeat(auto-fit,minmax(320px,1fr))}
.grid.c3{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}
.grid.c4{grid-template-columns:repeat(auto-fit,minmax(200px,1fr))}
.card{background:#fff;border:1px solid var(--line);border-radius:14px;padding:1rem 1.2rem;box-shadow:var(--shadow)}
.card.soft{background:var(--bg-soft);box-shadow:none}
.card h3{color:var(--red);font-size:1.05rem;margin-bottom:.6rem}
.screen-title{text-align:center;font-size:1.5rem;font-weight:700;margin:1.2rem 0 .4rem}
.muted{color:var(--muted)} .small{font-size:.85rem} .bold{font-weight:700} .red{color:var(--red)} .ok{color:var(--ok)} .warn{color:var(--warn)}
.center{text-align:center} .num{font-variant-numeric:tabular-nums;direction:ltr;unicode-bidi:isolate;text-align:end}
.mt{margin-top:1rem} .mb{margin-bottom:1rem} .hidden{display:none!important}
.badge{display:inline-block;padding:.05rem .55rem;border-radius:999px;font-size:.78rem;background:#eee;color:#333;font-weight:600;white-space:nowrap}
.badge.red{background:var(--red-soft);color:var(--red)} .badge.ok{background:#e5f5ea;color:var(--ok)} .badge.warn{background:#fff3df;color:var(--warn)}
.badge.info{background:#e6eefb;color:var(--info)} .badge.black{background:var(--black);color:#fff}
.clickable{cursor:pointer}

/* ---------- forms ---------- */
.field{display:flex;align-items:center;gap:.5rem;min-width:0}
.field>label{background:var(--red);color:#fff;border-radius:999px;padding:.3rem .9rem;font-weight:600;white-space:nowrap;font-size:.9rem}
.field>label.black{background:var(--black)}
.field>input,.field>select,.field>textarea,.field>.static{flex:1;min-width:0}
input:not([type]),input[type=text],input[type=password],input[type=number],input[type=date],input[type=datetime-local],input[type=email],input[type=search],select,textarea{
  border:1.5px solid var(--black);border-radius:999px;padding:.38rem .9rem;background:#fff;outline:none;width:100%;min-width:0}
textarea{border-radius:14px;min-height:80px;resize:vertical}
input:focus,select:focus,textarea:focus{border-color:var(--red);box-shadow:0 0 0 3px rgba(225,21,27,.12)}
input[readonly]{background:var(--bg-soft)}
.static{padding:.38rem .9rem;border-bottom:1px dashed var(--line)}
.picker{flex:1;min-width:0} .picker input{width:100%}
.picker .search-results{position:fixed;z-index:60;max-height:260px;overflow:auto;padding:0;min-width:240px}
input[type=number],input[type=date],input[type=datetime-local]{direction:ltr;text-align:start}
.nowrap{white-space:nowrap}
.lock-banner{background:#fff3df;border:1px solid var(--warn);color:#7a4a00;border-radius:12px;padding:.5rem .9rem;margin-bottom:.8rem;font-size:.92rem}
tr.overdue td{background:#fff1f1}
.form-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:.7rem 1.2rem}
.form-grid .wide{grid-column:1/-1}
.check{display:inline-flex;align-items:center;gap:.4rem;cursor:pointer}
.check input{width:1.05rem;height:1.05rem;accent-color:var(--red)}
.help{font-size:.8rem;color:var(--muted)}
.error-text{color:var(--red);font-size:.88rem;font-weight:600}

/* ---------- tables ---------- */
.table-wrap{overflow-x:auto;border:2px solid var(--black);border-radius:4px;background:#fff}
table.data{width:100%;border-collapse:collapse;min-width:720px}
table.data th{background:var(--red);color:#fff;font-weight:700;padding:.5rem .6rem;border:1px solid #fff;white-space:nowrap;position:sticky;top:0;font-size:.92rem}
table.data td{padding:.38rem .6rem;border-bottom:1px solid #eee;border-inline:1px solid #f1f1f1;vertical-align:middle}
table.data td.num,table.data td.nowrap,table.data td.date{white-space:nowrap}
table.data tbody tr:hover{background:#fff7f7}
table.data tbody tr.selected{background:var(--red-soft);outline:2px solid var(--red)}
table.data tbody tr.deleted{opacity:.5;text-decoration:line-through}
table.data td.num,table.data th.num{text-align:end}
table.data tfoot td{font-weight:700;background:var(--bg-soft);border-top:2px solid var(--black)}
table.data .actions{white-space:nowrap}
.totals-bar{display:flex;gap:2.5rem;justify-content:space-around;flex-wrap:wrap;font-weight:700;padding:.6rem 1rem;margin-top:.4rem}
.totals-bar span b{color:var(--red);margin-inline-start:.4rem;direction:ltr;unicode-bidi:isolate;display:inline-block}
.empty{padding:2rem;text-align:center;color:var(--muted)}

/* editable items grid */
table.items{font-size:.88rem;min-width:0;width:100%}
table.items input,table.items select{border-radius:6px;padding:.15rem .3rem;border:1px solid #bbb;min-width:0;width:100%}
table.items input.w-l{min-width:120px} table.items input.w-s{width:64px;min-width:56px} table.items input.w-xs{width:100%;margin-top:2px;font-size:.78rem;padding:.05rem .3rem;border-style:dashed}
table.items td{padding:.12rem .18rem}
table.items th{font-size:.78rem;padding:.3rem .25rem;line-height:1.15;white-space:normal}
table.items th small{display:block;font-weight:400;opacity:.85;font-size:.68rem}
table.items td.calc{font-size:.85rem;padding-inline:.3rem}
.items-wrap{border-width:1px}
@media (min-width:1100px){table.items.compact{table-layout:auto}}
table.items td.calc{background:var(--bg-soft);text-align:end;font-variant-numeric:tabular-nums;direction:ltr}

/* ---------- side buttons (like the mock-ups) ---------- */
.screen{display:grid;grid-template-columns:minmax(0,1fr) 150px;gap:1rem;align-items:start}   /* RTL: side column on the left, as in the mock-ups */
.screen>*{min-width:0}
html[dir=ltr] .screen{grid-template-columns:minmax(0,1fr) 150px}                               /* LTR: mirrored -> side on the right */
.side{display:flex;flex-direction:column;gap:.5rem;position:sticky;top:1rem}
.side .pill{justify-content:center}
@media (max-width:900px){.screen{grid-template-columns:1fr}.side{flex-direction:row;flex-wrap:wrap;position:static;order:-1}}

/* ---------- dashboard ---------- */
.menu-tree{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:1.2rem 1.5rem;margin-top:1rem}
.menu-col{display:flex;flex-direction:column;gap:.5rem;align-items:stretch}
.menu-col .head{background:var(--red);color:#fff;border-radius:999px;padding:.4rem 1rem;text-align:center;font-weight:700}
.menu-col .sub{display:flex;flex-direction:column;gap:.45rem;border-inline-start:3px solid var(--red);padding-inline-start:.8rem;margin-inline-start:.5rem}
.menu-col .sub .pill{justify-content:center}
.stat{display:flex;flex-direction:column;gap:.1rem;padding:.7rem 1rem;border-radius:12px;background:var(--bg-soft);border:1px solid var(--line)}
.stat b{font-size:1.3rem;color:var(--red);direction:ltr;unicode-bidi:isolate}
.stat span{font-size:.82rem;color:var(--muted)}

/* ---------- login ---------- */
.login-wrap{display:grid;grid-template-columns:1fr 1fr;gap:2rem;align-items:center;margin-top:2rem}
@media (max-width:900px){.login-wrap{grid-template-columns:1fr}}
.login-form{display:flex;flex-direction:column;gap:.9rem;max-width:520px;margin:auto;width:100%}
.slideshow{border:3px solid var(--black);border-radius:26px;min-height:320px;display:flex;flex-direction:column;justify-content:center;align-items:center;text-align:center;padding:1.5rem;position:relative;overflow:hidden;background:#fff}
.slideshow img{max-width:100%;max-height:220px;object-fit:contain;border-radius:12px}
.slideshow h2{font-size:1.8rem;letter-spacing:1px}
.slideshow .dots{position:absolute;bottom:.6rem;display:flex;gap:.4rem}
.slideshow .dots i{width:9px;height:9px;border-radius:50%;background:#ccc;display:inline-block;cursor:pointer}
.slideshow .dots i.on{background:var(--red)}
.public-nav{display:flex;gap:.6rem;flex-wrap:wrap;justify-content:flex-end}

/* ---------- modal ---------- */
.modal-bg{position:fixed;inset:0;background:rgba(0,0,0,.45);display:flex;align-items:flex-start;justify-content:center;padding:3vh 1rem;z-index:50;overflow:auto}
.modal{background:#fff;border-radius:16px;max-width:900px;width:100%;padding:1.2rem 1.4rem;box-shadow:0 10px 40px rgba(0,0,0,.3);animation:pop .15s ease-out}
.modal.wide{max-width:1200px}
.modal.narrow{max-width:520px}
.modal h3{color:var(--red)}
.modal .actions{display:flex;gap:.6rem;justify-content:flex-end;margin-top:1rem;flex-wrap:wrap}
@keyframes pop{from{transform:translateY(-8px);opacity:0}to{transform:none;opacity:1}}

/* ---------- toast ---------- */
.toast-root{position:fixed;bottom:1rem;inset-inline-start:1rem;display:flex;flex-direction:column;gap:.5rem;z-index:100}
.toast{background:var(--black);color:#fff;padding:.6rem 1rem;border-radius:10px;box-shadow:var(--shadow);max-width:420px;animation:pop .2s}
.toast.err{background:var(--red)} .toast.ok{background:var(--ok)}

/* ---------- timeline ---------- */
.timeline{list-style:none;padding:0;margin:0;border-inline-start:3px solid var(--red);padding-inline-start:1rem}
.timeline li{margin-bottom:.8rem;position:relative}
.timeline li::before{content:"";position:absolute;inset-inline-start:-1.45rem;top:.35rem;width:12px;height:12px;border-radius:50%;background:var(--red)}
.note-card{border-radius:12px;padding:.8rem 1rem;border:1px solid var(--line);box-shadow:var(--shadow);position:relative;white-space:pre-wrap}
.note-card.yellow{background:#fff8d6} .note-card.red{background:#ffe3e3} .note-card.green{background:#e3f7e8} .note-card.blue{background:#e3edff} .note-card.gray{background:#f0f0f0}
.note-card .tools{position:absolute;top:.4rem;inset-inline-end:.5rem;display:flex;gap:.3rem}
.tabs{display:flex;gap:.4rem;flex-wrap:wrap;margin-bottom:.8rem}
.tabs .pill{background:#eee;color:var(--ink);box-shadow:none} .tabs .pill.active{background:var(--red);color:#fff;outline:none}
.kpi{font-size:1.6rem;font-weight:800;color:var(--red);direction:ltr;unicode-bidi:isolate}
.search-results .item{padding:.4rem .6rem;border-bottom:1px solid #eee;cursor:pointer}
.search-results .item:hover{background:var(--red-soft)}
.progress{height:10px;background:#eee;border-radius:999px;overflow:hidden}
.progress i{display:block;height:100%;background:var(--red)}

/* ---------- print area (filled only while printing) ---------- */
#print-area{display:none;padding:0 .5rem}
html.printing .app,html.printing #modal-root,html.printing #toast-root{display:none!important}
html.printing #print-area{display:block}
#print-area .table-wrap{overflow:visible;border-width:1px}
#print-area table.data{min-width:0;font-size:11px}
#print-area table.data th{position:static}
#print-area .no-print{display:none!important}

/* ---------- print ---------- */
.print-only{display:none}
@media print{
  @page{margin:12mm}
  body{font-size:12px;background:#fff}
  .topbar-side,.subnav,.side,.no-print,.toast-root,.modal-bg,.footer,.lang-switch{display:none!important}
  .print-only{display:block}
  .view{padding:0;max-width:none}
  .screen{display:block}
  .table-wrap{overflow:visible;border-width:1px}
  table.data{min-width:0;font-size:11px}
  table.data th{background:var(--red)!important;color:#fff!important;-webkit-print-color-adjust:exact;print-color-adjust:exact;position:static}
  .card{box-shadow:none;break-inside:avoid}
  input,select,textarea{border:none!important;background:transparent!important;padding:0!important}
  .field>label{background:#000!important;color:#fff!important;-webkit-print-color-adjust:exact;print-color-adjust:exact}
  .redbar{-webkit-print-color-adjust:exact;print-color-adjust:exact}
  a{color:inherit;text-decoration:none}
}

/* platform announcements bar */
#announce{width:100%;max-width:1400px;margin:0 auto;padding:0 1rem;box-sizing:border-box;align-self:center}
.announce{width:100%;box-sizing:border-box;display:flex;align-items:center;justify-content:space-between;gap:1rem;background:#eef2ff;color:#1e3a8a;border:1px solid #c7d2fe;border-radius:10px;padding:.5rem .9rem;margin:.5rem 0;font-size:.92rem}
.announce.warn{background:#fff7ed;color:#9a3412;border-color:#fed7aa}
.announce .x{background:transparent;border:0;cursor:pointer;font-size:1rem;color:inherit}
.kv{display:grid;grid-template-columns:auto 1fr;gap:.25rem .8rem;font-size:.92rem;align-items:baseline}
.kv b{color:var(--muted,#666);font-weight:600}
