/* «رصد رقبا» — competitors.js. Prefix: cm- */
.cm-head{display:flex; justify-content:space-between; align-items:flex-start; gap:12px; flex-wrap:wrap; margin-bottom:12px;}
.cm-head-actions{display:flex; gap:8px; align-items:center; flex-wrap:wrap;}
.cm-head-actions .btn{width:auto;}
.cm-live{display:inline-flex; align-items:center; gap:6px; font-size:12px; color:var(--ok); background:#eaf6ef; border-radius:999px; padding:4px 10px;}
.cm-live i{width:8px; height:8px; border-radius:50%; background:var(--ok); animation:cm-pulse 1.8s infinite;}
@keyframes cm-pulse{0%{box-shadow:0 0 0 0 rgba(47,143,91,.55);} 70%{box-shadow:0 0 0 7px rgba(47,143,91,0);} 100%{box-shadow:0 0 0 0 rgba(47,143,91,0);}}
.cm-tabs{margin-bottom:16px;}
.cm-filters{display:flex; gap:12px; flex-wrap:wrap; align-items:flex-end; margin-bottom:16px;}
.cm-filters .field{margin-bottom:0; min-width:170px;}
.cm-h3{margin:0 0 14px; font-size:14px;}
.cm-h3 small{font-weight:400; color:var(--text-dim);}
.cm-hint{font-size:11.5px; color:var(--text-dim); margin-top:10px; line-height:1.8;}
.cm-dim{color:var(--text-dim); font-size:12px;}
.cm-danger{color:var(--danger);}
.cm-empty{color:var(--text-dim); font-size:13px; padding:14px 4px; text-align:center;}
.cm-sub{margin-bottom:12px;}
.cm-note{background:var(--steel-tint); border-radius:10px; padding:10px 12px; margin:10px 0 16px; white-space:pre-wrap; font-size:13px;}
.cm-click{cursor:pointer;}
tr.cm-click:hover td{background:#f7f9fc;}
.cm-panel-head{display:flex; justify-content:space-between; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:10px;}
.cm-panel-head .cm-h3{margin:0;}
.cm-panel-head .btn{width:auto;}
.cm-inline{display:flex; gap:10px; align-items:center; flex-wrap:wrap;}
.cm-inline select{width:auto;}
.cm-search{max-width:260px;}
#view-competitors .panel, #mgmt-report-competitors .panel, .cm-modal .panel{margin-bottom:16px;}

/* KPI cards */
.cm-kpis{display:grid; grid-template-columns:repeat(auto-fit, minmax(140px,1fr)); gap:14px; margin-bottom:16px;}
.cm-kpi{background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); padding:16px 14px; text-align:center; box-shadow:var(--shadow-soft);}
.cm-kpi-v{font-size:24px; font-weight:800; color:var(--navy, #2b2873);}
.cm-kpi-t{font-size:12.5px; color:var(--text-dim); margin-top:4px;}
.cm-kpi-s{font-size:11.5px; color:var(--text-dim); margin-top:6px; line-height:1.7;}
.cm-kpi.warn .cm-kpi-v{color:var(--danger);}
.cm-grid2{display:grid; grid-template-columns:repeat(auto-fit, minmax(340px,1fr)); gap:16px; margin-bottom:0;}

/* tables */
.cm-table-wrap{overflow-x:auto;}
.cm-table{width:100%; border-collapse:collapse; font-size:13px;}
.cm-table th{text-align:right; white-space:nowrap; font-size:12px; color:var(--text-dim); font-weight:600; padding:8px; border-bottom:1px solid var(--line);}
.cm-table td{text-align:right; padding:8px; border-bottom:1px solid var(--line); vertical-align:top;}
.cm-table .mono{font-variant-numeric:tabular-nums; white-space:nowrap;}
.cm-stale-row td{background:#fff6f4;}
.cm-pos{display:inline-block; border-radius:6px; padding:1px 7px; font-size:12px; white-space:nowrap;}
.cm-pos.bad{background:var(--accent-tint, #fdece7); color:var(--danger);}
.cm-pos.good{background:#eaf6ef; color:var(--ok);}
.cm-pos.equal{background:var(--steel-tint); color:var(--text-dim);}
.cm-tag{display:inline-block; border-radius:6px; padding:0 7px; font-size:11.5px; background:var(--steel-tint); color:var(--steel, #4e72b8); white-space:nowrap;}
.cm-tag.lost{background:var(--accent-tint, #fdece7); color:var(--danger);}
.cm-tag.won{background:#eaf6ef; color:var(--ok);}
.cm-av{display:inline-block; border-radius:6px; padding:0 7px; font-size:11.5px; white-space:nowrap; background:var(--steel-tint); color:var(--text-dim);}
.cm-av.in_stock{background:#eaf6ef; color:var(--ok);}
.cm-av.limited{background:#fff4e0; color:#b45309;}
.cm-av.lead_time{background:#fff4e0; color:#b45309;}
.cm-av.out{background:var(--accent-tint, #fdece7); color:var(--danger);}

/* lists + feed */
.cm-list{display:flex; flex-direction:column; max-height:420px; overflow-y:auto;}
.cm-li{display:flex; justify-content:space-between; gap:10px; padding:8px 2px; border-bottom:1px solid var(--line); font-size:13px; flex-wrap:wrap;}
.cm-li:last-child{border-bottom:0;}
.cm-chips{display:flex; flex-wrap:wrap; gap:8px;}
.cm-chip{border-radius:999px; padding:3px 10px; font-size:12px;}
.cm-chip.ok{background:#eaf6ef; color:var(--ok);}
.cm-chip.stale{background:var(--accent-tint, #fdece7); color:var(--danger);}

/* diverging index bars */
.cm-div-legend{display:flex; justify-content:space-between; font-size:11px; color:var(--text-dim);}
.cm-div-row{display:grid; grid-template-columns:minmax(90px,140px) 1fr 74px; gap:10px; align-items:center; margin-bottom:8px; font-size:13px;}
.cm-div-name{white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.cm-div-track{position:relative; height:16px; background:#f3f5f8; border-radius:4px;}
.cm-div-mid{position:absolute; left:50%; top:-3px; bottom:-3px; width:2px; background:#9aa7b4;}
.cm-div-bar{position:absolute; top:2px; bottom:2px; border-radius:3px;}
.cm-div-bar.bad{background:var(--danger);}
.cm-div-bar.good{background:var(--ok);}
.cm-div-bar.equal{background:#9aa7b4; width:2px !important;}
.cm-div-val{font-weight:700; font-variant-numeric:tabular-nums; text-align:left; direction:ltr;}
.cm-div-val small{display:block; font-weight:400; font-size:10.5px; color:var(--text-dim); direction:rtl; text-align:right;}
.cm-div-val.bad{color:var(--danger);} .cm-div-val.good{color:var(--ok);}

/* simple bars */
.cm-hbar-row{display:grid; grid-template-columns:minmax(90px,150px) 1fr auto; gap:10px; align-items:center; margin-bottom:8px; font-size:13px;}
.cm-hbar-name{white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.cm-hbar-track{height:14px; background:#f3f5f8; border-radius:4px; overflow:hidden;}
.cm-hbar-fill{height:100%; border-radius:4px;}
.cm-hbar-val{font-size:12px; color:var(--text-dim); white-space:nowrap;}

/* columns (weekly / 30-day buckets) */
.cm-cols{display:flex; align-items:flex-end; gap:6px; height:180px; padding-top:18px;}
.cm-col{flex:1; display:flex; flex-direction:column; align-items:center; height:100%; min-width:0;}
.cm-col-total{font-size:11px; color:var(--text-dim); height:16px;}
.cm-col-stack{flex:1; width:100%; max-width:34px; display:flex; flex-direction:column-reverse; background:#f6f8fa; border-radius:4px 4px 0 0; overflow:hidden;}
.cm-col-stack > div{width:100%;}
.cm-idx.bad{background:var(--danger);} .cm-idx.good{background:var(--ok);} .cm-idx.equal{background:#9aa7b4;}
.cm-col-lbl{font-size:10px; color:var(--text-dim); margin-top:5px; text-align:center; direction:rtl; line-height:1.35; min-height:27px; max-width:100%;}
.cm-legend{display:flex; gap:14px; flex-wrap:wrap; font-size:12px; color:var(--text-dim); margin-top:10px;}
.cm-legend i{display:inline-block; width:10px; height:10px; border-radius:3px; margin-inline-end:5px; vertical-align:-1px;}
.cm-chart svg{width:100%; height:auto; display:block;}

/* contributor points bar */
.cm-pts{position:relative; min-width:90px; height:18px; background:#f3f5f8; border-radius:4px; overflow:hidden;}
.cm-pts div{position:absolute; inset-block:0; right:0; background:linear-gradient(90deg, #23b0dc, #2b2873); border-radius:4px;}
.cm-pts span{position:relative; font-size:12px; font-weight:700; color:#fff; padding-inline:6px; line-height:18px; mix-blend-mode:normal; text-shadow:0 0 3px rgba(0,0,0,.35);}

/* competitor cards */
.cm-cards{display:grid; grid-template-columns:repeat(auto-fill, minmax(250px,1fr)); gap:12px;}
.cm-card{border:1px solid var(--line); border-radius:12px; padding:12px; background:var(--panel); display:flex; flex-direction:column; gap:6px; transition:box-shadow .15s;}
.cm-card:hover{box-shadow:var(--shadow-soft);}
.cm-card.archived{opacity:.6;}
.cm-card-h{display:flex; gap:8px; align-items:center; flex-wrap:wrap;}
.cm-card-stats{display:grid; grid-template-columns:1fr 1fr; gap:4px 10px; font-size:12px; color:var(--text-dim);}
.cm-card-stats b{color:var(--text);}

/* profile */
.cm-prof-head{display:flex; justify-content:space-between; gap:10px; flex-wrap:wrap; align-items:flex-start; margin-bottom:12px;}
.cm-prof-head .btn{width:auto; margin-inline-start:6px;}
.cm-facts{display:grid; grid-template-columns:repeat(auto-fit, minmax(180px,1fr)); gap:10px; margin-bottom:12px; font-size:13px;}
.cm-timeline{display:flex; flex-direction:column; gap:0;}
.cm-tl{display:grid; grid-template-columns:110px 1fr; gap:12px; padding:10px 0; border-bottom:1px solid var(--line); font-size:13px;}
.cm-tl:last-child{border-bottom:0;}
.cm-tl-date{color:var(--text-dim); font-size:12px; border-inline-end:3px solid var(--line); padding-inline-end:8px;}
.cm-tl.high .cm-tl-date{border-inline-end-color:var(--danger);}
.cm-tl.medium .cm-tl-date{border-inline-end-color:#d97706;}
.cm-tl-body{display:flex; flex-direction:column; gap:4px; line-height:1.8;}
.cm-tl-lines{display:flex; flex-direction:column; gap:2px;}

/* modal */
.cm-overlay{display:none; position:fixed; inset:0; background:rgba(43,40,115,.55); z-index:160; align-items:flex-start; justify-content:center; padding:24px 16px; overflow-y:auto;}
.cm-overlay.active{display:flex;}
.cm-modal{background:var(--panel); border-radius:var(--radius); padding:18px 20px; width:100%; max-width:620px; box-shadow:var(--shadow);}
.cm-modal.wide{max-width:1080px;}
.cm-mhead{display:flex; justify-content:space-between; align-items:center; margin-bottom:14px;}
.cm-mhead h3{margin:0; font-size:16px;}
.cm-mhead .btn{width:auto;}
.cm-form2{display:grid; grid-template-columns:repeat(auto-fit, minmax(220px,1fr)); gap:0 14px;}
.cm-form3{display:grid; grid-template-columns:repeat(auto-fit, minmax(180px,1fr)); gap:0 14px;}
.cm-actions{display:flex; justify-content:space-between; align-items:center; gap:10px; margin-top:12px; flex-wrap:wrap;}
.cm-actions .btn{width:auto; min-width:120px;}

/* entry lines */
.cm-lines-head{display:flex; gap:10px; align-items:baseline; flex-wrap:wrap; margin:6px 0 8px;}
.cm-line{display:grid; grid-template-columns:minmax(260px,1.6fr) 3fr; gap:8px; align-items:start; padding:8px; border:1px solid var(--line); border-radius:10px; margin-bottom:8px; background:#fbfcfd;}
.cm-line-rest{display:grid; grid-template-columns:150px minmax(150px,1.4fr) minmax(130px,1fr) 90px auto; gap:8px; align-items:start;}
.cm-line input, .cm-line select{width:100%; margin:0;}
.cm-line .cml-del{width:auto; padding:6px 10px;}
.cml-ours{font-size:11.5px; line-height:1.7; padding-top:2px;}
.cml-ours b{color:var(--text); font-variant-numeric:tabular-nums;}
.cm-line-item{position:relative;}
.cml-picked{align-items:center; justify-content:space-between; gap:8px; padding:7px 10px; background:var(--steel-tint); border-radius:8px; font-size:13px; min-height:38px;}
.cml-picked a{font-size:12px; white-space:nowrap;}
.cml-dd{display:none; position:absolute; inset-inline:0; top:100%; z-index:5; background:#fff; border:1px solid var(--line); border-radius:8px; box-shadow:var(--shadow); max-height:280px; overflow-y:auto; margin-top:2px;}
.cml-opt{padding:8px 10px; cursor:pointer; font-size:13px; border-bottom:1px solid var(--line);}
.cml-opt:hover{background:var(--steel-tint);}
.cml-free{color:var(--steel, #4e72b8);}
.cml-cmp{font-size:11.5px; margin-top:3px; min-height:14px;}
.cm-watch-add{min-width:280px;}
@media (max-width:900px){
  .cm-line{grid-template-columns:1fr;}
  .cm-line-rest{grid-template-columns:1fr 1fr;}
  .cm-tl{grid-template-columns:1fr;}
  .cm-tl-date{border-inline-end:0; border-bottom:2px solid var(--line); padding-bottom:4px;}
}
@media (max-width:560px){
  .cm-div-row, .cm-hbar-row{grid-template-columns:90px 1fr 60px;}
  .cm-head-actions{width:100%;}
}



/* the app sets RTL on everything; charts that are drawn left→right must opt out */
.cm-div-legend, .cm-div-track, .cm-cols, .cm-chart{direction:ltr !important;}
.cm-search, .cm-inline select, .cm-watch-add input{padding:8px 12px; border:1px solid var(--line); border-radius:10px; font:inherit; font-size:13px; background:#fff; min-width:200px;}
#view-competitors input:not([type=checkbox]):not([type=radio]), .cm-modal input:not([type=checkbox]):not([type=radio]), .cm-modal textarea{
  box-sizing:border-box; width:100%; min-height:40px; padding:8px 12px; border:1px solid var(--line); border-radius:10px; font:inherit; font-size:13.5px; background:#fff; color:var(--text);}
#view-competitors input:focus, .cm-modal input:focus, .cm-modal textarea:focus{outline:none; border-color:var(--steel, #4e72b8); box-shadow:0 0 0 3px rgba(78,114,184,.15);}
#view-competitors .cm-search{width:auto; min-width:220px;}

.cml-cmp.good{color:var(--ok);} .cml-cmp.bad{color:var(--danger);}
.cm-h4{margin:0 0 10px; font-size:13px;}
.cm-tag.warn{background:#fff4e0; color:#b45309;}

/* tags */
.cm-tagchip{display:inline-flex; align-items:center; gap:4px; box-sizing:border-box; height:24px; line-height:1; border-radius:999px; padding:0 10px; font-size:11.5px; margin:2px 0 2px 4px; white-space:nowrap; vertical-align:middle; border:1px solid transparent;}
.cm-tagchip.brand{background:#eef0f9; color:#2b2873;}
.cm-tagchip.category{background:#e6f7fb; color:#1a7a99;}
.cm-tagchip a{color:inherit; text-decoration:none; font-weight:700; opacity:.6;}
.cm-tagchip a:hover{opacity:1;}
.cm-tagchip small{opacity:.65;}
.cm-tagchip.on{border-color:currentColor; box-shadow:0 0 0 2px rgba(43,40,115,.12);}
.cm-taginput{position:relative;}
.cm-tagbox{display:flex; flex-wrap:wrap; align-items:center; gap:4px; min-height:42px; padding:4px 8px; border:1px solid var(--line); border-radius:10px; background:#fff; cursor:text;}
/* the chips sit in the same row as the input and wrap with it, instead of stacking in their own column */
.cm-tagchips{display:contents;}
.cm-tagbox .cm-tagchip{margin:0;}
.cm-tagbox input{border:0 !important; box-shadow:none !important; min-height:32px !important; padding:4px !important; flex:1; min-width:160px; width:auto !important;}
.cm-tf{display:flex; flex-direction:column; gap:6px; padding:10px 12px; background:#f7f9fc; border-radius:10px; margin-bottom:14px; font-size:12.5px;}
.cm-tf-row{display:flex; flex-wrap:wrap; align-items:center; gap:2px;}
.cm-tf-row > .cm-dim{margin-inline-end:6px;}
.cm-card-tags{display:flex; flex-wrap:wrap; align-items:center;}

/* candles */
.cm-candles-wrap{overflow-x:auto; direction:ltr !important; padding-bottom:4px;}
.cm-candles-wrap svg{display:block;}
.cm-candle:hover rect[fill="transparent"]{fill:rgba(43,40,115,.05);}

/* purchase reasons as chips */
.cm-reasons{display:flex; flex-wrap:wrap; gap:8px;}
.cm-reason{display:inline-flex; align-items:center; cursor:pointer;}
.cm-reason input{display:none;}
.cm-reason span{border:1px solid var(--line); border-radius:999px; padding:6px 12px; font-size:13px; background:#fff;}
.cm-reason input:checked + span{background:var(--accent-tint, #fdece7); border-color:var(--danger); color:var(--danger); font-weight:600;}

/* quick "new competitor" box on top of an open form */
.cm-quick{position:fixed; inset:0; background:rgba(43,40,115,.35); z-index:170; display:flex; align-items:flex-start; justify-content:center; padding:60px 16px; overflow-y:auto;}
.cm-quick-in{background:#fff; border-radius:var(--radius); padding:16px 18px; width:100%; max-width:520px; box-shadow:var(--shadow);}
