/* PO tracker — one stylesheet, mobile first.
   Tokens: cool neutral surfaces, one teal-blue accent, status colours only where they mean something. */
:root {
  --bg: #F3F5F7;
  --surface: #FFFFFF;
  --ink: #17212B;
  --muted: #5D6976;
  --faint: #8A95A1;
  --line: #E1E5EA;
  --accent: #0F6E8C;
  --accent-ink: #0B5A73;
  --accent-soft: #E5F1F4;
  --red: #B9332C;      --red-soft: #FCEBEA;
  --amber: #9A5B06;    --amber-soft: #FDF1DC;
  --green: #1D7447;    --green-soft: #E6F4EC;
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg);
       font-feature-settings: "tnum" 1; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
h1 { font-size: 22px; line-height: 1.25; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 16px; font-weight: 650; margin: 28px 0 10px; }
p { margin: 0 0 12px; }
small, .muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- App frame ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1180px; margin: 0 auto; height: 56px; padding: 0 16px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); font-size: 16px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 7px; }
.nav-desktop { display: none; gap: 2px; flex: 1; }
.nav-desktop a { color: var(--muted); padding: 7px 12px; border-radius: var(--radius-sm); font-weight: 550; font-size: 14.5px; }
.nav-desktop a:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.nav-desktop a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }
.user-menu { display: none; align-items: center; gap: 12px; margin-left: auto; color: var(--muted); font-size: 14px; }

main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 104px; }

/* Bottom tab bar (phones) */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface);
          border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr);
          padding-bottom: env(safe-area-inset-bottom); }
.tabbar a, .tabbar summary { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 7px;
          color: var(--faint); font-size: 11.5px; font-weight: 600; cursor: pointer; list-style: none; }
.tabbar summary::-webkit-details-marker { display: none; }
.tabbar a:hover { text-decoration: none; }
.tabbar a[aria-current="page"], .tabbar details[open] summary { color: var(--accent); }
.tabbar svg { width: 22px; height: 22px; }
.more { position: relative; }
.more-menu { position: absolute; right: 8px; bottom: calc(100% + 8px); min-width: 220px; background: var(--surface);
             border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(23,33,43,.14);
             padding: 6px; }
.more-menu a, .more-menu button { display: block; width: 100%; text-align: left; padding: 11px 12px; border-radius: var(--radius-sm);
             font-size: 15px; color: var(--ink); background: none; border: 0; font-weight: 500; min-height: 0; }
.more-menu a:hover, .more-menu button:hover { background: var(--bg); text-decoration: none; }
.more-menu .who { padding: 8px 12px 6px; color: var(--muted); font-size: 13px; }

@media (min-width: 761px) {
  main { padding: 28px 24px 104px; }
  h1 { font-size: 26px; }
}
/* The top menu from 900px (five daily links, More, the account menu); below that the tab bar */
@media (min-width: 900px) {
  .nav-desktop, .user-menu { display: flex; }
  .tabbar { display: none; }
  main { padding-bottom: 56px; }
}
.nav-desktop a { white-space: nowrap; }
.tabbar .more.is-current > summary { color: var(--accent); }

/* Dropdown menus in the top bar (More, account) */
.menu { position: relative; }
.menu > summary { display: flex; align-items: center; gap: 8px; list-style: none; cursor: pointer; white-space: nowrap; }
.menu > summary::-webkit-details-marker { display: none; }
.nav-desktop .menu > summary { color: var(--muted); padding: 7px 12px; border-radius: var(--radius-sm); font-weight: 550; font-size: 14.5px; }
.nav-desktop .menu > summary::after { content: ""; width: 6px; height: 6px; margin: -3px 0 0 2px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.nav-desktop .menu > summary:hover { background: var(--bg); color: var(--ink); }
.nav-desktop .menu[open] > summary, .nav-desktop .menu.is-current > summary { background: var(--accent-soft); color: var(--accent-ink); }
.menu-panel { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 210px; padding: 6px; background: var(--surface);
              border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(23, 33, 43, .14); }
.menu-panel.right { left: auto; right: 0; }
.menu-panel a, .menu-panel button { display: block; width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14.5px;
              text-align: left; color: var(--ink); background: none; border: 0; font-weight: 500; min-height: 0; }
.menu-panel a:hover, .menu-panel button:hover { background: var(--bg); text-decoration: none; }
.menu-panel .who { padding: 8px 12px 6px; color: var(--muted); font-size: 13px; }
.user-menu .menu > summary { padding: 4px 6px 4px 4px; border-radius: 999px; color: var(--muted); }
.user-menu .menu > summary:hover, .user-menu .menu[open] > summary { background: var(--bg); }
.avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft);
          color: var(--accent-ink); font-weight: 700; font-size: 14px; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .actions-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
       font-size: 14.5px; line-height: 1.2; padding: 10px 16px; min-height: 42px; border-radius: var(--radius-sm); cursor: pointer;
       border: 1px solid var(--accent); background: var(--accent); color: #fff; text-decoration: none; }
button:hover, .button:hover { background: var(--accent-ink); border-color: var(--accent-ink); text-decoration: none; }
button.secondary, .button.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
button.secondary:hover, .button.secondary:hover { background: var(--bg); border-color: #CBD2D9; }
button.danger { background: var(--surface); color: var(--red); border-color: #EBC3C0; }
button.danger:hover { background: var(--red-soft); }
button.link { background: none; border: 0; color: var(--accent); padding: 0; min-height: 0; font-weight: 550; }
button.link:hover { text-decoration: underline; background: none; }
.inline { display: inline; }

/* ---------- Surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-pad { padding: 18px; }
.narrow { max-width: 560px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* ---------- Messages ---------- */
.msg { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; background: var(--accent-soft);
       color: var(--accent-ink); border: 1px solid #C9E2E9; font-size: 14.5px; }
.msg.success { background: var(--green-soft); color: var(--green); border-color: #C3E3D0; }
.msg.warning { background: var(--amber-soft); color: var(--amber); border-color: #F3D9A8; }
.msg.error { background: var(--red-soft); color: var(--red); border-color: #F1C6C3; }
.msg ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12.5px;
        font-weight: 650; white-space: nowrap; background: var(--bg); color: var(--muted); }
.pill-red { background: var(--red); color: #fff; }
.pill-amber { background: var(--amber-soft); color: var(--amber); }
.pill-soon { background: #FFF8E1; color: #7A5A00; }
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-accent { background: var(--accent-soft); color: var(--accent-ink); }
.tag { font-size: 11.5px; font-weight: 650; background: var(--red-soft); color: var(--red); padding: 2px 7px; border-radius: 999px; }
.tag.ok { background: var(--green-soft); color: var(--green); }
.tag.wait { background: var(--amber-soft); color: var(--amber); }

/* Stage progress: 8 short segments, filled up to the current stage */
.steps { display: flex; gap: 3px; width: 112px; margin-top: 6px; }
.steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.steps i.on { background: var(--accent); }
.stage { display: block; font-size: 13.5px; }

/* ---------- Tables (desktop) and cards (phones) ---------- */

.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-size: 12.5px; font-weight: 650; color: var(--muted); padding: 11px 14px;
            border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #FAFBFC; }
.table .right { text-align: right; }
.table .po { font-weight: 650; }
.table .sub { color: var(--muted); font-size: 13px; }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
        display: block; color: var(--ink); }
a.card:hover { text-decoration: none; border-color: #C6CED6; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-title { font-weight: 700; font-size: 15.5px; overflow-wrap: anywhere; }
.card-item { margin-top: 4px; }
.card-meta { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.card-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; margin-top: 12px; }
.card.is-overdue { box-shadow: inset 4px 0 0 var(--red); }
.card.is-urgent { box-shadow: inset 4px 0 0 #D9902A; }

/* PO detail: facts and line cards with actions */
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; margin: 0; padding: 18px; }
.facts dt { font-size: 12.5px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 550; overflow-wrap: anywhere; }
.line-card .line-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px;
        margin: 14px 0 0; padding: 12px 0 0; border-top: 1px solid var(--line); }
.line-card dt { font-size: 12.5px; color: var(--muted); }
.line-card dd { margin: 1px 0 0; overflow-wrap: anywhere; }
.line-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.line-actions form { display: contents; }
.line-actions:not(:has(*)) { display: none; }
.dispatch-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid #E6EAEE; }
.progress-row { margin: 10px 0 0; font-size: 13.5px; color: var(--muted); }
@media (max-width: 760px) {
  .line-actions .button, .line-actions button { flex: 1 1 100%; }
}

.dispatch-row .tracking { flex-basis: 100%; font-size: 14px; }
.dispatch-row .inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; }
.dispatch-row .inline-form input[type="date"] { min-height: 36px; }

.report-links { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 6px 6px 0; }
.report-links .button { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.report-cell { min-width: 310px; }
.line-actions .report-links { margin: 0; }

/* ---------- Raise a call ---------- */
.call-filter { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 18px; padding: 16px 18px; margin-bottom: 22px; }
.call-filter label { flex: 1 1 220px; max-width: 320px; font-weight: 600; font-size: 14px; }
.call-filter select, .call-filter input { margin-top: 6px; }
.call-filter .small-link { align-self: center; }
.call-form > * + * { margin-top: 16px; }
.call-form h2 { margin: 6px 0 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.call-form h2 small { font-size: 13.5px; font-weight: 400; }
.call-table .nowrap { white-space: nowrap; }
.call-table .item-cell { min-width: 120px; }
.call-table td.over { color: var(--red); font-weight: 600; }
.call-table input[type=text] { min-width: 76px; }
.call-table th:first-child, .call-table td:first-child { width: 36px; padding-right: 0; }
.call-form .call-details { margin: 16px 0 0; padding: 16px 18px; }
.call-table th, .call-table td { padding-left: 10px; padding-right: 10px; }
.call-table td:nth-child(4) { min-width: 150px; }

/* ---------- Call planning downloads ---------- */
.plan { margin-bottom: 20px; }
.plan h2 { margin-top: 0; }
.plan > p { margin: 0 0 14px; }
.plan-until { display: block; max-width: 260px; margin: 0 0 16px; font-weight: 600; font-size: 14px; }
.plan-until input { margin-top: 6px; }
.plan-until .helptext { font-weight: 400; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.plan-card { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px 16px;
        border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); }
.plan-card .muted { font-size: 14px; flex: 1; }
.plan-card select { background: var(--surface); }
@media (max-width: 760px) { .plan-card .button, .plan-card button { width: 100%; } }

/* ---------- Forms ---------- */
.form p { margin: 0 0 16px; }
.form label, .field > span { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; color: var(--ink); }
input, select, textarea { font: inherit; font-size: 16px; color: var(--ink); background: var(--surface); width: 100%;
        border: 1px solid #CDD4DB; border-radius: var(--radius-sm); padding: 10px 12px; min-height: 44px; }
textarea { min-height: 76px; resize: vertical; }
textarea.code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; line-height: 1.45; white-space: pre; overflow-x: auto; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
input[type=file] { padding: 9px; background: var(--bg); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.helptext { display: block; font-size: 13px; color: var(--muted); margin-top: 5px; }
.errorlist { list-style: none; margin: 0 0 8px; padding: 0; color: var(--red); font-size: 13.5px; font-weight: 550; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
@media (max-width: 760px) { .form-actions > * { flex: 1 1 auto; } }
.context { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 18px; font-size: 14.5px; }

/* Filters (PO list) */
.filters { margin-bottom: 16px; }
.filters > summary { cursor: pointer; font-weight: 600; padding: 4px 0 10px; color: var(--accent); list-style: none; }
.filters > summary::-webkit-details-marker { display: none; }
.filters form { display: grid; gap: 12px; grid-template-columns: 1fr; padding: 16px; }
.filters label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.filters label > * { margin-top: 5px; }
.filters .form-actions { align-items: center; margin: 0; }
@media (min-width: 761px) {
  .filters > summary { display: none; }
  .filters form { grid-template-columns: 1.3fr 1.1fr 1fr .8fr 1fr auto; align-items: end; padding: 14px; }
}

/* PO confirm page: editable line table (wide; scrolls on phones) */
.header-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; border: 0; margin: 0 0 16px; padding: 18px; }
.header-fields > div { margin-bottom: 10px; }
.header-fields label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 5px; }
.scroll-x { overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; }
.grid th { text-align: left; font-size: 12.5px; color: var(--muted); padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid.edit input, .grid.edit textarea { min-width: 110px; }
.grid.edit input[name$="-name"], .grid.edit input[name$="-requirement"] { min-width: 210px; }
.grid.edit input[type=checkbox] { min-width: 0; }

/* Digest */
.digest-list { list-style: none; margin: 0; padding: 0; }
.digest-list li { padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.digest-list li:last-child { border-bottom: 0; }
.pick { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.pick input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; }
.card-pick { padding: 8px 16px 0; font-size: 14px; color: var(--muted); }
.close-bar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 10px 0 18px; }
.stage-change { margin-top: 10px; font-size: 14px; }
.by-hand { margin-top: 22px; }
.line-docs { margin-top: 10px; }
.doc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; }
.doc-list li { display: flex; align-items: center; gap: 4px; }
.doc-list form { display: inline; }
.link-button { background: none; border: 0; padding: 0 4px; color: var(--muted); cursor: pointer; font-size: 16px; min-height: 0; }
.by-hand > summary { cursor: pointer; color: var(--muted); }
.stage-change summary { cursor: pointer; color: var(--muted); }
.stage-change form { display: grid; gap: 10px; margin-top: 8px; max-width: 420px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* IREPS check summary */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.stat { padding: 14px 16px; }
.stat b { display: block; font-size: 26px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 13.5px; }
.stat.missing b { color: var(--red); }
.stat.waiting b { color: var(--amber); }
.stat.ok b { color: var(--green); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; padding: 30px 26px; }
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand img { border-radius: 12px; }
.login-brand h1 { margin: 12px 0 4px; font-size: 22px; }
.login-brand p { margin: 0; color: var(--muted); font-size: 14.5px; }
.field { display: block; margin-bottom: 16px; }
.field > .password-row { display: flex; gap: 8px; margin: 0; }
.password-row input { flex: 1; min-width: 0; }
.password-row button { flex: none; }
.login-submit { width: 100%; min-height: 48px; font-size: 16px; margin-top: 4px; }
.login-help { text-align: center; color: var(--muted); font-size: 13.5px; margin: 18px 0 0; }
body.bare main { padding: 0; max-width: none; }

@media (prefers-reduced-motion: no-preference) {
  .more-menu { animation: pop .12s ease-out; }
  @keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
}
.crumb { margin: 0 0 4px; font-size: 14px; }
input[type=file]::file-selector-button { font: inherit; font-weight: 600; font-size: 14px; margin-right: 12px; padding: 8px 14px;
        border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }

@media (min-width: 761px) {
  .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .line-card .line-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* Desktop table vs phone cards: last so it wins over .cards / .panel display */
.only-desktop { display: none; }
@media (min-width: 761px) { .only-desktop { display: block; } .only-mobile { display: none; } }
.import-box { margin-bottom: 16px; }
.import-box > summary { color: var(--accent); margin-bottom: 8px; }

/* IREPS check: close POs that will never be entered */
.close-bar { margin-bottom: 14px; }
.close-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.close-row input { flex: 1 1 240px; }
.link-button { background: none; border: 0; padding: 0; min-height: 0; width: auto; color: var(--accent);
               font: inherit; text-decoration: underline; cursor: pointer; }

/* Consignee contacts on the PO page: big tap-to-call buttons */
.button.call { background: var(--green); border-color: var(--green); min-height: 40px; padding: 8px 14px; }
.button.call:hover { background: var(--green); filter: brightness(0.92); }
.line-call { margin-top: 6px; }
.contact-cards .card { display: block; }
.people { list-style: none; margin: 10px 0; padding: 0; }
.people li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
             padding: 10px 0; border-top: 1px solid #E6EAEE; }
.people li:first-child { border-top: 0; }
.people-actions { display: flex; gap: 8px; }
.small-link { font-size: 13px; }

/* An amount in words under the figure (Indian style: crore, lakh, thousand) */
.in-words { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; font-weight: 400; line-height: 1.35; }

/* Search on every page, under the top bar */
.searchbar { max-width: 1180px; margin: 12px auto 0; padding: 0 16px; display: flex; gap: 8px; }
.searchbar input { flex: 1; min-height: 46px; font-size: 16px; }
.searchbar button { min-width: 50px; min-height: 46px; padding: 0 12px; }

/* One-tap views above the PO list; they scroll sideways on a phone */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; margin-bottom: 4px; -webkit-overflow-scrolling: touch; }
.chips a { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 14px;
           border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink);
           font-weight: 550; font-size: 14.5px; white-space: nowrap; }
.chips a:hover { text-decoration: none; border-color: var(--accent); }
.chips a b { font-weight: 700; color: var(--muted); }
.chips a.alert b { color: var(--red); }
.chips a[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chips a[aria-current="true"] b { color: #fff; }

/* Masters pages */
.master-cards .card-meta { margin-top: 4px; }
.advanced-link { margin-top: 18px; font-size: 14px; }
.list-search { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.list-search input { flex: 1; }
.form p.check { display: flex; flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 10px; }
.subform { border: 1px solid var(--line); margin: 0 0 10px; padding: 12px 14px; }
.subform-fields { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.subform-fields label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.subform-fields label > input, .subform-fields label > select, .subform-fields label > textarea { margin-top: 5px; }
.subform .remove { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 13.5px; color: var(--red); }
.subform .remove input { width: auto; min-height: 0; }
[data-add] { margin: 2px 0 6px; }

/* Report template page */
.template-current { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.field-guide { margin-top: 18px; }
.field-guide summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.field-guide code { font-size: 13px; white-space: nowrap; }
.field-guide .table td { vertical-align: top; padding: 6px 8px; }
.test-report-fields { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* Upload POs: what happened to each PDF */
.upload-list { list-style: none; margin: 0 0 16px; padding: 0; }
.upload-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
                  padding: 12px 16px; border-top: 1px solid var(--line); }
.upload-list li:first-child { border-top: 0; }

/* Digest: what to supply in the next 30 days */
.requirement { overflow-x: auto; margin-bottom: 8px; }
.requirement .table { min-width: 560px; }

/* PO list: dispatched lines in their own section below the open ones */
.dispatched-section { margin-top: 1.5rem; }
.dispatched-section > summary { cursor: pointer; display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; margin-bottom: .75rem; }
.dispatched-section > summary h2 { display: inline; margin: 0; font-size: 1.15rem; }

/* Inventory: four figures per item */
.stock-figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; margin: .6rem 0; }
.stock-figures dt { font-size: .8rem; color: var(--muted, #666); }
.stock-figures dd { margin: 0; font-size: 1.15rem; font-weight: 600; }
.stock-figures dd.negative { color: var(--red, #b42318); }
.stock-cards details { margin-top: .5rem; }
.stock-entries { list-style: none; padding: 0; margin: .4rem 0 0; font-size: .9rem; }
.stock-entries li { padding: .2rem 0; border-top: 1px solid var(--line, #eee); }
@media (max-width: 480px) { .stock-figures { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Digest page: count chips and one row per PO */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13.5px; color: inherit; text-decoration: none; }
.chip b { font-size: 12.5px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); }
h2 .hint { font-weight: 400; font-size: 13.5px; margin-left: 6px; }
.digest-rows { list-style: none; margin: 0; padding: 0; }
.drow { padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.drow:last-child { border-bottom: 0; }
.drow-main { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.drow-main input[type=checkbox] { width: 20px; height: 20px; margin: 0; align-self: center; }
.drow .when { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 150px; }
.drow.is-late .when b { color: var(--red); }
.drow.is-soon .when b { color: var(--amber); }
.drow .po { font-weight: 650; }
.drow .where, .drow .who { color: var(--muted); }
.drow-note { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin-top: 4px; font-size: 13.5px; color: var(--muted); }
.drow-items > summary { cursor: pointer; color: var(--accent); font-size: 13.5px; margin-top: 4px; list-style: none; }
.drow-items > summary::-webkit-details-marker { display: none; }
.drow-items ul { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13.5px; }
.drow-items li { padding: 3px 0; }
button.small { min-height: 30px; padding: 3px 10px; font-size: 13px; }
h2[id] { scroll-margin-top: 70px; }

/* Consignments page: a ledger, one row per dispatch; the route strip is the dispatch-to-due-date line */
.add-lr { margin-bottom: 14px; }
.add-lr > summary { cursor: pointer; }
.lr-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 600px) { .lr-fields { grid-template-columns: 1fr; } }
.add-lr select { width: 100%; max-width: 100%; }
.cons-search { display: flex; gap: 8px; margin: 0 0 12px; }
.cons-search input[type=search] { flex: 1; }
.cons-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.cons-status > summary { list-style: none; cursor: pointer; }
.cons-status > summary::-webkit-details-marker { display: none; }
.cons-status form { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 8px; }
.cons-status input[type=text] { min-width: 220px; }
.ledger { list-style: none; margin: 0; padding: 0; overflow: hidden; }
.lrow { --rail: var(--accent); display: grid; gap: 12px 20px; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--line);
        box-shadow: inset 4px 0 0 var(--rail); }
.lrow:last-child { border-bottom: 0; }
.lrow.s-risk { --rail: var(--red); }
.lrow.s-delivered, .lrow.s-received { --rail: var(--green); }
.lrow.is-late { --rail: var(--amber); }
.lr-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.lr-title .po { font-weight: 700; }
.lr-name { font-weight: 600; }
.lr-qty { font-variant-numeric: tabular-nums; }
.lr-sub { color: var(--muted); font-size: 13.5px; line-height: 1.4; overflow-wrap: anywhere; }
.lr-no { font-size: 17px; font-weight: 700; letter-spacing: .01em; overflow-wrap: anywhere; }
.lr-none { font-weight: 650; color: var(--red); }
.lr-dest { font-weight: 600; overflow-wrap: anywhere; }
.lr-state { font-weight: 650; color: var(--accent-ink); }
.s-risk .lr-state { color: var(--red); }
.is-late .lr-state { color: var(--amber); }
.s-delivered .lr-state, .s-received .lr-state { color: var(--green); }
.route { min-width: 0; }
.route-track { position: relative; height: 6px; margin: 9px 7px 6px 0; background: var(--line); border-radius: 3px; }
.route-fill { position: absolute; inset: 0 auto 0 0; background: var(--rail); border-radius: 3px; }
.route-dot { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
             background: var(--surface); border: 3px solid var(--rail); }
.s-delivered .route-dot, .s-received .route-dot { background: var(--rail); }
.route-ends { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.route-note { font-weight: 650; color: var(--ink); text-align: center; }
.lrow.s-risk .route-note { color: var(--red); }
.lrow .cons-actions { margin-top: 0; }
@media (min-width: 900px) {
  .lrow { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) minmax(0, 1.2fr) minmax(200px, 1.15fr); align-items: start; }
  .lrow .cons-actions { grid-column: 1 / -1; justify-content: flex-end; margin-top: -4px; }
}
.chips a[aria-current="true"] b { background: rgba(255, 255, 255, .24); color: #fff; }
.lrow .cons-actions { gap: 2px 6px; }
.lrow .cons-actions > .button, .lrow .cons-actions > form > button, .lrow .cons-actions > details > summary {
  background: none; border-color: transparent; color: var(--accent); min-height: 36px; padding: 6px 10px; font-weight: 600; }
.lrow .cons-actions > .button:hover, .lrow .cons-actions > form > button:hover, .lrow .cons-actions > details > summary:hover {
  background: var(--accent-soft); border-color: transparent; text-decoration: none; }
.samples-choice { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-right: 6px; }
