/* Supplier orders + money tracking */
.ord { padding: 16px; }
.ord[hidden] { display: none !important; }
.ord .muted, .ord-overlay .muted { color: var(--muted); }
.ord small, .ord-overlay small { color: var(--muted); }

/* money overview (admins) */
.ord-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.ord-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.ord-card span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ord-card b { font-size: 24px; font-variant-numeric: tabular-nums; }
.ord-card small { font-size: 12.5px; }
.ord-card.owe { background: #fff7ed; border-color: #fed7aa; }
.ord-card.owe b { color: #c2410c; }
.ord-panels { display: grid; grid-template-columns: 3fr 2fr; gap: 10px; margin-bottom: 14px; }
.ord-panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.ord-panel h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ord-panel h4 + p, .ord-panel ul + h4 { margin-top: 12px; }
.ord-panel h4 small { text-transform: none; letter-spacing: 0; font-weight: 500; }
.ord-chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 6px; }
.ord-chart .bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.ord-chart .fill { width: 100%; max-width: 34px; min-height: 2px; background: var(--brand); border-radius: 4px 4px 0 0; }
.ord-chart .bar:last-child .fill { background: #0f172a; }
.ord-chart span { font-size: 11px; color: var(--muted); }
.ord-rank { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.ord-rank li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.ord-rank li:last-child { border-bottom: 0; }
.ord-rank span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ord-rank b { font-variant-numeric: tabular-nums; }

/* list */
.ord-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.ord-toolbar .grow { flex: 1; }
.ord-search { flex: 1 1 260px; max-width: 420px; font: inherit; font-size: 15px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.ord-list { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
.ord-empty { padding: 30px; text-align: center; color: var(--muted); margin: 0; }
.ord-empty p { margin: 4px 0; }
.ord-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ord-table th { text-align: left; font-size: 12px; text-transform: uppercase; color: var(--muted); background: #fafafa; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ord-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ord-table tbody tr { cursor: pointer; }
.ord-table tbody tr:hover td { background: #f8fafc; }
.ord-table td small { display: block; font-size: 12px; margin-top: 3px; }
.ord-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ord-table .id { color: var(--muted); font-weight: 700; }
.ord-table .dt { white-space: nowrap; }
.ord-table .tot { font-weight: 700; }
.ord-table small.late { color: #c2410c; font-weight: 600; }

.tag.st-ordered { background: #dbeafe; color: #1d4ed8; }
.tag.st-partial { background: #fef3c7; color: #92400e; }
.tag.st-received { background: #dcfce7; color: #166534; }
.tag.st-cancelled { background: #f1f5f9; color: #64748b; text-decoration: line-through; }
.tag.pay-unpaid { background: #fee2e2; color: #b91c1c; }
.tag.pay-partial { background: #ffedd5; color: #c2410c; }
.tag.pay-paid { background: #dcfce7; color: #166534; }
.tag.pay-none { background: #f1f5f9; color: #64748b; }

/* editor */
.ord-overlay { position: fixed; inset: 0; z-index: 55; background: rgba(15,23,42,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.ord-overlay[hidden] { display: none; }
.ord-modal { background: #fff; color: var(--text); border-radius: 14px; width: 100%; max-width: 980px; max-height: 94vh; display: flex; flex-direction: column; overflow: hidden; }
.ord-hd { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.ord-hd h3 { margin: 0; font-size: 17px; }
.ord-badges { flex: 1; }
.ord-x { border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.ord-bd { padding: 16px 18px; overflow-y: auto; }
.ord-bd h4 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ord-bd h4 small { text-transform: none; letter-spacing: 0; font-weight: 500; }
.ord-bd section[hidden] { display: none; }
.ord-ft { display: flex; gap: 8px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); background: #fafafa; }
.ord-ft .grow { flex: 1; }
.ord-ft [hidden] { display: none; }

.ord-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 10px 12px; }
.ord-grid .full { grid-column: 1 / -1; }
.ord-grid .wide { grid-column: span 2; }
.ord-grid label, .ord-extra label, .ord-notes { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.ord-overlay input, .ord-overlay select, .ord-overlay textarea { font: inherit; font-size: 14px; color: var(--text); padding: 8px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-width: 0; }
.ord-overlay input:disabled, .ord-overlay select:disabled, .ord-overlay textarea:disabled { background: #f8fafc; color: var(--muted); }
.ord-notes { margin-top: 12px; }
.ord-notes textarea { resize: vertical; }

.ord-line { display: grid; grid-template-columns: 1.4fr 1.6fr .9fr 64px 92px 104px 30px; gap: 6px; align-items: start; margin-bottom: 6px; }
.ord-line.head span { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.ord-line .num { text-align: right; font-weight: 700; padding-top: 8px; font-variant-numeric: tabular-nums; }
.ord-line .num small { display: block; font-weight: 500; font-size: 11.5px; }
.ord-rm { width: 30px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); font-size: 18px; cursor: pointer; }
.ord-rm:hover:not(:disabled) { color: var(--urgent); border-color: #fecaca; }
.ord-rm:disabled { opacity: .35; cursor: default; }
.ord-addline[hidden] { display: none; }

.ord-extra { display: grid; grid-template-columns: 130px 130px 1fr; gap: 12px; align-items: end; margin-top: 12px; }
.ord-sum { justify-self: end; min-width: 240px; font-size: 14px; }
.ord-sum div { display: flex; justify-content: space-between; gap: 20px; padding: 2px 0; }
.ord-sum b { font-variant-numeric: tabular-nums; }
.ord-sum .grand { border-top: 2px solid var(--text); margin-top: 4px; padding-top: 6px; font-size: 17px; }

/* receive / pay / photos */
.ord-side[hidden] { display: none; }
.ord-money-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ord-money-row div { background: var(--bg); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; }
.ord-money-row span { font-size: 12px; font-weight: 700; color: var(--muted); }
.ord-money-row b { font-size: 22px; font-variant-numeric: tabular-nums; }
.ord-money-row .owe { background: #fff7ed; } .ord-money-row .owe b { color: #c2410c; }
.ord-money-row .ok { background: #ecfdf5; } .ord-money-row .ok b { color: #166534; }
.ord-box { border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px 12px; margin-top: 10px; }
.ord-box h4 { margin-top: 10px; }
.ord-recv { display: grid; grid-template-columns: 1fr auto 80px; gap: 10px; align-items: center; padding: 4px 0; font-size: 14px; }
.ord-btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.ord-pays { list-style: none; margin: 0 0 8px; padding: 0; font-size: 14px; }
.ord-pays li { display: grid; grid-template-columns: 100px 1fr auto 30px; gap: 10px; align-items: center; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.ord-pays li b { font-variant-numeric: tabular-nums; color: #166534; }
.ord-pays .ord-rm { height: 28px; width: 28px; font-size: 15px; }
.ord-payform { display: grid; grid-template-columns: 110px 140px 150px 1fr auto; gap: 8px; }
.paid-ok { color: #166534; font-weight: 700; margin: 4px 0 0; }
.ord-photos { display: flex; gap: 8px; flex-wrap: wrap; }
.ord-ph, .ord-addph { width: 84px; height: 84px; border-radius: 10px; overflow: hidden; padding: 0; border: 1px solid var(--line); background: var(--bg); cursor: pointer; }
.ord-ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ord-addph { display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 22px; border-style: dashed; color: var(--muted); }
.ord-addph span { font-size: 11px; font-weight: 600; }
.ord-hist { list-style: none; margin: 0; padding: 0; font-size: 13.5px; max-height: 220px; overflow-y: auto; }
.ord-hist li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.ord-hist li small { white-space: nowrap; }

.ord-viewer { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.9); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; }
.ord-viewer[hidden] { display: none; }
.ord-viewer img { max-width: 100%; max-height: calc(100vh - 90px); object-fit: contain; border-radius: 6px; cursor: pointer; }
.ord-vbar { display: flex; gap: 10px; align-items: center; margin-top: 12px; color: #e2e8f0; font-size: 13px; }
.ord-vbar [hidden] { display: none; }

@media (max-width: 900px) {
  .ord-cards { grid-template-columns: 1fr 1fr; }
  .ord-panels { grid-template-columns: 1fr; }
  .ord-grid { grid-template-columns: 1fr 1fr; }
  .ord-line { grid-template-columns: 1fr 1fr 64px 92px 30px; }
  .ord-line.head { display: none; }
  .ord-line select { grid-column: 1 / -1; }
  .ord-line [data-k="partNumber"] { display: none; }
  .ord-line .num { display: none; }
  .ord-extra { grid-template-columns: 1fr 1fr; }
  .ord-sum { grid-column: 1 / -1; justify-self: stretch; }
  .ord-payform { grid-template-columns: 1fr 1fr; }
  .ord-payform .pay-note, .ord-payform button { grid-column: 1 / -1; }
  .ord-pays li { grid-template-columns: 90px 1fr 30px; }
  .ord-pays li small { display: none; }
}
@media (max-width: 560px) {
  /* five tabs in the header: let them scroll sideways instead of widening the page */
  .view-tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .view-tabs button { padding: 6px 9px; flex-shrink: 0; }
  .ord { padding: 10px; }
  .ord-table th:nth-child(1), .ord-table td:nth-child(1), .ord-table th:nth-child(4), .ord-table td:nth-child(4) { display: none; }
  .ord-table th, .ord-table td { padding: 8px 6px; }
  .ord-card b { font-size: 19px; }
  .ord-grid { grid-template-columns: 1fr; }
  .ord-grid .wide { grid-column: auto; }
  .ord-money-row b { font-size: 17px; }
  .ord-ft { flex-wrap: wrap; }
}

/* parts orders inside a ticket */
.t-orders { display: flex; flex-direction: column; gap: 6px; }
.t-none { margin: 0; font-size: 13px; }
.t-order { font: inherit; text-align: left; display: flex; flex-direction: column; gap: 3px; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; }
.t-order:hover { border-color: var(--brand); }
.t-order.off { opacity: .6; }
.t-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.t-items { font-size: 13px; }
.t-meta { font-size: 12px; color: var(--muted); }
.t-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.t-sum { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 13px; background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.t-sum b { text-align: right; font-variant-numeric: tabular-nums; }
.t-sum b.owe { color: #c2410c; }

/* returns & refunds */
.tag.st-returned { background: #ede9fe; color: #6d28d9; }
.tag.pay-refund { background: #ede9fe; color: #6d28d9; }
.ord-money-row .refund { background: #f5f3ff; } .ord-money-row .refund b { color: #6d28d9; }
.ord-card small.ref, .t-sum b.ref { color: #6d28d9; font-weight: 600; }
.ord-pays li.is-refund b { color: #6d28d9; }
.refund-due { margin: 4px 0 8px; color: #5b21b6; }
.ret-note { width: 100%; box-sizing: border-box; margin-top: 6px; }

/* supplier quick-pick buttons */
.ord-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ord-chips[hidden] { display: none; }
.ord-chips button { font: inherit; font-size: 13.5px; font-weight: 600; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; }
.ord-chips button:hover { border-color: var(--brand); }
.ord-chips button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
