/* Paws' Pantry staff dashboard (v2). Builds on b2b.css tokens.
   Compact density: 14px base, 32px controls, 44px table rows. */

body.staff {
  --control-height: 32px;
  --side-w: 212px;
  --row-h: 44px;
  --hover: rgba(255, 255, 255, 0.025);
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  font-size: 14px;
  line-height: 1.45;
}

/* Compact versions of the shared components */
.staff .btn {
  padding: 0 12px;
  gap: 6px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
}
.staff .btn-primary { font-weight: 600; }
.staff .btn svg { width: 15px; height: 15px; }
.staff .btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 6px; }
.staff .btn-ghost { color: var(--text-muted); }
.staff .btn-ghost.danger { color: var(--red); }
.staff .btn-ghost.danger:hover { background: var(--red-soft); }
.staff .input {
  padding: 0 10px;
  border-radius: 7px;
  background: var(--bg);
  font-size: 13px;
}
.staff select.input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236f7571' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
  cursor: pointer;
}
.staff .badge {
  height: 20px;
  padding: 0 7px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 500;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-raised); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

.ic { width: 16px; height: 16px; flex: none; }
.grow { flex: 1; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }

/* Sidebar */
.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px 10px 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 18px;
}
.brand img { width: 26px; height: 26px; }
.brand-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--text-faint); line-height: 1.3; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font: 500 13px var(--font-sans);
  text-align: left;
  cursor: pointer;
}
.nav-item .ic { color: var(--text-faint); }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--surface-raised); color: var(--text); }
.nav-item[aria-current="page"] .ic { color: var(--text-muted); }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.nav-item .count.hot {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--amber-soft);
  color: var(--amber);
  text-align: center;
  line-height: 18px;
  font-weight: 600;
}

.me {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 4px 0 8px;
  border-top: 1px solid var(--border);
}
.avatar {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  flex: none;
}
.me-name { flex: 1; font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Main frame */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  margin: 8px 8px 8px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}
.top {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.top h1 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.005em; }
.sim {
  margin-left: auto;
  padding: 3px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text-faint);
  font-size: 12px;
  white-space: nowrap;
}
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* Toolbar, tabs, search */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font: 500 13px var(--font-sans);
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { background: var(--hover); color: var(--text); }
.tab[aria-pressed="true"] { background: var(--surface-raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }
.tab .n { color: var(--text-faint); font-size: 12px; font-variant-numeric: tabular-nums; }

.search { position: relative; width: 240px; flex: none; }
.search .ic { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-faint); pointer-events: none; }
.search .input { padding-left: 30px; }
.search.full { width: 100%; }

/* Tables */
.split { flex: 1; min-height: 0; display: flex; }
.list-pane { flex: 1; min-width: 0; overflow: auto; container-type: inline-size; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 34px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
.table td {
  height: var(--row-h);
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: var(--hover); }
.table tbody tr[aria-selected="true"] td { background: var(--surface-raised); }
.table tbody tr[aria-selected="true"] td:first-child { box-shadow: inset 2px 0 0 var(--green); }
.table .r { text-align: right; }
.c-id { color: var(--text-muted); font-variant-numeric: tabular-nums; width: 1%; }
.c-cust { font-weight: 500; }
.c-items { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.c-method { color: var(--text-muted); }
.c-win { font-variant-numeric: tabular-nums; }
.flags { display: flex; gap: 4px; }
.flag {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
}
.flag.allergy { color: var(--red); border-color: rgba(255, 123, 107, 0.3); }
tr.is-closed .c-cust, tr.is-closed .c-win { color: var(--text-muted); }

@container (max-width: 700px) {
  .c-items, .c-method { display: none; }
}
@container (max-width: 560px) {
  .c-flags { display: none; }
}

.empty { padding: 48px 20px; color: var(--text-faint); font-size: 13px; text-align: center; }

/* Order detail */
.detail {
  width: 460px;
  flex: none;
  min-height: 0;
  overflow: auto;
  border-left: 1px solid var(--border);
}
@media (max-width: 1360px) { .detail { width: 440px; } }

.d-head { padding: 16px 20px 0; }
.d-row { display: flex; align-items: center; gap: 8px; }
.d-num { color: var(--text-faint); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.d-row .icon-btn { margin-left: auto; margin-right: -6px; }
.d-head h2 { margin: 6px 0 2px; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.d-meta { color: var(--text-muted); font-size: 13px; }

.d-track { padding: 22px 20px 16px; }
.tracker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0;
  padding: 0;
  list-style: none;
}
.tracker li {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.tracker li::before {
  content: "";
  position: absolute;
  top: 7px;
  right: 50%;
  width: 100%;
  height: 2px;
  background: var(--border-strong);
}
.tracker li:first-child::before { display: none; }
.tracker li.done::before { background: var(--green); }
.tracker .dot {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin-bottom: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
}
.tracker .dot svg { width: 10px; height: 10px; color: var(--on-green); opacity: 0; }
.tracker li.done .dot { background: var(--green); border-color: var(--green); }
.tracker li.done .dot svg { opacity: 1; }
.tracker li.current .dot { box-shadow: 0 0 0 4px var(--green-soft); }
.tracker .lbl { font-size: 12.5px; color: var(--text-faint); line-height: 1.3; }
.tracker li.done .lbl { color: var(--text-muted); }
.tracker li.current .lbl { color: var(--text); font-weight: 600; }
.tracker .when { min-height: 16px; white-space: nowrap; font-size: 11.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

.tracker.off li.done::before { background: var(--text-faint); }
.tracker.off li.done .dot { background: var(--text-faint); border-color: var(--text-faint); }
.tracker.off li.done .dot svg { color: var(--surface); }
.tracker.off li.current .dot { box-shadow: none; }
.tracker.off .lbl, .tracker.off li.current .lbl { color: var(--text-faint); font-weight: 400; }
.cancel-line { margin-top: 14px; font-size: 12.5px; color: var(--text-muted); text-align: center; }

.d-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 2px;
  margin-top: 18px;
}
.d-actions .btn-primary { margin-right: 8px; }
.d-actions .btn-ghost { padding: 0 8px; }
.d-actions .danger { margin-left: auto; }

.sec { padding: 16px 20px; border-top: 1px solid var(--border); }
.sec-h {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  margin: -4px 0 8px;
}
.sec-h h3 { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.sec-h .meta { margin-left: auto; font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.sec-h .btn + .btn { margin-left: 2px; }
.sec-h .meta + .btn, .sec-h .push { margin-left: auto; }

/* Item rows */
.items { margin: 0 -8px; padding: 0; list-style: none; }
.it {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 5px 8px;
  border-radius: 7px;
}
.it:hover { background: var(--hover); }
.thumb {
  display: block;
  width: 32px;
  height: 32px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb img.drawn { object-fit: contain; padding: 10%; }
.it-name { font-size: 13px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.it-pkg { font-size: 12px; color: var(--text-faint); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.it-qty { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; min-width: 22px; text-align: right; }
.it.is-packed .it-name { color: var(--text-muted); }
.it.zero { opacity: 0.45; }
.it .badge { margin-left: 6px; vertical-align: 1px; height: 18px; font-size: 11px; }

.chk {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}
.chk:hover:not(:disabled) { border-color: var(--text-faint); }
.chk:checked {
  border-color: var(--green);
  background: var(--green) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2304140a' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 11px no-repeat;
}
.chk:disabled { cursor: default; opacity: 0.45; }
.chk:disabled:checked { opacity: 0.55; }

.stepper {
  display: inline-flex;
  align-items: center;
  height: 26px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
}
.stepper button {
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: 500 14px var(--font-sans);
  cursor: pointer;
}
.stepper button:hover:not(:disabled) { color: var(--text); }
.stepper button:disabled { color: var(--text-faint); opacity: 0.4; cursor: default; }
.stepper output { min-width: 20px; font-size: 12.5px; text-align: center; font-variant-numeric: tabular-nums; }
.add-row { margin-top: 8px; }

/* Key/value lists */
.kv {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 7px 12px;
  margin: 0;
  font-size: 13px;
}
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv dd.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; overflow-wrap: normal; }

/* Notes */
.notes { display: flex; flex-direction: column; gap: 12px; }
.note-meta { font-size: 12px; color: var(--text-faint); margin-bottom: 2px; }
.note-text { font-size: 13px; }
.note-add { display: flex; gap: 6px; margin-top: 12px; }

/* History */
.hist { margin: 0; padding: 0; list-style: none; font-size: 12.5px; }
.hist li {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  gap: 12px;
  padding: 5px 0;
}
.hist .t { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.hist .by { color: var(--text-faint); white-space: nowrap; }

/* Chats */
.chats {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 290px;
}
@media (max-width: 1360px) { .chats { grid-template-columns: 272px minmax(0, 1fr) 264px; } }
.c-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); }
.c-list .toolbar { padding: 10px 12px; }
.c-rows { flex: 1; min-height: 0; overflow: auto; }
.c-row {
  display: block;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.c-row:hover { background: var(--hover); }
.c-row[aria-current="true"] { background: var(--surface-raised); box-shadow: inset 2px 0 0 var(--green); }
.c-row-top { display: flex; align-items: center; gap: 8px; }
.c-row-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-row-time { margin-left: auto; font-size: 12px; color: var(--text-faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.c-row-prev { margin-top: 4px; font-size: 12.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.c-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.c-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.c-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.c-head .lang { font-size: 12px; color: var(--text-faint); }
.c-head .btn { margin-left: auto; }

.msgs { flex: 1; min-height: 0; overflow: auto; padding: 20px 24px 12px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 78%; }
.msg.assistant, .msg.staff { align-self: flex-end; align-items: flex-end; }
.m-meta { font-size: 11.5px; color: var(--text-faint); margin: 0 2px 4px; }
.bubble {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  font-size: 13.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.msg.assistant .bubble { background: transparent; border-color: var(--border-strong); }
.msg.staff .bubble { background: var(--green-soft); border-color: rgba(57, 255, 122, 0.22); }
.tr {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12.5px;
}
.tr b { margin-right: 6px; color: var(--text-faint); font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em; }
.sys { align-self: center; font-size: 12px; color: var(--text-faint); }
.sys.warn { color: var(--amber); }

.composer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex: none;
}
.composer .input { height: 34px; }
.composer .btn { height: 34px; }

.c-info { min-height: 0; overflow: auto; border-left: 1px solid var(--border); }
.c-info .sec:first-child { border-top: 0; }
.c-info .kv { grid-template-columns: 84px minmax(0, 1fr); }
.i-name { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.link-order {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.link-order:hover { background: var(--hover); border-color: var(--border-strong); }
.link-order .top-line { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; }
.link-order .top-line .badge { margin-left: auto; }
.link-order .sub { font-size: 12px; color: var(--text-muted); }

/* Stock */
.stock-tools .input.select { width: 220px; flex: none; }
.t-thumb { width: 1%; }
.t-thumb .thumb { width: 30px; height: 30px; }
.t-name { font-weight: 500; }
.clip-cell { display: block; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.t-pkg, .t-group { color: var(--text-muted); }
.stock-table tbody tr { cursor: default; }
.seg {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
}
.seg button {
  height: 24px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-faint);
  font: 500 12px var(--font-sans);
  cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"].in_stock { background: var(--green-soft); color: var(--green-text); }
.seg button[aria-pressed="true"].low { background: var(--amber-soft); color: var(--amber); }
.seg button[aria-pressed="true"].out { background: var(--red-soft); color: var(--red); }
@container (max-width: 760px) { .t-group { display: none; } }

/* Modal */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
}
.dialog {
  width: 380px;
  max-width: calc(100vw - 32px);
  padding: 20px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-raised);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.dialog h2 { margin: 0; font-size: 15px; font-weight: 600; }
.dialog p { margin: 6px 0 0; font-size: 13px; color: var(--text-muted); }
.dialog label { display: block; margin: 16px 0 6px; font-size: 12px; color: var(--text-faint); }
.dialog .btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.staff .mock-toast { font-size: 13px; padding: 8px 14px; }

/* Print: order detail only */
@media print {
  body.staff { display: block; height: auto; overflow: visible; background: #fff; color: #000; }
  .side, .top, .toolbar, .list-pane, .d-actions, .note-add, .mock-toast, #modal, .d-row .icon-btn { display: none !important; }
  .main, .detail { margin: 0; border: 0; width: auto; overflow: visible; background: #fff; }
  .split { display: block; }
  .sec { border-color: #ccc; }
  .d-meta, .kv dt, .hist .t, .hist .by, .it-pkg, .note-meta, .sec-h h3 { color: #444 !important; }
}
