body { background: #fff; font-size: 16px; }
.container { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.loading { min-height: 60vh; }

.bad { color: var(--danger); }
.warn { color: #D4501F; }
.good { color: var(--gs1-blue); }
a { color: var(--gs1-link); }

/* ---------- Status bands (only when something is wrong) ---------- */
.preview-bar { background: #FEEFEA; color: #B23E12; text-align: center; font-size: 14px; padding: 6px 16px; }
.band { color: #fff; padding: 10px 0; }
.band.bad { background: var(--danger); }
.band.warn { background: var(--gs1-orange); }

/* ---------- Barcode showcase (GS1 palette + pastel anatomy) ---------- */
:root {
  --blue: #002C6C; --orange: #F26334; --black: #111111;
  --hair: rgba(0, 44, 108, .14);   /* blue hairline */
  --soft: rgba(17, 17, 17, .55);   /* secondary text: black at reduced strength */
}
.carriers {
  border-bottom: 1px solid var(--hair);
  background: linear-gradient(120deg, #F6F8FF 0%, #FFF7F3 30%, #F7F4FF 60%, #F2FAF7 85%, #F6F8FF 100%);
  background-size: 300% 300%; animation: drift 24s ease-in-out infinite;
}
@keyframes drift { 50% { background-position: 100% 50%; } }
.car-wrap { max-width: 1120px; margin: 0 auto; padding: 18px 24px 20px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--soft); }

/* standalone page head: home | title | view switch on one line */
.car-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; margin-bottom: 14px; }
.car-head .home-btn { justify-self: start; }
.car-title { text-align: center; min-width: 0; }
.car-title .eyebrow { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 620px; margin: 0 auto; }
.car-head h1 { font-size: clamp(24px, 3vw, 30px); margin-top: 2px; color: var(--blue); }
.car-head .viewsw { justify-self: end; }

.tiles { display: flex; justify-content: center; gap: 40px; margin-bottom: 6px; }
.car-code { margin: 0; text-align: center; }
.code-tile { width: 160px; height: 160px; display: grid; place-items: center; background: #fff; border: 1px solid var(--hair); border-radius: 12px;
  box-shadow: 0 6px 22px -14px rgba(0, 44, 108, .35); animation: rise .5s ease both; }
.code-tile img { width: 132px; height: 132px; image-rendering: pixelated; }
.car-code.dm .code-tile img { width: 112px; height: 112px; }
.car-code figcaption { margin-top: 6px; font-weight: 700; font-size: 15px; color: var(--blue); }
.car-code.oned .code-tile { width: auto; min-width: 160px; height: auto; padding: 12px 16px; }
.car-code.oned .code-tile img { width: auto; height: 110px; max-width: 100%; }

.t-ai { color: var(--blue); font-weight: 700; }
.gs { display: inline-block; font: 700 9.5px var(--font-data); color: #fff; background: var(--orange); border-radius: 3px; padding: 1px 4px; margin: 0 2px; vertical-align: 1px; }

/* scan result: code tile beside the summary */
.sum { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 22px; align-items: center; }
.sum-t h1 { font-size: clamp(24px, 3vw, 30px); color: var(--blue); margin: 2px 0 0; line-height: 1.15; }
.sum-sub { margin: 4px 0 0; font-size: 14px; color: var(--soft); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: #fff; border: 1px solid var(--hair); color: var(--blue); animation: rise .4s ease both; }
.p-ok { background: #E6F6EC; border-color: #BFE5CD; color: #17663A; }
.p-info { background: #EAF0FF; border-color: #C9D7FA; color: #1E3A8A; }
.p-warn { background: #FFF1DC; border-color: #F6D9AA; color: #9A5B00; }
.p-bad { background: #FDE7E7; border-color: #F5C2C2; color: #B42318; }
.nf { margin: 10px 0 0; font-size: 13.5px; color: #1E3A8A; background: #EEF3FF; border-radius: 8px; padding: 7px 12px; }
.notes { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.notes li { position: relative; padding: 7px 12px 7px 30px; border-radius: 8px; font-size: 13.5px; color: var(--black); background: #FFF3EC; }
.notes li::before { content: "!"; position: absolute; left: 10px; top: 8px; width: 14px; height: 14px; border-radius: 50%; background: var(--orange); color: #fff; font: 700 10px/14px var(--font-data); text-align: center; }

/* ---------- Anatomy: string row, elbow connectors, cards ---------- */
.k-domain   { --c: #ECEBFF; --i: #4338A8; }
.k-prefix   { --c: #EEF1F5; --i: #556070; }
.k-key      { --c: #E1ECFF; --i: #0B3D91; }
.k-batch    { --c: #DFF5E8; --i: #17663A; }
.k-serial   { --c: #FFEFD6; --i: #94560A; }
.k-date     { --c: #FCE6F0; --i: #A3245E; }
.k-price    { --c: #DAF4F0; --i: #0F6B61; }
.k-sym      { --c: #FFE6DC; --i: #B23E12; }
.k-measure  { --c: #EEF6D9; --i: #4D6B12; }
.k-location { --c: #E2F2FA; --i: #0E5E86; }
.k-variant  { --c: #F1E6FD; --i: #6B2FA6; }
.k-check    { --c: #DFF5E8; --i: #17663A; }
.k-other    { --c: #EEF1F5; --i: #454F5E; }

.anat { margin-top: 18px; }
.anat + .meta-row { margin-top: 12px; }
.meta-row + .anat { margin-top: 22px; }
.anat-h { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.anat-h span { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--blue); }
.anat-h small { font-size: 12px; color: var(--soft); }
.anat-stage { position: relative; }
.anat-lines { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 0; }
.anat-stage > :not(svg) { position: relative; z-index: 1; }

.anat-str { background: #fff; border: 1px solid var(--hair); border-radius: 10px; padding: 8px 12px; text-align: center; }
.anat-str code { font-family: var(--font-data); font-size: 12.5px; line-height: 2.1; word-break: break-all; color: var(--black); }
.seg { background: var(--c); color: var(--i); border-radius: 5px; padding: 3px 4px; margin: 0 1px; cursor: default;
  transition: filter .2s, box-shadow .2s; animation: pop .7s ease both; animation-delay: calc(var(--d) * 110ms); }
.seg .sa { font-weight: 700; }
.seg .sp { opacity: .55; }
.sx { color: var(--soft); }
.seg-gs { display: inline-block; font: 700 9.5px var(--font-data); color: #fff; background: var(--orange); border-radius: 3px; padding: 1px 4px; margin: 0 2px; vertical-align: 1px; }
.seg.on { box-shadow: 0 0 0 1.5px var(--i); }

.anat-cards { list-style: none; margin: 46px 0 0; padding: 0; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 190px)); justify-content: center; gap: 12px; }
.ac { background: #fff; border: 1px solid var(--hair); border-radius: 12px; padding: 10px 12px 11px; min-width: 0;
  transition: filter .2s, border-color .2s, box-shadow .2s, translate .2s; animation: rise .8s ease both; animation-delay: calc(var(--d) * 130ms + 650ms); }
.ac-top { display: flex; align-items: center; gap: 8px; }
.ac-ic { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: var(--i); }
.ac-tag { font: 700 11px var(--font-data); color: var(--i); line-height: 1.25; }
.ac-n { display: none; margin-left: auto; font: 700 11px var(--font-data); color: var(--i); }
.ac-v { margin-top: 8px; font: 700 12.5px var(--font-data); color: var(--black); word-break: break-all; }
.ac-hv { font-size: 12px; color: var(--i); margin-top: 1px; }
.ac-t { display: block; margin-top: 6px; font-size: 14px; font-weight: 600; color: var(--black); line-height: 1.25; }
.ac.on { border-color: var(--i); box-shadow: 0 8px 22px -14px var(--i); translate: 0 -2px; }
.anat.wrapped .anat-lines { display: none; }
.anat.wrapped .anat-cards { margin-top: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.anat.wrapped .ac-n { display: inline; }
.anat.wrapped .seg::after { content: attr(data-n); font: 700 9px var(--font-data); vertical-align: super; margin-left: 1px; }
.anat[data-hl] .seg:not(.on), .anat[data-hl] .ac:not(.on) { filter: opacity(.45) saturate(.6); }

.al path { fill: none; stroke: var(--i); stroke-width: 2.4; stroke-linecap: round; opacity: .6; transition: opacity .25s, stroke-width .25s; }
.al circle { fill: var(--i); opacity: .75; }
.anat-lines.anim .al path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.1s ease forwards; animation-delay: calc(var(--d) * 130ms + 250ms); }
.anat-lines.anim .al circle { animation: rise .5s ease both; animation-delay: calc(var(--d) * 130ms + 250ms); }
.anat[data-hl] .al:not(.on) path { opacity: .15; }
.al.on path { opacity: 1; stroke-width: 3.2; }

.meta-row { margin: 10px 0 0; font-size: 13.5px; color: var(--soft); line-height: 1.6; word-break: break-word; }
.meta-k { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--blue); margin-right: 8px; }
.meta-row b { color: var(--black); font-weight: 600; }
.meta-row code { font-family: var(--font-data); font-size: 12.5px; color: var(--black); background: #fff; border: 1px solid var(--hair); border-radius: 5px; padding: 0 5px; }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes pop { from { opacity: 0; transform: scale(.94); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
  .carriers, .code-tile, .pill, .seg, .ac, .anat-lines.anim .al path, .anat-lines.anim .al circle { animation: none !important; }
  .anat-lines.anim .al path { stroke-dasharray: none; }
}

/* View switch */
.viewsw { display: inline-flex; border: 1px solid var(--hair); border-radius: 999px; padding: 3px; background: #fff; }
.viewsw button { border: 0; background: none; padding: 7px 16px; border-radius: 999px; font: inherit; font-size: 14px; color: var(--blue); cursor: pointer; white-space: nowrap; transition: background .2s, color .2s; }
.viewsw button[aria-pressed="true"] { background: var(--blue); color: #fff; font-weight: 600; }
.viewsw button:focus-visible { outline: 2px solid var(--orange); outline-offset: 1px; }

/* Home button: back to the scanning station */
.home-btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
  border: 1px solid var(--hair); border-radius: 999px; color: var(--blue); text-decoration: none; font-size: 14px; font-weight: 600; background: #fff; }
.home-btn:hover { border-color: var(--blue); }
.home-btn:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

@media (max-width: 860px) {
  .car-head { grid-template-columns: 1fr auto; }
  .car-title { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 640px) {
  .car-wrap { padding: 14px 14px 18px; }
  .sum { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: 12px; }
  .pills { justify-content: center; }
  .sum .nf, .sum .notes { text-align: left; }
  .tiles { gap: 16px; }
  .code-tile { width: 132px; height: 132px; }
  .code-tile img { width: 110px; height: 110px; }
  .car-code.dm .code-tile img { width: 94px; height: 94px; }
  .car-code figcaption { font-size: 13px; }
  /* phones: no connectors; chips and cards share colour and number */
  .anat-lines { display: none; }
  .anat-cards, .anat.wrapped .anat-cards { margin-top: 12px; grid-template-columns: 1fr 1fr; }
  .ac-n { display: inline; }
  .seg::after { content: attr(data-n); font: 700 9px var(--font-data); vertical-align: super; margin-left: 1px; }
  .viewsw button { padding: 7px 12px; }
}
@media (max-width: 400px) { .anat-cards { grid-template-columns: 1fr; } }

/* ---------- Tabs ---------- */
.tabs-wrap { position: sticky; top: 0; z-index: 30; background: #fff; border-bottom: 1px solid var(--line); }
.tabs { display: flex; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; padding: 12px 16px 10px; border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer; color: var(--muted); font: inherit; white-space: nowrap; transition: color .2s, border-color .2s; }
.tab:hover { color: var(--ink); }
.tab[aria-selected=true] { color: var(--gs1-blue); border-bottom-color: var(--gs1-blue); font-weight: 600; }
.tab .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); margin-left: 6px; vertical-align: middle; }

/* ---------- Tables ---------- */
.panel { padding: 8px 0 20px; }
.panel:not([hidden]) { animation: rise .3s ease both; }
.panel[hidden] { display: none; }
table { width: 100%; border-collapse: collapse; }
.kv th, .kv td, .grid th, .grid td { text-align: left; vertical-align: top; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line-2); font-size: 16px; line-height: 1.45; }
.kv th { width: 36%; font-weight: 400; color: var(--muted); }
.kv td { color: var(--ink); word-break: break-word; }
.sub { font-size: 16px; font-weight: 600; color: var(--ink); margin: 16px 0 4px; }
.grid thead th { font-weight: 400; color: var(--muted); }
.grid td:first-child, .grid th:first-child { width: 32px; color: var(--muted); }
.map { height: 340px; margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; z-index: 0; }
.map .leaflet-tile-pane { filter: grayscale(1) contrast(.9) brightness(1.05); }
.trace-seg { padding-bottom: 16px; border-top: 1px solid var(--line); }
.muted { color: var(--muted); margin: 4px 0 0; }

.foot { font-size: 13px; color: var(--muted); padding-top: 4px; padding-bottom: 24px; }

@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .tab { padding: 12px 12px 10px; font-size: 15px; }
  .kv th, .kv td { display: block; width: auto; padding: 0; border: 0; }
  .kv th { padding-top: 10px; font-size: 14px; }
  .kv td { padding: 2px 0 10px; border-bottom: 1px solid var(--line-2); }
  .grid { display: block; overflow-x: auto; }
  .grid th, .grid td { font-size: 14px; white-space: nowrap; }
  .map { height: 280px; }
}

/* ---------- Traceability: GS1 EPCIS events ---------- */
.tr-h { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; margin: 16px 0 4px; }
.tr-h .sub { margin: 0; }
.tr-meta { font-size: 13px; color: var(--muted); }
.trace-t small { font-size: 13px; color: var(--muted); }
.trace-t tr.this td { background: #F4F8FF; }
.tag-this { display: inline-block; font-size: 11px; font-weight: 700; color: var(--gs1-blue); background: #E1ECFF; border-radius: 999px; padding: 1px 7px; vertical-align: 1px; }
