:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1c2430;
  --muted: #6b7684;
  --line: #e5e9ef;
  --brand: #1f6feb;
  /* Deep navy sampled from the New Age logo wordmark/mark. */
  --brand-navy: #160d65;
  --brand-ink: #ffffff;
  --done: #1a9e5f;
  --pending: #c3cad4;
  --progress: #e08a1e;
  --urgent: #d64545;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(20, 30, 45, 0.06), 0 8px 24px rgba(20, 30, 45, 0.06);
}

* { box-sizing: border-box; }

/* Mobile-first fluid base: the root font-size scales with the viewport width
   between small and large phones, and everything sized in rem scales with it.
   ~15px at 320px, ~18px cap on wide phones / small tablets. */
html { font-size: clamp(15px, 3.6vw + 3.5px, 18px); }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  /* Never let the page scroll sideways on a phone. */
  overflow-x: hidden;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  /* Respect notched-phone safe areas on the sides. */
  padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-right));
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
  padding-top: max(16px, env(safe-area-inset-top));
  position: sticky;
  top: 0;
  z-index: 5;
}
/* Logo stacked above the status line. */
.brandbar {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
/* Status label sits at the right end of the bar. */
.brandbar .brand { margin-left: auto; text-align: right; }
/* Logo + company name grouped at the left of the bar. */
.brandmark {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.topbar .logo {
  height: 40px;
  width: auto;
  display: block;
  flex: none;
}
.company-name {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.2px;
  color: var(--brand-navy);
  white-space: nowrap;
}
/* On phones, shrink the labels so the logo + company name + status line stays
   compact; the status text may wrap to a second line on the narrowest screens. */
@media (max-width: 480px) {
  .brandmark { gap: 7px; }
  .topbar .logo { height: 32px; }
  .company-name { font-size: 0.9rem; }
  .brandbar .brand { font-size: 0.8rem; }
}
.brand {
  font-weight: 700;
  letter-spacing: 0.2px;
  font-size: 0.95rem;
}

main.wrap { padding-top: 14px; padding-bottom: 28px; }

.muted { color: var(--muted); }
.hidden { display: none !important; }

/* States */
.state {
  text-align: center;
  padding: 64px 20px;
}
.message-icon { font-size: 2.6rem; margin-bottom: 8px; }
.state h1 { font-size: 1.3rem; margin: 8px 0; }

.spinner {
  width: 34px; height: 34px;
  margin: 0 auto 14px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Header block */
.order-head {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(16px, 5vw, 22px);
  margin-bottom: 18px;
}
.order-head .customer {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin: 0 0 4px;
}
.order-head h1 {
  font-size: clamp(1.25rem, 6vw, 1.5rem);
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px 10px;
  flex-wrap: wrap;
  /* A long mold id should wrap rather than force horizontal scroll. */
  overflow-wrap: anywhere;
}
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(31, 111, 235, 0.12);
  color: var(--brand);
}
.badge.urgent { background: rgba(214, 69, 69, 0.12); color: var(--urgent); }

/* Tested count — right-aligned on the title line, only shown once QC is done. */
.order-head h1 .tested {
  margin-left: auto;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--done);
}
.order-head h1 .tested b { font-weight: 800; }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
  margin-top: 6px;
}
.meta .item { min-width: 0; }
.meta .item .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}
.meta .item .value { font-weight: 600; }

/* Progress bar */
.progress-wrap { margin: 18px 0 4px; }
.progress-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  font-size: 0.82rem;
}
.progress-top .pct { font-weight: 700; font-size: 0.9rem; }
.bar {
  height: 10px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #4c8dff);
  border-radius: 999px;
  transition: width 0.5s ease;
}

/* Stages */
.stages {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px clamp(16px, 5vw, 22px);
}
.stages h2 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin: 16px 0 4px;
}
/* Stages laid out as compact chips that sit side-by-side and wrap to the
   next line only when they run out of horizontal room. */
.stage-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0 12px;
}
.stage {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  max-width: 100%;
}
.stage .name {
  font-size: 0.8rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}
/* Colour is the only state cue now that there is no marker dot:
   done = green tint, in progress = orange tint, pending = muted grey. */
.stage.done {
  border-color: rgba(26, 158, 95, 0.35);
  background: rgba(26, 158, 95, 0.1);
}
.stage.done .name { color: var(--ink); }
.stage.in_progress {
  border-color: var(--progress);
  background: rgba(224, 138, 30, 0.1);
}
.stage.in_progress .name { color: var(--progress); }
.stage.pending .name { color: var(--muted); font-weight: 500; }

/* Part-based molds: one card per part */
.part-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px 14px 10px;
  margin: 12px 0;
  background: #fbfcfe;
}
.part-head {
  padding: 12px 0 4px;
}
.part-name { font-weight: 700; font-size: 0.9rem; }
.part-card .stage-grid { padding-bottom: 6px; }

.foot { padding-top: 8px; padding-bottom: 28px; text-align: center; font-size: 0.8rem; }

/* Lobby (root URL) — branded welcome, no data */
.lobby {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 24px;
  padding-bottom: 24px;
}
.lobby-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(28px, 8vw, 44px);
  text-align: center;
  width: 100%;
}
.lobby-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.lobby-logo {
  height: 56px;
  width: auto;
  display: block;
  flex: none;
}
.lobby-card .company,
.lobby-card .company:link,
.lobby-card .company:visited,
.lobby-card .company:active,
.lobby-card .company:focus {
  display: inline-block;
  font-size: clamp(0.9rem, 3.6vw, 1.05rem);
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.3;
  overflow-wrap: anywhere;
  text-align: left;
}
/* Only tint on devices with a real pointer, so a mobile tap doesn't leave it stuck. */
@media (hover: hover) {
  .lobby-card .company:hover { color: var(--brand); }
}
.lobby-card .portal {
  margin: 24px 0 0;
  font-size: clamp(1.2rem, 5vw, 1.45rem);
  color: var(--brand);
  font-weight: 800;
  font-style: italic;
  letter-spacing: 0.2px;
  line-height: 1.2;
}
.lobby-card .note {
  margin: 22px 0 0;
  font-size: 0.95rem;
}
.lobby-card .note a,
.lobby-card .note a:link,
.lobby-card .note a:visited,
.lobby-card .note a:active,
.lobby-card .note a:focus {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1px;
}
@media (hover: hover) {
  .lobby-card .note a:hover { color: var(--brand); border-bottom-color: var(--brand); }
}
