/* Tool Manager — a thin layer over Bootstrap 5.3.
   Built for a phone in a gang box: big targets, high contrast, no decoration.
   Sharp corners, steel greys, one maroon accent. Light only. */

:root {
  --tc-steel:    #1b1f26;   /* nav, primary buttons */
  --tc-steel-2:  #0f1216;
  --tc-accent:   #7a1f2b;   /* maroon: active nav, primary actions, the login stripe */
  --tc-accent-2: #5c1620;
  --tc-hivis:    var(--tc-accent);
  --tc-line:     #cfd4dc;   /* every border */
  --tc-surface:  #ffffff;   /* cards, tables, modals */
  --tc-canvas:   #eef0f3;   /* page background */
  --tc-muted:    #5b6472;

  /* Bootstrap reads these for buttons, inputs, cards, badges, modals. */
  --bs-border-radius:      3px;
  --bs-border-radius-sm:   2px;
  --bs-border-radius-lg:   4px;
  --bs-border-radius-xl:   4px;
  --bs-border-radius-xxl:  4px;
  --bs-border-radius-pill: 3px;
  --bs-border-color: var(--tc-line);
  --bs-body-bg: var(--tc-canvas);
  --bs-secondary-color: var(--tc-muted);
  --bs-link-color-rgb: 27, 31, 38;
  --bs-link-hover-color-rgb: 15, 18, 22;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-font-smoothing: antialiased;
}

/* Numbers in tables line up; counts are read at a glance, not parsed. */
.tc-num, table td, table th { font-variant-numeric: tabular-nums; }

/* Tool codes and order numbers are identifiers, so they get an identifier face. */
.tc-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82em;
  letter-spacing: .02em;
}

/* Small caps for anything that labels a field or a column. */
.form-label,
.table > thead > tr > th,
.tc-label {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
}
.form-label { margin-bottom: .3rem; }
.table > thead > tr > th {
  border-bottom: 2px solid var(--tc-line);
  padding-top: .55rem;
  padding-bottom: .55rem;
  white-space: nowrap;
}

/* --- Nav ------------------------------------------------------------ */
.tc-nav {
  background: var(--tc-steel);
  border-top: 4px solid var(--tc-accent);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  padding-top: .55rem;
  padding-bottom: .55rem;
}
.tc-nav .navbar-brand {
  color: #fff;
  font-weight: 700;
  letter-spacing: -.01em;
}
.tc-nav .navbar-brand i { color: #fff; opacity: .9; }

/* Nav items are buttons: bordered, flat, the active one filled. */
.tc-nav .navbar-nav { gap: .35rem; }
.tc-nav .nav-link {
  color: rgba(255, 255, 255, .82);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: var(--bs-border-radius);
  padding: .42rem .85rem;
  font-size: .9rem;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
  transition: background-color .12s, color .12s, border-color .12s;
}
.tc-nav .nav-link:hover,
.tc-nav .nav-link:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .3);
}
.tc-nav .nav-link.active {
  color: #fff;
  background: var(--tc-accent);
  border-color: var(--tc-accent);
  font-weight: 600;
}
.tc-nav .nav-link.dropdown-toggle { border-color: transparent; }
.tc-nav .nav-link.dropdown-toggle:hover { border-color: rgba(255, 255, 255, .3); }
.tc-nav .btn-outline-light {
  --bs-btn-color: rgba(255, 255, 255, .82);
  --bs-btn-border-color: rgba(255, 255, 255, .16);
  --bs-btn-hover-bg: rgba(255, 255, 255, .08);
  --bs-btn-hover-border-color: rgba(255, 255, 255, .3);
  --bs-btn-hover-color: #fff;
  padding: .42rem .7rem;
}
.tc-nav .navbar-toggler {
  border-color: rgba(255, 255, 255, .3);
  border-radius: var(--bs-border-radius);
}
.tc-nav .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255,255,255,0.85%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
.tc-nav .dropdown-menu {
  border: 1px solid var(--tc-line);
  border-radius: var(--bs-border-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.tc-nav .dropdown-item-text { text-transform: uppercase; letter-spacing: .06em; font-size: .7rem; font-weight: 600; }
.tc-main { max-width: 1500px; }

/* Collapsed on a phone: full-width rows with room to tap. */
@media (max-width: 991.98px) {
  .tc-nav .navbar-collapse { padding-top: .75rem; }
  .tc-nav .navbar-nav { gap: .4rem; }
  .tc-nav .nav-link { padding: .7rem .9rem; }
  .tc-nav .navbar-nav.align-items-lg-center { margin-top: .4rem; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .tc-nav .navbar-nav.align-items-lg-center > .nav-item { flex: 1 1 auto; }
  .tc-nav .navbar-nav.align-items-lg-center > .nav-item > .btn { width: 100%; height: 100%; }
}

/* --- Page heading --------------------------------------------------- */
.tc-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .5rem 1rem;
  margin-bottom: 1.1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--tc-line);
}
.tc-head h1 {
  font-size: clamp(1.25rem, 1.05rem + 1vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -.015em;
  margin: 0;
}
.tc-head .tc-sub { color: var(--bs-secondary-color); margin: 0; font-size: .9rem; }

h2.h5, h2.h6 {
  font-weight: 700;
  letter-spacing: -.01em;
}
.card .h6 {
  font-size: .72rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
}

/* --- Surfaces ------------------------------------------------------- */
.card,
.tc-card {
  background: var(--tc-surface);
  border: 1px solid var(--tc-line);
  box-shadow: none;
}
.card .card-footer { border-top-color: var(--tc-line); }
.table { --bs-table-bg: var(--tc-surface); }
.table-responsive { border: 1px solid var(--tc-line); border-radius: var(--bs-border-radius); background: var(--tc-surface); }
.table-responsive > .table { margin-bottom: 0; }
.list-group-item { background: transparent; }
.modal-content { border: 1px solid var(--tc-line); }
.alert { border-width: 1px; }
.nav-tabs { border-bottom-color: var(--tc-line); }
.nav-tabs .nav-link {
  color: var(--bs-secondary-color);
  text-transform: uppercase;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .05em;
  border-radius: var(--bs-border-radius) var(--bs-border-radius) 0 0;
}
.nav-tabs .nav-link.active {
  color: var(--bs-body-color);
  background: var(--tc-surface);
  border-color: var(--tc-line) var(--tc-line) var(--tc-surface);
}

/* --- Controls ------------------------------------------------------- */
.btn { font-weight: 600; letter-spacing: .01em; }
.btn-dark {
  --bs-btn-bg: var(--tc-steel);
  --bs-btn-border-color: var(--tc-steel);
  --bs-btn-hover-bg: var(--tc-steel-2);
  --bs-btn-hover-border-color: var(--tc-steel-2);
  --bs-btn-active-bg: var(--tc-steel-2);
}
/* The primary action buttons carry the accent; Bootstrap's warning/info palette is untouched. */
.btn-accent {
  --bs-btn-bg: var(--tc-accent); --bs-btn-border-color: var(--tc-accent); --bs-btn-color: #fff;
  --bs-btn-hover-bg: var(--tc-accent-2); --bs-btn-hover-border-color: var(--tc-accent-2); --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--tc-accent-2); --bs-btn-active-color: #fff;
}
.btn-outline-accent {
  --bs-btn-color: var(--tc-accent); --bs-btn-border-color: var(--tc-accent);
  --bs-btn-hover-bg: var(--tc-accent); --bs-btn-hover-border-color: var(--tc-accent); --bs-btn-hover-color: #fff;
}
.border-accent { border-color: var(--tc-accent) !important; }
.form-control, .form-select { border-color: var(--tc-line); background-color: var(--tc-surface); }
.form-control:focus, .form-select:focus {
  border-color: var(--tc-accent);
  box-shadow: 0 0 0 2px rgba(122, 31, 43, .25);
}
.input-group-text { border-color: var(--tc-line); background: var(--tc-canvas); }

.badge {
  font-weight: 600;
  font-size: .68rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: .38em .55em;
}
.badge.text-bg-light { background: var(--tc-canvas) !important; color: var(--bs-body-color) !important; border-color: var(--tc-line) !important; }

/* --- Tool cards ----------------------------------------------------- */
.tc-tool-img {
  aspect-ratio: 4 / 3;
  object-fit: cover;
  width: 100%;
  background: var(--tc-canvas);
  border-bottom: 1px solid var(--tc-line);
}
.tc-tool-img-empty {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  background: var(--tc-canvas);
  color: var(--bs-secondary-color);
  font-size: 2rem;
  border-bottom: 1px solid var(--tc-line);
}
.tc-card .card-title { font-size: 1rem; font-weight: 600; margin-bottom: .15rem; }

/* Stock readout under each tool */
.tc-stock { font-size: .85rem; }
.tc-stock strong { font-size: 1.05rem; }

/* Thumbnails in inventory + order tables */
.tc-thumb {
  width: 52px; height: 52px;
  object-fit: cover;
  border-radius: var(--bs-border-radius-sm);
  background: var(--tc-canvas);
  border: 1px solid var(--tc-line);
}
.tc-thumb-empty {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border-radius: var(--bs-border-radius-sm);
  background: var(--tc-canvas);
  border: 1px solid var(--tc-line);
  color: var(--bs-secondary-color);
}

/* --- Quantity stepper ----------------------------------------------- */
.tc-qty { max-width: 9.5rem; }
.tc-qty .form-control { text-align: center; font-weight: 600; }
.tc-qty .btn { width: 2.6rem; }

/* --- Login ---------------------------------------------------------- */
.tc-login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    linear-gradient(180deg, var(--tc-steel-2), var(--tc-steel));
}
.tc-login .card { width: min(24rem, 100%); border: 0; box-shadow: 0 20px 50px rgba(0, 0, 0, .4); }
.tc-login-mark {
  height: 6px;
  background: var(--tc-accent);
}
.tc-login h1 { font-weight: 700; letter-spacing: -.01em; }

/* --- Photo capture -------------------------------------------------- */
/* The visible control is a <label for> the file input (native activation,
   no script needed); app.js also calls input.click() from the tap. The
   input is off-screen but real: never display:none or visibility:hidden,
   which iOS Safari may refuse to open, and never resized to the button,
   because Safari only treats the input's inner widget as clickable. */
.tc-photo { position: relative; }
.tc-photo-input {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 1px; height: 1px;
  opacity: 0;
}
.tc-photo-btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  min-height: 44px;
  justify-content: center;
  margin: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tc-photo.has-photo .tc-photo-btn {
  --bs-btn-color: var(--bs-body-color);
  --bs-btn-border-color: var(--tc-steel);
}
.tc-photo-preview {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  margin-top: .5rem;
  border: 1px solid var(--tc-line);
  border-radius: var(--bs-border-radius);
  background: var(--tc-canvas);
}

/* --- Modals --------------------------------------------------------- */
/* Our modals wrap header/body/footer in a <form>. Bootstrap's scrollable
   layout expects those to be direct flex children of .modal-content, so
   without this the body never shrinks and the footer buttons get clipped
   off the bottom once a photo preview appears. */
.modal-dialog-scrollable .modal-content > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}
.modal-header, .modal-footer { border-color: var(--tc-line); }
.modal-title { font-weight: 700; }

/* --- Routes --------------------------------------------------------- */
.tc-stop.tc-stop-done { opacity: .75; }
.tc-stop-head {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .75rem;
}
.tc-stop-seq {
  width: 2rem; height: 2rem;
  display: grid; place-items: center;
  border-radius: var(--bs-border-radius-sm);
  background: var(--tc-steel);
  color: #fff;
  font-weight: 700;
  flex: 0 0 auto;
}
.tc-stop-done .tc-stop-seq { background: var(--bs-success); }
.tc-stop-toggle {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .3rem 0;
  background: none;
  border: 0;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
/* Header is one line: "Supervisor  ·  address", truncated, chevron at the end. */
.tc-stop-title {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: baseline;
  gap: .5rem;
  overflow: hidden;
  white-space: nowrap;
  line-height: 1.3;
}
.tc-stop-who { font-weight: 600; flex: 0 0 auto; }
.tc-stop-where {
  color: var(--bs-secondary-color);
  font-size: .9rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tc-stop-where::before { content: "·"; margin-right: .5rem; }
.tc-stop-chev { flex: 0 0 auto; transition: transform .15s; color: var(--bs-secondary-color); }
.tc-stop-toggle[aria-expanded="true"] .tc-stop-chev { transform: rotate(180deg); }
.tc-stop .collapse .card-body, .tc-stop .collapsing .card-body { border-top: 1px solid var(--tc-line); }
.tc-stop-grip { color: var(--bs-secondary-color); cursor: grab; flex: 0 0 auto; }
.tc-stop-tools { flex: 0 0 auto; }
.tc-stop-tools .form-select-sm { width: auto; min-width: 3.6rem; }
.tc-dragging { opacity: .4; }
/* Contents of the order: qty, name, code on one row; long names wrap, never overflow. */
.tc-items { list-style: none; margin: 0; padding: 0; border: 1px solid var(--tc-line); border-radius: var(--bs-border-radius); }
.tc-items li {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  padding: .45rem .6rem;
  min-width: 0;
}
.tc-items li + li { border-top: 1px solid var(--tc-line); }
.tc-items-qty { flex: 0 0 2.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tc-items-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.tc-items-code { flex: 0 0 auto; color: var(--bs-secondary-color); }
.tc-stop .card-body { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 575.98px) {
  .tc-stop-head { padding: .5rem .6rem; gap: .5rem; }
  .tc-stop-who { max-width: 45%; overflow: hidden; text-overflow: ellipsis; }
  .tc-stop-tools .form-select-sm { min-height: 38px; }
  .tc-items-code { display: none; }
}
.tc-proof {
  width: 72px; height: 72px;
  object-fit: cover;
  border-radius: var(--bs-border-radius-sm);
  border: 1px solid var(--tc-line);
  background: var(--tc-canvas);
}

/* --- Collapsible sections (manager's Orders page) -------------------- */
.tc-section {
  display: flex; align-items: center; gap: .6rem;
  width: 100%;
  margin: .25rem 0 .75rem;
  padding: .55rem .8rem;
  background: var(--tc-surface);
  border: 1px solid var(--tc-line);
  border-left: 4px solid var(--tc-steel);
  border-radius: var(--bs-border-radius);
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.tc-section.collapsed { border-left-color: var(--tc-line); }
.tc-section-title { font-weight: 700; letter-spacing: -.01em; }
.tc-section-meta { color: var(--bs-secondary-color); font-size: .85rem; }
.tc-section-chev { margin-left: auto; color: var(--bs-secondary-color); transition: transform .15s; }
.tc-section[aria-expanded="true"] .tc-section-chev { transform: rotate(180deg); }

/* --- Attention bubbles (warehouse) ---------------------------------- */
.tc-bubble {
  position: absolute;
  top: -.5rem; right: -.4rem;
  min-width: 1.5rem; height: 1.5rem;
  padding: 0 .4rem;
  display: grid; place-items: center;
  border-radius: 1rem;
  background: var(--bs-danger);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  box-shadow: 0 0 0 2px var(--tc-canvas);
  z-index: 1;
}
/* Phones: a double tap on + / − must step the number, not zoom the page. */
body, .btn, button, input, select, textarea, label, a, .form-check-input { touch-action: manipulation; }
.tc-multi { font-size: .6rem; letter-spacing: .06em; vertical-align: middle; }

/* Phones: a .tc-stack table becomes a list of cards, one per row; app.js
   copies each column heading onto its cells as data-label and marks the
   wrapper .tc-stack-wrap so the desktop frame goes away. */
@media (max-width: 767.98px) {
  .tc-stack-wrap { border: 0; background: transparent; border-radius: 0; overflow: visible; }
  .tc-stack { --bs-table-bg: transparent; --bs-table-accent-bg: transparent; --bs-table-hover-bg: transparent; background: transparent; margin: 0; }
  .tc-stack thead { display: none; }
  .tc-stack, .tc-stack tbody, .tc-stack tr, .tc-stack td { display: block; width: 100% !important; max-width: none !important; }
  .tc-stack tr {
    background: var(--tc-surface); border: 1px solid var(--tc-line); border-radius: var(--bs-border-radius);
    padding: .55rem .9rem .6rem; margin-bottom: .6rem;
  }
  .tc-stack tr.table-success { background: var(--bs-success-bg-subtle); }
  .tc-stack tr.tc-part { margin-left: 1.25rem; width: calc(100% - 1.25rem); }
  .tc-stack td {
    display: flex; align-items: baseline; gap: .6rem;
    padding: .22rem 0; border: 0; box-shadow: none; background: transparent;
    text-align: left !important; white-space: normal;
  }
  .tc-stack td:empty { display: none; }
  .tc-stack td[data-label]::before {
    content: attr(data-label); flex: 0 0 5.5rem; padding-top: .15em;
    font-size: .64rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--bs-secondary-color);
  }
  .tc-stack td[data-label] > .tc-cell { flex: 1 1 auto; min-width: 0; }
  .tc-stack td[data-label] .tc-cell > .small { margin-top: .1rem; }
  .tc-stack td:not([data-label]) { padding-top: .45rem; gap: .4rem; flex-wrap: wrap; }
  .tc-stack td .form-check-input { margin: 0; }
}

/* Routes: the week calendar. Five day columns on wide screens, a stack of
   day sections on phones with today first in the eye line. */
.tc-weeknav { display: flex; align-items: center; gap: .5rem; margin-bottom: .9rem; flex-wrap: wrap; }
.tc-weeknav-title { flex: 1 1 auto; text-align: center; font-size: 1.05rem; }
.tc-week { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .6rem; align-items: start; margin-bottom: .6rem; }
.tc-day {
  background: var(--tc-surface); border: 1px solid var(--tc-line); border-radius: var(--bs-border-radius);
  padding: .55rem .6rem .6rem; min-height: 9rem; display: flex; flex-direction: column; gap: .45rem;
}
.tc-day-today { border-color: var(--tc-accent); box-shadow: inset 0 3px 0 var(--tc-accent); }
.tc-day-closed { background: var(--tc-canvas); }
.tc-day-closed .tc-day-name, .tc-day-closed .tc-day-num { color: var(--bs-secondary-color); }
.tc-day-past:not(.tc-day-today) { opacity: .75; }
.tc-day-head { display: flex; align-items: baseline; gap: .35rem; padding-bottom: .35rem; border-bottom: 1px solid var(--tc-line); flex-wrap: wrap; }
.tc-day-name { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--bs-secondary-color); }
.tc-day-num { font-size: 1.2rem; font-weight: 700; line-height: 1; white-space: nowrap; }
.tc-day-out { font-size: .78rem; color: var(--bs-secondary-color); }
.tc-day-empty { font-size: .8rem; color: var(--bs-secondary-color); padding: .4rem 0; }
.tc-day-add {
  margin-top: auto; border: 1px dashed var(--tc-line); background: transparent; border-radius: var(--bs-border-radius);
  color: var(--bs-secondary-color); font-size: .82rem; padding: .35rem; width: 100%;
}
.tc-day-add:hover { color: var(--tc-accent); border-color: var(--tc-accent); }
.tc-route {
  display: block; text-decoration: none; color: inherit;
  border: 1px solid var(--tc-line); border-left: 4px solid var(--bs-secondary); border-radius: var(--bs-border-radius);
  background: var(--bs-body-bg); padding: .5rem .6rem .55rem;
}
.tc-route:hover { border-color: var(--tc-accent); color: inherit; }
.tc-route-today { border-left-color: var(--tc-accent); }
.tc-route-late { border-left-color: var(--bs-danger); }
.tc-route-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.tc-route-driver { font-weight: 700; }
.tc-route-count { font-family: var(--tc-mono, ui-monospace, monospace); font-size: .85rem; color: var(--bs-secondary-color); }
.tc-route-bar { height: .3rem; background: var(--tc-canvas); border-radius: 1rem; margin: .4rem 0 .35rem; overflow: hidden; }
.tc-route-bar span { display: block; height: 100%; background: var(--bs-success); }
.tc-route-meta { display: flex; flex-wrap: wrap; gap: .25rem; min-height: 1.2rem; }
@media (max-width: 991.98px) {
  .tc-week { grid-template-columns: 1fr; }
  .tc-day { min-height: 0; }
  .tc-day-closed { padding-bottom: .55rem; }
  .tc-day-closed .tc-day-head { border-bottom: 0; padding-bottom: 0; }
  .tc-route { padding: .7rem .75rem; }
  .tc-route-driver { font-size: 1.05rem; }
  .tc-day-add { padding: .6rem; font-size: .95rem; }
  .tc-weeknav .btn { padding: .55rem .9rem; }
}

.tc-banner .tc-banner-body { white-space: normal; }

/* Date + Morning/Afternoon: side by side when there's room, stacked on phones. */
.tc-when { display: flex; flex-wrap: wrap; gap: .5rem; }
.tc-when > .form-control { flex: 1 1 11rem; min-width: 0; }
.tc-when > .btn-group { flex: 0 0 auto; }
@media (max-width: 575.98px) {
  .tc-when > .form-control, .tc-when > .btn-group { flex: 1 1 100%; }
  .tc-when > .btn-group .btn { flex: 1 1 0; }
  .tc-qty { max-width: 100%; flex-wrap: nowrap; }
  .tc-qty .form-control { min-width: 3.5rem; }
}
/* Nothing inside a card may push past it. */
.card, .tc-card, .tc-next, .tc-day, .tc-route, .tc-stack tr { min-width: 0; max-width: 100%; }
.tc-next-body { min-width: 0; }
.tc-stack td .tc-cell > form { max-width: 100%; }
img.tc-thumb { max-width: 100%; height: auto; }
.tc-footer-banners { margin-top: 1.5rem; }
.tc-footer-banners .alert:last-child { margin-bottom: 0; }
.tc-footer { text-align: center; font-size: .78rem; color: var(--bs-secondary-color); padding: 1.25rem 1rem 1.5rem; letter-spacing: .02em; }
/* Sign-in: the card centres in the space left after the footer, so the two never overlap. */
.tc-footer-dark { color: rgba(255, 255, 255, .55); padding: .75rem 1rem 0; align-self: end; }
.tc-login { grid-template-rows: 1fr auto; }
.tc-login > .card { align-self: center; }
html, body { min-height: 100%; }
body { display: flex; flex-direction: column; }
main.tc-main { flex: 1 0 auto; width: 100%; }
.tc-banner .fw-bold + .tc-banner-body { margin-top: .15rem; }

/* Order page: the next step, and the control that takes it. */
.tc-next {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
  padding: .6rem .9rem; margin-bottom: 1rem;
  border: 1px solid var(--bs-border-color); border-left: 4px solid var(--bs-secondary);
  background: var(--bs-body-bg); border-radius: var(--bs-border-radius);
}
.tc-next-mine { border-left-color: var(--tc-accent); }
.tc-next-delayed { border-left-color: var(--bs-danger); background: var(--bs-danger-bg-subtle); }
.tc-next-delayed .tc-next-label { color: var(--bs-danger); }
.tc-next-label { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--tc-accent); white-space: nowrap; }
.tc-next-body { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; flex: 1 1 auto; }
.tc-next .js-next-go { margin-left: auto; }
.tc-next-action { box-shadow: 0 0 0 3px var(--tc-canvas), 0 0 0 5px var(--tc-accent); animation: tc-next-pulse 1.6s ease-in-out 3; }
@keyframes tc-next-pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--tc-canvas), 0 0 0 5px var(--tc-accent); }
  50%      { box-shadow: 0 0 0 3px var(--tc-canvas), 0 0 0 9px rgba(122, 31, 43, .25); }
}

/* Waiting on a driver or a supervisor, not the warehouse: still counted, quieter. */
.tc-bubble-muted { background: var(--bs-secondary); }
.tc-dot {
  display: inline-block;
  width: .55rem; height: .55rem;
  margin-left: .35rem;
  border-radius: 50%;
  background: var(--bs-danger);
  vertical-align: middle;
}
.tc-attention { box-shadow: inset 3px 0 0 var(--bs-danger); }
.tc-part { background: var(--tc-canvas); }
.tc-part td { font-size: .9rem; }

/* --- Wizard steps --------------------------------------------------- */
.tc-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.tc-steps li {
  display: flex; align-items: center; gap: .4rem;
  padding: .35rem .7rem;
  border: 1px solid var(--tc-line);
  border-radius: var(--bs-border-radius);
  font-size: .85rem;
  color: var(--bs-secondary-color);
  background: var(--tc-surface);
}
.tc-steps-n {
  width: 1.4rem; height: 1.4rem;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--tc-line);
  color: var(--bs-body-color);
  font-size: .75rem; font-weight: 700;
}
.tc-steps li.current { color: var(--bs-body-color); border-color: var(--tc-accent); font-weight: 600; }
.tc-steps li:not(.current) { padding: .35rem .45rem; }
.tc-steps li.current .tc-steps-n { background: var(--tc-accent); color: #fff; }
.tc-steps li.done { color: var(--bs-body-color); }
.tc-steps li.done .tc-steps-n { background: var(--bs-success); color: #fff; }

/* --- Return form ---------------------------------------------------- */
.tc-ret-cond2 { margin-top: .6rem; }
.tc-condwrap { border: 0; background: transparent; }
.tc-condtable { width: auto; }
.tc-condtable th { font-size: .68rem; padding: .25rem .6rem; }
.tc-condtable td { padding: .25rem .6rem; vertical-align: middle; text-align: center; }
.tc-condtable .form-control { width: 3.2rem; }
.tc-qty-sm { width: 7.6rem; }
.tc-qty-sm .btn { width: 2.1rem; min-height: 0; padding: .15rem 0; }
.tc-qty-sm .form-control { min-height: 0; font-size: .9rem; padding: .15rem; }
.tc-ret-qty .tc-qty { max-width: 9.5rem; }
.tc-ret { padding: .75rem 0; border-top: 1px solid var(--tc-line); }
.tc-ret:first-of-type { border-top: 0; }
.tc-ret-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 10rem;
  gap: .75rem;
  align-items: end;
}
.tc-ret-row .tc-thumb, .tc-ret-row .tc-thumb-empty { align-self: center; }
.tc-ret-name { min-width: 0; align-self: center; overflow-wrap: anywhere; }
.tc-ret-damage {
  margin-top: .6rem;
  padding: .75rem;
  background: var(--tc-canvas);
  border: 1px solid var(--tc-line);
  border-radius: var(--bs-border-radius);
}
.tc-ret-err { box-shadow: inset 3px 0 0 var(--bs-danger); padding-left: .6rem; }
.tc-unit { padding: .45rem 0 .45rem .5rem; border-top: 1px dashed var(--tc-line); }
.tc-unit-row { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem 1rem; }
.tc-unit-flags { display: flex; flex-wrap: wrap; gap: .25rem .5rem; margin-left: auto; }
.tc-unit-flags .form-check-inline { margin-right: 0; }
.tc-pickline + .tc-pickline { border-top: 1px solid var(--tc-line); padding-top: .75rem; margin-top: .75rem; }
.tc-twid { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }
.tc-picklist tbody tr.table-success { --bs-table-bg: rgba(25, 135, 84, .12); }
.tc-picklist td { vertical-align: middle; }
.tc-pickgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .5rem; }
select.tc-twid { font-size: .9rem; }
@media (max-width: 575.98px) {
  .tc-unit-flags { margin-left: 0; width: 100%; }
}
@media (max-width: 767.98px) {
  .tc-ret-row { grid-template-columns: 52px minmax(0, 1fr); }
  .tc-ret-qty { grid-column: 2 / 3; }
}

/* --- Proof of delivery ---------------------------------------------- */
.tc-pod-photo {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border: 1px solid var(--tc-line);
  border-radius: var(--bs-border-radius);
  background: var(--tc-canvas);
}
.tc-tracker {
  list-style: none;
  margin: 0 0 .25rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
}
.tc-tracker-3 { grid-template-columns: repeat(3, 1fr); }
.tc-tracker-4 { grid-template-columns: repeat(4, 1fr); }
.tc-tracker-5 { grid-template-columns: repeat(5, 1fr); }
.tc-tracker-7 { grid-template-columns: repeat(7, 1fr); }
.tc-tracker li {
  position: relative;
  text-align: center;
  padding-top: 2rem;
  font-size: .8rem;
  color: var(--bs-secondary-color);
}
.tc-tracker li::before {
  content: "";
  position: absolute;
  top: .7rem; left: 0; right: 0;
  height: 3px;
  background: var(--tc-line);
}
.tc-tracker li:first-child::before { left: 50%; }
.tc-tracker li:last-child::before  { right: 50%; }
.tc-tracker li.done::before { background: var(--bs-success); }
.tc-tracker li.done + li:not(.done)::before {
  background: linear-gradient(90deg, var(--bs-success) 50%, var(--tc-line) 50%);
}
.tc-tracker-dot {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 1.45rem; height: 1.45rem;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--tc-surface);
  border: 3px solid var(--tc-line);
  color: transparent;
  font-size: .8rem;
}
.tc-tracker li.done .tc-tracker-dot {
  background: var(--bs-success);
  border-color: var(--bs-success);
  color: #fff;
}
.tc-tracker li.done .tc-tracker-label { color: var(--bs-body-color); font-weight: 600; }
.tc-tracker-label { display: block; }
.tc-tracker-when  { display: block; font-size: .72rem; }
@media (max-width: 575.98px) {
  .tc-tracker { grid-template-columns: 1fr; gap: .35rem; }
  .tc-tracker li { text-align: left; padding: .1rem 0 .1rem 2.2rem; }
  .tc-tracker li::before { top: 0; bottom: -0.5rem; left: .62rem; right: auto; width: 3px; height: auto; }
  .tc-tracker li:first-child::before { top: .5rem; left: .62rem; }
  .tc-tracker li:last-child::before  { bottom: auto; height: .6rem; right: auto; }
  .tc-tracker li.done + li:not(.done)::before { background: var(--tc-line); }
  .tc-tracker-dot { top: 0; left: 0; transform: none; }
  .tc-tracker-label, .tc-tracker-when { display: inline; }
  .tc-tracker-when { margin-left: .4rem; }
}

/* --- Misc ----------------------------------------------------------- */
.tc-timeline { list-style: none; margin: 0; padding: 0; }
.tc-timeline li {
  padding: .5rem 0 .5rem 1.15rem;
  border-left: 2px solid var(--tc-line);
  position: relative;
}
.tc-timeline li::before {
  content: ""; position: absolute; left: -5px; top: .95rem;
  width: 8px; height: 8px;
  background: var(--bs-secondary-color);
}
.tc-timeline li:first-child::before { background: var(--tc-accent); }

.tc-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--bs-secondary-color);
  background: var(--tc-surface);
  border: 1px dashed var(--tc-line);
  border-radius: var(--bs-border-radius);
}
.tc-empty i { font-size: 2.2rem; display: block; margin-bottom: .5rem; opacity: .5; }

/* Field use: nothing under 44px to tap on a phone. */
@media (max-width: 575.98px) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  .form-control, .form-select { min-height: 44px; font-size: 1rem; }

  /* A full-width photo per tool means scrolling past two tools a screen.
     Fold the card sideways instead: small photo, details beside it,
     the add row across the bottom where a thumb can reach it. */
  .tc-tool-card {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
  }
  .tc-tool-card > .tc-tool-img,
  .tc-tool-card > .tc-tool-img-empty {
    grid-area: 1 / 1;
    aspect-ratio: auto;
    height: 100%;
    min-height: 96px;
    font-size: 1.5rem;
    border-bottom: 0;
    border-right: 1px solid var(--tc-line);
  }
  .tc-tool-card > .card-body {
    grid-area: 1 / 2;
    padding: .6rem .75rem;
  }
  .tc-tool-card > .card-footer {
    grid-column: 1 / -1;
  }
  .tc-tool-card .card-text { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
