/* Locto brand: blue #298398 (logo blue on white), orange #e14817 for highlights only. */
:root {
  --locto-blue: #298398;
  --locto-blue-dark: #1f6677;
  --locto-blue-soft: #e8f3f6;
  --locto-orange: #e14817;
  --locto-orange-soft: #fdeee8;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --text: #16242a;
  --muted: #64767c;
  --faint: #8d9ca1;
  --border: #e3e8ea;
  --border-strong: #d2dadd;
  --green: #23824a;
  --green-soft: #e6f4ec;
  --amber: #a15c00;
  --amber-soft: #fff4e0;
  --slate: #4f6a73;
  --slate-soft: #edf1f3;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(16 36 42 / 0.04), 0 1px 3px rgb(16 36 42 / 0.06);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "tnum";
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); font-size: 14px; line-height: 1.45; }
a { color: var(--locto-blue-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--locto-blue); outline-offset: 2px; }

/* ------------------------------------------------------------------ header */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: rgb(255 255 255 / 0.92); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border); padding: 12px 24px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand img { height: 34px; width: auto; display: block; }
.product { font-size: 15px; font-weight: 600; color: var(--text); padding-left: 14px; border-left: 1px solid var(--border-strong); }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sync-state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.sync-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.sync-state.failed::before { background: var(--locto-orange); }
.sync-state.never::before { background: var(--faint); }
.user { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--border); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--locto-blue-soft); color: var(--locto-blue-dark); font-size: 12px; font-weight: 700;
}

main { max-width: 1320px; margin: 0 auto; padding: 24px 24px 64px; display: grid; gap: 20px; }
main > * { min-width: 0; }

/* ------------------------------------------------------------------ buttons */

.btn {
  font: inherit; font-size: 13px; font-weight: 600; line-height: 1;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  padding: 9px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { border-color: var(--locto-blue); color: var(--locto-blue-dark); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--locto-blue); border-color: var(--locto-blue); color: #fff; }
.btn-primary:hover { background: var(--locto-blue-dark); border-color: var(--locto-blue-dark); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--slate-soft); border-color: transparent; color: var(--text); }
.btn-small { padding: 7px 11px; font-size: 12px; }

.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-warn { background: var(--amber-soft); color: var(--amber); }

/* ------------------------------------------------------------------ status tiles */

.tiles { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 12px; }
.tile {
  text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; cursor: pointer; font: inherit; color: inherit;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.tile:hover { border-color: var(--border-strong); }
.tile[aria-pressed="true"] { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent); }
.tile .l { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--muted); }
.tile .l::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.tile .n { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 6px; }
.tile.zero .n { color: var(--faint); }

/* ------------------------------------------------------------------ panels */

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-head h2 { font-size: 16px; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 8px; }
.count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--slate-soft); border-radius: 999px; padding: 2px 8px; }
.panel-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 14px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); cursor: pointer; }
.check input { accent-color: var(--locto-blue); }
input[type="search"], dialog input, dialog select {
  font: inherit; font-size: 13px; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: 8px; min-width: 0;
  background: var(--surface); color: var(--text);
}
input[type="search"] { width: 320px; max-width: 100%; padding-left: 34px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238d9ca1' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 3.5 3.5'/%3E%3C/svg%3E") no-repeat 11px center; }
input[type="search"]:focus, dialog input:focus, dialog select:focus { outline: none; border-color: var(--locto-blue); box-shadow: 0 0 0 3px var(--locto-blue-soft); }

.ready { border-color: color-mix(in srgb, var(--green) 35%, var(--border)); }
.ready h2::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.ready-list, .unmatched-list { list-style: none; margin: 0; padding: 0; display: grid; }
.ready-list li, .unmatched-list li {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 4px; border-top: 1px solid var(--border);
}
.ready-list li:first-child, .unmatched-list li:first-child { border-top: 0; }
.ready-list .grow, .unmatched-list .grow { flex: 1; min-width: 200px; }
.ready-list input { accent-color: var(--locto-blue); width: 16px; height: 16px; }

/* ------------------------------------------------------------------ PO table */

.table-wrap { overflow-x: auto; margin: 14px -20px -18px; }
table.pos { width: 100%; border-collapse: collapse; font-size: 13px; }
table.pos th {
  text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint);
  padding: 10px 10px; border-bottom: 1px solid var(--border); background: #fafbfc; white-space: nowrap;
}
table.pos th:first-child, table.pos td:first-child { padding-left: 20px; }
table.pos th:last-child, table.pos td:last-child { padding-right: 20px; text-align: right; }
table.pos td { padding: 14px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.pos tbody tr { transition: background 0.1s; }
table.pos tbody tr:hover { background: #f9fbfb; }
table.pos tr:last-child td { border-bottom: 0; }
.nowrap { white-space: nowrap; }
/* Complete and + Tracking stacked, so the action column stays narrow. */
table.pos td.actions .btn { display: block; width: 100%; margin-left: auto; }
table.pos td.actions .btn + .btn { margin-top: 6px; }
table.pos td.actions { width: 1%; white-space: nowrap; }
.ref { font-weight: 600; white-space: nowrap; color: var(--locto-blue-dark); font-size: 14px; }
.client { font-weight: 500; }
table.pos td.item { min-width: 190px; }
@media (max-width: 700px) { table.pos td.item { min-width: 0; } }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.ticket { color: var(--faint); font-size: 12px; }
.ticket:hover { color: var(--locto-blue-dark); }
.ship { min-width: 160px; }
.ship a { white-space: nowrap; }
.ship b { font-weight: 600; }
.ship + .ship { margin-top: 8px; }
.ship .sub { max-width: 220px; }

/* Where the supplier ships (Halo "Deliver to us"): orange = comes to Locto, blue = straight to the client. */
.shipto {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 600; white-space: nowrap; color: var(--c); background: var(--bg-c);
}
.shipto::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.shipto-locto { --c: var(--locto-orange); --bg-c: var(--locto-orange-soft); }
.shipto-client { --c: var(--locto-blue-dark); --bg-c: var(--locto-blue-soft); }
table.pos tr.row-locto td:first-child { box-shadow: inset 3px 0 0 var(--locto-orange); }
table.pos tr.row-client td:first-child { box-shadow: inset 3px 0 0 var(--locto-blue); }
.ready-list .shipto { margin: 0 6px; vertical-align: 1px; }

/* Waiting two weeks or more since ordering (e.g. a long backorder). */
.sub.waiting-long { color: var(--locto-orange); font-weight: 600; }

.status {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--c); background: var(--bg-c);
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.s-not_ordered { --c: var(--faint); --bg-c: var(--slate-soft); }
.s-ordered { --c: var(--slate); --bg-c: var(--slate-soft); }
.s-shipped { --c: var(--locto-blue-dark); --bg-c: var(--locto-blue-soft); }
.s-part_shipped { --c: var(--amber); --bg-c: var(--amber-soft); }
.s-coming_today { --c: var(--locto-orange); --bg-c: var(--locto-orange-soft); }
.s-delivered { --c: var(--green); --bg-c: var(--green-soft); }
.s-closed { --c: var(--faint); --bg-c: var(--slate-soft); }

.empty { color: var(--muted); text-align: center; padding: 28px; }

.activity summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
.activity summary::-webkit-details-marker { display: none; }
.activity summary::before { content: "›"; color: var(--faint); font-size: 18px; transition: transform 0.15s; }
.activity[open] summary::before { transform: rotate(90deg); }
.activity ul { list-style: none; margin: 12px 0 0; padding: 0; font-size: 13px; color: var(--muted); display: grid; gap: 6px; }

dialog { border: 1px solid var(--border); border-radius: 14px; padding: 22px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgb(16 36 42 / 0.2); }
dialog::backdrop { background: rgb(16 36 42 / 0.35); backdrop-filter: blur(2px); }
dialog h3 { margin: 0 0 16px; font-size: 16px; }
dialog label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; margin-bottom: 14px; }
/* Receive dialog: quantity per PO line for part deliveries. */
.receive-dialog { width: min(560px, calc(100vw - 32px)); }
.rcv-lines { display: grid; gap: 8px; margin: 10px 0 14px; max-height: 50vh; overflow: auto; }
.rcv-line { display: grid; grid-template-columns: 1fr 80px; gap: 12px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.rcv-line input { width: 80px; margin: 0; }
dialog .rcv-line { margin: 0; }
.rcv-options { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.rcv-options .rcv-boxes { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.rcv-options .rcv-boxes input { width: 70px; }
.part-note { margin: 4px 0 0; padding: 6px 10px; border-radius: 8px; background: var(--amber-soft); color: var(--amber); font-size: 13px; font-weight: 600; }
.progress { color: var(--amber); font-weight: 600; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff;
  padding: 11px 18px; border-radius: 10px; font-size: 13px; max-width: calc(100vw - 32px); box-shadow: 0 10px 30px rgb(16 36 42 / 0.25);
}

/* ------------------------------------------------------------------ smaller screens */

@media (max-width: 1240px) {
  /* Narrower laptop windows: let long PO refs and text wrap so the table fits without scrolling. */
  table.pos td { padding: 12px 7px; }
  table.pos th { padding: 10px 7px; }
  table.pos td.item { min-width: 140px; }
  .ref { white-space: normal; overflow-wrap: anywhere; }
  .ship { min-width: 120px; }
  .ship a { white-space: normal; overflow-wrap: anywhere; }
  .ship .sub { max-width: 170px; }
}

@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .topbar { padding: 10px 16px; }
  .brand img { height: 28px; }
  .product { display: none; }
  main { padding: 16px 16px 48px; gap: 16px; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 10px 12px; }
  .tile .l { font-size: 11px; }
  .tile .l::before { display: none; }
  .tile .n { font-size: 22px; margin-top: 2px; }
  .topbar { position: static; }
  .panel { padding: 16px; }
  .table-wrap { margin: 12px -16px -16px; }
  input[type="search"] { width: 100%; }
  table.pos thead { display: none; }
  table.pos tr { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  table.pos td, table.pos td:first-child, table.pos td:last-child { border: 0; padding: 0; text-align: left; }
  .ship { white-space: normal; }
}
