/* Jawaher shipping desk.
   The page is a dispatch manifest on brushed silver: a white sheet with folder
   tabs, rows grouped by shipping day, a carrier-coloured edge on every row, and
   one bold moment: the green ink stamp a row gets when it is received.
   Type: IBM Plex Sans Arabic throughout, chosen for legibility in dense
   Arabic tables that agents read all day. */

:root {
  --ink: #0d1b3e;            /* Jawaher navy: text, wordmark, primary action */
  --ink-2: #1d2f5c;
  --silver: #e8ebf0;         /* brushed-silver desk */
  --silver-2: #dde2ea;
  --sheet: #ffffff;          /* the manifest */
  --rule: #d5dbe5;
  --rule-soft: #eceff4;
  --steel: #5b6478;          /* secondary text */
  --stamp: #16774b;          /* received: stamp ink */
  --stamp-bg: #e6f3ec;
  --amber: #b4690e;          /* check the amount / late */
  --amber-bg: #fbf0dc;
  --signal: #b42318;         /* errors */
  --signal-bg: #fbe9e7;
  --prime: #2a5bd7;          /* carrier edges */
  --prime-bg: #e8eefc;
  --oa: #7b3fc4;
  --oa-bg: #f1e9fb;
  --waseet: #b4690e;
  --hl: #fff7e3;
  --on-ink: #ffffff;
  --focus: rgba(42, 91, 215, .35);
  --lift: 0 1px 0 rgba(13, 27, 62, .04), 0 12px 32px -18px rgba(13, 27, 62, .35);
  --font-ui: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  --font-display: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --ink: #e6ebf5; --ink-2: #c9d3e8;
  --silver: #0a1226; --silver-2: #0f1932;
  --sheet: #111b33; --rule: #24314f; --rule-soft: #19243f;
  --steel: #93a0ba;
  --stamp: #56c98d; --stamp-bg: #12301f;
  --amber: #f0b45a; --amber-bg: #33270e;
  --signal: #ff8a7a; --signal-bg: #3a1714;
  --prime: #7ea2ff; --prime-bg: #18264a;
  --oa: #c29bf5; --oa-bg: #26193f;
  --hl: #2a2410;
  --on-ink: #0a1226;
  --focus: rgba(126, 162, 255, .4);
  --lift: 0 1px 0 rgba(0, 0, 0, .3), 0 14px 34px -18px rgba(0, 0, 0, .7);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e6ebf5; --ink-2: #c9d3e8;
    --silver: #0a1226; --silver-2: #0f1932;
    --sheet: #111b33; --rule: #24314f; --rule-soft: #19243f;
    --steel: #93a0ba;
    --stamp: #56c98d; --stamp-bg: #12301f;
    --amber: #f0b45a; --amber-bg: #33270e;
    --signal: #ff8a7a; --signal-bg: #3a1714;
    --prime: #7ea2ff; --prime-bg: #18264a;
    --oa: #c29bf5; --oa-bg: #26193f;
    --hl: #2a2410;
    --on-ink: #0a1226;
    --focus: rgba(126, 162, 255, .4);
    --lift: 0 1px 0 rgba(0, 0, 0, .3), 0 14px 34px -18px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--silver);
  color: var(--ink);
  font: 15px/1.7 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--prime); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
.muted { color: var(--steel); }
.spacer { flex: 1; }
.num { font-variant-numeric: tabular-nums; }
.icon { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
kbd {
  font: 600 11px/1 var(--font-ui); padding: 3px 6px; color: var(--steel);
  border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 5px; background: var(--sheet);
}
:focus-visible { outline: 2px solid var(--prime); outline-offset: 2px; }

/* ------------------------------------------------------------ wordmark */
.logo { display: inline-flex; flex-direction: column; align-items: center; line-height: 1; }
.wordmark {
  direction: ltr; font: 900 21px/1 "Segoe UI", system-ui, Arial, sans-serif;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink);
}
.logo .sub { font: 500 11px/1 var(--font-ui); color: var(--steel); margin-top: 5px; }
.logo.big .wordmark { font-size: 38px; }
.logo.big .sub { font-size: 13px; margin-top: 9px; }

/* ------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--rule); background: var(--sheet); border-radius: 8px;
  padding: 7px 13px; cursor: pointer; white-space: nowrap; font-weight: 500;
  transition: border-color .15s, background-color .15s;
}
.btn:hover { border-color: var(--steel); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); font-weight: 600; }
.btn.primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--silver-2); }
.btn.icon-only { padding: 7px; }
.btn.small { padding: 4px 10px; font-size: 13px; border-radius: 7px; }
.btn.loading .icon { animation: spin .8s linear infinite; }

.field {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--rule); background: var(--sheet); border-radius: 8px; padding: 0 10px;
}
.field:focus-within { border-color: var(--prime); box-shadow: 0 0 0 3px var(--focus); }
.field input { border: 0; outline: none; background: transparent; padding: 7px 0; min-width: 0; flex: 1; }
.field .icon { color: var(--steel); }
select {
  border: 1px solid var(--rule); background: var(--sheet); border-radius: 8px; padding: 7px 10px;
}
select:focus-visible, input:focus-visible { outline: none; border-color: var(--prime); box-shadow: 0 0 0 3px var(--focus); }

/* --------------------------------------------------------------- chips */
.chip {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 6px;
}
.chip.ok { background: var(--stamp-bg); color: var(--stamp); }
.chip.warn { background: var(--amber-bg); color: var(--amber); }
.chip.bad { background: var(--signal-bg); color: var(--signal); }
.chip.info { background: var(--prime-bg); color: var(--prime); }
.chip.plain { background: var(--rule-soft); color: var(--steel); }
.chip.new { background: var(--prime-bg); color: var(--prime); margin-inline-start: 6px; }
.chip.src-prime { background: transparent; color: var(--prime); padding-inline: 0; }
.chip.src-online_agent { background: transparent; color: var(--oa); padding-inline: 0; }
.chip.src-alwaseet { background: transparent; color: var(--waseet); padding-inline: 0; }
.chip.src-prime::before, .chip.src-online_agent::before, .chip.src-alwaseet::before {
  content: ""; width: 7px; height: 7px; border-radius: 2px; background: currentColor; margin-inline-end: 3px;
}

/* -------------------------------------------------------------- top bar */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 10px clamp(16px, 2.2vw, 40px);
  background: var(--silver); border-bottom: 1px solid var(--rule);
}
.top form { margin: 0; display: flex; }
[data-icon] { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
.top .btn, .top .who { height: 38px; }
.top .btn { padding-block: 0; line-height: 1; }
.top .btn.icon-only { width: 38px; padding: 0; }
.top .who { display: inline-flex; align-items: center; }
.top .avatar { width: 34px; height: 34px; }
.who { display: inline-flex; align-items: center; gap: 8px; color: var(--steel); margin-inline-start: 4px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); color: var(--on-ink); font-weight: 700; font-size: 13px;
}

/* ---------------------------------------------------------------- desk */
.desk { padding: 0 clamp(16px, 2.2vw, 40px) 40px; }

/* masthead: one plain sentence, then a ledger line of figures */
.masthead { padding: 30px 0 18px; }
.headline {
  margin: 0; max-width: 28ch;
  font: 700 clamp(24px, 2.6vw, 32px)/1.4 var(--font-display);
  color: var(--ink); letter-spacing: 0;
}
.ledger {
  display: flex; flex-wrap: wrap; margin-top: 16px;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.ledger-item {
  display: flex; align-items: baseline; gap: 8px; padding: 10px 18px;
  border: 0; border-inline-start: 1px solid var(--rule); background: transparent;
  text-align: start; color: var(--steel); font-size: 14px;
}
.ledger-item:first-child { border-inline-start: 0; padding-inline-start: 0; }
.ledger-item strong { font: 700 19px/1 var(--font-ui); color: var(--ink); font-variant-numeric: tabular-nums; }
.ledger-item.warn strong { color: var(--amber); }
.ledger-item.ok strong { color: var(--stamp); }
button.ledger-item { cursor: pointer; }
button.ledger-item:hover span { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }

/* controls */
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0 10px; }
#search-box { width: 340px; max-width: 100%; }
#search-box .hint { opacity: .8; }
.status {
  display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center;
  padding: 0 0 12px; color: var(--steel); font-size: 13.5px;
}
.status .bad { color: var(--signal); flex-basis: 100%; }

.bulk {
  position: sticky; top: 56px; z-index: 15;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 12px; padding: 9px 14px;
  background: var(--ink); color: var(--on-ink); border-radius: 10px;
}
.bulk .muted { color: inherit; opacity: .75; }
.bulk .btn.primary { background: var(--on-ink); color: var(--ink); border-color: var(--on-ink); }
.bulk .btn.ghost { color: var(--on-ink); }
.bulk .btn.ghost:hover { background: rgba(255, 255, 255, .12); }

/* ------------------------------------------------- the manifest sheet */
.manifest { position: relative; }
.tabs { display: flex; gap: 4px; padding-inline-start: 14px; position: relative; z-index: 1; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font: 600 15px/1.5 var(--font-display); color: var(--steel);
  padding: 9px 18px 8px; border: 1px solid transparent; border-bottom: 0;
  border-radius: 10px 10px 0 0; background: transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.active { background: var(--sheet); color: var(--ink); border-color: var(--rule); }
.count {
  font: 600 12px/1 var(--font-ui); font-variant-numeric: tabular-nums;
  padding: 3px 7px; border-radius: 6px; background: var(--silver-2); color: var(--steel);
}
.tab.active .count { background: var(--ink); color: var(--on-ink); }
.sheet {
  background: var(--sheet); border: 1px solid var(--rule); border-radius: 12px;
  box-shadow: var(--lift); overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: start; white-space: nowrap; vertical-align: middle; }
td { border-bottom: 1px solid var(--rule-soft); }
th {
  position: sticky; top: 0; z-index: 1; background: var(--sheet);
  font-size: 13.5px; font-weight: 600; color: var(--steel);
  border-bottom: 1px solid var(--rule); user-select: none;
}
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--ink); }
th .arrow { font-size: 10px; margin-inline-start: 4px; }
td.num { font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 180px; max-width: 320px; }
tbody tr:hover td { background: var(--rule-soft); }

/* carrier edge: a thin coloured bar on the row's leading side */
tbody tr[class*="src-"] > td:first-child { box-shadow: inset -3px 0 0 var(--edge, transparent); }
tr.src-prime { --edge: var(--prime); }
tr.src-online_agent { --edge: var(--oa); }
tr.src-alwaseet { --edge: var(--waseet); }

/* shipping-day groups */
tr.group td {
  background: var(--silver); border-bottom: 1px solid var(--rule); padding: 7px 14px;
  position: sticky; top: 47px; z-index: 0;
}
tbody tr.group:hover td { background: var(--silver); }
.group-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; color: var(--steel); }
.group-row strong { color: var(--ink); font-weight: 600; }

tr.hl td { background: var(--hl); }
tr.done td { color: var(--steel); }
tr.done td .chip:not(.ok) { opacity: .7; }
tr.done a { color: inherit; }
tr.reviewed td { opacity: .72; }

.case { display: inline-flex; align-items: center; gap: 4px; }
.copy {
  border: 0; background: transparent; color: var(--steel); padding: 2px; border-radius: 5px;
  cursor: pointer; opacity: 0; transition: opacity .15s;
}
tr:hover .copy, .copy:focus-visible { opacity: 1; }
.copy:hover { color: var(--ink); background: var(--rule); }

td.action { min-width: 170px; }
td.sel { width: 36px; }
.result { font-size: 13.5px; display: inline-flex; align-items: center; gap: 6px; }
.result.done { color: var(--stamp); font-weight: 600; }
.result.refused { color: var(--amber); }
.result.error { color: var(--signal); }
.action-stack { display: grid; gap: 6px; justify-items: start; }

/* ------------------------------------------------- the received stamp */
.stamp {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 4px 14px 3px; margin: 4px 2px; transform: rotate(-5deg);
  color: var(--stamp); border: 2.5px solid currentColor; border-radius: 7px;
  outline: 1.5px solid currentColor; outline-offset: 2.5px;
  font: 700 19px/1.25 var(--font-display); opacity: .9;
  mask-image: radial-gradient(circle at 30% 40%, #000 62%, rgba(0, 0, 0, .78) 100%);
}
.stamp small { font: 600 12px/1 var(--font-ui); font-variant-numeric: tabular-nums; }
.stamp-in { animation: stamp-down .42s cubic-bezier(.2, .9, .3, 1.25) both; }
@keyframes stamp-down {
  0% { transform: rotate(-14deg) scale(2.1); opacity: 0; }
  70% { transform: rotate(-4deg) scale(.95); opacity: 1; }
  100% { transform: rotate(-5deg) scale(1); opacity: .9; }
}
.zd-line { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }

.mark-cell { display: inline-flex; gap: 2px; align-items: center; }
.mark-note { font: inherit; font-size: 12.5px; color: var(--steel); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: inline-block; vertical-align: middle; border: 0; background: transparent; padding: 2px 4px; border-radius: 6px; cursor: pointer; text-align: start; }
.mark-note:hover { background: var(--silver-2); color: var(--ink); }
.mark-note strong { color: var(--ink); font-weight: 600; }
.note-btn { position: relative; }
.note-count { position: absolute; top: -3px; inset-inline-end: -4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--prime); color: #fff; font: 700 10px/16px var(--font-ui); text-align: center; }
.note-btn.fu-today, .note-btn.fu-late { color: var(--amber); }
.note-btn.fu-late .note-count, .note-btn.fu-today .note-count { background: var(--amber); }
.fu-chip { font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.fu-chip.late { background: var(--signal-bg); color: var(--signal); }
.fu-chip.today { background: var(--amber-bg); color: var(--amber); }
.fu-chip.soon, .fu-chip.later { background: var(--prime-bg); color: var(--prime); }
#note-filter.alert-due { border-color: var(--amber); color: var(--amber); font-weight: 600; }
.icon-btn {
  border: 0; background: transparent; color: var(--steel); border-radius: 6px; padding: 4px;
  cursor: pointer; display: inline-flex;
}
.icon-btn:hover { background: var(--silver-2); color: var(--ink); }
.icon-btn.on { color: var(--stamp); }
.icon-btn.has-note { color: var(--prime); }

.spin {
  display: inline-block; width: 13px; height: 13px; flex: none;
  border: 2px solid var(--rule); border-top-color: var(--ink); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skel td { padding: 13px 12px; }
.skel span {
  display: block; height: 11px; border-radius: 4px;
  background: linear-gradient(90deg, var(--rule-soft), var(--silver), var(--rule-soft));
  background-size: 200% 100%; animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.empty { text-align: center; color: var(--steel); padding: 56px 16px 64px; }
.empty .icon { color: var(--rule); margin-bottom: 10px; }
.empty strong { display: block; color: var(--ink); font: 600 20px/1.4 var(--font-display); margin-bottom: 6px; }

/* --------------------------------------------------- history drawer */
.scrim { position: fixed; inset: 0; background: rgba(8, 14, 30, .38); z-index: 40; }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; width: min(440px, 100%); z-index: 41;
  background: var(--sheet); border-inline-end: 1px solid var(--rule); box-shadow: var(--lift);
  display: flex; flex-direction: column;
}
.drawer header { display: flex; align-items: center; gap: 8px; padding: 16px 18px; border-bottom: 1px solid var(--rule); }
.drawer header h3 { margin: 0; font: 600 20px/1 var(--font-display); }
.drawer .body { overflow-y: auto; padding: 16px 18px; display: grid; gap: 20px; align-content: start; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 76px; border-bottom: 1px solid var(--rule); }
.bars div { flex: 1; background: var(--ink); opacity: .75; border-radius: 3px 3px 0 0; min-height: 2px; }
.bars div.today { background: var(--stamp); opacity: 1; }
.bars-legend { display: flex; justify-content: space-between; font-size: 11px; color: var(--steel); margin-top: 5px; }
.agents { display: grid; gap: 6px; }
.agents div { display: flex; justify-content: space-between; font-size: 13px; }
.feed { display: grid; }
.feed .item { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; padding: 9px 0; border-bottom: 1px solid var(--rule-soft); font-size: 13px; }
.feed .item .when { color: var(--steel); font-size: 12px; }
.feed .item .msg { grid-column: 2 / 4; color: var(--steel); font-size: 12px; }
.feed .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: var(--steel); }
.feed .dot.done, .feed .dot.zd-tagged { background: var(--stamp); }
.feed .dot.refused, .feed .dot.zd-skipped { background: var(--amber); }
.feed .dot.error, .feed .dot.zd-error { background: var(--signal); }
.feed .dot.zd-already { background: var(--rule); }
.section-title { font-size: 13px; color: var(--steel); font-weight: 600; margin: 0 0 8px; }

/* ------------------------------------------------------------- dialog */
dialog {
  border: 1px solid var(--rule); border-radius: 14px; padding: 0; width: min(460px, calc(100% - 32px));
  background: var(--sheet); color: var(--ink); box-shadow: var(--lift);
}
dialog::backdrop { background: rgba(8, 14, 30, .45); }
dialog .dlg-body { padding: 22px; display: grid; gap: 12px; }
dialog h3 { margin: 0; font: 600 20px/1.35 var(--font-display); }
dialog p { margin: 0; color: var(--steel); }
dialog ul { margin: 0; padding-inline-start: 18px; max-height: 180px; overflow-y: auto; font-size: 13px; }
dialog textarea {
  width: 100%; min-height: 96px; resize: vertical; border: 1px solid var(--rule);
  border-radius: 8px; padding: 9px 11px; background: var(--silver);
}
dialog .dlg-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 22px; border-top: 1px solid var(--rule-soft); }
.alert { padding: 10px 12px; border-radius: 8px; font-size: 13px; text-align: start; }
.alert.bad { background: var(--signal-bg); color: var(--signal); }
.alert.warn { background: var(--amber-bg); color: var(--amber); }
.shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 9px 14px; align-items: center; font-size: 13px; }

/* ------------------------------------------------------------- toasts */
.toasts { position: fixed; bottom: 18px; left: 18px; z-index: 60; display: grid; gap: 8px; width: min(380px, calc(100% - 36px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: 10px;
  background: var(--ink); color: var(--on-ink); box-shadow: var(--lift);
  animation: rise .2s ease-out; font-size: 13.5px;
}
.toast.ok .icon { color: #7fe0a8; }
.toast.warn .icon { color: #ffcf7a; }
.toast.bad .icon { color: #ff9c8f; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all .25s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
:root[data-theme="dark"] .toast.ok .icon { color: var(--stamp); }

/* --------------------------------------------- login: a waybill slip */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; text-align: center; }
.slip {
  position: relative; margin-top: 30px; text-align: start;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: 12px;
  padding: 26px 26px 24px; box-shadow: var(--lift);
}
.slip::before {
  /* the waybill's tear-off edge */
  content: ""; position: absolute; inset-inline: 18px; top: 58px; height: 0;
  border-top: 2px dashed var(--rule);
}
.slip h2 { margin: 0 0 30px; font: 600 19px/1.3 var(--font-display); color: var(--ink); }
.login-card form { display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--steel); }
.login-card .field { border-radius: 10px; padding: 0 12px; }
.login-card .field input { padding: 11px 0; }
.login-card .btn.primary { padding: 12px; border-radius: 10px; font-size: 15px; margin-top: 6px; }
.login-foot { display: flex; justify-content: center; gap: 8px; margin-top: 22px; }

/* ----------------------------------------------- phones: waybill slips */
@media (max-width: 760px) {
  .top { padding: 8px 10px; gap: 2px; }
  .top .who span:not(.avatar) { display: none; }
  .top .wordmark { font-size: 18px; }
  #open-help, .top > .chip { display: none; }
  #open-history > span:last-child, #open-zd > span:last-child, #open-tickets > span:nth-child(2) { display: none; }
  #open-zd, #open-tickets { padding: 7px; position: relative; }
  .top .btn.ghost { padding: 5px; }
  .top .who { display: none; }
  .top .sub { display: none; }
  #open-history { padding: 7px; }
  .desk { padding: 0 14px 28px; }
  .masthead { padding: 20px 0 12px; }
  .headline { font-size: 24px; }
  .ledger { display: grid; grid-template-columns: 1fr 1fr; }
  .ledger-item { padding: 10px 0; border-inline-start: 0; flex-direction: column; gap: 4px; align-items: flex-start; }
  .ledger-item:nth-child(2n) { border-inline-start: 1px solid var(--rule); padding-inline-start: 12px; }
  .ledger-item:nth-child(n + 3) { border-top: 1px solid var(--rule); }
  #search-box { width: 100%; }
  .controls select { flex: 1 1 40%; }
  .controls .spacer { display: none; }
  .bulk { top: 50px; }
  .tabs { padding-inline-start: 6px; overflow-x: auto; scrollbar-width: none; }
  .tab { padding: 10px 12px 9px; font-size: 14px; }
  .sheet { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody tr {
    position: relative; background: var(--sheet); border: 1px solid var(--rule);
    border-radius: 12px; margin-bottom: 10px; padding: 8px 4px; box-shadow: var(--lift);
  }
  tbody tr[class*="src-"] { border-inline-start: 4px solid var(--edge, var(--rule)); }
  tbody tr[class*="src-"] > td:first-child { box-shadow: none; }
  tbody tr:hover td { background: transparent; }
  tr.group { background: transparent; border: 0; box-shadow: none; padding: 10px 2px 4px; margin: 0; }
  tr.group td { position: static; background: transparent; border: 0; padding: 0; }
  td { border: 0; padding: 4px 12px; display: flex; justify-content: space-between; gap: 12px; white-space: normal; }
  td::before { content: attr(data-label); color: var(--steel); font-size: 12px; flex: none; }
  td.sel::before, td.action::before, tr.group td::before { content: none; }
  td.sel { position: absolute; width: auto; padding: 10px; inset-inline-end: 0; top: 0; }
  td.action { min-width: 0; justify-content: flex-start; padding-block: 6px 8px; }
  td.wrap { max-width: none; }
  .copy { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .stamp-in { animation: none; }
}

/* ------------------------------------------------ Prime tickets panel */
#open-tickets { position: relative; }
#open-tickets .badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: inline-grid; place-items: center;
  background: var(--signal); color: #fff; font: 700 11px/1 var(--font-ui);
}
.tickets-drawer { width: min(480px, 100%); }
.tickets-drawer .body { flex: 1; gap: 10px; }
.new-ticket { justify-self: start; }
.ticket-item {
  display: grid; gap: 4px; text-align: start; width: 100%; cursor: pointer;
  padding: 12px 14px; border: 1px solid var(--rule); border-radius: 10px; background: var(--sheet);
}
.ticket-item:hover { border-color: var(--prime); }
.ticket-item.closed { opacity: .7; }
.ticket-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.ticket-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--steel); }
.ticket-latest { font-size: 13.5px; color: var(--steel); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-bottom: 10px; border-bottom: 1px solid var(--rule-soft); }
.thread { display: grid; gap: 10px; padding: 6px 0 4px; }
.msg { max-width: 82%; padding: 9px 12px; border-radius: 12px; display: grid; gap: 3px; }
.msg.mine { justify-self: start; background: var(--ink); color: var(--on-ink); border-start-start-radius: 4px; }
.msg.theirs { justify-self: end; background: var(--silver); color: var(--ink); border-start-end-radius: 4px; }
.msg.auto { opacity: .75; font-style: italic; }
.msg-who { font-size: 12px; opacity: .75; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.composer { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--rule); }
.composer textarea {
  resize: none; border: 1px solid var(--rule); border-radius: 10px; padding: 9px 11px;
  background: var(--sheet); min-height: 44px; max-height: 160px;
}
.composer textarea:focus-visible { outline: none; border-color: var(--prime); box-shadow: 0 0 0 3px var(--focus); }
.composer .btn { align-self: end; }
.composer-note { grid-column: 1 / -1; margin: 0; font-size: 13px; color: var(--steel); }
.ticket-form { display: grid; gap: 12px; }
.ticket-form label { display: grid; gap: 5px; font-size: 13.5px; color: var(--steel); }
.ticket-form input, .ticket-form select, .ticket-form textarea {
  border: 1px solid var(--rule); border-radius: 8px; padding: 8px 10px; background: var(--sheet); color: var(--ink);
}
.ticket-form textarea { resize: vertical; }
.ticket-form .btn { justify-self: start; }
.empty.small { padding: 28px 12px; }
.empty.small strong { font-size: 16px; }

/* row button: Prime ticket for this shipment */
.case-cell { display: inline-flex; align-items: center; gap: 4px; }
.ticket-btn { position: relative; opacity: .45; }
tr:hover .ticket-btn, .ticket-btn.has, .ticket-btn:focus-visible { opacity: 1; }
.ticket-btn.has { color: var(--prime); }
.ticket-btn.open { color: var(--amber); }
.ticket-count { font: 700 11px/1 var(--font-ui); margin-inline-start: 2px; }

.feed .dot.ticket-open, .feed .dot.ticket-msg { background: var(--prime); }

/* ---------------------------------------- waiting for our decision */
.snag-options { display: grid; gap: 8px; max-height: 52vh; overflow-y: auto; }
.snag-option { border: 1px solid var(--rule); border-radius: 10px; padding: 8px 12px; }
.snag-option:has(input:checked) { border-color: var(--prime); background: var(--prime-bg); }
.snag-choice { display: flex; gap: 8px; align-items: center; cursor: pointer; color: var(--ink); }
.snag-fields { display: grid; gap: 8px; padding: 10px 0 4px; }
.snag-fields label { display: grid; gap: 4px; font-size: 13px; color: var(--steel); }
.combo { display: grid; }
.combo-list { list-style: none; margin: 4px 0 0; padding: 4px; max-height: 220px; overflow-y: auto;
  border: 1px solid var(--rule); border-radius: 8px; background: var(--sheet); color: var(--ink); font-size: 14px; }
.combo-list li { padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.combo-list li.on, .combo-list li:hover { background: var(--prime-bg); color: var(--prime); }
.combo-list li.picked { font-weight: 700; }
.combo-list li.picked::after { content: " ✓"; }
.combo-list .combo-empty { color: var(--steel); cursor: default; }
.combo-list .combo-empty:hover { background: none; color: var(--steel); }
.snag-fields input, .snag-fields select, .snag-fields textarea {
  border: 1px solid var(--rule); border-radius: 8px; padding: 7px 10px; background: var(--sheet); color: var(--ink);
}
.msg-text strong, .msg-text b { font-weight: 700; }
.msg-text p { margin: 0 0 6px; }
.msg-text ul, .msg-text ol { margin: 4px 0; padding-inline-start: 18px; }

/* ------------------------------------------------------- Odoo hover card */
.hover-card {
  position: fixed; z-index: 70; width: min(360px, calc(100vw - 16px));
  background: var(--sheet); color: var(--ink); border: 1px solid var(--rule); border-radius: 12px;
  box-shadow: var(--lift); padding: 12px 14px; font-size: 13.5px;
}
.hover-title { display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--rule-soft); }
.hover-title strong { font-size: 15px; }
.hover-card dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; margin: 0; }
.hover-card dt { color: var(--steel); white-space: nowrap; }
.hover-card dd { margin: 0; overflow-wrap: anywhere; }
.hover-loading { display: flex; align-items: center; gap: 8px; color: var(--steel); }

/* --------------------------------------------------- Prime notifications */
.notes-wrap { position: relative; }
#open-notes { position: relative; }
#open-notes .badge, #notes-badge {
  position: absolute; top: 2px; inset-inline-end: 2px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; display: grid; place-items: center; background: var(--signal); color: #fff; font: 700 10px/1 var(--font-ui);
}
.notes-panel {
  position: absolute; top: calc(100% + 8px); inset-inline-end: -60px; z-index: 50; width: min(380px, 92vw);
  background: var(--sheet); border: 1px solid var(--rule); border-radius: 12px; box-shadow: var(--lift);
}
.notes-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--rule-soft); }
.notes-list { max-height: 60vh; overflow-y: auto; padding: 6px; display: grid; gap: 4px; }
.note-item {
  display: grid; gap: 3px; text-align: start; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px;
  background: transparent; cursor: pointer; color: var(--ink);
}
.note-item:hover { background: var(--silver); }
.note-item.unread { background: var(--prime-bg); }
.note-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 12px; }
.note-text { font-size: 13px; color: var(--steel); }
@media (max-width: 760px) { .notes-panel { position: fixed; top: 56px; inset-inline: 8px; width: auto; } }

.composer { grid-template-columns: auto 1fr auto; }
.composer-note { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.msg-media img { display: block; max-width: 220px; max-height: 220px; border-radius: 8px; margin-top: 4px; }
.msg-video { max-width: 240px; border-radius: 8px; margin-top: 4px; }
.msg-file { display: inline-flex; align-items: center; gap: 4px; color: inherit; text-decoration: underline; }
.msg.mine .msg-file { color: var(--on-ink); }

.seg { border: 1px solid var(--rule); background: transparent; padding: 5px 12px; border-radius: 8px; cursor: pointer; color: var(--steel); font-weight: 600; }
.seg.on { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

/* ---------------------------------------------------- Zendesk workspace */
/* A one-to-one copy of Zendesk's Agent Workspace look, using the values of its
   Garden design system: kale rail, grey panels, blue actions, the system font
   at 14/20, status colours, yellow internal notes. Always light, like Zendesk. */
.zd-drawer {
  --g100: #f8f9f9; --g200: #e9ebed; --g300: #d8dcde; --g400: #c2c8cc; --g500: #87929d; --g600: #68737d; --g700: #49545c; --g800: #2f3941;
  --blue: #1f73b7; --blue-700: #144a75; --blue-100: #edf7ff; --blue-200: #cee2f2;
  --kale: #03363d; --kale-700: #17494d;
  --note-bg: #fff8ed; --note-rule: #fed6a8; --note-tag: #ac5918;
  --zd-focus: 0 0 0 3px rgba(31, 115, 183, .35);
  left: 0; right: 0; width: 100%; border: 0; box-shadow: none;
  display: grid; grid-template-columns: 60px minmax(0, 1fr);
  background: #fff; color: var(--g800); color-scheme: light;
  font: 14px/20px system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
}
.zd-drawer :where(button, input, select, textarea) { font: inherit; color: inherit; }
.zd-drawer .spacer { flex: 1; }
.zd-drawer svg { flex: none; }

/* rail */
.zd-rail { background: var(--kale); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0; }
.zd-rail-mark { width: 40px; height: 40px; display: grid; place-items: center; color: #fff; margin-bottom: 14px; }
.zd-rail-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 4px; background: transparent; color: rgba(255, 255, 255, .75); cursor: pointer; }
.zd-rail-btn:hover { background: var(--kale-700); color: #fff; }
.zd-rail-btn:focus-visible { outline: none; box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .5); }

/* top bar with ticket tabs */
.zd-frame { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.zd-drawer header.zd-top { height: 50px; flex: none; display: flex; align-items: stretch; border-bottom: 1px solid var(--g300); background: #fff; padding: 0; gap: 0; }
.zd-tabs { display: flex; align-items: stretch; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.zd-tab-top { display: flex; align-items: center; border: 0; border-right: 1px solid var(--g300); background: var(--g100); color: var(--g700); cursor: pointer; padding: 0; max-width: 240px; position: relative; }
.zd-tab-top.home { padding: 0 16px; gap: 8px; font-weight: 600; }
.zd-tab-top.on { background: #fff; color: var(--g800); }
.zd-tab-top.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: #fff; }
.zd-tab-top.on::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--blue); }
.zd-tab-open { display: flex; align-items: center; gap: 8px; height: 100%; padding: 0 4px 0 14px; border: 0; background: transparent; cursor: pointer; min-width: 0; text-align: left; }
.zd-tab-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
.zd-tab-id { color: var(--g600); font-size: 12px; }
.zd-tab-x { width: 28px; height: 28px; margin-right: 6px; border: 0; border-radius: 4px; background: transparent; color: var(--g600); display: grid; place-items: center; cursor: pointer; }
.zd-tab-x:hover { background: var(--g200); color: var(--g800); }
.zd-me { display: flex; align-items: center; padding: 0 12px; color: var(--g700); white-space: nowrap; }
.zd-me > span { display: inline-flex; align-items: center; gap: 8px; }
.zd-top-btn { width: 50px; display: grid; place-items: center; border: 0; border-left: 1px solid var(--g300); background: #fff; color: var(--g700); cursor: pointer; }
.zd-top-btn:hover { background: var(--g100); color: var(--g800); }
.zd-top-btn[hidden] { display: none; }

.zd-drawer .body { flex: 1; min-height: 0; padding: 0; gap: 0; overflow: hidden; background: #fff; }
.zd-drawer .body.zd-plain { padding: 24px; overflow-y: auto; }
.zd-msg { margin: 24px; color: var(--g600); }
.zd-msg.bad { color: #cc3340; }

/* form controls */
.zd-drawer select, .zd-drawer input[type="text"], .zd-drawer input[type="date"], .zd-drawer input[type="search"], .zd-drawer textarea {
  width: 100%; min-height: 40px; padding: 9px 12px; border: 1px solid var(--g300); border-radius: 4px; background: #fff; color: var(--g800); line-height: 20px;
}
.zd-drawer select { appearance: none; padding-right: 32px; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2368737d' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center; }
.zd-drawer textarea { resize: vertical; }
.zd-drawer select:hover, .zd-drawer input:hover, .zd-drawer textarea:hover { border-color: var(--blue); }
.zd-drawer select:focus-visible, .zd-drawer input:focus-visible, .zd-drawer textarea:focus-visible, .zd-drawer button:focus-visible, .zd-drawer a:focus-visible {
  outline: none; border-color: var(--blue); box-shadow: var(--zd-focus);
}
.zd-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 18px; border: 1px solid var(--blue); border-radius: 4px; background: #fff; color: var(--blue); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.zd-btn:hover { background: var(--blue-100); }
.zd-btn.primary { background: var(--blue); color: #fff; }
.zd-btn.primary:hover { background: var(--blue-700); border-color: var(--blue-700); }
.zd-btn:disabled { opacity: .45; cursor: default; }
.zd-icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 4px; background: transparent; color: var(--g600); cursor: pointer; }
.zd-icon-btn:hover { background: var(--g200); color: var(--g800); }

/* status pills and letters */
.cat-new { --cat: #ffb648; --cat-ink: #703b15; }
.cat-open { --cat: #e34f32; --cat-ink: #fff; }
.cat-pending { --cat: #3091ec; --cat-ink: #fff; }
.cat-hold { --cat: #2f3941; --cat-ink: #fff; }
.cat-solved, .cat-closed { --cat: #87929d; --cat-ink: #fff; }
.zd-pill { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 4px; font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap; background: var(--cat, var(--g500)); color: var(--cat-ink, #fff); }
.zd-letter { flex: none; width: 20px; height: 20px; border-radius: 4px; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--cat, var(--g500)); color: var(--cat-ink, #fff); }

/* avatars */
.zd-avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; overflow: hidden; font-size: 14px; font-weight: 600; text-transform: uppercase;
  background: var(--g700); color: #fff; }
.zd-avatar.customer { background: hsl(var(--h, 200) 40% 86%); color: hsl(var(--h, 200) 45% 25%); }
.zd-avatar.agent { background: var(--kale); }
.zd-avatar.small { width: 28px; height: 28px; font-size: 11px; }
.zd-avatar.tiny { width: 24px; height: 24px; font-size: 10px; }
.zd-avatar.big { width: 48px; height: 48px; font-size: 16px; }
.zd-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---- views home */
.zd-home { display: grid; grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); align-content: stretch; }
.zd-views { background: var(--g100); border-right: 1px solid var(--g300); overflow-y: auto; padding: 0 0 20px; display: flex; flex-direction: column; }
.zd-views-head { padding: 20px 20px 12px; }
.zd-views-head h3 { margin: 0; font-size: 22px; line-height: 28px; font-weight: 600; }
.zd-views button { display: flex; justify-content: space-between; gap: 12px; width: 100%; padding: 10px 20px; border: 0; background: transparent; color: var(--g800); cursor: pointer; text-align: left; }
.zd-views button:hover { background: var(--g200); }
.zd-views button.on { background: var(--g200); font-weight: 600; }
.zd-count { color: var(--g600); font-variant-numeric: tabular-nums; }
.zd-views button.on .zd-count { color: var(--g800); }
.zd-main { overflow-y: auto; padding: 20px 30px 30px; display: flex; flex-direction: column; gap: 16px; }
.zd-main-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.zd-list-title { margin: 0; font-size: 22px; line-height: 28px; font-weight: 600; }
.zd-list-sub { margin: 2px 0 0; color: var(--g600); }
.zd-search { position: relative; width: min(380px, 100%); }
.zd-search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--g600); }
.zd-drawer .zd-search input { padding-left: 36px; }
.zd-table { display: grid; }
.zd-tr { display: grid; grid-template-columns: 110px minmax(0, 2.6fr) minmax(0, 1.1fr) 120px 150px minmax(0, 1fr); gap: 16px; align-items: center; min-height: 44px;
  padding: 8px 12px; border: 0; border-bottom: 1px solid var(--g200); background: transparent; color: var(--g800); text-align: left; cursor: pointer; width: 100%; }
button.zd-tr:hover { background: var(--blue-100); }
.zd-th { min-height: 36px; cursor: default; font-weight: 600; color: var(--g600); border-bottom-color: var(--g300); }
.zd-tr > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zd-td-subject { display: flex; gap: 8px; align-items: baseline; }
.zd-td-subject strong { overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.zd-td-id { color: var(--g600); flex: none; }

/* ---- ticket */
.zd-ws { display: grid; align-content: stretch;
  grid-template-columns: 320px minmax(0, 1fr) 320px; grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "fields conv ctx" "foot foot foot"; }
.zd-col { overflow-y: auto; min-height: 0; }

.zd-fields { grid-area: fields; background: var(--g100); border-right: 1px solid var(--g300); }
.zd-fields-top { padding: 20px; display: grid; gap: 16px; border-bottom: 1px solid var(--g300); }
.zd-fields-rest { padding: 20px 20px 32px; display: grid; gap: 16px; }
.zd-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.zd-field { display: grid; gap: 8px; min-width: 0; }
.zd-label { font-weight: 600; color: var(--g800); }
.zd-ro { color: var(--g800); overflow-wrap: anywhere; }
.zd-box { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 7px 12px; border: 1px solid var(--g300); border-radius: 4px; background: #fff; }
.zd-field.dirty .zd-label::after { content: " •"; color: var(--blue); }
.zd-field.dirty select, .zd-field.dirty input[type="text"], .zd-field.dirty input[type="date"], .zd-field.dirty textarea { border-color: var(--blue); background-color: var(--blue-100); }
.zd-tagwrap { position: relative; }
.zd-tagbox { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 40px; padding: 5px 8px; border: 1px solid var(--g300); border-radius: 4px; background: #fff; cursor: text; }
.zd-tagbox:hover { border-color: var(--blue); }
.zd-tagbox:focus-within { border-color: var(--blue); box-shadow: var(--zd-focus); }
.zd-field.dirty .zd-tagbox { border-color: var(--blue); }
.zd-chips { display: contents; }
.zd-chip { display: inline-flex; align-items: center; gap: 2px; height: 24px; padding: 0 2px 0 8px; border: 1px solid var(--g300); border-radius: 4px; background: var(--g100); color: var(--g800); font-size: 13px; max-width: 100%; }
.zd-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zd-drawer .zd-chip-x { width: 20px; height: 20px; display: grid; place-items: center; border: 0; border-radius: 3px; background: transparent; color: var(--g600); cursor: pointer; }
.zd-drawer .zd-chip-x:hover { background: var(--g300); color: var(--g800); }
.zd-drawer input.zd-tag-input { flex: 1; min-width: 80px; min-height: 26px; padding: 0 2px; border: 0; background: transparent; box-shadow: none; }
.zd-drawer input.zd-tag-input:focus-visible { box-shadow: none; }
.zd-suggest { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 5; list-style: none; margin: 0; padding: 4px 0; max-height: 220px; overflow-y: auto;
  background: #fff; border: 1px solid var(--g300); border-radius: 4px; box-shadow: 0 8px 20px rgba(4, 68, 77, .15); }
.zd-suggest li { padding: 7px 12px; cursor: pointer; }
.zd-suggest li.on, .zd-suggest li:hover { background: var(--blue-100); }
.zd-suggest-new { color: var(--g600); }
.zd-check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.zd-check input { width: 16px; height: 16px; accent-color: var(--blue); margin: 0; }
.zd-multi { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; min-height: 40px; border: 1px solid var(--g300); border-radius: 4px; background: #fff; }
.zd-field.dirty .zd-multi { border-color: var(--blue); }
.zd-opt { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 10px; border: 1px solid var(--g300); border-radius: 13px; background: #fff; color: var(--g600); cursor: pointer; font-size: 13px; }
.zd-opt.on { background: var(--g200); border-color: var(--g200); color: var(--g800); font-weight: 600; }

.zd-conv { grid-area: conv; display: flex; flex-direction: column; overflow: hidden; background: #fff; }
.zd-drawer header.zd-conv-head { padding: 16px 24px; border-bottom: 1px solid var(--g300); display: grid; gap: 6px; align-items: start; }
.zd-conv-head h2 { margin: 0; font-size: 22px; line-height: 28px; font-weight: 600; }
.zd-conv-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; color: var(--g600); }
.zd-thread { flex: 1; overflow-y: auto; padding: 8px 0 16px; display: flex; flex-direction: column; }

.zd-event { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--g200); }
.zd-event.note { background: var(--note-bg); }
.zd-event-body { display: grid; gap: 8px; min-width: 0; }
.zd-event-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.zd-event-head strong { font-weight: 600; }
.zd-event-head time { color: var(--g600); font-size: 13px; }
.zd-note-tag { display: inline-flex; align-items: center; gap: 4px; color: var(--note-tag); font-size: 12px; font-weight: 600; }
.zd-event-text { font-size: 14px; line-height: 20px; color: var(--g800); }
.zd-event-via { color: var(--g600); font-size: 12px; }

/* messaging (chat transcripts) */
.zd-chat { display: flex; flex-direction: column; gap: 6px; padding: 16px 24px; border-bottom: 1px solid var(--g200); }
.zd-chat-day { display: flex; align-items: center; gap: 12px; color: var(--g600); font-size: 12px; margin-bottom: 6px; }
.zd-chat-day::before, .zd-chat-day::after { content: ""; flex: 1; height: 1px; background: var(--g200); }
.zd-msg-row { display: flex; align-items: flex-end; gap: 8px; max-width: 75%; }
.zd-msg-row.ours { align-self: flex-end; }
.zd-msg-row.theirs { align-self: flex-start; }
.zd-bubble-wrap { display: grid; gap: 4px; min-width: 0; }
.zd-msg-row.ours .zd-bubble-wrap { justify-items: end; }
.zd-bubble-who { font-size: 12px; color: var(--g600); }
.zd-bubble { padding: 8px 12px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.zd-msg-row.theirs .zd-bubble { background: var(--g200); color: var(--g800); border-bottom-left-radius: 4px; }
.zd-msg-row.ours .zd-bubble { background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }

/* files */
.zd-files-row { display: flex; flex-wrap: wrap; gap: 8px; }
.zd-thumb { padding: 0; border: 1px solid var(--g300); border-radius: 8px; overflow: hidden; background: var(--g100); cursor: zoom-in; width: 160px; height: 160px; }
.zd-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.zd-video { max-width: 280px; border-radius: 8px; }
.zd-file { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--g300); border-radius: 4px; color: var(--blue); background: #fff; text-decoration: none; }
.zd-file:hover { background: var(--blue-100); }
.zd-lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(4, 68, 77, .85); display: grid; place-items: center; align-content: center; gap: 14px; padding: 24px; cursor: zoom-out; }
.zd-lightbox img { max-width: 92vw; max-height: 80vh; border-radius: 4px; background: #fff; }
.zd-lightbox .zd-btn { background: #fff; }

/* composer */
.zd-composer { flex: none; border-top: 1px solid var(--g300); padding: 8px 24px 12px; display: grid; gap: 4px; background: #fff; }
.zd-composer.note { background: var(--note-bg); border-top-color: var(--note-rule); }
.zd-composer-head { display: flex; align-items: center; gap: 4px; min-height: 36px; }
.zd-mode { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border: 0; border-radius: 4px; background: transparent; color: var(--g600); font-weight: 600; cursor: pointer; }
.zd-mode:hover { background: var(--g200); color: var(--g800); }
.zd-mode.on { color: var(--blue); background: var(--blue-100); }
.zd-mode.note.on { color: var(--note-tag); background: #ffeedb; }
.zd-to { color: var(--g600); }
.zd-drawer .zd-composer textarea { border: 0; padding: 8px 0; min-height: 96px; max-height: 260px; background: transparent; box-shadow: none; resize: none; }
.zd-composer-tools { display: flex; align-items: center; gap: 8px; }
.zd-picked { color: var(--g600); font-size: 13px; }

/* customer context */
.zd-ctx { grid-area: ctx; border-left: 1px solid var(--g300); background: #fff; }
.zd-ctx-block { padding: 20px; border-bottom: 1px solid var(--g300); display: grid; gap: 14px; }
.zd-ctx-block h3 { margin: 0; font-size: 14px; font-weight: 600; }
.zd-customer-top { display: flex; align-items: center; gap: 12px; }
.zd-customer-top > div { display: grid; }
.zd-customer-top strong { font-size: 16px; font-weight: 600; }
.zd-customer-top span { color: var(--g600); }
.zd-dl { margin: 0; display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 10px 12px; }
.zd-dl dt { color: var(--g600); }
.zd-dl dd { margin: 0; overflow-wrap: anywhere; }
.zd-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.zd-tag { font-size: 12px; padding: 0 8px; border-radius: 4px; background: var(--g200); line-height: 20px; }
.zd-notes { margin: 0; white-space: pre-wrap; }
.zd-other { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 8px; margin: 0 -8px; border: 0; border-radius: 4px; background: transparent; color: var(--g800); text-align: left; cursor: pointer; }
.zd-other:hover:not(:disabled) { background: var(--g100); }
.zd-other.on { cursor: default; background: var(--blue-100); }
.zd-other-text { display: grid; min-width: 0; }
.zd-other-text > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zd-other-text small { color: var(--g600); font-size: 12px; }

/* footer: apply macro, close tab, submit as */
.zd-foot { grid-area: foot; display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 20px; border-top: 1px solid var(--g300); background: var(--g100); }
.zd-macro { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border-radius: 4px; color: var(--g700); font-weight: 600; cursor: pointer; }
.zd-macro:hover { background: var(--g200); }
.zd-drawer .zd-macro select { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.zd-macro::before { content: "Apply macro"; order: 1; }
.zd-macro > :last-child { order: 2; }
.zd-split { display: inline-flex; height: 40px; border-radius: 4px; overflow: hidden; background: var(--blue); }
.zd-submit { display: inline-flex; align-items: center; gap: 8px; padding: 0 18px; border: 0; background: transparent; color: #fff; cursor: pointer; white-space: nowrap; }
.zd-submit strong { font-weight: 600; }
.zd-submit:hover, .zd-split-menu:hover { background: var(--blue-700); }
.zd-submit:disabled { opacity: .6; cursor: default; }
.zd-swatch { width: 12px; height: 12px; border-radius: 2px; background: var(--cat, #fff); box-shadow: 0 0 0 1px rgba(255, 255, 255, .6); }
.zd-split-menu { position: relative; width: 40px; display: grid; place-items: center; color: #fff; border-left: 1px solid rgba(255, 255, 255, .35); cursor: pointer; }
.zd-drawer .zd-split-menu select { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; }

@media (max-width: 1240px) {
  .zd-ws { grid-template-columns: 300px minmax(0, 1fr); grid-template-areas: "fields conv" "foot foot"; }
  .zd-ctx { display: none; }
  .zd-tr { grid-template-columns: 100px minmax(0, 2.4fr) minmax(0, 1fr) 130px; }
  .zd-tr > span:nth-child(4), .zd-tr > span:nth-child(6) { display: none; }
}
@media (max-width: 760px) {
  .zd-drawer { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .zd-rail { flex-direction: row; padding: 4px 8px; }
  .zd-rail-mark { margin: 0 8px 0 0; }
  .zd-me { display: none; }
  .zd-home { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .zd-views { flex-direction: row; overflow-x: auto; padding: 0; border: 0; border-bottom: 1px solid var(--g300); }
  .zd-views-head { display: none; }
  .zd-views button { width: auto; white-space: nowrap; padding: 10px 14px; }
  .zd-main { padding: 14px 16px; }
  .zd-tr { grid-template-columns: auto minmax(0, 1fr); }
  .zd-tr > span:nth-child(n+3) { display: none; }
  .zd-drawer .body.zd-ws { display: flex; flex-direction: column; overflow-y: auto; }
  .zd-ws > * { flex: none; }
  .zd-col, .zd-conv { overflow: visible; }
  .zd-fields { order: 2; border: 0; border-top: 1px solid var(--g300); }
  .zd-thread { overflow: visible; }
  .zd-foot { position: sticky; bottom: 0; order: 3; height: auto; padding: 10px 12px; flex-wrap: wrap; }
  .zd-foot > .zd-btn { display: none; }
  .zd-thumb { width: 120px; height: 120px; }
  .zd-msg-row { max-width: 92%; }
}

/* --------------------------------------------------- order notes drawer */
.onotes-drawer { width: min(460px, 100%); }
.onotes-drawer header { gap: 10px; padding-bottom: 6px; border-bottom: 0; }
.onotes-drawer header h3 { font-size: 19px; }
.onotes-sub { margin: 0; padding: 0 18px 12px; color: var(--steel); font-size: 13.5px; border-bottom: 1px solid var(--rule); }
.onotes-drawer .body { flex: 1; gap: 12px; padding: 14px 18px; }
.onotes-empty { display: grid; gap: 6px; padding: 24px 6px; color: var(--steel); text-align: center; }
.onotes-empty strong { color: var(--ink); font-size: 15px; }
.onotes-day { display: flex; align-items: center; gap: 10px; color: var(--steel); font-size: 12px; }
.onotes-day::before, .onotes-day::after { content: ""; flex: 1; height: 1px; background: var(--rule-soft); }
.onote { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 10px; align-items: start; }
.onote-avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px;
  background: var(--silver-2); color: var(--ink); }
.onote.mine .onote-avatar { background: var(--ink); color: var(--on-ink); }
.onote-main { display: grid; gap: 4px; min-width: 0; padding: 8px 12px; border-radius: 4px 12px 12px 12px; background: var(--silver); }
.onote.mine .onote-main { background: var(--prime-bg); }
.onote-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-size: 13px; }
.onote-head time { color: var(--steel); font-size: 12px; }
.onote-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; font-size: 14.5px; }
.onote-fu { display: flex; align-items: center; gap: 6px; margin-top: 2px; padding: 4px 4px 4px 8px; border-radius: 8px; font-size: 12.5px; font-weight: 600; }
.onote-fu .btn { margin-inline-start: auto; padding: 2px 10px; }
.onote-fu.late { background: var(--signal-bg); color: var(--signal); }
.onote-fu.today { background: var(--amber-bg); color: var(--amber); }
.onote-fu.soon, .onote-fu.later { background: var(--sheet); color: var(--prime); }
.onote-fu.done { background: var(--stamp-bg); color: var(--stamp); }
.onote-tools { display: flex; flex-direction: column; gap: 2px; opacity: 0; transition: opacity .12s; }
.onote:hover .onote-tools, .onote:focus-within .onote-tools { opacity: 1; }
.icon-btn.danger:hover { color: var(--signal); background: var(--signal-bg); }
.onote-edit { display: grid; gap: 6px; }
.onote-edit textarea, .onotes-foot textarea {
  width: 100%; border: 1px solid var(--rule); border-radius: 10px; padding: 9px 11px; background: var(--sheet); color: var(--ink);
  font: inherit; font-size: 14.5px; line-height: 1.6; resize: vertical; min-height: 64px;
}
.onote-edit textarea:focus-visible, .onotes-foot textarea:focus-visible { outline: none; border-color: var(--prime); box-shadow: 0 0 0 3px var(--focus); }
.onote-actions { display: flex; gap: 6px; }
.onotes-foot { border-top: 1px solid var(--rule); padding: 12px 18px 16px; display: grid; gap: 10px; background: var(--sheet); }
.onotes-quick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.chip-btn { flex: none; border: 1px solid var(--rule); background: var(--sheet); color: var(--ink); border-radius: 999px; padding: 4px 11px;
  font: inherit; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.chip-btn:hover { border-color: var(--prime); color: var(--prime); background: var(--prime-bg); }
.onotes-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.onotes-row.end { font-size: 12.5px; }
.onotes-label { font-size: 13px; font-weight: 600; color: var(--steel); }
.onotes-fu-pick { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.onotes-fu-pick .seg { padding: 4px 10px; font-size: 13px; }
.onotes-fu-pick input[type="date"] { border: 1px solid var(--rule); border-radius: 8px; padding: 3px 8px; background: var(--sheet); color: var(--ink); font: inherit; font-size: 13px; }
@media (max-width: 760px) {
  .onote-tools { opacity: 1; }
  .mark-note { max-width: 160px; }
}
.zd-event.pending, .zd-chat.pending { opacity: .6; }
tr.flash td { background: var(--hl) !important; transition: background .4s; }
.zd-drawer .zd-foot select.zd-after { width: auto; min-width: 170px; background-color: #fff; }
@media (max-width: 760px) { .zd-drawer .zd-foot select.zd-after { min-width: 0; flex: 1; } }

/* late tabs */
.tab-sep { align-self: center; margin-inline: 10px 2px; padding-inline-start: 12px; border-inline-start: 1px solid var(--rule);
  font-size: 12px; font-weight: 600; color: var(--steel); white-space: nowrap; }
.tab.late .count { background: var(--amber-bg); color: var(--amber); }
.tab.late.active .count { background: var(--amber); color: #fff; }
.late-kind { display: inline-grid; gap: 2px; justify-items: start; }
.late-kind small { font-size: 11.5px; }

/* paging */
.pager { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 4px; }
.pager-info { color: var(--steel); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.pager-btns { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-inline-start: auto; }
.pager-btn { min-width: 36px; height: 34px; padding: 0 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--sheet);
  color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; font-variant-numeric: tabular-nums; }
.pager-btn:hover:not(:disabled) { border-color: var(--prime); color: var(--prime); }
.pager-btn.on { background: var(--ink); border-color: var(--ink); color: var(--on-ink); font-weight: 700; cursor: default; }
.pager-btn:disabled { opacity: .45; cursor: default; }
.pager-gap { color: var(--steel); padding: 0 2px; }
.pager select { border: 1px solid var(--rule); border-radius: 8px; padding: 6px 8px; background: var(--sheet); color: var(--ink); font: inherit; font-size: 13.5px; }
@media (max-width: 760px) { .pager-btns { margin-inline-start: 0; width: 100%; } }

.zd-drawer .zd-next-btn { display: inline-flex; align-items: center; gap: 6px; align-self: center; height: 34px; margin: 0 8px; padding: 0 14px;
  border: 0; border-radius: 4px; background: var(--blue); color: #fff; font-weight: 600; cursor: pointer; }
.zd-drawer .zd-next-btn:hover { background: var(--blue-700); }
.zd-drawer .zd-next-btn[hidden] { display: none; }

/* AI: decision copilot, diagnosis drawer, hover summary */
.ai-btn { color: #7b3fc4; }
.ai-btn:hover { color: #7b3fc4; background: var(--oa-bg); }
.copilot { border: 1px solid #c9b2ec; background: linear-gradient(0deg, var(--sheet), var(--oa-bg)); border-radius: 10px; padding: 10px 12px; display: grid; gap: 6px; }
.copilot-head { display: flex; align-items: center; gap: 6px; color: var(--oa); }
.copilot-summary { margin: 0; font-size: 14px; line-height: 1.7; }
.copilot blockquote { margin: 0; padding: 4px 10px; border-inline-start: 3px solid var(--oa); color: var(--steel); font-size: 13.5px; }
.copilot-suggest { display: grid; gap: 6px; padding: 8px 10px; border-radius: 8px; background: var(--sheet); border: 1px solid var(--rule); }
.copilot-values { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; font-size: 13.5px; }
.copilot-values dt { color: var(--steel); }
.copilot-values dd { margin: 0; display: grid; }
.copilot-values small { color: var(--steel); font-size: 12px; }
.copilot-suggest .btn { justify-self: start; }
.copilot-check { margin: 0; font-size: 12.5px; color: var(--amber); }
.copilot-foot { margin: 0; font-size: 11.5px; color: var(--steel); }
.ai-filled input, input.ai-filled, textarea.ai-filled, .combo.ai-filled input { background: var(--oa-bg) !important; border-color: var(--oa) !important; }
.insight-drawer { width: min(520px, 100%); }
.insight-drawer .body { gap: 16px; }
.insight-ai { border: 1px solid #c9b2ec; background: var(--oa-bg); border-radius: 12px; padding: 12px 14px; display: grid; gap: 6px; }
.insight-ai p { margin: 0; line-height: 1.75; font-size: 14.5px; }
.insight-ai-head { display: flex; align-items: center; gap: 8px; color: var(--oa); }
.insight-ai-head .chip { margin-inline-start: auto; }
.insight-next { padding-top: 4px; border-top: 1px dashed #c9b2ec; }
.insight-drawer h4 { margin: 0 0 6px; font-size: 13px; color: var(--steel); }
.insight-finds .find { margin: 0 0 4px; padding: 6px 10px; border-radius: 8px; font-size: 13.5px; border-inline-start: 4px solid; }
.find.high { background: var(--signal-bg); color: var(--signal); }
.find.medium { background: var(--amber-bg); color: var(--amber); }
.find.info { background: var(--silver); color: var(--steel); border-color: var(--rule); }
.insight-facts dl { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; font-size: 13.5px; }
.insight-facts dt { color: var(--steel); white-space: nowrap; }
.insight-facts dd { margin: 0; overflow-wrap: anywhere; }
.insight-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tl-item { display: grid; grid-template-columns: 72px 112px minmax(0, 1fr); gap: 8px; align-items: baseline; font-size: 13px; padding: 4px 0; border-bottom: 1px solid var(--rule-soft); }
.tl-item time { color: var(--steel); font-variant-numeric: tabular-nums; font-size: 12px; }
.tl-src { font-size: 11.5px; font-weight: 700; color: var(--steel); }
.tl-src.src-Prime { color: var(--prime); }
.tl-src.src-Zendesk { color: #03363d; }
.hover-ai { display: flex; gap: 6px; align-items: flex-start; margin: 6px 0; padding: 6px 8px; border-radius: 8px; background: var(--oa-bg); color: var(--ink); font-size: 13px; line-height: 1.6; }
.hover-ai svg { color: var(--oa); flex: none; margin-top: 3px; }
@media (max-width: 760px) { .tl-item { grid-template-columns: 60px minmax(0, 1fr); } .tl-item span:last-child { grid-column: 1 / -1; } }
