/* LR Auto Entry - light theme, dark theme via prefers-color-scheme. No external fonts or CDN. */

:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --card-2: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --line: #e4e8ef;
  --line-2: #d3d9e3;
  --primary: #1e4fd8;
  --primary-hover: #183fb0;
  --primary-soft: #e9effd;
  --focus: rgba(30, 79, 216, .35);
  --top-1: #0d2259;
  --top-2: #1b46c2;

  --ok: #137a3a;      --ok-bg: #e2f5e9;
  --dup: #9a5b00;     --dup-bg: #fff1d6;
  --unr: #c2410c;     --unr-bg: #ffe8d9;
  --err: #bf1f2a;     --err-bg: #fde4e6;
  --dry: #1d5bcf;     --dry-bg: #e3ecff;
  --oth: #22667d;     --oth-bg: #dff0f5;   /* consignee not recognized: a normal outcome, not an error */
  --wait: #566176;    --wait-bg: #eceff4;
  --busy: #6a3ccf;    --busy-bg: #eee7ff;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 6px rgba(16, 24, 40, .06);
  --mono: "Cascadia Mono", Consolas, "Courier New", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e131b;
    --card: #161d28;
    --card-2: #1b2430;
    --text: #e5e9f1;
    --muted: #97a1b4;
    --line: #273142;
    --line-2: #344055;
    --primary: #4a7cff;
    --primary-hover: #6a93ff;
    --primary-soft: #1d2a4a;
    --focus: rgba(74, 124, 255, .45);
    --top-1: #0a1638;
    --top-2: #17357f;

    --ok: #5fd38a;      --ok-bg: #133524;
    --dup: #f2b84b;     --dup-bg: #3a2a0c;
    --unr: #ff9a5c;     --unr-bg: #3d2112;
    --err: #ff7b84;     --err-bg: #3f171c;
    --dry: #8fb2ff;     --dry-bg: #1b2a4d;
    --oth: #86cbe0;     --oth-bg: #16323b;
    --wait: #aab3c4;    --wait-bg: #252e3c;
    --busy: #b89cff;    --busy-bg: #2b2148;

    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 2px 8px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
h4 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 6px; }
h4:first-child { margin-top: 0; }
a { color: var(--primary); }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 13px; }
.nowrap { white-space: nowrap; }
.ok-text { color: var(--ok); font-weight: 600; }
.error-text { color: var(--err); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }

/* ------------------------------------------------------------------ header */
.offline {
  position: sticky; top: 0; z-index: 60;
  background: var(--err); color: #fff; text-align: center; padding: 8px 16px; font-weight: 600;
}
.topbar {
  background: linear-gradient(120deg, var(--top-1), var(--top-2));
  color: #fff;
  box-shadow: 0 2px 10px rgba(13, 34, 89, .25);
}
.topbar-inner {
  max-width: 1400px; margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 44px; height: 44px; border-radius: 11px; flex: none;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .28);
  font-weight: 800; letter-spacing: .02em;
}
.brand h1 { font-size: 20px; font-weight: 700; }
.tagline { margin: 2px 0 0; opacity: .82; font-size: 13px; }

.checks { display: flex; gap: 10px; flex-wrap: wrap; }
.pill {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px 5px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .22);
  font-size: 13px; white-space: nowrap;
}
.pill .dot { width: 9px; height: 9px; border-radius: 50%; background: #c3cad8; flex: none; }
.pill[data-state="ok"] .dot { background: #41d27a; box-shadow: 0 0 0 3px rgba(65, 210, 122, .25); }
.pill[data-state="warn"] .dot { background: #ffc145; box-shadow: 0 0 0 3px rgba(255, 193, 69, .25); }
.pill[data-state="bad"] .dot { background: #ff5d6c; box-shadow: 0 0 0 3px rgba(255, 93, 108, .3); }
.pill[data-state="busy"] .dot { background: #b9c8ff; animation: pulse 1s infinite ease-in-out; }
.pill-text { opacity: .9; }
.top-right { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; justify-content: flex-end; }
.user-box {
  display: flex; align-items: center; gap: 8px; font-size: 13px; white-space: nowrap;
  padding: 5px 6px 5px 12px; border-radius: 999px; background: rgba(0, 0, 0, .14);
}
.user-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.user-sep { opacity: .6; }
.pill-btn {
  border: 0; border-radius: 999px; padding: 3px 11px; cursor: pointer;
  background: rgba(255, 255, 255, .92); color: #10235d; font-weight: 600; font-size: 12px;
}
.pill-btn:hover { background: #fff; }
.pill-btn:disabled { opacity: .55; cursor: default; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ------------------------------------------------------------------ layout */
.wrap { max-width: 1400px; margin: 0 auto; padding: 16px 24px 48px; }

.check-msg {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 12px; padding: 10px 14px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--primary);
  white-space: pre-wrap; word-break: break-word;
}
.check-msg[data-kind="ok"] { border-left-color: var(--ok); }
.check-msg[data-kind="bad"] { border-left-color: var(--err); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-2); margin-bottom: 16px; }
.tab {
  border: 0; background: none; cursor: pointer;
  padding: 10px 16px; font-weight: 600; color: var(--muted);
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 16px;
}
.card-head { margin-bottom: 14px; }
.card-head p { margin: 4px 0 0; }
.card-head.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ------------------------------------------------------------------ buttons, tags, badges */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 9px; cursor: pointer; text-decoration: none;
  border: 1px solid var(--line-2); background: var(--card); color: var(--text); font-weight: 600;
  white-space: nowrap;
}
.btn:hover { background: var(--card-2); border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:disabled:hover { background: var(--primary); }
.btn-primary.is-test { background: var(--dry); border-color: var(--dry); }
.btn-danger { border-color: var(--err); color: var(--err); }
.btn-danger:hover { background: var(--err-bg); border-color: var(--err); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); border-color: transparent; }
.btn-big { padding: 12px 34px; font-size: 16px; border-radius: 11px; min-width: 180px; }
.link-btn { border: 0; background: none; color: var(--primary); cursor: pointer; text-decoration: underline; padding: 0; }
.icon-btn {
  border: 0; background: none; cursor: pointer; font-size: 24px; line-height: 1;
  width: 36px; height: 36px; border-radius: 8px; color: var(--muted);
}
.icon-btn:hover { background: var(--card-2); color: var(--text); }
.icon-btn.small { width: 26px; height: 26px; font-size: 18px; }

.tag {
  display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 700;
  background: var(--wait-bg); color: var(--wait); white-space: nowrap;
}
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--wait-bg); color: var(--wait);
}
.t-completed, .b-completed { background: var(--ok-bg); color: var(--ok); }
.t-duplicate, .b-duplicate { background: var(--dup-bg); color: var(--dup); }
.t-unreadable, .b-unreadable { background: var(--unr-bg); color: var(--unr); }
.t-error, .b-error { background: var(--err-bg); color: var(--err); }
.t-dryrun, .b-dryrun { background: var(--dry-bg); color: var(--dry); }
.t-other, .b-other { background: var(--oth-bg); color: var(--oth); }
.t-waiting, .b-waiting { background: var(--wait-bg); color: var(--wait); }
.b-busy { background: var(--busy-bg); color: var(--busy); }
.b-busy::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor;
  margin-right: 6px; animation: pulse 1s infinite ease-in-out;
}

.alert { padding: 10px 14px; border-radius: 10px; margin: 12px 0; border: 1px solid transparent; word-break: break-word; }
.alert-info { background: var(--primary-soft); color: var(--text); }
.alert-warn { background: var(--dup-bg); color: var(--text); border-color: var(--dup); }
.alert-error { background: var(--err-bg); color: var(--text); border-color: var(--err); }

/* ------------------------------------------------------------------ start card */
.field-label { display: block; font-weight: 600; margin-bottom: 6px; }
.folder-row { display: flex; gap: 8px; }
.folder-row input {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--line-2); background: var(--card); color: var(--text);
  font: 14px var(--mono);
}
.folder-row input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
.folder-info { min-height: 20px; margin: 6px 0 2px; font-size: 13px; color: var(--muted); }
.folder-info.is-ok { color: var(--ok); font-weight: 600; }
.folder-info.is-warn { color: var(--dup); }
.folder-info.is-bad { color: var(--err); }

.recent { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0 4px; }
.recent-label { color: var(--muted); font-size: 12px; margin-right: 2px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line-2); background: var(--card); color: var(--text);
  padding: 4px 11px; border-radius: 999px; cursor: pointer; font-size: 12.5px;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.is-selected { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip-n { font-weight: 700; opacity: .8; }
.chip-folder { font-family: var(--mono); font-size: 12px; }
.chip.is-missing { opacity: .5; text-decoration: line-through; }

.check-row { display: flex; align-items: flex-start; gap: 10px; margin: 16px 0; cursor: pointer; }
.check-row input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--primary); flex: none; }

.start-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.start-note { color: var(--muted); font-size: 13px; }
.folders-help { margin: 16px 0 0; padding-top: 14px; border-top: 1px dashed var(--line-2); color: var(--muted); font-size: 13px; line-height: 1.8; }

/* ------------------------------------------------------------------ upload card */
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.upload-pick { min-width: 220px; }
.upload-progress { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.upload-progress .progress { width: 100%; }
.upload-result { margin-top: 16px; padding: 14px; border-radius: 11px; background: var(--card-2); border: 1px solid var(--line); }
.upload-summary { margin-bottom: 8px; word-break: break-word; }
.warn-text { color: var(--dup); font-weight: 600; }
.file-list {
  list-style: none; margin: 0 0 12px; padding: 0; max-height: 220px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: 13px;
}
.file-list li { display: flex; flex-wrap: wrap; gap: 2px 10px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.file-list li:last-child { border-bottom: 0; }
.file-list .file-name { font-family: var(--mono); font-size: 12px; word-break: break-all; min-width: 0; }
.file-list .is-skipped .file-name { color: var(--text); font-weight: 600; }
.file-list .file-why { color: var(--unr); font-size: 12.5px; }
.file-list .is-saved .file-name::before { content: "\2713  "; color: var(--ok); font-weight: 700; }
.file-list.in-alert { margin: 8px 0 0; max-height: 180px; }
.upload-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-test { border-color: var(--dry); color: var(--dry); }
.btn-test:hover { background: var(--dry-bg); border-color: var(--dry); }
.btn-small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.upload-recent { margin-top: 18px; }
.upload-recent h3 { margin-bottom: 8px; }
.recent-uploads { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.recent-upload {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card-2); font-size: 13px;
}
.recent-upload.is-current { border-color: var(--primary); box-shadow: 0 0 0 2px var(--focus); }
.ru-main { flex: 1 1 220px; min-width: 0; }
.ru-run { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ run panel */
.empty { padding: 36px 12px; text-align: center; color: var(--muted); }
.run-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.run-head-main { min-width: 0; flex: 1; }
.run-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.run-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; color: var(--muted); font-size: 13px; }
.folder-path { color: var(--text); word-break: break-all; }
.run-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.stepper { list-style: none; display: flex; padding: 0; margin: 18px 0 8px; }
.step { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; text-align: center; }
.step::before {
  content: ""; position: absolute; top: 14px; right: 50%; width: 100%; height: 3px;
  background: var(--line-2); z-index: 0;
}
.step:first-child::before { display: none; }
.step.s-done::before, .step.s-current::before, .step.s-failed::before { background: var(--primary); }
.step-dot {
  position: relative; z-index: 1;
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
  background: var(--card); border: 2px solid var(--line-2); color: var(--muted);
}
.step-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.s-done .step-dot { background: var(--primary); border-color: var(--primary); color: #fff; }
.s-done .step-label { color: var(--text); }
.s-current .step-dot { border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 5px var(--primary-soft); animation: pulse 1.4s infinite ease-in-out; }
.s-current .step-label { color: var(--primary); }
.s-failed .step-dot { background: var(--err); border-color: var(--err); color: #fff; }
.s-failed .step-label { color: var(--err); }

.progress-wrap { margin: 10px 0 16px; }
.progress-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.progress { height: 10px; border-radius: 999px; background: var(--wait-bg); overflow: hidden; }
.progress-bar { height: 100%; width: 0; border-radius: 999px; background: var(--primary); transition: width .5s ease; }
.progress-bar.is-active {
  background-image: linear-gradient(45deg, rgba(255,255,255,.22) 25%, transparent 25%, transparent 50%,
    rgba(255,255,255,.22) 50%, rgba(255,255,255,.22) 75%, transparent 75%, transparent);
  background-size: 22px 22px; animation: stripes 1s linear infinite;
}
@keyframes stripes { from { background-position: 0 0; } to { background-position: 22px 0; } }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 8px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; text-align: left;
  padding: 12px 14px; border-radius: 11px; cursor: pointer;
  border: 1px solid var(--line); border-left-width: 5px; background: var(--card-2);
}
.tile:hover { border-color: var(--line-2); }
.tile.is-selected { box-shadow: 0 0 0 3px var(--focus); }
.tile-num { font-size: 28px; font-weight: 750; line-height: 1.1; }
.tile-label { font-weight: 650; }
.tile-sub { font-size: 12px; color: var(--muted); }
.tile.t-completed { border-left-color: var(--ok); background: var(--card-2); color: var(--text); }
.tile.t-duplicate { border-left-color: var(--dup); background: var(--card-2); color: var(--text); }
.tile.t-unreadable { border-left-color: var(--unr); background: var(--card-2); color: var(--text); }
.tile.t-error { border-left-color: var(--err); background: var(--card-2); color: var(--text); }
.tile.t-dryrun { border-left-color: var(--dry); background: var(--card-2); color: var(--text); }
.tile.t-other { border-left-color: var(--oth); background: var(--card-2); color: var(--text); }
.tile.t-completed .tile-num { color: var(--ok); }
.tile.t-duplicate .tile-num { color: var(--dup); }
.tile.t-unreadable .tile-num { color: var(--unr); }
.tile.t-error .tile-num { color: var(--err); }
.tile.t-dryrun .tile-num { color: var(--dry); }
.tile.t-other .tile-num { color: var(--oth); }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 22px 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mini { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
thead th {
  background: var(--card-2); font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .03em; white-space: nowrap;
}
tbody tr:last-child > td { border-bottom: 0; }
td.num, th.num { text-align: right; }
thead th.wrap { white-space: normal; min-width: 96px; }
td.entry { font-weight: 800; font-size: 15px; }
td.reason { color: var(--muted); font-size: 13px; min-width: 200px; max-width: 420px; }
.empty-cell { text-align: center; color: var(--muted); padding: 22px; }

.lr-row { cursor: pointer; }
.lr-row:hover > td, tr.click:hover > td { background: var(--card-2); }
.lr-row.is-open > td { background: var(--primary-soft); border-bottom-color: transparent; }
.lr-row.flash > td { animation: flash 2s ease-out; }
@keyframes flash { from { background: var(--dup-bg); } to { background: transparent; } }
tr.click { cursor: pointer; }
.lr-detail > td { background: var(--card-2); padding: 14px 16px 18px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 22px; }
table.kv { border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: 13px; }
table.kv th { width: 34%; color: var(--muted); font-weight: 600; text-transform: none; letter-spacing: 0; font-size: 12.5px; background: none; white-space: normal; }
table.kv thead th { text-transform: uppercase; font-size: 11px; background: var(--card-2); }
table.kv td, table.kv th { padding: 6px 10px; }
table.kv td { word-break: break-word; }
table.kv td.src { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.reason-full { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); }
.photo-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.photo-list li { padding: 8px 10px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); }
.path { font-family: var(--mono); font-size: 11.5px; color: var(--muted); word-break: break-all; }
.folder-cell { font-family: var(--mono); font-size: 12px; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------------ thumbnails */
.thumbs { display: flex; flex-wrap: wrap; gap: 4px; min-width: 52px; max-width: 160px; }
.thumb {
  position: relative; width: 48px; height: 48px; padding: 0; border-radius: 7px; overflow: hidden; cursor: zoom-in;
  border: 1px solid var(--line-2); background: var(--wait-bg); flex: none;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb:hover { border-color: var(--primary); box-shadow: 0 0 0 2px var(--focus); }
.thumb-fallback {
  display: none; position: absolute; inset: 0; place-items: center; text-align: center;
  font-size: 9.5px; line-height: 1.1; color: var(--muted); padding: 2px;
}
.thumb.no-preview img { display: none; }
.thumb.no-preview .thumb-fallback { display: grid; }

.loose-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 10px; }
.loose-grid > p { grid-column: 1 / -1; margin: 0; }
.loose-card {
  display: flex; gap: 12px; padding: 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card-2); min-width: 0;
}
.loose-card .thumb { width: 84px; height: 84px; }
.loose-info { min-width: 0; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.loose-name { font-weight: 650; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loose-reason { font-size: 13px; }
.waiting-note { font-style: italic; }

/* ------------------------------------------------------------------ activity log */
.log {
  max-height: 300px; overflow-y: auto; padding: 8px 0; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card-2); font-size: 13px;
}
.log-line { display: flex; gap: 12px; padding: 3px 12px; }
.log-line:hover { background: var(--card); }
.log-time { font-family: var(--mono); font-size: 12px; color: var(--muted); flex: none; padding-top: 1px; }
.log-msg { word-break: break-word; }
.lvl-warn .log-msg { color: var(--dup); }
.lvl-error .log-msg { color: var(--err); font-weight: 600; }
.log-empty { padding: 6px 12px; }

/* ------------------------------------------------------------------ history */
.search {
  width: 100%; padding: 11px 14px; border-radius: 10px; font-size: 15px;
  border: 1px solid var(--line-2); background: var(--card); color: var(--text); margin-bottom: 10px;
}
.search:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }

/* ------------------------------------------------------------------ settings: transporter freight rules */
.rules-help { margin: 0 0 14px; padding: 12px 14px; border-radius: 10px; background: var(--card-2); border: 1px solid var(--line); font-size: 13.5px; }
.rules-help p { margin: 0; }
.rules-help p + p { margin-top: 8px; }
.readonly-note { margin: 0 0 12px; padding: 8px 12px; border-radius: 9px; background: var(--wait-bg); color: var(--wait); font-weight: 600; font-size: 13px; }
.rules-table td { vertical-align: middle; }
.rules-table .rule-name { font-weight: 700; word-break: break-word; }
.rules-table .rule-note { color: var(--muted); font-size: 13px; min-width: 140px; max-width: 280px; word-break: break-word; }
.rules-table .nowrap-wide { white-space: nowrap; font-size: 13px; }
.rule-row.is-off > td:not(:first-child):not(.rule-actions) { opacity: .55; }
.rule-btns { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.btn-icon { min-width: 34px; padding-left: 8px; padding-right: 8px; }
.btn-small.btn-danger { background: var(--card); }

/* on / off switch (a real checkbox, stretched over the drawn switch) */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; font-weight: 600; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch input:disabled { cursor: wait; }
.switch-track {
  position: relative; width: 40px; height: 22px; border-radius: 999px; flex: none;
  background: var(--line-2); transition: background .15s ease;
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s ease;
}
.switch input:checked + .switch-track { background: var(--ok); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch-text { color: var(--muted); min-width: 22px; }

.rule-form {
  margin-top: 16px; padding: 16px 18px; border-radius: 11px;
  border: 1px solid var(--primary); background: var(--card-2); box-shadow: 0 0 0 3px var(--primary-soft);
}
.rule-form h3 { margin-bottom: 12px; word-break: break-word; }
.text-input {
  width: 100%; max-width: 560px; padding: 10px 12px; border-radius: 9px; font: inherit;
  border: 1px solid var(--line-2); background: var(--card); color: var(--text);
}
.text-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
.field-help { margin: 6px 0 14px; color: var(--muted); font-size: 12.5px; }
.radio-group { border: 0; margin: 0 0 14px; padding: 0; min-width: 0; }
.radio-group legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.radio-row {
  display: flex; align-items: flex-start; gap: 10px; max-width: 560px; cursor: pointer;
  padding: 8px 12px; margin-bottom: 6px; border-radius: 9px; border: 1px solid var(--line); background: var(--card);
}
.radio-row:hover { border-color: var(--primary); }
.radio-row:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.radio-row input { width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--primary); flex: none; }
.rule-form .check-row { margin: 14px 0; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* a value decided by a transporter rule (LR table and LR details) */
.tag.t-rule { background: var(--busy-bg); color: var(--busy); font-size: 11px; padding: 0 6px; vertical-align: 1px; }
table.kv td.src-rule { color: var(--text); background: var(--busy-bg); }

/* ------------------------------------------------------------------ folder browser modal */
.modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px;
  background: rgba(10, 16, 30, .55);
}
.modal-box {
  width: min(980px, 100%); height: min(680px, 100%); display: flex; flex-direction: column;
  background: var(--card); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); overflow: hidden;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 12px 20px; border-bottom: 1px solid var(--line); }
.browser { flex: 1; min-height: 0; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.places { border-right: 1px solid var(--line); background: var(--card-2); overflow-y: auto; padding: 10px 8px; }
.places-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 10px 4px; }
.place, .dir {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 0; background: none; cursor: pointer; border-radius: 8px; padding: 7px 10px;
}
.place:hover, .dir:hover { background: var(--primary-soft); }
.place-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-sub { margin-left: auto; font-size: 11px; color: var(--muted); white-space: nowrap; }
.ico { width: 20px; height: 20px; flex: none; color: #e0a526; }
.ico svg { width: 20px; height: 20px; fill: currentColor; display: block; }
.dir-up .ico { color: var(--muted); }
.browser-main { display: flex; flex-direction: column; min-height: 0; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.crumb { border: 0; background: none; cursor: pointer; padding: 3px 7px; border-radius: 6px; font-weight: 600; color: var(--primary); }
.crumb:hover { background: var(--primary-soft); }
.crumb:last-child { color: var(--text); }
.crumb-sep { color: var(--muted); }
.dir-list { flex: 1; overflow-y: auto; padding: 8px; }
.dir { padding: 9px 12px; }
.dir-name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dir-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dir .count { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; padding-left: 12px; }
.dir .count.has { color: var(--ok); font-weight: 700; }
.dir.is-dim { opacity: .55; }
.dir-empty { padding: 18px 12px; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--card-2); }
.sel-info { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13px; }
.sel-info .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------------ lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: rgba(5, 8, 15, .92); padding: 16px;
}
.lb-figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: calc(100vw - 150px); }
.lb-figure img { max-width: 100%; max-height: calc(100vh - 150px); object-fit: contain; border-radius: 6px; background: #222; }
.lb-figure figcaption { color: #dfe4ee; text-align: center; font-size: 13px; }
.lb-figure figcaption .path { color: #9aa4b8; }
.lb-figure figcaption a { color: #9cb8ff; }
.lb-ctx { color: #b8c0cf; }
.lb-count { margin-left: 10px; color: #9aa4b8; font-family: var(--mono); }
.lb-error { color: #ffd2d2; padding: 40px; max-width: 520px; text-align: center; }
.lb-btn {
  border: 0; cursor: pointer; color: #fff; background: rgba(255, 255, 255, .12);
  width: 52px; height: 52px; border-radius: 50%; font-size: 34px; line-height: 1; flex: none;
}
.lb-btn:hover { background: rgba(255, 255, 255, .25); }
.lb-btn:disabled { opacity: .2; cursor: default; }
.lb-close { position: absolute; top: 14px; right: 16px; width: 44px; height: 44px; font-size: 28px; }

/* ------------------------------------------------------------------ toast */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 80; max-width: 440px;
  padding: 12px 16px; border-radius: 10px; color: #fff; background: #26324a;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3); font-weight: 600;
}
.toast-ok { background: #137a3a; }
.toast-bad { background: #b4232e; }
.toast-warn { background: #9a5b00; }

/* ------------------------------------------------------------------ smaller screens (laptops) */
@media (max-width: 1100px) {
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .topbar-inner, .wrap { padding-left: 14px; padding-right: 14px; }
  .topbar-inner { padding-top: 10px; padding-bottom: 10px; }
  .top-right { justify-content: flex-start; }
  .browser { grid-template-columns: 1fr; }
  .places { display: none; }
  .folder-row { flex-wrap: wrap; }
  .btn-big { width: 100%; min-width: 0; }
  .lb-figure { max-width: calc(100vw - 32px); }
  .lb-prev, .lb-next { position: absolute; bottom: 16px; }
  .lb-prev { left: 16px; }
  .lb-next { right: 16px; }
  .toast { left: 14px; right: 14px; bottom: 14px; max-width: none; }
  .lightbox:not([hidden]) ~ .toast { display: none; }   /* it would cover the photo's prev / next buttons */
  /* the LR table scrolls sideways; an opened row's details stay in view at the screen's width */
  #run-body .table-wrap { container-type: inline-size; }
  .lr-detail > td { padding: 0; }
  .lr-detail .detail-grid { position: sticky; left: 0; width: 100cqw; padding: 12px; }
  /* the rules table: one card per rule, each value with its column name */
  .rules-wrap { overflow-x: visible; border: 0; }
  .rules-table thead { display: none; }
  .rules-table, .rules-table tbody, .rules-table tr, .rules-table td { display: block; width: 100%; }
  .rules-table tr.rule-row { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; padding: 6px 0; background: var(--card); }
  .rules-table td { border: 0; padding: 5px 12px; display: flex; gap: 10px; align-items: baseline; }
  .rules-table td[data-label]::before {
    content: attr(data-label); flex: 0 0 38%; min-width: 0; color: var(--muted);
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  }
  .rules-table td[data-label] > * { flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; }
  .rules-table td[data-label] > .switch, .rules-table td[data-label] > .badge { flex: 0 0 auto; }
  .rules-table .rule-note, .rules-table .nowrap-wide { max-width: none; white-space: normal; }
  .rules-table td.empty-cell { display: block; border: 1px dashed var(--line-2); border-radius: 10px; }
  .rules-table td.rule-actions { padding-top: 8px; border-top: 1px solid var(--line); margin-top: 4px; }
  .rule-btns { justify-content: flex-start; }
  .rule-form { padding: 14px 12px; }
}
/* phones (375 px): nothing may be wider than the screen */
@media (max-width: 480px) {
  .card { padding: 16px 14px; border-radius: 11px; }
  .brand h1 { font-size: 17px; }
  .logo { width: 38px; height: 38px; }
  .tabs { overflow-x: auto; }
  .tab { padding: 10px 12px; white-space: nowrap; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-num { font-size: 24px; }
  .run-actions { width: 100%; }
  .stepper .step-label { font-size: 11px; }
  .user-name { max-width: 150px; }
  .pill { white-space: normal; }
  td.reason { min-width: 160px; }
  .loose-card .thumb { width: 64px; height: 64px; }
}
