:root {
  --bg: #f5f3ee; --surface: #ffffff; --line: #e4e0d6; --text: #1d1c19; --muted: #6d6a62;
  --accent: #2f4a3a; --accent-soft: #e3ebe5;
  --green: #2e6b45; --green-bg: #e2f0e6; --amber: #8a5a00; --amber-bg: #fbeccc; --red: #a3302f; --red-bg: #f7e1df; --grey-bg: #ecebe6;
  --bar: #c9d6cd; --bar-ship: #e0a93b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151614; --surface: #1d1f1c; --line: #30332e; --text: #ecebe6; --muted: #a09d94;
    --accent: #a8c7b2; --accent-soft: #26332b;
    --green: #8fd0a4; --green-bg: #1f3326; --amber: #f2c46d; --amber-bg: #3a2f17; --red: #f0a19c; --red-bg: #3b2120; --grey-bg: #2a2c28;
    --bar: #3b4d41; --bar-ship: #b9852a;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
button, input { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; padding: 20px 24px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.brand .sub { color: var(--muted); font-size: 13px; }
.sync { text-align: right; font-size: 12px; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--green); }
.dot.warn { background: var(--amber); }

main { padding: 16px 24px 48px; max-width: 1500px; margin: 0 auto; }
.daynav { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.daypick { display: flex; gap: 6px; align-items: center; }
.daypick button, .daypick input { height: 36px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 0 12px; cursor: pointer; }
.daypick #prev, .daypick #next { font-size: 20px; line-height: 1; width: 36px; padding: 0; }
.daypick .ghost { background: transparent; }
.search { position: relative; flex: 1; max-width: 420px; }
.search input { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; background: var(--surface); }
.results { position: absolute; top: 40px; left: 0; right: 0; z-index: 20; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 360px; overflow: auto; }
.results button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.results button:hover { background: var(--accent-soft); }
.pad { padding: 10px 12px; }

.strip { display: grid; grid-template-columns: repeat(30, minmax(0, 1fr)); gap: 3px; margin: 16px 0; padding: 12px 14px 10px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.bar { border: 0; background: none; padding: 2px 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; border-radius: 6px; }
.bar:hover, .bar.on { background: var(--accent-soft); }
.bar { position: relative; }
.bar .check-dot { position: absolute; top: -9px; right: -7px; z-index: 1; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #d93025; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--surface); }
.bar .n { font-size: 11px; color: var(--muted); height: 15px; }
.bar .col { position: relative; width: 70%; height: 56px; display: flex; align-items: flex-end; }
.bar .fill { width: 100%; background: var(--bar); border-radius: 3px 3px 0 0; min-height: 1px; }
.bar .ship { position: absolute; left: 0; bottom: 0; width: 100%; background: var(--bar-ship); border-radius: 3px 3px 0 0; }
.bar.on .fill { background: var(--accent); }
.bar .d { font-size: 10px; line-height: 1.2; color: var(--muted); text-align: center; }

.cards { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.card .k { font-size: 12px; color: var(--muted); }
.card .v { font-size: 24px; font-weight: 650; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.card .s { font-size: 12px; color: var(--muted); min-height: 18px; }
.card.amber { border-color: var(--bar-ship); background: var(--amber-bg); }

.filters { display: flex; gap: 6px; margin: 16px 0 8px; flex-wrap: wrap; }
.filters button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.filters button span { color: var(--muted); margin-left: 4px; }
.filters button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.filters button[aria-selected="true"] span { color: inherit; opacity: .8; }

.tablewrap { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; }
table.orders { width: 100%; border-collapse: collapse; }
.orders th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.orders td { padding: 8px 12px; vertical-align: top; }
.orders tbody tr { cursor: pointer; }
.orders tbody tr:hover { background: var(--accent-soft); }
.orders tr.cancelled td { opacity: .55; }
.orders .name { font-weight: 650; white-space: nowrap; }
.orders .time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.orders .items { min-width: 280px; }
.orders .line .var { color: var(--muted); }
.orders .qty { font-weight: 650; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.trk { white-space: nowrap; font-size: 13px; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.tags span { font-size: 11px; font-weight: 500; background: var(--grey-bg); border-radius: 4px; padding: 0 5px; }
.note { margin-top: 6px; font-size: 12px; background: var(--amber-bg); color: var(--text); border-radius: 6px; padding: 4px 8px; white-space: pre-wrap; }
.note.big { font-size: 13px; margin: 10px 0; }
.flags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.flag { font-size: 11px; border-radius: 4px; padding: 1px 6px; background: var(--grey-bg); }
.flag.small, .flag.cancel, .flag.risk { background: var(--red-bg); color: var(--red); }
.flag.asl { background: var(--accent-soft); color: var(--accent); }
.flag.intl { background: var(--grey-bg); }
.pill { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 1px 9px; white-space: nowrap; }
.pill.sm { font-size: 11px; padding: 0 6px; font-weight: 500; }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.grey { background: var(--grey-bg); color: var(--muted); }
.empty { padding: 24px; text-align: center; color: var(--muted); margin: 0; }

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 30; }
.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: var(--surface); z-index: 40; overflow-y: auto; box-shadow: -8px 0 32px rgba(0,0,0,.18); }
.panel-inner { padding: 20px 24px 40px; }
.phead { display: flex; justify-content: space-between; align-items: flex-start; }
.phead h2 { margin: 0; font-size: 22px; }
.close { border: 0; background: var(--grey-bg); width: 32px; height: 32px; border-radius: 8px; font-size: 20px; cursor: pointer; }
.pills { display: flex; gap: 6px; margin: 10px 0; }
.panel section { border-top: 1px solid var(--line); padding: 12px 0; }
.panel h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.panel table { width: 100%; border-collapse: collapse; }
.panel td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.panel .lines img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; background: var(--grey-bg); }
.panel .lines tr.fee { opacity: .6; }
.panel dl { display: grid; grid-template-columns: 150px 1fr; gap: 4px 12px; margin: 0; }
.panel dt { color: var(--muted); }
.panel dd { margin: 0; overflow-wrap: anywhere; }
.box { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; }
.log { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.log li { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.addr { line-height: 1.6; }

/* Step buttons: a 6-step stepper joined by a line */
.stepper { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 14px; position: relative; }
.stepper::before { content: ""; position: absolute; left: 10%; right: 10%; top: 31px; height: 2px; background: var(--line); z-index: 0; }
.step { position: relative; z-index: 1; display: flex; }
.step-card { width: 100%; text-align: left; font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 3px; box-shadow: 0 1px 2px rgba(0,0,0,.04);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.step-btn { cursor: pointer; }
.step-btn:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.step-btn:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; border-color: var(--accent); }
.step-btn:active:not(:disabled) { transform: translateY(0); }
.step-btn:disabled { cursor: wait; }
.step-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.badge { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px;
  background: var(--accent-soft); color: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); flex: none; }
.ico svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); display: block; }
.step-title { font-weight: 700; font-size: 15px; letter-spacing: -0.005em; }
.step-desc { font-size: 12.5px; color: var(--muted); }
.qc-list { margin: 6px 0 0; padding-left: 18px; font-size: 12px; color: var(--red); }
.step-status { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--muted); min-height: 18px; font-variant-numeric: tabular-nums; }
.step-status b { color: var(--text); font-weight: 600; }
.auto { background: transparent; border-style: dashed; box-shadow: none; }
.auto-tag { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 1px 8px; }
.step-card.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.step-card.primary .badge { background: var(--surface); color: var(--accent); box-shadow: none; }
.step-card.primary .ico svg, .step-card.primary .step-desc, .step-card.primary .step-status, .step-card.primary .step-status b { color: inherit; }
.step-card.primary .step-desc, .step-card.primary .step-status { opacity: .85; }
.step-card.primary .step-status { border-top-color: rgba(255,255,255,.3); }
/* states set by action-buttons-and-write-preview.js */
.step.is-done .badge { background: var(--green); color: var(--surface); }
.step.is-done .step-card.primary .badge { background: var(--surface); color: var(--green); }
.step.is-warn .badge { background: var(--amber-bg); color: var(--amber); }
.step.is-running .badge { font-size: 0; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; box-shadow: none; }
.step.is-running .step-card { border-color: var(--accent); }
.step.is-failed .badge { background: var(--red-bg); color: var(--red); }
.stepper.busy .step-btn:not(.running) { opacity: .55; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .step-card { transition: none; } .step.is-running .badge { animation: none; } }
.jobwrap { margin-top: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.jobline { display: inline; font-size: 13px; }
.jobline.run b { color: var(--amber); } .jobline.ok b { color: var(--green); } .jobline.bad b { color: var(--red); }
.linkish { border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 12px; margin-left: 8px; text-decoration: underline; }
.joblog { white-space: pre-wrap; font-size: 12px; max-height: 260px; overflow: auto; background: var(--grey-bg); border-radius: 6px; padding: 8px; margin: 8px 0 0; }
.pv-dialog { position: fixed; z-index: 50; top: 5vh; left: 50%; transform: translateX(-50%); width: min(860px, 94vw); max-height: 90vh; overflow: auto; background: var(--surface); border-radius: 12px; padding: 18px 22px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.pv-dialog h3 { margin: 0 0 10px; } .pv-dialog h4 { margin: 14px 0 6px; } .pv-dialog h4.bad { color: var(--red); }
.pv { width: 100%; border-collapse: collapse; font-size: 13px; } .pv td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.pv-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.pv-actions button { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 14px; cursor: pointer; font-weight: 600; }
.pv-actions .primary { background: var(--accent); color: var(--surface); border-color: var(--accent); }

/* Step 6: partner tab (partner-push-tab.js) */
.step.is-open .step-card { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.partners { margin-top: 16px; }
.partners-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 12px; }
.partners-head h2 { margin: 0 0 2px; font-size: 18px; }
.partners-head p { margin: 0; max-width: 760px; }
.back { flex: none; height: 34px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 0 12px; cursor: pointer; }
.partner-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.pcard { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.pcard h3 { margin: 0; }
.pcard-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pcard-top .wh { font-size: 15px; padding: 2px 12px; }
.pnums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pnums div { display: flex; flex-direction: column; }
.pnums b { font-size: 22px; font-variant-numeric: tabular-nums; }
.pnums span { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.warnbox { background: var(--amber-bg); color: var(--text); border-radius: 8px; padding: 6px 10px; margin: 0; }
.pbtn { margin-top: auto; height: 40px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; font: inherit; font-weight: 650; cursor: pointer; }
.pbtn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.pbtn:disabled { cursor: not-allowed; color: var(--muted); background: var(--grey-bg); }
.pbtn:hover:not(:disabled) { border-color: var(--accent); }

/* Warehouse column */
.stocknote { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.orders tr.cont td { border-top: 0; }
.orders tr.first td { border-top: 1px solid var(--line); }
.orders td.name { width: 190px; border-right: 1px solid var(--line); }
.orders td.item { min-width: 280px; }
.orders td.whcell { width: 34%; }
.orders td.trk { border-left: 1px solid var(--line); width: 170px; }
.wh { display: inline-block; font-weight: 650; font-size: 13px; border-radius: 6px; padding: 1px 9px; }
.wh.asl { background: var(--accent-soft); color: var(--accent); }
.wh.speego { background: var(--accent-soft); color: var(--accent); }
.wh.stella, .wh.warn-stella { background: var(--amber-bg); color: var(--amber); }
.wh.warn-stella { outline: 2px solid var(--red); }
.wh.merry { background: var(--grey-bg); color: var(--text); }
.wh.warn { background: var(--red-bg); color: var(--red); }
.wh.grey { background: var(--grey-bg); color: var(--muted); }
.why { font-size: 12px; color: var(--muted); margin-top: 3px; }
.alert { margin-top: 4px; font-size: 12px; font-weight: 650; color: var(--red); background: var(--red-bg); border-radius: 6px; padding: 2px 8px; display: inline-block; }

@media (max-width: 1000px) {
  .stepper { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stepper::before { display: none; }
  .partner-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .strip { grid-template-columns: repeat(15, minmax(0, 1fr)); }
  .strip .bar:nth-child(-n+15) { display: none; }
  main, .top { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 640px) {
  .stepper { grid-template-columns: 1fr; gap: 8px; }
  .partner-grid { grid-template-columns: 1fr; }
  .partners-head { flex-direction: column; }
  .step-card { padding: 10px 12px; }
  .top { flex-direction: column; align-items: flex-start; }
  .sync { text-align: left; }
  .daypick { flex-wrap: wrap; }
  .search { max-width: none; flex-basis: 100%; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strip { grid-template-columns: repeat(10, minmax(0, 1fr)); }
  .strip .bar:nth-child(-n+20) { display: none; }
  .card .v { font-size: 20px; }
  .panel dl { grid-template-columns: 110px 1fr; }
}

/* Step 6 held lines + chat (owner 2026-12-03) */
.pcard.has-held { border: 2px solid var(--red); }
.pnums .held-num b, .pnums .held-num span { color: var(--red); font-weight: 700; }
.held-box { border-top: 1px dashed var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.held-title { margin: 0; font-weight: 700; color: var(--red); font-size: 13px; }
.held-list { margin: 0; padding: 8px 10px 8px 26px; background: var(--red-bg); border-radius: 8px; font-size: 12.5px; }
.partner-grid { align-items: start; }
.held-list { list-style: none; padding-left: 10px; }
.held-list li { margin: 4px 0; } .held-list li div { margin: 2px 0 4px 10px; } .held-list .why { color: var(--red); font-weight: 650; }
.chat-thread { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.chat-thread:empty { display: none; }
.msg { font-size: 12.5px; padding: 6px 9px; border-radius: 8px; background: var(--grey-bg); }
.msg.anh { background: var(--accent-soft); align-self: flex-end; max-width: 90%; }
.msg.claude { align-self: flex-start; max-width: 95%; } .msg.err { background: var(--red-bg); }
.msg .who { display: block; font-size: 11px; color: var(--muted); }
.chat-form { display: flex; gap: 6px; align-items: flex-end; }
.chat-form textarea { flex: 1; resize: vertical; min-height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
.chat-form button { padding: 8px 14px; }
.chat-form button { border: 1px solid var(--accent); background: var(--accent); color: var(--surface); border-radius: 8px; font-weight: 650; cursor: pointer; }
.chat-form button:disabled { opacity: .5; cursor: wait; }

/* Owner 2026-12-03: "Có cờ" chip bold red; orders handled in step 6 turn dark green ("Đã xử lý"). */
.filters button[data-filter="flagged"] { color: var(--red); font-weight: 700; border-color: var(--red); }
.filters button[data-filter="flagged"] span { color: var(--red); }
.filters button[data-filter="flagged"][aria-selected="true"] { background: var(--red); border-color: var(--red); color: #fff; }
.filters button[data-filter="flagged"][aria-selected="true"] span { color: #fff; }
.note.done, .flag.done, .alert.done { background: #1f5c3a; color: #fff; }

/* Tracking countdown (owner 2026-12-03): the longer without tracking, the redder. */
.wait { display: inline-flex; align-items: baseline; gap: 6px; border-radius: 8px; padding: 4px 10px; white-space: normal; line-height: 1.25; }
.wait b { font-size: 18px; font-variant-numeric: tabular-nums; } .wait span { font-size: 12px; }
.wait.t1 { background: var(--grey-bg); color: var(--muted); }
.wait.t2 { background: var(--amber-bg); color: var(--amber); }
.wait.t3 { background: #f7d4d1; color: #a3302f; }
.wait.t4 { background: #d93025; color: #fff; }
.wait.t5 { background: #7f1313; color: #fff; font-weight: 700; }
.ptrk { margin-bottom: 8px; } .ptrk:last-child { margin-bottom: 0; }
.wh-mini { display: block; font-size: 11px; font-weight: 650; color: var(--muted); margin-bottom: 2px; }

/* Step 7 tracking tab (owner 2026-12-03) */
.track-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.track-findings { margin: 0; padding: 8px 10px 8px 24px; background: var(--red-bg); border-radius: 8px; font-size: 12.5px; max-height: 260px; overflow-y: auto; }
.track-ok { background: var(--green-bg); color: var(--green); border-radius: 8px; padding: 6px 10px; margin: 0; font-weight: 650; }
.pv .kind { font-size: 11px; font-weight: 700; border-radius: 6px; padding: 1px 7px; white-space: nowrap; }
.pv .kind.create { background: var(--green-bg); color: var(--green); } .pv .kind.add { background: var(--amber-bg); color: var(--amber); } .pv .kind.protection { background: var(--grey-bg); color: var(--muted); }
@media (max-width: 1000px) { .track-grid { grid-template-columns: 1fr; } }

/* Accounts + roles (owner 2026-12-03, VPS) */
.top { position: relative; }
.me { display: flex; gap: 10px; align-items: center; font-size: 13px; margin-left: 16px; }
.dev-badge { background: var(--amber-bg); color: var(--amber); font-weight: 800; border-radius: 6px; padding: 2px 8px; letter-spacing: .04em; }
.decide { display: inline-flex; gap: 6px; margin-left: 6px; }
.decide button { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 1px 8px; font-size: 12px; cursor: pointer; }
.decide button[data-do="allow"] { border-color: var(--green); color: var(--green); }
.decide button[data-do="skip"] { border-color: var(--red); color: var(--red); }
a.bm { display: inline-block; background: var(--accent); color: var(--surface); border-radius: 6px; padding: 2px 10px; text-decoration: none; font-weight: 700; }
