/*
 * Kashef — Courier Matching Tool · styles
 * Design system container: 960px. Flat colours only — no gradients, no glow.
 * Logical properties are used so RTL/LTR flip cleanly.
 */
:root{
  --brand:#0B4543;        /* Kashef primary */
  --brand-tint:#E4EFED;
  --paper:#F7F6F2;
  --surface:#FFFFFF;
  --ink:#17211F;
  --muted:#5C6B67;
  --line:#DCD8CE;
  --red:#A93226;
  --red-tint:#F9ECEA;
  --amber-tint:#FBF3DF;
  --amber-line:#D9A441;
  --radius:10px;
}
*{box-sizing:border-box}
/* The hidden attribute must always win — e.g. .tag is display:inline-block,
   which otherwise overrides [hidden] and leaks the sample tag onto real files. */
[hidden]{display:none!important}
body{margin:0;background:var(--paper);color:var(--ink);
  font-family:system-ui,"Segoe UI",Tahoma,Arial,sans-serif;line-height:1.65}
.wrap{max-width:960px;margin:0 auto;padding:0 20px}

/* Header */
.topbar{background:var(--brand);color:#fff}
.topbar-in{display:flex;justify-content:space-between;align-items:center;padding-top:14px;padding-bottom:14px}
.brand{font-size:19px}.brand-name{font-weight:800}.brand-sep{opacity:.6;margin:0 6px}

/* Buttons + text links */
.btn{background:var(--brand);color:#fff;border:1px solid var(--brand);border-radius:var(--radius);
  padding:11px 22px;font-size:16px;font-weight:700;cursor:pointer;font-family:inherit}
.btn-quiet{background:transparent;color:var(--brand);border-color:var(--line)}
.topbar .btn-quiet{color:#fff;border-color:#ffffff55}
.btn:focus-visible,.dropbox:focus-visible,.textlink:focus-visible{outline:3px solid var(--brand);outline-offset:2px}
.textlink{background:none;border:0;padding:4px 2px;font:inherit;font-weight:700;color:var(--brand);
  cursor:pointer;text-decoration:underline;text-underline-offset:4px}
.link-row{margin:16px 0 0;display:flex;gap:10px;align-items:center}
.link-sep{color:var(--muted)}

/* Step indicator */
.steps{display:flex;align-items:center;gap:12px;padding:22px 0 0;margin:0;color:var(--muted);font-size:16px;list-style:none}
.steps>li{list-style:none}
.step-num{font-weight:800}
.step.is-active{color:var(--brand);font-weight:800}
.step-arrow{color:var(--muted)}
[dir="rtl"] .step-arrow{transform:none} /* RTL: progress runs right to left, the ← arrow already points forward */

/* Sections & type */
.section{padding:32px 0 8px}
h1{font-size:28px;margin:0 0 8px}h2{font-size:24px;margin:0 0 12px}h3{font-size:19px;margin:28px 0 10px}
.lede{color:var(--muted);max-width:640px;margin:0 0 20px}
.tag{display:inline-block;font-size:13px;font-weight:700;color:var(--brand);
  border:1px solid var(--brand);border-radius:6px;padding:1px 8px;vertical-align:middle}
.tag-red{color:var(--red);border-color:var(--red)}
.tag-amber{color:#7A5B12;border-color:var(--amber-line)}

/* Drop zone: dashed frame + icon; solid green + tint once a file is loaded */
.dropbox{border:2px dashed #9DB8B3;background:var(--surface);border-radius:var(--radius);
  padding:34px 20px;text-align:center;cursor:pointer;color:var(--brand)}
.dropbox.dragover{border-color:var(--brand);background:var(--brand-tint)}
.dropbox.loaded{border:2px dashed var(--brand);background:var(--brand-tint)} /* stays dashed: it is a drop zone */
.drop-icon{margin-bottom:8px}
.drop-title{font-size:18px;font-weight:700;margin:0;color:var(--ink)}
.drop-or{margin:6px 0;color:var(--muted)}
.drop-choose{margin:0;font-weight:700;text-decoration:underline;text-underline-offset:4px}
.drop-hint{color:var(--muted);margin:12px 0 0}
.drop-file{margin:12px 0 0;font-weight:700;color:var(--brand)}

#pasteWrap textarea{width:100%;margin:12px 0;padding:12px;border:1px solid var(--line);
  border-radius:var(--radius);font-family:ui-monospace,Menlo,Consolas,monospace;font-size:14px;background:var(--surface)}
.footer{padding:28px 20px 36px;color:var(--muted);font-size:14px}

/* Messages */
.error{background:var(--red-tint);color:var(--red);border:1px solid var(--red);
  border-radius:var(--radius);padding:12px 16px;margin-top:16px}
.warn{background:var(--amber-tint);border:1px solid var(--line);border-radius:var(--radius);
  padding:12px 16px;margin-top:16px}
.notice{border:1px solid var(--line);background:var(--surface);border-radius:var(--radius);
  padding:11px 16px;margin:14px 0 0;font-weight:600}

/* Mapping: one-line summary bar; expands to one card per field */
.map-summary{display:flex;justify-content:space-between;align-items:center;gap:12px;
  background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:12px 16px}
.map-summary.has-warning{background:var(--amber-tint);border-color:var(--amber-line)}
.map-rows{display:grid;gap:10px;margin:16px 0 8px} /* full width: selects stretch with the row */
.map-row{display:grid;grid-template-columns:210px 1fr;gap:14px;align-items:center;
  background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:12px 16px}
.map-row.is-unmatched{background:var(--amber-tint);border-color:var(--amber-line)} /* the unmatched row itself is coloured */
.map-row label{font-weight:700}
.map-src{display:block;font-weight:400;font-size:13px;color:var(--muted);margin-top:2px}
.map-row select{padding:10px;border:1px solid var(--line);border-radius:var(--radius);
  font-size:16px;font-family:inherit;background:var(--surface);width:100%}
.req-note{color:var(--muted);font-size:14px;margin:6px 0 0}
.analyze-row{display:flex;justify-content:flex-end;margin-top:18px}

/* Results */
.panel{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:20px 22px}
.panel h3{margin-top:0}
.rec-text{font-size:18px;margin:0}
.only-one{margin:10px 0 0;color:var(--muted)}
.loser-text{margin:12px 0 0} /* normal text colour; only the tag is red */
.scroll-hint{display:none;color:var(--muted);font-size:14px;margin:0 0 8px}
.table-wrap{overflow-x:auto;overflow-y:hidden;max-width:100%;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius)}
table{border-collapse:collapse;width:100%}
th,td{padding:10px 12px;font-size:15px;text-align:start;border-bottom:1px solid var(--line)}
/* Courier name: never clipped, never ellipsis. It may wrap to a second
   line; the Best tag is inline, so it simply lands at the end of the
   wrapped line. (Round 5's nowrap clipped long names in the EN table.) */
td:first-child{min-width:150px}
/* Arabic (RTL): the name + «الأفضل» tag must stay on ONE line (round-5
   requirement), so the cell is nowrap with enough room — 190px. The
   English cell keeps the round-8 behaviour (wraps, never clipped). */
html[dir="rtl"] td:first-child{min-width:190px;white-space:nowrap}
td .tag{padding-top:0;padding-bottom:0;font-size:12.5px;line-height:1.5;flex:none;white-space:nowrap}
td:nth-child(2){min-width:100px;white-space:nowrap} /* "5 (open: 1)" never wraps */
.open-note{white-space:nowrap;color:var(--muted)}
thead th{background:var(--brand-tint);font-size:14px} /* headers wrap — never cut off */
th.num,td.num{text-align:end} /* numbers to the end side, text to the start */
tbody tr:last-child td{border-bottom:0}
/* Sticky first column (courier name) while scrolling sideways */
th:first-child,td:first-child{position:sticky;inset-inline-start:0;background:var(--surface);font-weight:700}
thead th:first-child{background:var(--brand-tint)}
tr.row-highlight td{background:var(--brand-tint)}
td.net{font-weight:800}td.neg{color:var(--red)}
.courier-cards{display:none}
.region-list{display:grid;gap:10px}
.region-item{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:14px 18px}
.region-item strong{color:var(--brand)}
.row-between{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-top:16px;flex-wrap:wrap}
bdi{font-variant-numeric:tabular-nums}

/* Tablets/phones: mapping cards stack */
@media (max-width:760px){
  .map-row{grid-template-columns:1fr;gap:6px}
}
/* Compact table between 741px and 960px so it still fits without cutting */
@media (max-width:960px){
  th,td{padding:8px 7px;font-size:13.5px}
  td:first-child{min-width:132px}
  html[dir="rtl"] td:first-child{min-width:150px}
  td:nth-child(2){min-width:88px}
}
/* Up to 740px: one card per courier instead of the table.
   Each stat is a full-width row: label at the start, value at the end —
   the same pattern as the net-received row above it. */
@media (max-width:740px){
  .table-wrap{display:none}
  .courier-cards{display:grid;gap:10px}
  .courier-card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:14px 16px}
  .courier-card .card-head{display:flex;justify-content:space-between;align-items:center;gap:8px}
  .courier-card h4{margin:0;font-size:17px;color:var(--brand)}
  .courier-card .card-net{display:flex;justify-content:space-between;align-items:baseline;margin-top:8px}
  .courier-card .card-net span{color:var(--muted)}
  .courier-card .card-net strong{font-size:21px}
  .courier-card .card-stats{margin-top:8px}
  .courier-card .stat-row{display:flex;justify-content:space-between;align-items:baseline;
    padding:5px 0;border-top:1px solid var(--line);color:var(--muted);font-size:15px}
  .courier-card .stat-row bdi{color:var(--ink);font-weight:700}
  .courier-card.row-highlight{border-color:var(--brand);background:var(--brand-tint)}
}
@media (max-width:480px){
  .analyze-row .btn{width:100%}
}
@media (max-width:560px){
  .brand{font-size:16px}
  .topbar .btn-quiet{padding:8px 14px;font-size:14px}
  h1{font-size:24px}h2{font-size:21px}
  .section{padding-top:24px}
  .dropbox{padding:26px 14px}
  .steps{font-size:14px;gap:8px}
}

/* ---- Profit tool additions ---- */
h3{font-size:19px;margin:26px 0 10px}
h4{font-size:16px;margin:20px 0 8px}
.note{color:var(--muted);font-size:14px;margin:8px 0}
.coverage-list{list-style:none;margin:6px 0;padding:0}
.coverage-list li{padding:7px 0;border-bottom:1px solid var(--line);font-size:15px}
.coverage-list li:last-child{border-bottom:0}
.excluded-list{list-style:none;margin:0;padding:0}
.excluded-list li{padding:7px 0;border-bottom:1px solid var(--line);font-size:15px}
.excluded-list li:last-child{border-bottom:0}
tfoot td{font-weight:700;background:var(--tint);border-top:2px solid var(--line)}
td .sub{display:block;font-weight:400;color:var(--muted);font-size:12.5px}
.cards{display:none}
@media (max-width:740px){
  .cards{display:grid;gap:12px}
  .rcard{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:14px 16px}
  .rcard .rcard-head{display:flex;justify-content:space-between;align-items:baseline;gap:10px;border-bottom:1px solid var(--line);padding-bottom:8px;margin-bottom:6px}
  .rcard .rcard-name{font-weight:700}
  .rcard .rcard-net{text-align:end}
  .rcard .rcard-net .nlab{display:block;font-size:12px;color:var(--muted);font-weight:400}
  .rcard .rcard-net .nval{font-size:19px;font-weight:700}
  .rcard .stat{display:flex;justify-content:space-between;padding:5px 0;font-size:14.5px;border-bottom:1px solid var(--line)}
  .rcard .stat:last-child{border-bottom:0}
  .rcard .stat .slab{color:var(--muted)}
  .rcard .stat .sval{font-weight:600}
}
/* Profit orders table has 10 columns: tighten padding and let the
   products list wrap, so the table fits the 920px content width. */
#ordersTable th,#ordersTable td{padding:10px 8px}
#ordersTable td:nth-child(2){min-width:0;white-space:normal}
#ordersTable td:first-child{min-width:90px}
html[dir="rtl"] #ordersTable td:first-child{min-width:90px}
/* Compact excluded list: with ~10% returns on a big file this list is
   hundreds of lines; tighter spacing keeps the page height sane. All
   excluded orders are still listed — only the padding shrinks. */
.excluded-list li{padding:3px 0;font-size:14.5px}
.analyze-row-start{justify-content:flex-start}

/* Returned-orders list: each fact stays on one line and wraps between facts,
   never through a separator dot (mobile bidi). */
.rl-part { display: inline-block; white-space: nowrap; margin-inline-start: 10px; }
.excluded-list li .rl-part:first-of-type { margin-inline-start: 8px; }

.kpi-board{margin:0 0 28px}
.kpi-row{display:grid;grid-template-columns:repeat(4,1fr);border-top:1px solid #E3E9E1;margin-bottom:12px}
.kpi{display:flex;flex-direction:column;gap:14px;padding:28px 28px 0 0;padding-inline:0 28px;min-width:0}
.kpi+.kpi{border-inline-start:1px solid #E3E9E1;padding-inline-start:28px}
.kpi.pre{opacity:0;transform:translateY(16px)}
.kpi.pre.in{opacity:1;transform:none;transition:opacity .7s cubic-bezier(.22,.61,.36,1),transform .7s cubic-bezier(.22,.61,.36,1)}
.kpi-spark{display:flex;align-items:flex-end;gap:4px;height:26px;direction:ltr}
.kpi-spark i{flex:1 1 0;max-width:11.9px;border-radius:2px;background:#D5DED3;display:block}
.kpi-spark i.g{background:#86C9A0}
.kpi-val{font-size:42px;line-height:42px;font-weight:500;letter-spacing:-1.26px;color:#10372A;font-variant-numeric:tabular-nums;direction:ltr;text-align:start}
.kpi.neg .kpi-val{color:#B4402F}
.kpi-lab{font-size:14px;line-height:21.7px;font-weight:400;color:#5D7166;padding-bottom:4px}
@media(max-width:700px){.kpi-row{grid-template-columns:repeat(2,1fr)}.kpi{padding-block-end:20px}.kpi:nth-child(3){border-inline-start:0;padding-inline-start:0}.kpi:nth-child(n+3){border-top:1px solid #E3E9E1}.kpi-val{font-size:32px;line-height:34px}}
@media(prefers-reduced-motion:reduce){.kpi.pre{opacity:1;transform:none}}

/* ---- Weekly verdict ---- */
.statrow{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;margin:18px 0 8px}
.vstat{border:1px solid #E3E7E5;border-radius:14px;padding:14px 16px;display:flex;flex-direction:column;gap:4px;background:#fff}
.vnum{font-size:26px;font-weight:700;line-height:1.1}
.vlab{font-size:14px;font-weight:600}
.vdesc{font-size:12.5px;color:#6B7A76;line-height:1.5}
.vbadge{display:inline-block;padding:4px 10px;border-radius:999px;font-size:12.5px;font-weight:600;white-space:nowrap}
.v-scale{border-color:#BFE3C8}
.v-scale .vnum,.v-scale .vlab{color:#1F7A3E}
.vbadge.v-scale{background:#E8F6EC;color:#1F7A3E}
.v-watch .vnum,.v-watch .vlab{color:#8A6A12}
.vbadge.v-watch{background:#FBF3DC;color:#8A6A12}
.v-kill .vnum,.v-kill .vlab{color:#B3261E}
.vbadge.v-kill{background:#FBE9E7;color:#B3261E}
.v-data .vnum,.v-data .vlab{color:#5B6B67}
.vbadge.v-data{background:#EEF2F1;color:#5B6B67}
.tr{font-weight:600}
.tr-up{color:#1F7A3E}
.tr-down{color:#B3261E}
.tr-flat{color:#5B6B67}
@media(max-width:820px){.statrow{grid-template-columns:repeat(2,1fr)}}
/* inline delta next to the trend word: stays on the same line and keeps the cell's own alignment */
.dlt{display:inline;font-size:12.5px;font-weight:600;color:#5B6B67;white-space:nowrap;margin-inline-start:0}
.tr-up + .dlt{color:#1F7A3E}
.tr-down + .dlt{color:#B3261E}
.trgrp{display:inline-block;white-space:nowrap;max-width:100%}
.trgrp .tr{margin-inline-end:4px}
.numnowrap{white-space:nowrap}
/* total row under the statement: same columns, visually a summary */
#monthTable tbody tr.row-total td{border-top:2px solid #0B4543;font-weight:700;background:#F4F8F7}
