/* ==========================================================================
   LogiMind prototype — tokens + components (see DESIGN.md)
   ========================================================================== */

:root {
  /* Brand / violet */
  --primary: #5B3DE0;
  --primary-hover: #4D30CC;
  --primary-pressed: #4226B3;
  --primary-soft: #EEEAFD;
  --rail-top: #6001D5;
  --rail-bottom: #3D12A0;
  --on-rail: #FFFFFF;
  --rail-active-tile: #FFFFFF;

  /* Neutrals */
  --shell: #F2F2F3;
  --sidebar: #F7F7F8;
  --surface: #FFFFFF;
  --nav-active: #EBEBED;
  --nav-hover: #F0F0F2;
  --row-hover: #FAFAFB;
  --border: #E4E4E7;
  --divider: #ECECEE;
  --ink: #1F1F23;
  --text-secondary: #3F3F46;
  --muted: #6B6B73;
  --muted-soft: #9C9CA3;
  --disabled: #B8B8BE;
  --on-primary: #FFFFFF;

  /* Identity */
  --avatar-teal: #4FB59F;
  --avatar-indigo: #4C5BD4;
  --avatar-violet: #6A4BE0;
  --badge-channel: #3D9C88;
  --presence-offline: #A1A1AA;
  --presence-online: #22A06B;

  /* Status */
  --success: #1F9D63;  --success-soft: #E7F6EE;
  --warning: #B7791F;  --warning-soft: #FDF4E3;
  --danger: #D93A3A;   --danger-soft: #FDECEC;
  --info: #2F6FDB;     --info-soft: #EAF1FD;

  --scrim: rgba(15, 15, 20, 0.45);

  /* Radius */
  --r-xs: 4px; --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px; --r-full: 9999px;

  /* Sizes */
  --rail-width: 56px;
  --sidebar-width: 240px;
  --sidebar-row: 30px;
  --tab-bar-height: 52px;
  --control-sm: 28px;
  --control-md: 32px;
  --control-lg: 40px;

  --shadow-lift: 0 1px 2px rgba(16,16,24,0.06);
  --shadow-pop: 0 8px 24px rgba(16,16,24,0.12);
  --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px rgba(91, 61, 224, 0.4);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--shell);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
svg.lucide { width: 16px; height: 16px; stroke-width: 1.6; flex: none; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.caption { font-size: 12px; line-height: 1.3; color: var(--muted); }

/* ---------- App shell ---------- */
.app {
  display: flex;
  gap: 4px;
  padding: 4px;
  height: 100vh;
  min-width: 1024px;
}

/* ---------- Icon rail ---------- */
.rail {
  width: var(--rail-width);
  flex: none;
  border-radius: var(--r-md);
  background: linear-gradient(180deg, var(--rail-top), var(--rail-bottom));
  color: var(--on-rail);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  overflow-y: auto;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail-logo {
  width: 36px; height: 36px; flex: none;
  border-radius: var(--r-sm);
  background: var(--rail-active-tile);
  display: grid; place-items: center;
  margin: 2px 0 12px;
}
.rail-logo img { width: 24px; height: 24px; display: block; }
.rail-list { display: flex; flex-direction: column; gap: 2px; width: 100%; align-items: center; }
.rail-item {
  width: 54px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 4px 0 6px;
  color: var(--on-rail);
  opacity: 0.9;
  border-radius: var(--r-sm);
}
.rail-item:hover { opacity: 1; }
.rail-item .glyph {
  width: 36px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  transition: background .12s;
}
.rail-item:hover .glyph { background: rgba(255,255,255,0.12); }
.rail-item svg.lucide { width: 20px; height: 20px; }
.rail-item .label { font-size: 10.5px; font-weight: 500; line-height: 1.2; white-space: nowrap; }
.rail-item.active { opacity: 1; }
.rail-item.active .glyph { background: var(--rail-active-tile); color: var(--primary); }
.rail-spacer { flex: 1; min-height: 12px; }

/* ---------- Workspace (sidebar + main) ---------- */
.workspace {
  flex: 1;
  display: flex;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
}

/* ---------- Context sidebar ---------- */
.sidebar {
  width: var(--sidebar-width);
  flex: none;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 0;
}
.sidebar-header {
  height: 56px;
  padding: 0 12px 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  flex: none;
}
.sidebar-title {
  font-size: 17px; font-weight: 600; line-height: 1.3; margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.split-add {
  height: var(--control-md);
  display: flex; align-items: stretch; flex: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  position: relative;
}
.split-add > button {
  display: grid; place-items: center;
  color: var(--text-secondary);
  padding: 0 7px;
}
.split-add > button:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.split-add > button:nth-child(2) { border-left: 1px solid var(--border); border-radius: 0 var(--r-md) var(--r-md) 0; padding: 0 5px; }
.split-add > button:nth-child(2) svg { width: 14px; height: 14px; }
.split-add > button:hover { background: var(--nav-hover); }

.menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  padding: 4px;
  z-index: 20;
  display: none;
}
.menu.open { display: block; }
.menu button {
  width: 100%; height: 32px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  text-align: left;
}
.menu button svg { color: var(--muted); }
.menu button:hover { background: var(--nav-hover); color: var(--ink); }

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 0 8px 16px; min-height: 0; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.row {
  height: var(--sidebar-row);
  display: flex; align-items: center; gap: 8px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-size: 14px; line-height: 1.3;
  width: 100%;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
}
.row > svg.lucide { color: var(--muted); }
.row:hover { background: var(--nav-hover); }
.row.active { background: var(--nav-active); color: var(--ink); }
.row.active > svg.lucide { color: var(--ink); }
.row .text { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.row .suffix { color: var(--muted-soft); font-size: 12px; }
.row .count {
  margin-left: auto; font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.row.placeholder, .row.placeholder > svg.lucide { color: var(--muted-soft); }

.divider { height: 1px; background: var(--divider); margin: 12px 8px; }
.section { margin-top: 24px; }
.section:first-of-type { margin-top: 0; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px 0 8px;
  margin-bottom: 8px;
}
.section-label { font-size: 12.5px; font-weight: 500; color: var(--muted); line-height: 1.3; }
.section-add {
  width: 22px; height: 22px;
  border-radius: var(--r-xs);
  display: grid; place-items: center;
  color: var(--muted);
}
.section-add:hover { background: var(--nav-hover); color: var(--ink); }
.section-add svg { width: 14px; height: 14px; }

/* ---------- Identity marks ---------- */
.space-avatar {
  width: 18px; height: 18px; flex: none;
  border-radius: var(--r-xs);
  background: var(--primary);
  color: var(--on-primary);
  font-size: 10.5px; font-weight: 600;
  display: grid; place-items: center;
}
.channel-glyph { position: relative; width: 18px; height: 18px; flex: none; display: grid; place-items: center; color: var(--muted); }
.channel-glyph .badge {
  position: absolute; right: -2px; bottom: -2px;
  width: 10px; height: 10px;
  border-radius: 2px;
  background: var(--badge-channel);
  color: #fff;
  font-size: 7px; font-weight: 700;
  display: grid; place-items: center;
  border: 1px solid var(--sidebar);
  box-sizing: content-box;
}
.user-avatar {
  position: relative;
  width: 18px; height: 18px; flex: none;
  border-radius: var(--r-full);
  color: #fff;
  font-size: 9.5px; font-weight: 600;
  display: grid; place-items: center;
}
.user-avatar .presence {
  position: absolute; right: -2px; bottom: -2px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 0 0 1.5px var(--presence-offline);
}
.user-avatar .presence.online { background: var(--presence-online); box-shadow: 0 0 0 1.5px var(--sidebar); }
/* Proposed: org-badge — external contact's organization on their avatar */
.user-avatar .org-badge {
  position: absolute; right: -4px; bottom: -3px;
  min-width: 11px; height: 11px; padding: 0 2px;
  border-radius: 3px;
  background: var(--text-secondary);
  color: #fff;
  font-size: 6.5px; font-weight: 700; letter-spacing: -0.2px;
  display: grid; place-items: center;
  border: 1px solid var(--sidebar);
  box-sizing: content-box;
}
.row .org { color: var(--muted-soft); font-size: 12px; }

/* Proposed: org-avatar — organization initials square (vendors, customers) */
.org-avatar {
  width: 28px; height: 28px; flex: none;
  border-radius: var(--r-sm);
  background: var(--nav-active);
  color: var(--text-secondary);
  font-size: 11px; font-weight: 600;
  display: grid; place-items: center;
}

/* ---------- Main panel ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--surface); }

.page-head {
  height: var(--tab-bar-height); flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  border-bottom: 1px solid var(--divider);
}
.page-head h1 { font-size: 14px; font-weight: 600; margin: 0; }
.page-head .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.tab-bar {
  height: var(--tab-bar-height);
  flex: none;
  display: flex;
  border-bottom: 1px solid var(--divider);
}
.tab {
  flex: 1; max-width: 220px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px;
  color: var(--text-secondary);
  font-size: 14px; font-weight: 500;
  border-right: 1px solid var(--divider);
  position: relative;
}
.tab > svg.lucide { color: var(--muted); }
.tab:hover { background: var(--row-hover); }
.tab.active { color: var(--ink); }
.tab.active > svg.lucide { color: var(--ink); }
.tab.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: var(--ink);
}
.tab .count { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: auto; font-variant-numeric: tabular-nums; }

.toolbar {
  height: 40px; flex: none;
  margin-top: 12px;
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.toolbar .left, .toolbar .right { display: flex; align-items: center; gap: 8px; }

.content { flex: 1; min-height: 0; overflow-y: auto; }

/* ---------- Buttons & controls ---------- */
.pill {
  height: var(--control-sm);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  color: var(--text-secondary);
  font-size: 13px; font-weight: 500; line-height: 1.2;
  white-space: nowrap;
}
.pill svg.lucide { width: 14px; height: 14px; color: var(--muted); }
.pill:hover { background: var(--nav-hover); }
.pill.selected { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.pill.selected svg.lucide { color: var(--primary); }

.icon-btn {
  width: var(--control-sm); height: var(--control-sm); flex: none;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--muted);
}
.icon-btn:hover { background: var(--nav-hover); color: var(--ink); }

.btn-secondary {
  height: var(--control-sm);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-size: 13px; font-weight: 500;
  white-space: nowrap;
}
.btn-secondary svg.lucide { width: 14px; height: 14px; color: var(--muted); }
.btn-secondary:hover:not(:disabled) { background: var(--nav-hover); }
.btn-secondary:disabled { color: var(--disabled); cursor: default; }
.btn-secondary:disabled svg.lucide { color: var(--disabled); }

.btn-primary {
  height: var(--control-lg);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 16px;
  background: var(--primary);
  color: var(--on-primary);
  border-radius: var(--r-md);
  font-size: 14px; font-weight: 500; line-height: 1.2;
  transition: background .12s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { background: var(--primary-pressed); }
.btn-primary:disabled { background: var(--primary); opacity: .45; cursor: default; }

.link-btn {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
}
.link-btn:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.link-btn svg.lucide { width: 14px; height: 14px; }

/* ---------- Status tag ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px;
  border-radius: var(--r-xs);
  font-size: 12px; line-height: 1.3; font-weight: 500;
  white-space: nowrap;
}
.tag svg.lucide { width: 12px; height: 12px; }
.tag.success { background: var(--success-soft); color: var(--success); }
.tag.warning { background: var(--warning-soft); color: var(--warning); }
.tag.danger  { background: var(--danger-soft);  color: var(--danger); }
.tag.info    { background: var(--info-soft);    color: var(--info); }
.tag.neutral { background: var(--nav-active);   color: var(--text-secondary); }
.tag.brand   { background: var(--surface); color: var(--primary); border: 1px solid rgba(91,61,224,.25); }

/* Proposed: visibility — "who can see this" indicator for shared objects */
.visibility {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; line-height: 1.3; color: var(--muted);
  white-space: nowrap;
}
.visibility svg.lucide { width: 12px; height: 12px; }
.visibility b { font-weight: 500; color: var(--text-secondary); }

/* ---------- Empty state ---------- */
.empty {
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 48px 24px;
}
.empty-tile {
  width: 48px; height: 48px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-lift);
  display: grid; place-items: center;
  color: var(--primary);
  margin-bottom: 24px;
}
.empty-tile svg.lucide { width: 22px; height: 22px; }
.empty-title { font-size: 18px; font-weight: 600; line-height: 1.3; letter-spacing: -0.1px; margin: 0 0 8px; }
.empty-body { color: var(--muted); margin: 0 0 20px; }

/* ---------- Content card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
}
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; min-height: 28px; }
.card-head h2, .card-head h3 { font-size: 14px; font-weight: 600; margin: 0; }
.card-head > svg.lucide { color: var(--muted); }
.card-head .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.card.flush { padding: 0; }
.card.flush .card-head { padding: 12px 16px 0; }

/* ---------- Prompt composer ---------- */
.composer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  min-height: 96px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
  transition: border-color .12s, box-shadow .12s;
  text-align: left;
}
.composer:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,61,224,.10); }
.composer textarea {
  border: 0; outline: none; resize: none;
  background: transparent;
  min-height: 24px; max-height: 200px;
  line-height: 1.45;
  padding: 0;
}
.composer textarea::placeholder { color: var(--muted-soft); }
.composer-actions { display: flex; align-items: center; justify-content: space-between; margin-top: auto; gap: 8px; }
.composer-actions .left { display: flex; gap: 6px; align-items: center; min-width: 0; }
.attach-btn {
  height: var(--control-sm);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  color: var(--muted);
  font-size: 13px; font-weight: 500;
}
.attach-btn:hover { background: var(--nav-hover); color: var(--ink); }
.attach-btn svg.lucide { width: 15px; height: 15px; }
.send-btn { width: 32px; height: 32px; padding: 0; border-radius: var(--r-md); }
.composer-hint { font-size: 12px; color: var(--muted-soft); display: inline-flex; align-items: center; gap: 4px; }
.composer-hint svg.lucide { width: 12px; height: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Data table ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 500; color: var(--muted);
  padding: 8px 12px; border-bottom: 1px solid var(--divider);
  white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--divider); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: var(--row-hover); }
.table th:first-child, .table td:first-child { padding-left: 16px; }
.table th:last-child, .table td:last-child { padding-right: 16px; }
.table .primary-cell { font-weight: 500; }
.table .sub { font-size: 12px; color: var(--muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px);
  background: var(--ink); color: #fff;
  padding: 10px 14px; border-radius: var(--r-md);
  font-size: 13px; display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow-pop);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast svg.lucide { color: #6EE7B7; }

/* ---------- Skeleton (loading) ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--nav-hover) 0%, var(--nav-active) 50%, var(--nav-hover) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  border-radius: var(--r-xs);
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.fade-in { animation: fade .28s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Prototype-only helper: sample-data note */
.proto-note { font-size: 12px; color: var(--muted-soft); text-align: center; padding: 16px 0 8px; }

/* ==========================================================================
   v0.4 — components for the prompt → request → RFQ flow
   ========================================================================== */

/* Source link for regulatory claims */
.source-link { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--info); }
.source-link svg.lucide { width: 12px; height: 12px; }
.source-link:hover { text-decoration: underline; }

/* Proposed: flow-stepper — where this request is in the RFQ lifecycle */
.stepper { display: flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 500; color: var(--muted-soft); }
.stepper .s { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: var(--r-full); white-space: nowrap; }
.stepper .s .dot { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--disabled); display: grid; place-items: center; font-size: 9.5px; }
.stepper .s.done { color: var(--text-secondary); }
.stepper .s.done .dot { background: var(--success); border-color: var(--success); color: #fff; }
.stepper .s.done .dot svg.lucide { width: 10px; height: 10px; stroke-width: 3; }
.stepper .s.current { color: var(--ink); background: var(--nav-active); }
.stepper .s.current .dot { border-color: var(--ink); color: var(--ink); }
.stepper .sep { width: 12px; height: 1px; background: var(--border); }

/* Proposed: provenance tag — where a value came from */
.prov { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; color: var(--muted-soft); white-space: nowrap; }
.prov svg.lucide { width: 11px; height: 11px; }
.prov.ai { color: var(--info); }
.prov.edited { color: var(--text-secondary); }
.prov.missing { color: var(--warning); }

/* Proposed: field — label / editable value / provenance */
.fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--divider); }
.field { padding: 10px 16px 10px 0; border-bottom: 1px solid var(--divider); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.field .k { font-size: 12px; color: var(--muted); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field input {
  width: 100%;
  border: 1px solid transparent; border-radius: var(--r-xs);
  padding: 2px 6px; margin-left: -6px;
  background: transparent;
  font-weight: 500;
  text-overflow: ellipsis;
}
.field input:hover { border-color: var(--border); }
.field input:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px rgba(91,61,224,.10); }
.field.missing input { color: var(--warning); }
.field.missing input::placeholder { color: var(--warning); opacity: .8; font-weight: 500; }
.field .hint { font-size: 12px; color: var(--muted); }

/* Toggle switch */
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.switch input { appearance: none; width: 28px; height: 16px; border-radius: 99px; background: var(--disabled); position: relative; cursor: pointer; transition: background .15s; margin: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(12px); }
.switch input:disabled { opacity: .5; cursor: not-allowed; }
.switch.disabled { color: var(--muted-soft); cursor: not-allowed; }

/* Checkbox */
.check { appearance: none; width: 16px; height: 16px; border: 1.5px solid var(--disabled); border-radius: var(--r-xs); display: grid; place-items: center; cursor: pointer; margin: 0; flex: none; background: var(--surface); }
.check:checked { background: var(--ink); border-color: var(--ink); }
.check:checked::after { content: ""; width: 8px; height: 4px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }

/* Chat thread */
.thread { max-width: 920px; margin: 0 auto; padding: 24px 24px 32px; display: flex; flex-direction: column; gap: 20px; }
.msg-user { align-self: flex-end; max-width: 75%; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.msg-user .bubble { background: var(--nav-active); padding: 10px 14px; border-radius: var(--r-lg); border-bottom-right-radius: var(--r-xs); }
.msg-ai { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; align-items: start; }
.ai-mark { width: 28px; height: 28px; border-radius: var(--r-sm); background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.ai-body { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.ai-body > p { margin: 4px 0 0; }
.thinking { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; padding-top: 5px; }
.thinking .step { display: flex; align-items: center; gap: 8px; }
.thinking .step svg.lucide { width: 14px; height: 14px; }
.thinking .step.done svg.lucide { color: var(--success); }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* AI label on output */
.ai-label { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; color: var(--info); }
.ai-label svg.lucide { width: 12px; height: 12px; }

/* Proposed: action-bar — sticky confirmation bar above the composer */
.action-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: 0 -4px 16px rgba(16,16,24,0.04);
}
.action-bar .summary { flex: 1; min-width: 0; }
.action-bar .summary b { font-weight: 600; }
.action-bar .summary .caption { margin-top: 2px; display: flex; align-items: center; gap: 4px; }
.action-bar .summary .caption svg.lucide { width: 12px; height: 12px; }

/* Neutral send button — used where a flow's violet primary action is already on screen */
.send-btn.neutral { background: var(--ink); }
.send-btn.neutral:hover { background: #000; }
.send-btn.neutral:disabled { background: var(--disabled); opacity: 1; }

/* Modal */
.scrim { position: fixed; inset: 0; background: var(--scrim); display: none; align-items: center; justify-content: center; z-index: 40; padding: 24px; }
.scrim.open { display: flex; }
.modal {
  width: 100%; max-width: 560px; max-height: calc(100vh - 48px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column;
  animation: fade .18s ease both;
}
.modal-head { display: flex; align-items: center; gap: 8px; padding: 16px 20px; border-bottom: 1px solid var(--divider); }
.modal-head h2 { font-size: 16px; font-weight: 600; margin: 0; }
.modal-head .icon-btn { margin-left: auto; border: 0; }
.modal-body { padding: 16px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--divider); }
.modal-foot .left { margin-right: auto; }

/* Select (compact, matches control-sm) */
.select {
  height: var(--control-sm);
  padding: 0 26px 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B6B73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center;
  appearance: none;
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
  cursor: pointer;
}

/* Segmented pills (one selected) */
.segmented { display: inline-flex; gap: 4px; }

/* ==========================================================================
   v0.5 — personas: demo chip, account menu, sender portal, partner
   ========================================================================== */

/* Demo-mode chip: sits in a thin shell strip above the panels */
body.demo-on .app { padding-top: 32px; }
.demo-chip {
  position: fixed; top: 5px; right: 8px; z-index: 60;
  height: 22px; display: inline-flex; align-items: center; gap: 6px;
  padding: 0 4px 0 10px; border-radius: var(--r-full);
  background: var(--ink); color: #fff; font-size: 11.5px; line-height: 1;
}
.demo-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: #FBBF24; }
.demo-chip b { font-weight: 600; }
.demo-chip .who { color: #B8B8BE; }
.demo-chip button { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; color: #B8B8BE; }
.demo-chip button:hover { background: rgba(255,255,255,.14); color: #fff; }
.demo-chip svg.lucide { width: 12px; height: 12px; }

/* Account avatar in the rail + menu */
.rail-avatar { margin-top: 8px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; }
.rail-avatar .user-avatar { width: 30px; height: 30px; font-size: 11.5px; box-shadow: 0 0 0 2px rgba(255,255,255,.6); }
.rail-avatar:hover .user-avatar { box-shadow: 0 0 0 2px #fff; }
.user-menu {
  position: fixed; left: 66px; bottom: 10px; z-index: 55; width: 260px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop); padding: 4px; display: none;
}
.user-menu.open { display: block; }
.user-menu .um-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 8px; }
.user-menu .um-head .user-avatar { width: 32px; height: 32px; font-size: 12px; }
.user-menu .um-head b { font-weight: 600; display: block; }
.user-menu .um-persona { display: flex; align-items: center; gap: 8px; padding: 0 10px 10px; border-bottom: 1px solid var(--divider); margin-bottom: 4px; flex-wrap: wrap; }
.user-menu a, .user-menu button { width: 100%; height: 32px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border-radius: var(--r-sm); color: var(--text-secondary); text-align: left; font-size: 14px; }
.user-menu a svg, .user-menu button svg { color: var(--muted); }
.user-menu a:hover, .user-menu button:hover { background: var(--nav-hover); color: var(--ink); }

/* Toast with a channel note ("Also sent to WhatsApp and email") */
.toast-body { display: flex; flex-direction: column; gap: 2px; }
.toast-note { font-size: 11.5px; color: #B8B8BE; }

/* Split button variants used by the portal */
.split-add > .split-main { display: grid; place-items: center; color: var(--text-secondary); padding: 0 7px; border-radius: var(--r-md) 0 0 var(--r-md); }
.split-add > .split-main:hover { background: var(--nav-hover); }
.menu a { width: 100%; height: 32px; display: flex; align-items: center; gap: 8px; padding: 0 8px; border-radius: var(--r-sm); color: var(--text-secondary); }
.menu a svg { color: var(--muted); }
.menu a:hover { background: var(--nav-hover); color: var(--ink); }

/* Sender portal: tenant logo tile + account-manager card */
.rail-logo.tenant-logo { font-size: 13px; font-weight: 700; letter-spacing: -0.3px; }
.am-card { flex: none; margin: 8px; padding: 10px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 8px 10px; }
.am-card .am-avatar { width: 36px; height: 36px; font-size: 12.5px; }
.am-card .am-avatar .presence { width: 9px; height: 9px; }
.am-card .am-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.am-card .am-text b { font-weight: 600; font-size: 13.5px; }
.am-card .am-text .caption { font-size: 11.5px; }
.am-card .am-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.am-card .am-actions .icon-btn { width: 100%; }

/* Proposed: route-line — map-style lane with the current position */
.route-line { position: relative; display: grid; align-items: start; padding: 4px 0 0; }
.route-line .rl-track { position: absolute; left: 0; right: 0; top: 14px; height: 2px; background: var(--border); }
.route-line .rl-done { position: absolute; left: 0; top: 14px; height: 2px; background: var(--primary); }
.route-line .rl-node { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; z-index: 1; }
.route-line .rl-node.first { align-items: flex-start; text-align: left; }
.route-line .rl-node.last { align-items: flex-end; text-align: right; }
.route-line .rl-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border); display: grid; place-items: center; }
.route-line .rl-dot svg.lucide { width: 12px; height: 12px; color: var(--muted); }
.route-line .rl-node.passed .rl-dot { border-color: var(--primary); background: var(--primary); }
.route-line .rl-node.passed .rl-dot svg { color: #fff; }
.route-line .rl-name { font-size: 12.5px; font-weight: 500; }
.route-line .rl-sub { font-size: 11.5px; color: var(--muted); margin-top: -4px; }
.route-line .rl-here { position: absolute; top: 3px; z-index: 2; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; }
.route-line .rl-here .pin { width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; box-shadow: 0 0 0 5px var(--primary-soft); }
.route-line .rl-here .pin svg.lucide { width: 13px; height: 13px; }
.route-line .rl-leg { position: absolute; top: 5px; transform: translateX(-50%); z-index: 1; background: var(--surface); padding: 0 4px; color: var(--muted-soft); }
.route-line .rl-leg svg.lucide { width: 14px; height: 14px; }

/* Proposed: status-stepper — sender request lifecycle */
.status-stepper { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.status-stepper .ss { position: relative; display: flex; flex-direction: column; gap: 6px; padding-right: 8px; }
.status-stepper .ss::before { content: ""; position: absolute; left: 22px; right: 0; top: 10px; height: 2px; background: var(--divider); }
.status-stepper .ss:last-child::before { display: none; }
.status-stepper .ss.done::before { background: var(--primary); }
.status-stepper .ss .d { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface); display: grid; place-items: center; position: relative; z-index: 1; font-size: 10.5px; font-weight: 600; color: var(--muted); }
.status-stepper .ss.done .d { background: var(--primary); border-color: var(--primary); color: #fff; }
.status-stepper .ss.done .d svg.lucide { width: 12px; height: 12px; stroke-width: 2.6; }
.status-stepper .ss.current .d { border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.status-stepper .ss.stop .d { border-color: var(--warning); color: var(--warning); background: var(--warning-soft); }
.status-stepper .ss .l { font-size: 12.5px; font-weight: 500; color: var(--text-secondary); }
.status-stepper .ss.current .l { color: var(--ink); font-weight: 600; }
.status-stepper .ss .w { font-size: 11.5px; color: var(--muted); margin-top: -4px; }

/* Estimate vs confirmed price labels */
.price-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.estimate-note { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.estimate-note svg.lucide { width: 12px; height: 12px; }

/* Generic helpers used by portal pages */
.icon-tile { width: 32px; height: 32px; border-radius: var(--r-md); display: grid; place-items: center; flex: none; }
.icon-tile svg.lucide { width: 16px; height: 16px; }
.tone-info    { background: var(--info-soft); color: var(--info); }
.tone-warning { background: var(--warning-soft); color: var(--warning); }
.tone-danger  { background: var(--danger-soft); color: var(--danger); }
.tone-success { background: var(--success-soft); color: var(--success); }
.tone-neutral { background: var(--nav-active); color: var(--muted); }
.tone-brand   { background: var(--primary-soft); color: var(--primary); }
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--r-lg); }
.banner > svg.lucide { width: 18px; height: 18px; flex: none; }
.banner .text { flex: 1; font-size: 13.5px; color: var(--text-secondary); }
.banner .text b { color: var(--ink); font-weight: 600; }
.banner.warning { background: var(--warning-soft); } .banner.warning > svg { color: var(--warning); }
.banner.info { background: var(--info-soft); } .banner.info > svg { color: var(--info); }
.banner.danger { background: var(--danger-soft); } .banner.danger > svg { color: var(--danger); }
.banner.success { background: var(--success-soft); } .banner.success > svg { color: var(--success); }
.powered { font-size: 11px; color: var(--muted-soft); text-align: center; padding: 16px 0 4px; }

/* ==========================================================================
   v0.6 — logistics company update
   ========================================================================== */

/* Shared branded quote document (staff preview + customer portal) */
.qdoc { border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-lift); font-size: 13px; }
.qdoc-top { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-top: 4px solid var(--brand); border-bottom: 1px solid var(--divider); }
.qdoc-logo { width: 34px; height: 34px; border-radius: var(--r-sm); background: var(--brand); color: #fff; font-weight: 700; font-size: 12px; display: grid; place-items: center; flex: none; }
.qdoc-name { font-weight: 600; font-size: 14px; }
.qdoc-url { font-size: 11.5px; color: var(--muted); }
.qdoc-no { margin-left: auto; text-align: right; font-size: 12px; color: var(--muted); }
.qdoc-no b { display: block; color: var(--ink); font-size: 13px; font-weight: 600; }
.qdoc-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.qdoc-route { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; }
.qdoc-route svg.lucide { width: 15px; height: 15px; color: var(--muted); }
.qdoc-meta { display: flex; gap: 6px 18px; flex-wrap: wrap; font-size: 12.5px; margin-top: -6px; }
.qdoc-meta span { color: var(--muted); }
.qdoc-meta b { font-weight: 500; }
.qdoc-path { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-secondary); padding: 8px 10px; background: var(--row-hover); border-radius: var(--r-sm); }
.qdoc-path svg.lucide { width: 12px; height: 12px; color: var(--muted-soft); }
.qdoc-lines { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.qdoc-lines td { padding: 8px 0; border-bottom: 1px solid var(--divider); vertical-align: top; }
.qdoc-lines td:last-child { text-align: right; white-space: nowrap; padding-left: 14px; }
.qdoc-lines tr.total td { border-bottom: 0; border-top: 1.5px solid var(--ink); font-weight: 600; font-size: 15px; padding-top: 10px; }
.qdoc-inc { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.qdoc-inc h4 { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.qdoc-inc ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-secondary); }
.qdoc-inc li { display: grid; grid-template-columns: 14px 1fr; gap: 6px; }
.qdoc-inc li svg.lucide { width: 12px; height: 12px; margin-top: 2px; }
.qdoc-inc .y svg { color: var(--success); } .qdoc-inc .n svg { color: var(--muted-soft); }
.qdoc-terms { font-size: 12px; color: var(--muted); padding-top: 10px; border-top: 1px solid var(--divider); }
.qdoc-foot { font-size: 11px; color: var(--muted-soft); text-align: center; padding: 8px; border-top: 1px solid var(--divider); background: var(--row-hover); }
@media (max-width: 1300px) { .qdoc-inc { grid-template-columns: 1fr; } }

/* "Only visible to <tenant>" promise */
.lock-badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: var(--r-full); background: var(--ink); color: #fff; font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.lock-badge svg.lucide { width: 11px; height: 11px; }
.lock-note { flex: none; margin: 8px; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); display: grid; grid-template-columns: 14px 1fr; gap: 8px; font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.lock-note svg.lucide { width: 13px; height: 13px; margin-top: 1px; color: var(--text-secondary); }

/* Staff previewing a customer's portal */
.viewas-banner { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--ink); color: #fff; font-size: 13px; }
.viewas-banner svg.lucide { width: 15px; height: 15px; }
.viewas-banner b { font-weight: 600; }
.viewas-banner a { margin-left: auto; color: #fff; font-weight: 500; text-decoration: underline; text-underline-offset: 2px; }
.view-as .main button, .view-as .main .composer, .view-as .main input, .view-as .main textarea { cursor: not-allowed; }

/* Response timer (Inbox, requests) */
.timer { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; color: var(--text-secondary); white-space: nowrap; }
.timer svg.lucide { width: 12px; height: 12px; }
.timer.overdue { color: var(--danger); }
.timer.soon { color: var(--warning); }

/* Integration status */
.integ { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.integ .dot { width: 7px; height: 7px; border-radius: 50%; }
.integ.api { color: var(--success); } .integ.api .dot { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.integ.offline { color: var(--danger); } .integ.offline .dot { background: var(--danger); }
.integ.manual { color: var(--muted); } .integ.manual .dot { background: var(--disabled); }
.integ.pending { color: var(--info); } .integ.pending .dot { background: var(--info); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.kpi { padding: 12px 16px; border-right: 1px solid var(--divider); display: flex; flex-direction: column; gap: 2px; text-align: left; }
.kpi:last-child { border-right: 0; }
.kpi:hover { background: var(--row-hover); }
.kpi .k { font-size: 12.5px; font-weight: 500; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .k svg.lucide { width: 14px; height: 14px; }
.kpi .v { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--muted-soft); }
.kpi .s.warning { color: var(--warning); } .kpi .s.danger { color: var(--danger); } .kpi .s.success { color: var(--success); }
@media (max-width: 1300px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .kpi:nth-child(3) { border-right: 0; } .kpi:nth-child(-n+3) { border-bottom: 1px solid var(--divider); } }

/* ==========================================================================
   v0.8 — ASCO import scenario: lifecycle, core-partner legs, magic-link pages
   (built only from the tokens and patterns above)
   ========================================================================== */
.lifecycle { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 16px 12px; overflow-x: auto; }
.lifecycle .status-stepper { min-width: 940px; }
.lifecycle .status-stepper .ss .l { font-size: 11.5px; line-height: 1.3; }
.lifecycle .lc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 12.5px; color: var(--muted); }
.lifecycle .lc-head b { color: var(--ink); font-weight: 600; }
.lifecycle .lc-head .right { margin-left: auto; display: flex; align-items: center; gap: 8px; position: relative; }

.jump-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; width: 300px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-pop); padding: 4px; display: none; }
.jump-menu.open { display: block; }
.jump-menu .jm-note { padding: 8px 10px 6px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--divider); margin-bottom: 4px; }
.jump-menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 10px; border-radius: var(--r-sm); font-size: 13px; text-align: left; color: var(--text-secondary); }
.jump-menu button:hover { background: var(--nav-hover); color: var(--ink); }
.jump-menu button .n { width: 18px; height: 18px; border-radius: 50%; background: var(--nav-active); display: grid; place-items: center; font-size: 10.5px; font-weight: 600; color: var(--muted); flex: none; }
.jump-menu button.cur .n { background: var(--primary); color: #fff; }

/* Two-lane delivery plan */
.lanes { display: flex; flex-direction: column; gap: 10px; }
.lane { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.lane-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--row-hover); border-bottom: 1px solid var(--divider); font-size: 13px; }
.lane-head b { font-weight: 600; }
.lane-head .caption { margin-left: 2px; }
.lane-head .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.lane-steps { display: flex; align-items: stretch; gap: 0; padding: 12px; overflow-x: auto; }
.lane-step { flex: 1 1 0; min-width: 132px; display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid var(--divider); border-radius: var(--r-md); background: var(--surface); font-size: 12.5px; position: relative; }
.lane-step .sn { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.lane-step .sn svg.lucide { width: 13px; height: 13px; }
.lane-step b { font-weight: 600; font-size: 13px; line-height: 1.3; }
.lane-step.done { border-color: rgba(31,157,99,.35); background: var(--success-soft); }
.lane-step.done .sn { color: var(--success); }
.lane-step.cur { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.lane-step.warn { border-color: rgba(183,121,31,.45); background: var(--warning-soft); }
.lane-arrow { flex: none; width: 22px; display: grid; place-items: center; color: var(--muted-soft); }
.lane-arrow svg.lucide { width: 14px; height: 14px; }
.lane.system .lane-head { background: var(--primary-soft); }
.lane-partners { border-top: 1px solid var(--divider); padding: 4px 12px 8px; }

.cp-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 0; border-top: 1px solid var(--divider); font-size: 13px; }
.cp-row:first-child { border-top: 0; }
.cp-row .n { font-weight: 500; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cp-row .x { font-size: 12px; color: var(--muted); }
.cp-row .c { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stars { display: inline-flex; gap: 1px; color: var(--warning); vertical-align: -2px; }
.stars svg.lucide { width: 12px; height: 12px; }
.stars .off { color: var(--disabled); }
.ontime { font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* Email preview (auto-generated mail with magic link) */
.mail { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.mail-head { padding: 10px 14px; background: var(--row-hover); border-bottom: 1px solid var(--divider); display: grid; grid-template-columns: 60px 1fr; gap: 2px 8px; font-size: 12.5px; }
.mail-head span { color: var(--muted); }
.mail-head b { font-weight: 500; overflow-wrap: anywhere; }
.mail-body { padding: 12px 14px; font-size: 13px; color: var(--text-secondary); display: flex; flex-direction: column; gap: 8px; }
.mail-body p { margin: 0; }
.mail-body ul { margin: 0; padding-left: 18px; }
.mail-link { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: var(--r-sm); background: var(--ink); color: #fff; font-size: 12.5px; font-weight: 500; }
.mail-link svg.lucide { width: 13px; height: 13px; }
.mail-sent { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--success); font-weight: 500; }
.mail-sent svg.lucide { width: 14px; height: 14px; }

/* Digital Shipment ID */
.dsid { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 4px 0 10px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12.5px; font-weight: 600; letter-spacing: .02em; }
.dsid button { width: 22px; height: 22px; border-radius: var(--r-xs); display: grid; place-items: center; color: var(--muted); }
.dsid button:hover { background: var(--nav-hover); color: var(--ink); }
.dsid svg.lucide { width: 13px; height: 13px; }

/* Checklists (documents, B/L, POD) */
.cl { list-style: none; margin: 0; padding: 0; }
.cl > li { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 0; border-top: 1px solid var(--divider); }
.cl > li:first-child { border-top: 0; padding-top: 2px; }
.cl .icon-tile { width: 32px; height: 32px; }
.cl .t { font-weight: 500; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cl .d { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.cl .warnline { margin-top: 6px; display: grid; grid-template-columns: 14px 1fr; gap: 6px; font-size: 12.5px; color: var(--danger); }
.cl .warnline.ok { color: var(--success); }
.cl .warnline svg.lucide { width: 13px; height: 13px; margin-top: 2px; }
.cl .acts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* Step timeline (execution) */
.tl { list-style: none; margin: 0; padding: 0; position: relative; }
.tl > li { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 12px; padding: 0 0 16px; position: relative; }
.tl > li::before { content: ""; position: absolute; left: 11px; top: 24px; bottom: 0; width: 2px; background: var(--divider); }
.tl > li:last-child::before { display: none; }
.tl > li.done::before { background: var(--success); }
.tl .dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface); display: grid; place-items: center; font-size: 10.5px; font-weight: 600; color: var(--muted); position: relative; z-index: 1; }
.tl .dot svg.lucide { width: 12px; height: 12px; }
.tl li.done .dot { background: var(--success); border-color: var(--success); color: #fff; }
.tl li.warn .dot { background: var(--warning); border-color: var(--warning); color: #fff; }
.tl li.cur .dot { border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.tl li.locked .dot { color: var(--disabled); }
.tl .t { font-weight: 500; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl .d { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tl .note { margin-top: 6px; font-size: 12.5px; color: var(--text-secondary); background: var(--row-hover); border: 1px solid var(--divider); border-radius: var(--r-sm); padding: 6px 10px; }
.tl .note.warn { background: var(--warning-soft); border-color: transparent; }
.tl .w { font-size: 12px; color: var(--muted); white-space: nowrap; text-align: right; }

/* Version history */
.vh { list-style: none; margin: 0; padding: 0; }
.vh li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 9px 0; border-top: 1px solid var(--divider); font-size: 13px; }
.vh li:first-child { border-top: 0; }
.vh .v { height: 22px; border-radius: var(--r-xs); background: var(--nav-active); display: grid; place-items: center; font-size: 11.5px; font-weight: 600; color: var(--text-secondary); }
.vh li.cur .v { background: var(--primary); color: #fff; }
.vh .x { font-size: 12px; color: var(--muted); margin-top: 2px; }
.vh .c { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }

/* Small helpers */
.kv2 { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 7px 16px; font-size: 13.5px; margin: 0; }
.kv2 dt { color: var(--muted); } .kv2 dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.fx-note { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.fx-note svg.lucide { width: 13px; height: 13px; }
.cond { display: inline-flex; align-items: center; gap: 4px; }
.in { height: 34px; border: 1px solid var(--border); border-radius: var(--r-sm); padding: 0 10px; background: var(--surface); width: 100%; min-width: 0; }
.in:focus, .ta2:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,61,224,.10); }
.in.missing { border-color: var(--warning); background: var(--warning-soft); }
.ta2 { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 8px 10px; min-height: 72px; resize: vertical; line-height: 1.45; width: 100%; background: var(--surface); }
.lbl { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.lbl > span { font-size: 12px; font-weight: 500; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 720px) { .grid2, .grid3, .kv2 { grid-template-columns: minmax(0, 1fr); } }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb { width: 64px; height: 64px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--row-hover) center/cover no-repeat; display: grid; place-items: center; color: var(--muted); }
.thumb svg.lucide { width: 18px; height: 18px; }
.sigpad { width: 100%; height: 160px; border: 1.5px dashed var(--border); border-radius: var(--r-md); background: var(--surface); touch-action: none; display: block; cursor: crosshair; }
.sigimg { height: 72px; border-bottom: 1px solid var(--border); }
.qrbox { width: 128px; height: 128px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: var(--r-sm); padding: 6px; background: #fff; }
.qrbox svg, .qrbox img { width: 100%; height: 100%; }

/* Magic-link and driver pages: no navigation, phone first */
.m-body { background: var(--shell); overflow: auto; }
.m-page { max-width: 560px; margin: 0 auto; padding: 16px 16px 40px; display: flex; flex-direction: column; gap: 14px; }
.m-top { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.m-top .logo { width: 30px; height: 30px; border-radius: var(--r-sm); display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; flex: none; }
.m-top b { font-weight: 600; }
.m-top .caption { display: block; }
.m-page .card { padding: 16px; }
.m-page h1 { font-size: 18px; font-weight: 600; margin: 0; }
.m-page .btn-primary.wide, .m-page .btn-secondary.wide { width: 100%; justify-content: center; height: 40px; }
.m-foot { text-align: center; font-size: 12px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; }
.m-foot img { width: 14px; height: 14px; }
.a-wrap { max-width: 1240px; margin: 0 auto; padding: 20px 32px 32px; display: flex; flex-direction: column; gap: 16px; }
.a-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.a-grid.wide-left { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .a-grid, .a-grid.wide-left { grid-template-columns: minmax(0, 1fr); } }
.a-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.a-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.a-title h1, .a-title .caption { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.a-list { list-style: none; margin: 0; padding: 0; }
.a-list > li { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--divider); }
.a-list > li:first-child { border-top: 0; padding-top: 0; }
.a-list .t { font-weight: 500; }
.a-list .d { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.internal-tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; border-radius: 4px; background: var(--ink); color: #fff; font-size: 11.5px; }
.internal-tag svg.lucide { width: 11px; height: 11px; }
.typed2 { display: grid; grid-template-columns: 32px 1fr; gap: 10px; }
.typed2 .user-avatar { width: 32px; height: 32px; font-size: 12px; }
.typed2 .bubble { background: var(--nav-active); padding: 10px 14px; border-radius: var(--r-lg); border-top-left-radius: var(--r-xs); font-size: 14px; }
.typed2 .who { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.radio { appearance: none; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--disabled); background: var(--surface); margin: 0; cursor: pointer; flex: none; display: grid; place-items: center; }
.radio:checked { border-color: var(--primary); }
.radio:checked::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.radio:disabled { opacity: .4; cursor: not-allowed; }
.cmp td { vertical-align: top; }
.cmp tr.best td { background: var(--primary-soft); }
.cmp .amt { font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; }
.stars svg.lucide { fill: currentColor; }
.stars svg.lucide.off, .stars .off { fill: none; }
