/* Evri Claim Generator (.ecg-*)
 * The Evri Claims page itself: build a claim file from order numbers or
 * barcodes. The older manual attach-and-send flow is the collapsed panel below.
 *
 * Visual language is the teal-blue family shared with Evri Claims (.ec-),
 * Message Templates (.mt-), Support Cases (.sc-) and Listing Photos (.alp-):
 * soft cards, teal->blue gradient, 1.5px borders, 11-20px radii, #0588b6
 * primary (the same token as style.css:3326, because this IS the same module).
 *
 * Structure copied from public/css/supportCases.css.
 *
 * TWO RULES THIS FILE KEEPS THAT THE OLD .ec- BLOCK DOES NOT:
 *   1. Mobile rules live ONLY inside @media (max-width:1180px) — the house
 *      standard (responsive.css:7, mobile-kit.css:352-353, supportCases.css:207).
 *      The .ec- block uses 880px, which is out of step; do not copy it.
 *   2. Dark mode covers EVERY surface introduced here. The .ec- dark block
 *      covers only 3 selectors (style.css:3435-3437); that gap is not inherited.
 */

:root {
  --ecg-primary: #0588b6;
  --ecg-primary-d: #03658e;
  --ecg-grad: linear-gradient(135deg, #03658e, #0588b6);
  --ecg-ink: #0f2740;
  --ecg-sub: #5b7183;
  --ecg-line: #e6edf5;
  --ecg-line-s: #cfdcea;
  --ecg-shadow: 0 10px 30px rgba(15, 23, 42, .06);
  --ecg-ok: #0f7b52;
  --ecg-warn: #9a6700;
  --ecg-bad: #b42318;
  --ecg-card: #fff;
  --ecg-bg-soft: #f6f9fc;
}

.ecg-wrap { max-width: 1180px; margin: 0 auto; padding: 6px 4px 44px; }

/* ---------- Secondary panel: "Send a file I made myself" ----------
   The builder is the page; this is the fallback for a file made outside RMS.
   When the builder is unavailable this panel stands alone (.ecg-manual--solo):
   summary hidden, no card chrome, so the page reads exactly as it did before
   the generator existed. */
.ecg-manual { max-width: 1180px; margin: 0 auto 16px; border: 1.5px solid var(--ecg-line); border-radius: 16px; background: var(--ecg-card); overflow: hidden; }
.ecg-manual > summary { cursor: pointer; list-style: none; padding: 14px 18px; font-size: 14px; font-weight: 800; color: var(--ecg-ink); display: flex; align-items: center; gap: 9px; }
.ecg-manual > summary::-webkit-details-marker { display: none; }
.ecg-manual > summary::before { content: "\25B8"; color: var(--ecg-primary); font-size: 13px; transition: .15s; }
.ecg-manual[open] > summary::before { transform: rotate(90deg); }
.ecg-manual > summary:hover { color: var(--ecg-primary); }
.ecg-manual > summary:focus-visible { outline: 2px solid var(--ecg-primary); outline-offset: -2px; }
.ecg-manual #evriClaimsRoot { padding: 0 4px 6px; }
/* Standalone: the only path on the page. */
.ecg-manual--solo { border: none; background: transparent; margin-bottom: 0; overflow: visible; }
.ecg-manual--solo > summary { display: none; }
.ecg-manual--solo #evriClaimsRoot { padding: 0; }

/* ---------- Bulk-apply bar ---------- */
.ecg-bulk { border: 1.5px solid var(--ecg-line-s); border-radius: 13px; padding: 11px 13px; margin-bottom: 13px; background: var(--ecg-bg-soft); }
.ecg-bulk-head { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; margin-bottom: 10px; }
.ecg-bulk-all { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ecg-ink); cursor: pointer; }
.ecg-bulk-all input { width: 17px; height: 17px; }
.ecg-bulk-actions { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.ecg-bulk-act { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ecg-bulk-lbl { font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--ecg-sub); }
.ecg-bulk-inp { width: 190px; padding: 6px 10px; font-size: 13px; }
.ecg-bulk-num { width: 92px; }
.ecg-bulk .ecg-bulk-none { display: none; }
.ecg-bulk.none-selected .ecg-bulk-none { display: inline; }
.ecg-table th.ecg-tick, .ecg-table td.ecg-tick { width: 34px; min-width: 34px; text-align: center; padding-left: 8px; padding-right: 4px; }
.ecg-table td.ecg-tick input { width: 17px; height: 17px; }
.ecg-table tr.sel td { background: #eef7fb; }
.ecg-rcard.sel { border-color: var(--ecg-primary); }
.ecg-rcard-tick { display: flex; align-items: center; padding-top: 2px; }
.ecg-rcard-tick input { width: 17px; height: 17px; }

/* ---------- Head ---------- */
.ecg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin: 4px 0 14px; }
.ecg-eyebrow { font-size: 12px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--ecg-primary); }
.ecg-title { font-size: 25px; font-weight: 800; color: var(--ecg-ink); margin: 4px 0; line-height: 1.15; }
.ecg-sub { font-size: 13.5px; color: var(--ecg-sub); margin: 0; max-width: 680px; line-height: 1.5; }
.ecg-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.ecg-btn { appearance: none; border: 1.5px solid var(--ecg-line-s); background: #fff; color: #21506f; font-size: 13px; font-weight: 700; padding: 9px 15px; border-radius: 11px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; transition: .15s; text-decoration: none; }
.ecg-btn:hover:not(:disabled) { border-color: var(--ecg-primary); color: var(--ecg-primary); }
.ecg-btn.primary { border: none; color: #fff; background: var(--ecg-grad); box-shadow: 0 8px 18px rgba(5, 136, 182, .28); }
.ecg-btn.primary:hover:not(:disabled) { color: #fff; filter: brightness(1.06); }
/* The background MUST be set here, not inherited from .ecg-btn.
   polish.css:429 has an unscoped `button.danger { background:#b42318 }`. That
   selector is (0,1,1) — element + class — which outranks `.ecg-btn` (0,1,0)
   whatever the load order, so it painted this button solid red. And #b42318 is
   the exact value of --ecg-bad, our text colour: identical red on red, and the
   label vanished completely.
   `.ecg-btn.danger` is (0,2,0), which beats it, so stating the background here
   makes the button self-contained rather than at the mercy of a global. */
.ecg-btn.danger { background: #fff; border-color: #f1c9c5; color: var(--ecg-bad); }
.ecg-btn.danger:hover:not(:disabled) { background: #fdf1f0; border-color: var(--ecg-bad); color: var(--ecg-bad); }
.ecg-btn:disabled { opacity: .5; cursor: not-allowed; }
.ecg-btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }

/* ---------- Cards ---------- */
.ecg-card { background: var(--ecg-card); border: 1.5px solid var(--ecg-line); border-radius: 18px; box-shadow: var(--ecg-shadow); padding: 18px; margin-bottom: 16px; }
.ecg-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.ecg-card-head h3 { font-size: 15.5px; font-weight: 800; color: var(--ecg-ink); margin: 0; }
.ecg-card-head .ecg-spacer { flex: 1; }
.ecg-step { width: 24px; height: 24px; border-radius: 50%; background: var(--ecg-grad); color: #fff; font-size: 12.5px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }

/* ---------- Inputs ---------- */
.ecg-field { margin-bottom: 13px; }
.ecg-label { display: block; font-size: 11.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--ecg-sub); margin-bottom: 5px; }
.ecg-label .req { color: var(--ecg-bad); margin-left: 3px; }
.ecg-inp, .ecg-textarea, .ecg-select {
  width: 100%; box-sizing: border-box; border: 1.5px solid var(--ecg-line-s); border-radius: 11px;
  padding: 9px 12px; font-size: 13.5px; font-family: inherit; color: var(--ecg-ink); background: #fff; transition: .15s;
}
.ecg-inp:focus, .ecg-textarea:focus, .ecg-select:focus { outline: none; border-color: var(--ecg-primary); box-shadow: 0 0 0 3px rgba(5, 136, 182, .13); }
.ecg-inp.bad, .ecg-textarea.bad { border-color: var(--ecg-bad); }
.ecg-textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.ecg-paste { min-height: 150px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.ecg-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ecg-counter { font-size: 11.5px; color: var(--ecg-sub); margin-top: 4px; display: flex; justify-content: space-between; gap: 8px; }
.ecg-counter.bad { color: var(--ecg-bad); font-weight: 700; }
.ecg-counter.ok { color: var(--ecg-ok); }
.ecg-src { font-size: 11px; font-weight: 700; color: var(--ecg-sub); background: var(--ecg-bg-soft); border: 1px solid var(--ecg-line); border-radius: 6px; padding: 1px 6px; margin-left: 6px; white-space: nowrap; }
.ecg-hint { font-size: 12px; color: var(--ecg-sub); margin-top: 5px; line-height: 1.45; }
/* Live sanitiser explanation — shown when typing loses a character. */
.ecg-strip { font-size: 12px; color: var(--ecg-warn); background: #fff8e6; border: 1px solid #f2dda0; border-radius: 8px; padding: 6px 9px; margin-top: 5px; line-height: 1.4; }

/* ---------- Segmented choice (Lost / Damaged, DOR Yes / No) ---------- */
.ecg-seg { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.ecg-seg-btn { appearance: none; border: 1.5px solid var(--ecg-line-s); background: #fff; color: #4a6885; font-size: 13px; font-weight: 700; padding: 8px 15px; border-radius: 10px; cursor: pointer; transition: .15s; }
.ecg-seg-btn:hover { border-color: var(--ecg-primary); color: var(--ecg-primary); }
.ecg-seg-btn.on { border-color: var(--ecg-primary); background: var(--ecg-grad); color: #fff; box-shadow: 0 6px 14px rgba(5, 136, 182, .24); }

/* ---------- Result cards ---------- */
.ecg-rcards { display: flex; flex-direction: column; gap: 11px; }
.ecg-rcard { border: 1.5px solid var(--ecg-line); border-radius: 14px; padding: 13px 15px; background: #fff; display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; transition: .15s; }
.ecg-rcard:hover { border-color: var(--ecg-line-s); }
.ecg-rcard.bad { border-color: #f1c9c5; background: #fff8f7; }
.ecg-rcard.warn { border-color: #f2dda0; background: #fffdf6; }
.ecg-rcard-main { flex: 1; min-width: 200px; }
.ecg-rcard-in { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; font-weight: 700; color: var(--ecg-ink); word-break: break-all; }
.ecg-rcard-meta { font-size: 12px; color: var(--ecg-sub); margin-top: 3px; line-height: 1.5; }
.ecg-rcard-acts { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }

/* ---------- Chips ---------- */
.ecg-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 800; padding: 3px 9px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.ecg-chip.ok { color: var(--ecg-ok); background: #eaf7f1; border-color: #bde3d1; }
.ecg-chip.warn { color: var(--ecg-warn); background: #fff8e6; border-color: #f2dda0; }
.ecg-chip.bad { color: var(--ecg-bad); background: #fdf1f0; border-color: #f1c9c5; }
.ecg-chip.neutral { color: #41607d; background: var(--ecg-bg-soft); border-color: var(--ecg-line-s); }
.ecg-reasons { display: flex; flex-direction: column; gap: 3px; margin-top: 7px; }
.ecg-reason { font-size: 12px; color: var(--ecg-warn); line-height: 1.45; }
.ecg-reason::before { content: "! "; font-weight: 800; }

/* ---------- Parcel chooser (multi-parcel orders) ---------- */
.ecg-parcels { margin-top: 9px; padding: 10px; border: 1.5px dashed var(--ecg-line-s); border-radius: 11px; background: var(--ecg-bg-soft); width: 100%; }
.ecg-parcels-t { font-size: 12px; font-weight: 800; color: var(--ecg-ink); margin-bottom: 7px; }
.ecg-parcel { display: flex; align-items: center; gap: 9px; padding: 6px 0; font-size: 12.5px; color: var(--ecg-ink); flex-wrap: wrap; }
.ecg-parcel code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

/* ---------- Skeletons (per-card, never a full-screen blocker) ---------- */
.ecg-skel { border: 1.5px solid var(--ecg-line); border-radius: 14px; padding: 15px; background: #fff; }
.ecg-skel-l { height: 11px; border-radius: 6px; background: linear-gradient(90deg, #eef3f8 25%, #e2eaf3 37%, #eef3f8 63%); background-size: 400% 100%; animation: ecg-sheen 1.3s ease infinite; margin-bottom: 8px; }
.ecg-skel-l.s { width: 40%; } .ecg-skel-l.m { width: 68%; } .ecg-skel-l.w { width: 88%; }
@keyframes ecg-sheen { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) { .ecg-skel-l { animation: none; } }

/* ---------- Preview table (13 columns, scrolls inside itself) ---------- */
.ecg-tablewrap { overflow-x: auto; border: 1.5px solid var(--ecg-line); border-radius: 13px; -webkit-overflow-scrolling: touch; }
.ecg-table { border-collapse: collapse; width: 100%; min-width: 1200px; font-size: 12.5px; }
.ecg-table th { text-align: left; padding: 9px 11px; background: var(--ecg-bg-soft); color: var(--ecg-ink); font-weight: 800; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; border-bottom: 1.5px solid var(--ecg-line); white-space: nowrap; position: sticky; top: 0; }
.ecg-table td { padding: 8px 11px; border-bottom: 1px solid var(--ecg-line); color: var(--ecg-ink); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.ecg-table tr { cursor: pointer; }
.ecg-table tbody tr:hover td { background: #f3f9fc; }
.ecg-table tr.bad td { background: #fff8f7; }
.ecg-table td.empty { color: #9db0c2; }
.ecg-tfoot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--ecg-sub); margin-top: 9px; }
.ecg-fname { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--ecg-ink); font-weight: 700; }

/* ---------- Validation panel ---------- */
.ecg-valid { border-radius: 13px; padding: 12px 14px; margin-bottom: 13px; border: 1.5px solid; font-size: 13px; }
.ecg-valid.ok { border-color: #bde3d1; background: #eaf7f1; color: var(--ecg-ok); }
.ecg-valid.bad { border-color: #f1c9c5; background: #fdf1f0; color: var(--ecg-bad); }
.ecg-valid h4 { margin: 0 0 7px; font-size: 13.5px; font-weight: 800; }
.ecg-verrs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 210px; overflow-y: auto; }
.ecg-verr { font-size: 12.5px; line-height: 1.45; }
.ecg-verr button { appearance: none; background: none; border: none; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; font-weight: 700; }

/* ---------- Empty state ---------- */
.ecg-empty { text-align: center; padding: 34px 18px; color: var(--ecg-sub); }
.ecg-empty-ico { font-size: 30px; margin-bottom: 9px; }
.ecg-empty h4 { margin: 0 0 6px; font-size: 15px; color: var(--ecg-ink); font-weight: 800; }
.ecg-empty p { margin: 0 auto; font-size: 13px; line-height: 1.55; max-width: 460px; }
.ecg-empty code { background: var(--ecg-bg-soft); border: 1px solid var(--ecg-line); border-radius: 5px; padding: 1px 5px; font-size: 12px; }

/* ---------- Banner (stale draft, resume, errors) ---------- */
.ecg-banner { border: 1.5px solid var(--ecg-line-s); background: #eef7fb; color: #21506f; border-radius: 13px; padding: 11px 14px; font-size: 13px; margin-bottom: 14px; display: flex; align-items: center; gap: 11px; flex-wrap: wrap; line-height: 1.45; }
.ecg-banner.warn { border-color: #f2dda0; background: #fff8e6; color: #7a5200; }
.ecg-banner.bad { border-color: #f1c9c5; background: #fdf1f0; color: var(--ecg-bad); }
.ecg-banner .ecg-spacer { flex: 1; }

/* ---------- DOR attach (dropzone) ---------- */
.ecg-drop { border: 2px dashed var(--ecg-line-s); border-radius: 13px; padding: 18px; text-align: center; cursor: pointer; transition: .15s; background: var(--ecg-bg-soft); }
.ecg-drop:hover, .ecg-drop.drag { border-color: var(--ecg-primary); background: #eef7fb; }
.ecg-drop:focus-visible { outline: 2px solid var(--ecg-primary); outline-offset: 2px; }
.ecg-drop-ico { font-size: 21px; margin-bottom: 5px; }
.ecg-drop-t { font-size: 13px; font-weight: 800; color: var(--ecg-ink); }
.ecg-drop-h { font-size: 11.5px; color: var(--ecg-sub); margin-top: 3px; line-height: 1.45; }
.ecg-file { display: flex; align-items: center; gap: 9px; border: 1.5px solid var(--ecg-line); border-radius: 11px; padding: 8px 11px; margin-top: 9px; background: #fff; }
.ecg-file-n { flex: 1; font-size: 12.5px; color: var(--ecg-ink); font-weight: 700; word-break: break-all; }
.ecg-file-x { appearance: none; border: none; background: none; color: var(--ecg-sub); font-size: 17px; cursor: pointer; line-height: 1; padding: 0 3px; }
.ecg-file-x:hover { color: var(--ecg-bad); }
.ecg-renamed { font-size: 11.5px; color: var(--ecg-primary); font-weight: 700; margin-top: 4px; }

/* ---------- Category picker ---------- */
.ecg-picker { position: relative; }
.ecg-opts { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1.5px solid var(--ecg-line-s); border-radius: 11px; box-shadow: 0 12px 28px rgba(15, 23, 42, .13); max-height: 210px; overflow-y: auto; }
.ecg-opt { padding: 8px 12px; font-size: 13px; color: var(--ecg-ink); cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.ecg-opt:hover, .ecg-opt.on { background: #eef7fb; color: var(--ecg-primary); }
.ecg-opt small { color: var(--ecg-sub); }

/* ---------- Modal (structure copied from .sc-modal) ---------- */
.ecg-modal { position: fixed; inset: 0; z-index: 6000; display: flex; align-items: center; justify-content: center; padding: 18px; }
.ecg-modal-bg { position: absolute; inset: 0; background: rgba(9, 24, 40, .5); backdrop-filter: blur(2px); }
.ecg-modal-shell { position: relative; background: #fff; border-radius: 19px; width: min(760px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 26px 70px rgba(9, 24, 40, .3); overflow: hidden; }
.ecg-modal-head { display: flex; align-items: center; gap: 12px; padding: 15px 19px; border-bottom: 1.5px solid var(--ecg-line); }
.ecg-modal-head h3 { margin: 0; font-size: 16px; font-weight: 800; color: var(--ecg-ink); flex: 1; }
.ecg-modal-body { padding: 17px 19px; overflow-y: auto; }
.ecg-modal-foot { display: flex; gap: 9px; justify-content: flex-end; padding: 13px 19px; border-top: 1.5px solid var(--ecg-line); flex-wrap: wrap; }
.ecg-x { appearance: none; border: none; background: none; font-size: 22px; line-height: 1; color: var(--ecg-sub); cursor: pointer; padding: 0 4px; }
.ecg-x:hover { color: var(--ecg-ink); }
.ecg-sec { border-top: 1.5px solid var(--ecg-line); margin-top: 15px; padding-top: 14px; }
.ecg-sec-t { font-size: 12.5px; font-weight: 800; color: var(--ecg-ink); margin-bottom: 9px; }

/* Quiet inline link-button (entry-mode switch). Looks like a link, behaves
   like a button, keeps a real focus ring. */
.ecg-linkbtn { appearance: none; background: none; border: none; padding: 0; margin-left: 6px; font: inherit; font-weight: 700; color: var(--ecg-primary); text-decoration: underline; cursor: pointer; }
.ecg-linkbtn:hover { color: var(--ecg-primary-d); }
.ecg-linkbtn:focus-visible { outline: 2px solid var(--ecg-primary); outline-offset: 2px; border-radius: 3px; }
.ecg-linkbtn.is-off { color: var(--ecg-warn); text-decoration: none; cursor: default; font-weight: 700; }

/* ---------- Data health ---------- */
.ecg-health summary { cursor: pointer; font-size: 13.5px; font-weight: 800; color: var(--ecg-ink); padding: 4px 0; list-style: none; display: flex; align-items: center; gap: 8px; }
.ecg-health summary::-webkit-details-marker { display: none; }
.ecg-health summary::before { content: "\25B8"; color: var(--ecg-primary); transition: .15s; }
.ecg-health[open] summary::before { transform: rotate(90deg); }
.ecg-health-body { padding-top: 12px; }
.ecg-hsec { margin-bottom: 15px; }
.ecg-hsec h5 { margin: 0 0 5px; font-size: 12.5px; font-weight: 800; color: var(--ecg-ink); }
.ecg-hsec p { margin: 0 0 6px; font-size: 12.5px; color: var(--ecg-sub); line-height: 1.55; }
.ecg-hbars { display: flex; flex-direction: column; gap: 7px; }
.ecg-hbar { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.ecg-hbar-l { flex: 0 0 130px; color: var(--ecg-ink); font-weight: 700; }
/* Track: a clearly visible neutral, NOT near-white, so a 0% row still reads
   as an empty bar rather than a broken one. */
.ecg-hbar-t { flex: 1; height: 10px; min-height: 8px; background: #d7e2ee; border-radius: 999px; overflow: hidden; border: 1px solid #7d90a5; }
.ecg-hbar-f { height: 100%; background: var(--ecg-primary); border-radius: 999px; min-width: 0; }
/* Figures are body text, not muted grey — they are the point of the row. */
.ecg-hbar-v { flex: 0 0 auto; color: var(--ecg-ink); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ================= DARK MODE — every surface above ================= */
html[data-theme="dark"] {
  --ecg-ink: #e6edf6;
  --ecg-sub: #9fb0c4;
  --ecg-line: #243049;
  --ecg-line-s: #2f3d5a;
  --ecg-card: #161f33;
  --ecg-bg-soft: #1a2438;
  --ecg-shadow: 0 10px 30px rgba(0, 0, 0, .3);
}
html[data-theme="dark"] .ecg-manual { background: #161f33; }
html[data-theme="dark"] .ecg-bulk { background: #1a2438; border-color: #2f3d5a; }
html[data-theme="dark"] .ecg-table tr.sel td { background: #1d2941; }
html[data-theme="dark"] .ecg-card,
html[data-theme="dark"] .ecg-rcard,
html[data-theme="dark"] .ecg-skel,
html[data-theme="dark"] .ecg-file,
html[data-theme="dark"] .ecg-modal-shell,
html[data-theme="dark"] .ecg-opts { background: #161f33; }
html[data-theme="dark"] .ecg-btn { background: #1d2941; border-color: #2f3d5a; color: #cfdcea; }
html[data-theme="dark"] .ecg-btn:hover:not(:disabled) { border-color: #6fc7e6; color: #6fc7e6; }
html[data-theme="dark"] .ecg-btn.primary { color: #fff; }
html[data-theme="dark"] .ecg-btn.danger { background: #1d2941; border-color: #5b2a26; color: #f5a29a; }
html[data-theme="dark"] .ecg-inp,
html[data-theme="dark"] .ecg-textarea,
html[data-theme="dark"] .ecg-select { background: #1a2438; border-color: #2f3d5a; color: #e6edf6; }
html[data-theme="dark"] .ecg-inp::placeholder,
html[data-theme="dark"] .ecg-textarea::placeholder { color: #6d8098; }
html[data-theme="dark"] .ecg-seg-btn { background: #1d2941; border-color: #2f3d5a; color: #b8c6d8; }
html[data-theme="dark"] .ecg-seg-btn.on { color: #fff; }
html[data-theme="dark"] .ecg-src { background: #1a2438; border-color: #2f3d5a; }
html[data-theme="dark"] .ecg-strip { background: #2c2413; border-color: #4a3d1c; color: #e3c06a; }
html[data-theme="dark"] .ecg-rcard.bad { background: #2a1a1a; border-color: #5b2a26; }
html[data-theme="dark"] .ecg-rcard.warn { background: #2a2415; border-color: #4a3d1c; }
html[data-theme="dark"] .ecg-chip.ok { color: #7ddcae; background: #10301f; border-color: #1d5237; }
html[data-theme="dark"] .ecg-chip.warn { color: #e3c06a; background: #2c2413; border-color: #4a3d1c; }
html[data-theme="dark"] .ecg-chip.bad { color: #f5a29a; background: #2a1616; border-color: #5b2a26; }
html[data-theme="dark"] .ecg-chip.neutral { color: #b8c6d8; background: #1a2438; border-color: #2f3d5a; }
html[data-theme="dark"] .ecg-reason { color: #e3c06a; }
html[data-theme="dark"] .ecg-parcels { background: #1a2438; border-color: #2f3d5a; }
html[data-theme="dark"] .ecg-tablewrap { border-color: #243049; }
html[data-theme="dark"] .ecg-table th { background: #1a2438; color: #e6edf6; border-color: #243049; }
html[data-theme="dark"] .ecg-table td { border-color: #243049; color: #e6edf6; }
html[data-theme="dark"] .ecg-table tbody tr:hover td { background: #1d2941; }
html[data-theme="dark"] .ecg-table tr.bad td { background: #2a1a1a; }
html[data-theme="dark"] .ecg-table td.empty { color: #66788c; }
html[data-theme="dark"] .ecg-valid.ok { border-color: #1d5237; background: #10301f; color: #7ddcae; }
html[data-theme="dark"] .ecg-valid.bad { border-color: #5b2a26; background: #2a1616; color: #f5a29a; }
html[data-theme="dark"] .ecg-banner { background: #14283a; border-color: #244152; color: #b7d3e2; }
html[data-theme="dark"] .ecg-banner.warn { background: #2c2413; border-color: #4a3d1c; color: #e3c06a; }
html[data-theme="dark"] .ecg-banner.bad { background: #2a1616; border-color: #5b2a26; color: #f5a29a; }
html[data-theme="dark"] .ecg-drop { background: #1a2438; border-color: #2f3d5a; }
html[data-theme="dark"] .ecg-drop:hover, html[data-theme="dark"] .ecg-drop.drag { background: #1d2941; border-color: #6fc7e6; }
html[data-theme="dark"] .ecg-opt { color: #e6edf6; }
html[data-theme="dark"] .ecg-opt:hover, html[data-theme="dark"] .ecg-opt.on { background: #1d2941; color: #6fc7e6; }
html[data-theme="dark"] .ecg-modal-head, html[data-theme="dark"] .ecg-modal-foot, html[data-theme="dark"] .ecg-sec { border-color: #243049; }
html[data-theme="dark"] .ecg-modal-bg { background: rgba(0, 0, 0, .62); }
html[data-theme="dark"] .ecg-empty code { background: #1a2438; border-color: #2f3d5a; }
/* Dark: the track must stay visibly lighter than the card behind it, and
   the fill brighter than the track. A 0% row still shows the track. */
html[data-theme="dark"] .ecg-hbar-t { background: #2b3852; border-color: #5d7290; }
html[data-theme="dark"] .ecg-hbar-f { background: #38b6e0; }
html[data-theme="dark"] .ecg-hbar-v, html[data-theme="dark"] .ecg-hbar-l { color: #e6edf6; }
html[data-theme="dark"] .ecg-linkbtn { color: #6fc7e6; }
html[data-theme="dark"] .ecg-linkbtn:hover { color: #9bd9ef; }
html[data-theme="dark"] .ecg-linkbtn.is-off { color: #e3c06a; }
html[data-theme="dark"] .ecg-skel-l { background: linear-gradient(90deg, #1d2941 25%, #243049 37%, #1d2941 63%); background-size: 400% 100%; }

/* ================= MOBILE (additive only, gated at 1180px) ================= */
@media (max-width: 1180px) {
  .ecg-wrap { padding: 4px 2px 40px; }
  .ecg-title { font-size: 21px; }
  .ecg-card { padding: 14px; border-radius: 15px; }
  .ecg-row2 { grid-template-columns: 1fr; }
  .ecg-head { flex-direction: column; gap: 11px; }
  .ecg-head-actions { width: 100%; }
  .ecg-head-actions .ecg-btn { flex: 1; justify-content: center; }
  /* The bar WRAPS rather than scrolling sideways, and every control keeps a
     comfortable touch target. */
  .ecg-bulk-actions { flex-direction: column; align-items: stretch; gap: 11px; }
  .ecg-bulk-act { width: 100%; }
  .ecg-bulk-inp, .ecg-bulk-num { flex: 1; width: auto; min-height: 40px; }
  .ecg-bulk-act .ecg-btn { min-height: 40px; }
  .ecg-bulk-all input, .ecg-table td.ecg-tick input, .ecg-rcard-tick input { width: 22px; height: 22px; }
  .ecg-manual > summary { min-height: 44px; }
  .ecg-rcard { flex-direction: column; align-items: stretch; gap: 9px; }
  .ecg-rcard-acts { width: 100%; }
  .ecg-rcard-acts .ecg-btn { flex: 1; justify-content: center; }
  /* The 13-column table cannot fit; it scrolls INSIDE its own wrapper so the
     page body never scrolls sideways. */
  .ecg-tablewrap { border-radius: 11px; }
  .ecg-table { min-width: 1100px; }
  .ecg-modal { padding: 0; align-items: flex-end; }
  .ecg-modal-shell { width: 100%; max-height: 94vh; border-radius: 19px 19px 0 0; }
  .ecg-modal-foot { position: sticky; bottom: 0; background: #fff; }
  .ecg-modal-foot .ecg-btn { flex: 1; justify-content: center; }
  .ecg-hbar-l { flex-basis: 92px; }
  /* Send confirmation: the DOR filename list must wrap rather than push the
     modal sideways, and the progress lines stay readable. */
  .ecg-parcel code { word-break: break-all; }
  #ecgSendProgress .ecg-banner { flex-direction: column; align-items: flex-start; }
  .ecg-tfoot { flex-direction: column; gap: 5px; }
  /* Comfortable touch targets. */
  .ecg-btn, .ecg-seg-btn { min-height: 40px; }
  .ecg-inp, .ecg-select { min-height: 40px; }
}
html[data-theme="dark"] .ecg-modal-foot { background: #161f33; }

/* ================= PRINT — a readable filing copy, not the raw CSV =========
   Driven by the BATCH, not by send state, so the same view serves as a
   pre-send check copy and as a filed record afterwards.
   Implemented as a print stylesheet over a rendered block (the cleaner of the
   two precedents in this repo) rather than a new window + document.write. */
#ecgPrintArea { display: none; }

@media print {
  /* Hide the whole app, show only the print block. */
  body.ecg-printing > *:not(#ecgPrintArea) { display: none !important; }
  body.ecg-printing #ecgPrintArea { display: block !important; }

  @page { size: A4 landscape; margin: 12mm 10mm 14mm; }

  #ecgPrintArea { font-family: Arial, Helvetica, sans-serif; color: #000; font-size: 9pt; }
  #ecgPrintArea h1 { font-size: 15pt; margin: 0 0 6pt; }

  .ecg-print-head { border-bottom: 1.5pt solid #000; padding-bottom: 6pt; margin-bottom: 8pt; }
  .ecg-print-meta { border-collapse: collapse; font-size: 8.5pt; }
  .ecg-print-meta td { padding: 1pt 10pt 1pt 0; vertical-align: top; }
  .ecg-print-meta td:first-child { font-weight: bold; white-space: nowrap; }

  .ecg-print-table { width: 100%; border-collapse: collapse; font-size: 7.5pt; table-layout: fixed; }
  /* Repeat the header on every page — a 499-row file runs to many pages and a
     headerless continuation is unreadable. */
  .ecg-print-table thead { display: table-header-group; }
  .ecg-print-table tfoot { display: table-footer-group; }
  .ecg-print-table tr { page-break-inside: avoid; }
  .ecg-print-table th, .ecg-print-table td {
    border: 0.5pt solid #666; padding: 2pt 3pt; text-align: left;
    word-wrap: break-word; overflow-wrap: break-word;
  }
  .ecg-print-table th { background: #e8e8e8; font-size: 6.5pt; text-transform: uppercase; }

  .ecg-print-foot { margin-top: 8pt; padding-top: 4pt; border-top: 0.5pt solid #666; font-size: 7pt; color: #333; }

  /* Never carry the screen's dark theme onto paper. */
  #ecgPrintArea, #ecgPrintArea * { background: transparent !important; color: #000 !important; }
}


/* The two collapsed sections sit in the same rhythm as the cards above them —
   previously the gap read as a failed load rather than a closed section. */
#evriClaimsHistory { max-width: 1180px; margin: 0 auto 16px; }
#evriClaimsHealth { max-width: 1180px; margin: 0 auto; padding-bottom: 40px; }
#evriClaimsHealth .ecg-health { margin-bottom: 0; }
#evriClaimsHistory .ec-history { margin-bottom: 0; }

/* ---------- Manual rows ----------
   A row typed by hand has nothing behind it: no shipment was found, so nothing
   verified the barcode, the recipient or the 28-day window. It must be
   distinguishable at a glance from a resolved row. */
.ecg-table tr.manual td:first-child { box-shadow: inset 3px 0 0 var(--ecg-warn); }
.ecg-table tr.manual td { background: #fffdf6; }
.ecg-table tr.manual.sel td { background: #fdf7e8; }
html[data-theme="dark"] .ecg-table tr.manual td { background: #221d10; }
html[data-theme="dark"] .ecg-table tr.manual.sel td { background: #2a2415; }

/* ---------- Order-first rows (the third provenance state) ----------
   Neither fully verified nor typed by hand: the recipient, value and items came
   from a real order, but the barcode was typed and nothing proves a parcel
   exists. Teal edge, distinct from the amber of a fully-manual row. */
.ecg-table tr.fromorder td:first-child { box-shadow: inset 3px 0 0 var(--ecg-primary); }
.ecg-table tr.fromorder.manual td:first-child { box-shadow: inset 3px 0 0 var(--ecg-warn); }
