@font-face {
  font-family: "Archivo";
  src: url("/static/fonts/archivo-latin-wdth-normal.woff2") format("woff2-variations"),
       url("/static/fonts/archivo-latin-wdth-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  color-scheme: light;
  --steel: #e4e7ea;          /* drum steel: the page ground */
  --steel-deep: #cfd4d9;
  --label: #ffffff;          /* label stock */
  --ink: #141518;
  --ink-2: #464b53;          /* secondary text on label stock, 8.6:1 */
  --muted: #646a73;          /* tertiary, 5.3:1 on white */
  --hair: #d5d9de;
  --red: #c8141b;            /* GHS red: approval + anything that leaves */
  --red-deep: #a30f15;
  --red-tint: #fbe8e8;
  --orange: #f28c0f;         /* ADR orange plate */
  --orange-tint: #fff0da;
  --frame: 2px solid var(--ink);
  --gap: 16px;
  --font: "Archivo", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--steel); scrollbar-color: var(--ink-2) var(--steel); }
body {
  margin: 0; background: var(--steel); color: var(--ink);
  font: 420 14px/1.45 var(--font); font-stretch: 100%;
  font-variant-numeric: tabular-nums; caret-color: var(--red);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--orange); color: var(--ink); }
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--steel-deep);
    text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
a:hover { text-decoration-color: var(--orange); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; box-shadow: 0 0 0 5px var(--orange); }
h1, h2, h3 { margin: 0; font-stretch: 78%; letter-spacing: -0.01em; }
h1 { font-size: 30px; font-weight: 760; line-height: 1.1; }
h2 { font-size: 17px; font-weight: 760; text-transform: uppercase; letter-spacing: 0.02em; }
.num { text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* ---------- shell ---------- */
.top { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 10; }
.top-in { max-width: 1360px; margin: 0 auto; padding: 0 24px; height: 54px; display: flex; align-items: center; gap: 28px; }
.mark { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none;
        font-stretch: 72%; font-weight: 800; font-size: 19px; text-transform: uppercase; letter-spacing: 0.03em; }
.mark svg { flex: none; }
.nav { display: flex; gap: 2px; height: 100%; }
.nav a { display: flex; align-items: center; padding: 0 12px; color: #c9ccd1; text-decoration: none;
         font-weight: 560; border-bottom: 3px solid transparent; padding-top: 3px; }
.nav a:hover { color: #fff; }
.nav a.on { color: #fff; border-bottom-color: var(--orange); }
.top .sp { flex: 1; }
.top .out { color: #c9ccd1; font-size: 13px; text-decoration: none; }
.top .out:hover { color: #fff; }
main { max-width: 1360px; margin: 0 auto; padding: 28px 24px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 6px 0 0; color: var(--ink-2); }
section { margin-top: 34px; }
section > .sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }

/* ---------- label panel (the signature) ---------- */
.label { background: var(--label); border: var(--frame); display: grid;
         grid-template-columns: auto 1fr auto; gap: 0; }
.label > * { padding: 18px 22px; }
.label .pict { display: flex; align-items: center; border-right: 1.5px solid var(--ink); padding: 18px 26px; }
.label .body { display: flex; flex-direction: column; justify-content: center; gap: 8px; min-width: 0; }
.signal { font-stretch: 66%; font-weight: 860; font-size: 38px; line-height: 0.95; text-transform: uppercase;
          letter-spacing: 0.005em; margin: 0; }
.signal.s-approve { color: var(--red); }
.statements { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 4px 22px; color: var(--ink-2); }
.statements b { color: var(--ink); font-weight: 700; }
.label .side { display: flex; align-items: center; border-left: 1.5px solid var(--hair); }

/* GHS pictogram: red-framed diamond (red only when it needs Ritam), black symbol */
.diamond { width: 76px; height: 76px; position: relative; flex: none; display: inline-block; vertical-align: middle; }
.diamond::before { content: ""; position: absolute; inset: 11px; background: #fff; border: 5px solid var(--ink);
                   transform: rotate(45deg); }
.diamond.red::before { border-color: var(--red); }
.diamond svg { position: absolute; inset: 0; margin: auto; width: 30px; height: 30px; }
.diamond.sm { width: 34px; height: 34px; }
.diamond.sm::before { inset: 5px; border-width: 2.5px; }
.diamond.sm svg { width: 14px; height: 14px; }

/* ADR orange plate: reference over best landed price */
.plate { background: var(--orange); border: 3px solid var(--ink); min-width: 168px; text-align: center;
         font-stretch: 74%; font-weight: 800; color: var(--ink); text-decoration: none; display: block; }
.plate .p-top, .plate .p-bot { padding: 6px 14px; }
.plate .p-top { font-size: 22px; letter-spacing: 0.04em; border-bottom: 3px solid var(--ink); }
.plate .p-bot { font-size: 22px; }
.plate .p-bot small { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 1px; }
.plate .p-bot .none { font-size: 15px; font-weight: 650; }
.plate .p-bot .also-sm { font-size: 9px; margin-left: 2px; }
.plate .p-bot small.also { margin: 3px 0 0; font-size: 10.5px; letter-spacing: 0.03em; }
.plate.sm { min-width: 0; border-width: 2px; display: inline-block; }
.plate.sm .p-top { font-size: 12px; padding: 1px 8px; border-bottom-width: 2px; }
.plate.sm .p-bot { font-size: 13px; padding: 1px 8px; }

/* ---------- tables ---------- */
.sheet { border: var(--frame); overflow-x: auto;
  background:
    linear-gradient(to right, var(--label) 30%, rgba(255,255,255,0)) left / 28px 100% no-repeat local,
    linear-gradient(to left, var(--label) 30%, rgba(255,255,255,0)) right / 28px 100% no-repeat local,
    linear-gradient(to right, rgba(20,21,24,.18), rgba(20,21,24,0)) left / 12px 100% no-repeat scroll,
    linear-gradient(to left, rgba(20,21,24,.18), rgba(20,21,24,0)) right / 12px 100% no-repeat scroll,
    var(--label); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-stretch: 82%; font-size: 11.5px; font-weight: 720; text-transform: uppercase;
     letter-spacing: 0.05em; color: var(--ink); padding: 9px 12px; border-bottom: 2px solid var(--ink);
     white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--hair); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfb; }
td .sub { display: block; font-size: 12.5px; color: var(--muted); margin-top: 1px; }
th.num, td.num { text-align: right; }
.price { font-weight: 640; }
.landed { font-weight: 800; font-size: 15px; }
.unit { color: var(--muted); font-weight: 450; }
tr.best td { background: var(--orange-tint); }
tr.faded td { color: var(--muted); }
tr.faded td .co { text-decoration: line-through; text-decoration-color: var(--muted); }
.empty { padding: 26px 16px; text-align: center; color: var(--ink-2); }
.empty b { display: block; color: var(--ink); font-stretch: 80%; font-size: 15px; margin-bottom: 4px; }

/* ---------- status tags: square, label-printed ---------- */
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px 1px; border: 1.5px solid var(--ink-2);
       color: var(--ink-2); font-stretch: 80%; font-size: 11.5px; font-weight: 720; text-transform: uppercase;
       letter-spacing: 0.04em; white-space: nowrap; line-height: 1.35; background: var(--label); }
.t-drafted { border-color: var(--red); color: var(--red); }
.t-approved { border-color: var(--red); background: var(--red); color: #fff; }
.t-inquiry_sent, .t-followed_up, .t-sent { border-color: var(--ink); color: var(--ink); }
.t-replied, .t-reading { border-color: var(--ink); background: var(--orange-tint); color: var(--ink); }
.t-quoted, .t-best { border-color: var(--ink); background: var(--orange); color: var(--ink); }
.t-won { border-color: var(--ink); background: var(--ink); color: #fff; }
.t-lost, .t-skipped, .t-no_reply, .t-failed { border-color: var(--hair); color: var(--muted); text-decoration: line-through; }
.t-lead, .t-received, .t-local, .t-unmatched { border-color: var(--hair); color: var(--ink-2); }
.t-unmatched { border-style: dashed; }

/* ---------- controls ---------- */
button, .btn { font: inherit; font-weight: 640; font-stretch: 92%; display: inline-flex; align-items: center; gap: 7px;
               padding: 7px 14px; border: 2px solid var(--ink); background: var(--label); color: var(--ink);
               border-radius: 2px; cursor: pointer; text-decoration: none; line-height: 1.2;
               transition: background-color .15s cubic-bezier(.16,1,.3,1), color .15s cubic-bezier(.16,1,.3,1); }
button:hover, .btn:hover { background: var(--ink); color: #fff; }
button.send { background: var(--red); border-color: var(--red); color: #fff; font-weight: 760; text-transform: uppercase;
              letter-spacing: 0.03em; font-stretch: 80%; padding: 9px 18px; }
button.send:hover { background: var(--red-deep); border-color: var(--red-deep); }
button.quiet { border-color: transparent; background: none; color: var(--ink-2); padding: 4px 6px; text-decoration: underline;
               text-underline-offset: 3px; }
button.quiet:hover { background: none; color: var(--ink); }
button.quiet.danger { color: var(--red); }
button.sm, .btn.sm { padding: 3px 9px; font-size: 12.5px; border-width: 1.5px; }
button:disabled { opacity: .45; cursor: not-allowed; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--label); border: 1.5px solid var(--ink-2);
                          border-radius: 2px; padding: 7px 9px; max-width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px var(--orange); }
select.sm { padding: 3px 6px; font-size: 12.5px; }
textarea { width: 100%; min-height: 200px; line-height: 1.5; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 650; color: var(--ink-2);
          text-transform: uppercase; letter-spacing: 0.04em; font-stretch: 85%; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
form.inline { display: inline; }
.toggle-state { font-weight: 800; }

/* ---------- approval block ---------- */
.approval { background: var(--label); border: 2px solid var(--red); }
.approval-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 18px; background: var(--red-tint);
                border-bottom: 1.5px solid var(--red); }
.approval-bar p { margin: 0; color: var(--ink-2); flex: 1; min-width: 240px; }
.draft { border-bottom: 1px solid var(--hair); }
.draft:last-child { border-bottom: 0; }
.draft summary { display: flex; align-items: center; gap: 12px; padding: 11px 18px; cursor: pointer; list-style: none; }
.draft summary::-webkit-details-marker { display: none; }
.draft summary .chev { transition: transform .2s cubic-bezier(.16,1,.3,1); color: var(--muted); }
.draft[open] summary .chev { transform: rotate(90deg); }
.draft summary input { width: 16px; height: 16px; accent-color: var(--red); }
.draft .ed { padding: 4px 18px 16px 46px; display: grid; gap: 10px; }
.draft .ed .row > label.f { flex: 1; min-width: 220px; }

/* ---------- misc blocks ---------- */
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
.two > * { min-width: 0; }
.card { background: var(--label); border: var(--frame); padding: 18px 20px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 7px 18px; margin: 0; }
dl.kv dt { font-stretch: 85%; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-2); padding-top: 1px; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
pre.mail { white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.6 var(--font); max-width: 78ch; margin: 0; }
.filters { display: flex; gap: 0; border: var(--frame); background: var(--label); }
.filters a { padding: 6px 13px; text-decoration: none; font-weight: 600; border-right: 1.5px solid var(--ink); }
.filters a:last-child { border-right: 0; }
.filters a.on { background: var(--ink); color: #fff; }
.search { display: flex; }
.search input { border: var(--frame); border-right: 0; min-width: 260px; }
.search button { border-radius: 0; }
td .sub.m-only, td .m-only, .m-only { display: none; }
.stars { color: var(--orange); letter-spacing: 1px; }
.attach { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border: 1.5px solid var(--ink); text-decoration: none; margin: 0 6px 6px 0; }
.attach:hover { background: var(--orange-tint); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .label { grid-template-columns: auto 1fr; width: min(520px, 100%); }
.login form { display: grid; gap: 10px; }
.err { color: var(--red); font-weight: 650; margin: 0; }

/* the one authored moment: the label settles in like it was just applied to the drum */
@media (prefers-reduced-motion: no-preference) {
  .label.apply { animation: apply .55s cubic-bezier(.16,1,.3,1) both; }
  .label.apply .diamond::before { animation: stamp .5s .12s cubic-bezier(.16,1,.3,1) both; }
}
@keyframes apply { from { transform: translateY(6px); box-shadow: 0 14px 28px -12px rgba(20,21,24,.35); }
                   to { transform: none; box-shadow: 0 2px 6px -4px rgba(20,21,24,.25); } }
@keyframes stamp { from { transform: rotate(45deg) scale(.82); } to { transform: rotate(45deg) scale(1); } }

@media (max-width: 900px) {
  .label { grid-template-columns: auto 1fr; }
  .label .side { grid-column: 1 / -1; border-left: 0; border-top: 1.5px solid var(--hair); }
  .two { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .top { position: static; }
  .top-in { height: auto; flex-wrap: wrap; gap: 6px 14px; padding: 10px 16px 0; }
  .nav { width: 100%; overflow-x: auto; order: 3; }
  .nav a { padding: 10px 10px 8px; }
  main { padding: 20px 16px 60px; }
  h1 { font-size: 24px; }
  .label { grid-template-columns: 1fr; }
  .label .pict { border-right: 0; border-bottom: 1.5px solid var(--ink); padding: 12px 16px; gap: 12px; }
  .label > * { padding: 14px 16px; }
  .signal { font-size: 28px; }
  .diamond { width: 56px; height: 56px; }
  .diamond::before { inset: 8px; border-width: 4px; }
  .diamond svg { width: 22px; height: 22px; }
  .search input { min-width: 0; flex: 1; }
  .sheet table { min-width: 760px; }
  .two .sheet table, .sheet table.fit-m { min-width: 0; }
  .m-hide { display: none; }
  td .sub.m-only, td .m-only, .m-only { display: block; margin-top: 4px; }
  .draft .ed { padding-left: 18px; }
}

/* ---------- CRM: product chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border: 1.5px solid var(--ink); background: var(--label);
        font-size: 12.5px; font-weight: 600; color: var(--ink); text-decoration: none; white-space: nowrap; }
.chip.src-quoted { background: var(--orange); }
.chip.src-search { border-style: dashed; border-color: var(--ink-2); color: var(--ink-2); font-weight: 500; }
.chip form { display: inline; }
.chip button { border: 0; background: none; padding: 0 0 0 2px; color: inherit; font-size: 14px; line-height: 1; }
.chip button:hover { background: none; color: var(--red); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--ink-2); }
.inline-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-add input { min-width: 0; }
details.add > summary { cursor: pointer; list-style: none; display: inline-flex; }
details.add > summary::-webkit-details-marker { display: none; }
details.add[open] > summary { margin-bottom: 12px; }
.notice { background: var(--orange-tint); border: 1.5px solid var(--ink); padding: 10px 14px; margin-bottom: 16px; }
