/* Yi Xing Goldsmith palette (yixinggoldsmith.com): teal #006771, logo gold #FBC327, accent red #CE1717 */
:root {
  --teal: #006771;
  --teal-dark: #004d55;
  --teal-soft: #e6f0f1;
  --gold: #fbc327;
  --gold-soft: #fff4d6;
  --red: #ce1717;
  --red-soft: #fbdede;
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #1d1d1d;
  --muted: #6b7478;
  --line: #e2e8ea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 55, 60, .06), 0 4px 16px rgba(0, 55, 60, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--teal); }
h1 { font-size: 26px; font-weight: 800; margin: 0 0 2px; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 800; margin: 0 0 12px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.blank { color: #b8c0c3; }

.container { max-width: 1280px; margin: 0 auto; padding: 24px 16px 48px; }

/* ---------------------------------------------------------------- top bar */
.topbar { background: var(--surface); border-bottom: 3px solid var(--teal); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; min-width: 0; }
.brand img { height: 28px; width: auto; display: block; }
.brand-sub { color: var(--teal); font-weight: 800; font-size: 15px; border-left: 1px solid var(--line); padding-left: 12px; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-right form { margin: 0; }
.team-badge { background: var(--teal-soft); color: var(--teal); font-weight: 700; font-size: 13px; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.link-btn { background: none; border: 0; color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; padding: 4px; }
.link-btn:hover { color: var(--red); }

/* ---------------------------------------------------------------- login */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.login-page { background: linear-gradient(160deg, var(--teal) 0%, var(--teal-dark) 100%); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 18px; padding: 32px 28px; box-shadow: 0 20px 50px rgba(0, 0, 0, .18); border-top: 5px solid var(--gold); }
.login-logo { height: 40px; width: auto; display: block; margin-bottom: 20px; }
.login-card h1 { font-size: 22px; }
.login-card form { margin-top: 20px; display: flex; flex-direction: column; }
.login-card label { font-weight: 700; font-size: 13px; margin: 12px 0 6px; }
.login-card input { font: inherit; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fafcfc; }
.login-card input:focus { outline: 2px solid var(--teal); outline-offset: -1px; background: #fff; }
.login-foot { color: rgba(255, 255, 255, .7); font-size: 13px; margin-top: 20px; }
.alert { background: var(--red-soft); color: var(--red); border-radius: 10px; padding: 10px 12px; font-size: 14px; font-weight: 600; margin-top: 16px; }
.btn-primary { margin-top: 22px; background: var(--teal); color: #fff; border: 0; border-radius: 10px; padding: 12px; font: inherit; font-weight: 800; cursor: pointer; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-primary.inline { display: inline-block; text-decoration: none; padding: 10px 18px; }

/* ---------------------------------------------------------------- orders list */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; }
.stat-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat {
  text-align: left; font: inherit; cursor: pointer; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px;
  transition: border-color .15s, box-shadow .15s;
}
.stat:hover { border-color: #b9d3d6; }
.stat.is-active { border-color: var(--teal); box-shadow: 0 0 0 2px var(--teal) inset; }
.stat-num { font-size: 24px; font-weight: 800; color: var(--teal); line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input, .toolbar select { font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.toolbar input { flex: 1 1 260px; min-width: 0; }
.toolbar input:focus, .toolbar select:focus { outline: 2px solid var(--teal); outline-offset: -1px; }

.table-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; }
.table-scroll { overflow: auto; max-height: calc(100vh - 290px); min-height: 240px; }
table.orders { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
.orders th {
  position: sticky; top: 0; z-index: 2; background: var(--teal); color: #fff; text-align: left; font-weight: 700;
  padding: 10px 12px; white-space: nowrap; font-size: 12.5px;
}
.orders td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
.orders td.desc { white-space: normal; min-width: 240px; max-width: 340px; }
.orders tbody.order-group:nth-of-type(even) td { background: #f8fbfb; }
.orders tbody.order-group:hover td { background: #eef6f6; }
.orders .sticky { position: sticky; left: 0; z-index: 1; box-shadow: 1px 0 0 var(--line); min-width: 150px; white-space: normal; }
.orders th.sticky { z-index: 3; }
.orders td.sticky { background: var(--surface); }
.orders td.po { display: table-cell; }
.orders td.po a { font-weight: 800; font-size: 14.5px; text-decoration: none; display: block; margin-bottom: 4px; }
.orders td.po a:hover { text-decoration: underline; }
.orders td.po .muted { display: block; margin-top: 4px; }
.order-group[hidden] { display: none; }

/* status pills — one colour per stage, index = position in the timeline */
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; background: #eceff0; color: #5b6468; }
.small-pill { font-size: 11.5px; padding: 2px 8px; }
.pill.big { font-size: 14px; padding: 6px 14px; }
.st-0 { background: #e3edf7; color: #2f5e8c; }
.st-1 { background: #ede7f6; color: #5e3f94; }
.st-2 { background: var(--gold-soft); color: #7d5800; }
.st-3 { background: #fde9d7; color: #9a4a00; }
.st-4 { background: var(--teal); color: #fff; }
.dot.st-0 { background: #2f5e8c; } .dot.st-1 { background: #5e3f94; } .dot.st-2 { background: #d9a300; }
.dot.st-3 { background: #d9730d; } .dot.st-4 { background: var(--teal); }

.empty-state { text-align: center; padding: 48px 16px; }
.updated { text-align: right; margin-top: 10px; }

/* ---------------------------------------------------------------- order detail */
.back { display: inline-block; text-decoration: none; font-weight: 700; margin-bottom: 14px; }
.order-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 22px; }
.side { display: flex; flex-direction: column; gap: 18px; }

.track-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.eyebrow { margin: 0; color: var(--muted); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.po-title { font-size: 28px; word-break: break-word; }
.current { margin: 18px 0 8px; padding: 12px 14px; border-radius: 12px; background: var(--teal-soft); border-left: 4px solid var(--gold); display: flex; flex-direction: column; }
.current strong { font-size: 18px; color: var(--teal); }

.timeline { list-style: none; margin: 18px 0 0; padding: 0; }
.step { display: grid; grid-template-columns: 40px 1fr auto; gap: 14px; position: relative; padding-bottom: 26px; }
.step:last-child { padding-bottom: 0; }
.step:not(:last-child)::after {
  content: ""; position: absolute; left: 19px; top: 42px; bottom: 2px; width: 2px;
  background: repeating-linear-gradient(to bottom, #c9d3d5 0 4px, transparent 4px 8px);
}
/* connector below a step is solid once the step after it has been reached */
.step.line-done::after { background: var(--teal) !important; }
.step-icon {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: #eef2f3; color: #9aa6aa; border: 2px solid #dfe6e8;
}
.step.done .step-icon { background: var(--teal-soft); color: var(--teal); border-color: var(--teal); }
.step.partial .step-icon { background: var(--gold-soft); color: #7d5800; border-color: var(--gold); border-style: dashed; }
.step.current-step .step-icon { background: var(--teal); color: #fff; border-color: var(--teal); box-shadow: 0 0 0 5px rgba(251, 195, 39, .35); }
.step-body { padding-top: 2px; min-width: 0; }
.step-name { font-weight: 800; font-size: 15px; }
.step.pending .step-name { color: #9aa6aa; }
.step-note { color: var(--muted); font-size: 13px; }
.step.partial .step-note { color: #7d5800; font-weight: 700; }
.step-time { text-align: right; font-weight: 800; font-size: 13.5px; color: var(--text); padding-top: 2px; white-space: nowrap; }
.step-time span { font-weight: 600; color: var(--muted); font-size: 12.5px; }

.kv { display: grid; grid-template-columns: 80px 1fr; gap: 8px 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; font-weight: 700; word-break: break-word; }

.items { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow: auto; }
.items li { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.items li:first-child { border-top: 0; padding-top: 0; }
.item-main { display: flex; flex-direction: column; min-width: 0; }
.item-desc { font-weight: 600; word-break: break-word; }
.item-note {
  margin-top: 8px; padding: 8px 10px; background: var(--gold-soft); border-radius: 8px;
  font-size: 13px; white-space: pre-line; word-break: break-word; color: #4a3b10;
}
.item-note span { display: block; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: #7d5800; margin-bottom: 2px; }
.orders td.desc { white-space: pre-line; }

/* phone layout of the orders list (the table is desktop-only) */
.order-cards { display: none; list-style: none; margin: 0; padding: 0; }
.order-cards-empty { display: none; }
.order-card[hidden] { display: none !important; }
.order-card a {
  display: block; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 10px;
}
.order-card a:active { background: #eef6f6; }
.oc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.oc-po { font-weight: 800; font-size: 16px; color: var(--teal); word-break: break-all; }
.oc-items { font-size: 14px; line-height: 1.45; }
.oc-items > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oc-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.oc-foot span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.oc-foot span:last-child { white-space: nowrap; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1000px) {
  .stat-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .order-layout { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  h1 { font-size: 22px; }
  .container { padding: 16px 16px 40px; }
  .hide-m { display: none; }
  .topbar-inner { padding: 8px 16px; }
  .brand img { height: 24px; }
  .brand-sub { display: none; }
  .team-badge { font-size: 12px; padding: 3px 8px; }

  /* status tiles become one swipeable row of chips */
  .stat-row { display: flex; overflow-x: auto; gap: 8px; margin: 0 -16px 12px; padding: 2px 16px 6px; scrollbar-width: none; }
  .stat-row::-webkit-scrollbar { display: none; }
  .stat { flex: none; flex-direction: row; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; box-shadow: none; }
  .stat-num { font-size: 16px; }
  .stat-label { font-size: 13px; white-space: nowrap; }

  .toolbar input { flex-basis: 100%; }
  .toolbar select { flex: 1; }
  .table-card { display: none; }
  .order-cards { display: block; }
  .order-cards-empty { display: block; }
  .order-cards-empty[hidden] { display: none; }
  .updated { text-align: center; }

  .back { margin-bottom: 10px; }
  .order-layout, .side { gap: 12px; }
  .card { padding: 16px; }
  .track-head { align-items: center; }
  .eyebrow { font-size: 12px; }
  .po-title { font-size: 22px; }
  .pill.big { font-size: 12.5px; padding: 4px 10px; }
  .current { margin: 14px 0 4px; padding: 10px 12px; }
  .current strong { font-size: 16px; }
  .timeline { margin-top: 14px; }
  .step { grid-template-columns: 34px 1fr auto; gap: 12px; padding-bottom: 20px; }
  .step:not(:last-child)::after { left: 16px; top: 36px; }
  .step-icon { width: 34px; height: 34px; }
  .step-icon svg { width: 17px; height: 17px; }
  .step-name { font-size: 14.5px; }
  .step-time { font-size: 12.5px; }
  .step-time span { font-size: 12px; }
  .items { max-height: none; }
  .items li { flex-direction: column; gap: 6px; }
}
