/* ProcureHub — shared styles */
:root {
  --bg: #F6F4F9;
  --surface: #FFFFFF;
  --ink: #2D1B40;
  --ink-2: #45355A;
  --muted: #6A6078;
  --line: #E7E2EE;
  --line-2: #F0EDF5;
  --hover: #F8F6FB;
  --accent: #6D2CD4;
  --accent-600: #5A20B8;
  --accent-50: #F4EEFD;
  --accent-100: #E7DBFB;
  --accent-200: #CDB4F6;
  --green: #067A55; --green-bg: #E3F6EE; --green-dot: #12B886;
  --amber: #9A4A06; --amber-bg: #FFF3DD; --amber-dot: #F59F00;
  --red: #B42318;   --red-bg: #FEECEB;   --red-dot: #F04438;
  --blue: #1D4ED8;  --blue-bg: #E8EFFE;  --blue-dot: #3B82F6;
  --gray: #3B4455;  --gray-bg: #F0EDF4;  --gray-dot: #98A2B3;
  --r-xl: 22px; --r-lg: 18px; --r: 12px; --r-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(45, 27, 64, .05);
  --shadow: 0 1px 2px rgba(45, 27, 64, .04), 0 12px 32px -16px rgba(45, 27, 64, .14);
  --orange: #FD7E1E; --orange-600: #E0680C; --orange-50: #FFF1E6;
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--ink);
  background: var(--bg); -webkit-font-smoothing: antialiased; font-feature-settings: "ss01", "cv11";
}
a { color: var(--accent-600); text-decoration: none; }
a:hover { color: var(--accent); }
h1, h2, h3 { margin: 0; color: var(--ink); }
p { margin: 0; }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 14px 0 14px 14px; z-index: 30; }
.sidebar-inner {
  height: 100%; display: flex; flex-direction: column; gap: 6px; padding: 18px 12px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); overflow-y: auto;
}
.brand { display: flex; align-items: center; padding: 2px 10px 14px; }
.brand img { height: 34px; width: auto; }
.public-top .brand, .portal-top .brand { padding: 0; }
.public-top .brand img, .portal-top .brand img { height: 32px; }
.auth-art .brand img { height: 38px; }
.nav-label { font-size: 12px; font-weight: 500; color: var(--muted); padding: 14px 12px 4px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px; height: 38px; padding: 0 12px; border-radius: 11px;
  color: var(--ink-2); font-weight: 500; transition: background .12s;
}
.nav a svg { color: var(--muted); }
.nav a:hover { background: var(--hover); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-50); color: var(--accent-600); font-weight: 600; }
.nav a[aria-current="page"] svg { color: var(--accent); }
.nav .count {
  margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 999px; font-size: 12px; font-weight: 600;
  display: grid; place-items: center; background: var(--orange); color: var(--ink);
}
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 12px; }
.portal-link {
  display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 14px; color: var(--ink-2); font-weight: 500;
  background: var(--bg);
}
.portal-link:hover { color: var(--ink); background: var(--line-2); }
.me { display: flex; align-items: center; gap: 10px; padding: 8px 6px 2px; }
.me .who { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.me .who span:last-child { font-size: 12px; color: var(--muted); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface);
  display: inline-grid; place-items: center; color: var(--ink-2); cursor: pointer; position: relative; flex-shrink: 0;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.plain { border-color: transparent; background: transparent; }
.dot-badge { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 2px #fff; }

.main { min-width: 0; padding: 14px 28px 56px; }
.topbar { display: flex; align-items: center; gap: 10px; height: 56px; }
.menu-btn { display: none; }
.cmd {
  display: flex; align-items: center; gap: 10px; width: min(460px, 100%); height: 42px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--muted);
}
.cmd input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; color: var(--ink); }
.cmd:focus-within { border-color: var(--accent-200); box-shadow: 0 0 0 4px var(--accent-50); }
kbd { font-family: inherit; font-size: 12px; padding: 1px 6px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--bg); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.page { max-width: 1360px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 22px 0 26px; flex-wrap: wrap; }
.page-head h1 { font-size: 34px; line-height: 1.08; font-weight: 600; letter-spacing: -.04em; }
.page-head .sub { margin-top: 8px; color: var(--muted); font-size: 15px; max-width: 70ch; }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--ink); }
.crumbs svg { color: #A79FB3; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: var(--r); border: 1px solid transparent; font-weight: 600; font-size: 14px; white-space: nowrap;
  cursor: pointer; transition: background .12s, border-color .12s, transform .06s; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #402C57; color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-600); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--hover); color: var(--ink); }
.btn-soft { background: var(--accent-50); color: var(--accent-600); }
.btn-soft:hover { background: var(--accent-100); color: var(--accent-600); }
.btn-danger { background: var(--surface); color: var(--red); border-color: #F7C9C4; }
.btn-danger:hover { background: var(--red-bg); color: var(--red); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-2); color: var(--ink); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-lg { height: 48px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent-600); font-weight: 600; cursor: pointer; }

/* ---------- Cards & layout ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.card.pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 14px; }
.card-head h2 { font-size: 16px; font-weight: 600; letter-spacing: -.015em; }
.card-head .hint { font-size: 13px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 4px 20px 20px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--line-2); font-size: 13px; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.stack-sm { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.grid { display: grid; gap: 20px; align-items: start; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1fr) 368px; }
.g-wide { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.g-list { grid-template-columns: 380px minmax(0, 1fr); }
.gap-lg { gap: 24px; }
.mt { margin-top: 20px; }

/* ---------- KPIs ---------- */
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--bg); color: var(--ink-2); }
.kpi-value { font-size: 28px; font-weight: 600; letter-spacing: -.035em; line-height: 1; font-variant-numeric: tabular-nums; }
.delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; align-self: flex-start; }
.delta.up { color: var(--green); background: var(--green-bg); }
.delta.warn { color: var(--amber); background: var(--amber-bg); }
.delta.down { color: var(--red); background: var(--red-bg); }
.delta.flat { color: var(--gray); background: var(--gray-bg); }

/* ---------- Pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.pill.green { color: var(--green); background: var(--green-bg); }
.pill.amber { color: var(--amber); background: var(--amber-bg); }
.pill.red { color: var(--red); background: var(--red-bg); }
.pill.blue { color: var(--blue); background: var(--blue-bg); }
.pill.gray { color: var(--gray); background: var(--gray-bg); }
.pill.violet { color: var(--accent-600); background: var(--accent-50); }
.tag { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 8px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--ink-2); border: 1px solid var(--line); }

/* ---------- Segmented tabs ---------- */
.seg { display: inline-flex; gap: 2px; padding: 4px; background: var(--gray-bg); border-radius: 13px; flex-wrap: wrap; }
.seg button {
  height: 32px; padding: 0 12px; border: 0; background: transparent; border-radius: 9px; font-weight: 500; color: var(--ink-2);
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.seg button .c { font-size: 12px; color: var(--muted); font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(45,27,64,.12); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 8px; height: 38px; width: 280px; max-width: 100%; padding: 0 12px; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); background: var(--surface); }
.search input { border: 0; outline: 0; flex: 1; min-width: 0; background: transparent; color: var(--ink); }
.search:focus-within { border-color: var(--accent-200); box-shadow: 0 0 0 4px var(--accent-50); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--line-2); white-space: nowrap; background: #FBFAFD; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--hover); }
.table .r { text-align: right; font-variant-numeric: tabular-nums; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.cell-2 { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.cell-2 span:last-child { font-size: 13px; color: var(--muted); }
.cell-2 .t { font-weight: 600; color: var(--ink); }
.id-link { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.id-link:hover { color: var(--accent-600); }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }

/* ---------- Avatars ---------- */
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; flex-shrink: 0; background: var(--gray-bg); color: var(--ink-2); }
.avatar.sq { border-radius: 11px; }
.avatar.lg { width: 64px; height: 64px; font-size: 20px; border-radius: 18px; }
.avatar.a1 { background: #EDE3FD; color: #5A20B8; }
.avatar.a2 { background: #DDF4EA; color: #067A55; }
.avatar.a3 { background: #FFE9D6; color: #9A4A06; }
.avatar.a4 { background: #DCEBFF; color: #1D4ED8; }
.avatar.dark { background: var(--ink); color: #fff; }

/* ---------- Progress ---------- */
.bar { height: 8px; border-radius: 999px; background: var(--gray-bg); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .25s ease; }
.bar.lg { height: 12px; }
.bar.green > span { background: var(--green-dot); }
.bar.amber > span { background: var(--amber-dot); }
.bar.red > span { background: var(--red-dot); }
.stackbar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--gray-bg); }
.stackbar span { height: 100%; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .help { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface);
  color: var(--ink); outline: none; transition: border-color .12s, box-shadow .12s;
}
.select { appearance: none; padding-right: 36px; background-image: 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='%235B6478' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 84px; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-50); }
.input.sm { height: 36px; border-radius: 9px; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.dropzone {
  border: 1.5px dashed #D6CFE0; border-radius: 14px; padding: 22px; display: flex; align-items: center; justify-content: center;
  gap: 10px; color: var(--muted); background: #FBFAFD; text-align: center;
}
.file-chip { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.file-chip .ext { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--red-bg); color: var(--red); }

.switch { position: relative; width: 42px; height: 24px; border-radius: 999px; border: 0; background: #D3CCDD; cursor: pointer; padding: 0; flex-shrink: 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }

/* ---------- Lists ---------- */
.list > * + * { border-top: 1px solid var(--line-2); }
.list-row { display: flex; align-items: center; gap: 14px; padding: 13px 20px; }
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; padding: 10px 0; font-size: 14px; }
.kv + .kv { border-top: 1px solid var(--line-2); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.dl-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.dl-grid dt { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.dl-grid dd { margin: 0; font-weight: 600; }
.sum { display: flex; flex-direction: column; gap: 8px; width: 300px; margin-left: auto; font-variant-numeric: tabular-nums; }
.sum > div { display: flex; justify-content: space-between; }
.sum > div span:first-child { color: var(--muted); }
.sum .total { padding-top: 10px; border-top: 1px solid var(--line); font-size: 17px; font-weight: 700; }
.sum .total span:first-child { color: var(--ink); }

/* ---------- Banners ---------- */
.banner { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 16px; border: 1px solid; flex-wrap: wrap; }
.banner .b-text { flex: 1; min-width: 220px; }
.banner .b-title { font-weight: 600; }
.banner.success { background: var(--green-bg); border-color: #BDE8D6; color: #054D36; }
.banner.warn { background: var(--amber-bg); border-color: #FBDDA6; color: #6B3304; }
.banner.danger { background: var(--red-bg); border-color: #F8CBC6; color: #7A1A12; }
.banner.info { background: var(--accent-50); border-color: var(--accent-100); color: #3B1780; }
.note { padding: 10px 12px; border-radius: 12px; font-size: 13px; }
.note.warn { background: var(--amber-bg); color: #6B3304; }
.note.ok { background: var(--green-bg); color: #054D36; }
.note.bad { background: var(--red-bg); color: #7A1A12; }
.note.plain { background: var(--bg); color: var(--ink-2); }

/* ---------- AI ---------- */
.ai { border-color: var(--accent-100); background: linear-gradient(180deg, #FBF8FF 0%, #FFFFFF 70%); }
.ai-chip { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: var(--accent); flex-shrink: 0; }
.ai-item { display: flex; flex-direction: column; gap: 4px; padding: 14px 0; }
.ai-item + .ai-item { border-top: 1px solid var(--line-2); }
.ai-item .k { font-size: 12px; font-weight: 600; color: var(--accent-600); }

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-direction: column; }
.tl { display: flex; gap: 14px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; }
.tl-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--green-bg); color: var(--green); }
.tl-dot.wait { background: var(--amber-bg); color: var(--amber); box-shadow: 0 0 0 4px #FFF9EC; }
.tl-dot.no { background: var(--red-bg); color: var(--red); }
.tl-dot.idle { background: var(--gray-bg); color: var(--gray); }
.tl-line { width: 2px; flex: 1; min-height: 18px; background: var(--line); margin: 4px 0; }
.tl-body { padding-bottom: 18px; display: flex; flex-direction: column; gap: 2px; }
.tl:last-child .tl-body { padding-bottom: 0; }

/* ---------- Stepper (PO) ---------- */
.stepper { display: flex; align-items: flex-start; padding: 22px 24px; overflow-x: auto; }
.step { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 96px; text-align: center; font-size: 12px; color: var(--muted); font-weight: 500; }
.step .s-dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--surface); border: 1.5px solid var(--line); color: var(--muted); }
.step.done .s-dot { background: var(--ink); border-color: var(--ink); color: #fff; }
.step.now .s-dot { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 0 5px var(--accent-50); }
.step.done, .step.now { color: var(--ink); }
.step.now { font-weight: 700; }
.step-line { flex: 1; height: 2px; background: var(--line); margin-top: 14px; min-width: 24px; }
.step-line.done { background: var(--ink); }

/* ---------- Dashboard pipeline ---------- */
.pipeline { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); padding: 8px; gap: 0; }
.stage {
  position: relative; display: flex; flex-direction: column; gap: 6px; padding: 16px 16px 14px; border-radius: 14px; color: var(--ink);
  transition: background .12s;
}
.stage:hover { background: var(--hover); color: var(--ink); }
.stage + .stage::before { content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 1px; background: var(--line-2); }
.stage .s-name { font-size: 13px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stage .s-count { font-size: 34px; font-weight: 600; letter-spacing: -.045em; line-height: 1; font-variant-numeric: tabular-nums; }
.stage .s-val { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.stage .s-flag { font-size: 12px; font-weight: 600; }
.stage.hot { background: var(--accent-50); }
.stage.hot .s-name { color: var(--accent-600); }
.flowbar { display: flex; height: 6px; margin: 0 24px 20px; border-radius: 999px; overflow: hidden; gap: 3px; }
.flowbar span { border-radius: 999px; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; }
.chart text { font-family: var(--font); }

/* ---------- Compare columns ---------- */
.compare { display: grid; grid-template-columns: 200px repeat(3, minmax(0, 1fr)); gap: 12px; align-items: stretch; }
.compare .labels { padding-top: 166px; }
.compare .labels div, .bid .cell { height: 50px; display: flex; align-items: center; border-bottom: 1px solid var(--line-2); font-size: 14px; }
.compare .labels div { color: var(--muted); font-weight: 500; }
.bid { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-lg); overflow: hidden; transition: opacity .2s, border-color .2s; }
.bid .head { height: 160px; padding: 16px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line-2); margin-bottom: 6px; }
.bid .cell { padding: 0 16px; font-weight: 600; font-variant-numeric: tabular-nums; gap: 8px; }
.bid .cell:last-child { border-bottom: 0; }
.bid.rec { border-color: var(--accent-200); box-shadow: 0 0 0 4px var(--accent-50); }
.bid.won { border-color: var(--green-dot); box-shadow: 0 0 0 4px var(--green-bg); }
.bid.lost { opacity: .5; }
.best { font-size: 11px; font-weight: 700; color: var(--green); background: var(--green-bg); padding: 2px 7px; border-radius: 6px; }
.score { font-size: 22px; letter-spacing: -.03em; }

/* ---------- Invoice queue ---------- */
.queue { display: flex; flex-direction: column; gap: 8px; padding: 12px; }
.q-item { width: 100%; text-align: left; padding: 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.q-item:hover { background: var(--hover); }
.q-item[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-50); }
.docs3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.docs3 > div { padding: 12px 14px; border-radius: 12px; background: var(--bg); display: flex; flex-direction: column; gap: 2px; }
.docs3 small { color: var(--muted); font-size: 12px; }
.match-ok { color: var(--green); font-weight: 600; }
.match-bad { color: var(--red); font-weight: 600; }

/* ---------- Vendor pick ---------- */
.pick { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 13px; border: 1.5px solid var(--line); cursor: pointer; transition: border-color .12s, background .12s; }
.pick:has(input:checked) { border-color: var(--accent); background: var(--accent-50); }
.range-row { display: grid; grid-template-columns: 180px minmax(0, 1fr) 52px; gap: 14px; align-items: center; font-weight: 500; }
.range-row input { accent-color: var(--accent); width: 100%; }

/* ---------- Settings ---------- */
.subnav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 16px; }
.subnav button { height: 40px; padding: 0 12px; border-radius: 11px; border: 0; background: transparent; text-align: left; font-weight: 500; color: var(--ink-2); cursor: pointer; }
.subnav button:hover { background: var(--line-2); }
.subnav button[aria-current="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line); }
.chain { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chain .node { height: 30px; padding: 0 12px; border-radius: 999px; display: inline-flex; align-items: center; font-size: 13px; font-weight: 600; background: var(--accent-50); color: var(--accent-600); }
.chain svg { color: #A79FB3; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; z-index: 100;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 500; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 10px; transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.auth-art {
  margin: 14px; border-radius: 28px; padding: 44px; display: flex; flex-direction: column; color: #fff; position: relative; overflow: hidden;
  background: radial-gradient(120% 90% at 100% 0%, #9A68FB 0%, rgba(154,104,251,0) 55%), radial-gradient(90% 70% at 0% 100%, #FD7E1E 0%, rgba(253,126,30,0) 60%), #2D1B40;
}
.auth-art .brand { color: #fff; padding: 0; }
.auth-art h1 { color: #fff; font-size: clamp(36px, 4vw, 54px); font-weight: 600; letter-spacing: -.045em; line-height: 1.02; max-width: 12ch; margin-top: auto; }
.auth-art p { color: #DDD3EC; font-size: 16px; max-width: 44ch; margin-top: 16px; }
.flow-demo { margin-top: 36px; display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.flow-demo div { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); font-size: 14px; color: #F1EAFF; backdrop-filter: blur(6px); }
.flow-demo b { margin-left: auto; font-weight: 600; color: #fff; }
.flow-demo .ok { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: #12B886; color: #fff; flex-shrink: 0; }
.flow-demo .pend { width: 22px; height: 22px; border-radius: 50%; border: 2px dashed rgba(255,255,255,.5); flex-shrink: 0; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-box { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 18px; }
.auth-box h2 { font-size: 30px; font-weight: 600; letter-spacing: -.035em; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Supplier portal ---------- */
.portal-top { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.portal-top .in { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 28px; height: 68px; padding: 0 24px; }
.portal-nav { display: flex; gap: 4px; }
.portal-nav a { height: 36px; padding: 0 12px; border-radius: 10px; display: flex; align-items: center; color: var(--ink-2); font-weight: 500; }
.portal-nav a:hover { background: var(--line-2); color: var(--ink); }
.portal-nav a[aria-current="page"] { background: var(--ink); color: #fff; }
.portal-main { max-width: 1280px; margin: 0 auto; padding: 8px 24px 56px; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pipeline { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stage + .stage::before { display: none; }
  .g-main, .g-wide, .g-list { grid-template-columns: minmax(0, 1fr); }
  .compare { grid-template-columns: 150px repeat(3, minmax(220px, 1fr)); overflow-x: auto; }
  .dl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 290px; transform: translateX(-105%); transition: transform .2s; padding: 10px; }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(45,27,64,.35); z-index: 20; }
  .menu-btn { display: inline-grid; }
  .main { padding: 10px 16px 48px; }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { min-height: 360px; }
  .portal-nav { display: none; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .hide-sm { display: none; }
}
@media (max-width: 600px) {
  .g4, .pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head h1 { font-size: 28px; }
  .docs3 { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* refinements */
.id-link { white-space: nowrap; }
.field .seg { align-self: flex-start; }
.pill:has(svg)::before { display: none; }
.compare .labels { padding-top: 167px; }
.flow-demo b { white-space: nowrap; }

/* ---------- Supplier chatbot ---------- */
.cb-launcher {
  position: fixed; right: 24px; bottom: 24px; z-index: 90; height: 52px; padding: 0 20px 0 16px; border-radius: 999px; border: 0;
  background: var(--ink); color: #fff; display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer;
  box-shadow: 0 10px 30px -8px rgba(45, 27, 64, .45);
}
.cb-launcher:hover { background: #402C57; }
.cb-launcher.open { background: var(--accent); }
.cb-panel {
  position: fixed; right: 24px; bottom: 88px; z-index: 90; width: min(400px, calc(100vw - 32px)); height: min(600px, calc(100vh - 120px));
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: 0 24px 60px -20px rgba(45, 27, 64, .35); overflow: hidden;
}
.cb-panel[hidden] { display: none !important; }
.cb-head { display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; border-bottom: 1px solid var(--line-2); }
.cb-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: #FBFAFD; }
.cb-msg { display: flex; flex-direction: column; gap: 6px; max-width: 88%; }
.cb-msg.me { align-self: flex-end; align-items: flex-end; }
.cb-bubble { padding: 10px 14px; border-radius: 16px 16px 16px 4px; background: var(--surface); border: 1px solid var(--line); line-height: 1.5; }
.cb-msg.me .cb-bubble { background: var(--ink); color: #fff; border-color: var(--ink); border-radius: 16px 16px 4px 16px; }
.cb-typing { color: var(--muted); }
.cb-src { font-size: 12px; color: var(--accent-600); font-weight: 500; padding-left: 4px; }
.cb-hand { align-self: flex-start; }
.cb-chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 16px 0; }
.cb-chip { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--accent-100); background: var(--accent-50); color: var(--accent-600); font-size: 12px; font-weight: 600; cursor: pointer; }
.cb-chip:hover { background: var(--accent-100); }
.cb-form { display: flex; gap: 8px; padding: 12px 16px 16px; }
.cb-inline { position: static; width: 100%; height: 560px; box-shadow: none; border-radius: var(--r-lg); }

/* ---------- Wizard ---------- */
.wizard { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.wz { flex: 1; min-width: 150px; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-weight: 500; }
.wz .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--gray-bg); color: var(--gray); flex-shrink: 0; }
.wz.now { border-color: var(--accent); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 4px var(--accent-50); }
.wz.now .n { background: var(--accent); color: #fff; }
.wz.done { color: var(--ink); }
.wz.done .n { background: var(--ink); color: #fff; }
.public-top { background: var(--surface); border-bottom: 1px solid var(--line); }
.public-top .in { max-width: 1080px; margin: 0 auto; height: 68px; padding: 0 24px; display: flex; align-items: center; gap: 16px; }
.public-main { max-width: 1080px; margin: 0 auto; padding: 8px 24px 64px; }
.chk-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

/* ---------- Catalog ---------- */
.products { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.product { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.product .img { height: 120px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(135deg, #F4EEFD, #FFF1E6); color: var(--accent-600); }
.product .price { font-size: 20px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 500; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.cart-line { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.cart-line + .cart-line { border-top: 1px solid var(--line-2); }

/* ---------- Notifications ---------- */
.notif { display: flex; gap: 14px; padding: 16px 20px; align-items: flex-start; }
.notif + .notif { border-top: 1px solid var(--line-2); }
.notif.unread { background: #FCFBFF; }
.notif .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 8px; flex-shrink: 0; }
.notif:not(.unread) .dot { background: transparent; }
.group-label { padding: 14px 20px 6px; font-size: 13px; font-weight: 600; color: var(--muted); }

/* ---------- Full-page assistant ---------- */
.chat-page { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; height: calc(100vh - 190px); min-height: 520px; }
.chat-main { display: flex; flex-direction: column; overflow: hidden; }
.chat-log { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.chat-log .cb-msg { max-width: 76%; }
.hist a { display: block; padding: 10px 12px; border-radius: 11px; color: var(--ink-2); font-weight: 500; }
.hist a:hover { background: var(--line-2); color: var(--ink); }
.hist a[aria-current="true"] { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }

/* ---------- Knowledge hub ---------- */
.train { display: flex; align-items: center; gap: 14px; }
.src-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.src-ico.pdf { background: var(--red-bg); color: var(--red); }
.src-ico.doc { background: var(--blue-bg); color: var(--blue); }
.src-ico.web { background: var(--green-bg); color: var(--green); }
.src-ico.xls { background: #E3F6EE; color: #067A55; }
.src-ico.faq { background: var(--accent-50); color: var(--accent-600); }

@media (max-width: 1100px) {
  .products { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chat-page { grid-template-columns: minmax(0, 1fr); height: auto; }
  .chat-page > .hist-card { display: none; }
  .chat-main { height: 640px; }
}
@media (max-width: 600px) {
  .products, .chk-grid { grid-template-columns: minmax(0, 1fr); }
  .cb-launcher span { display: none; }
  .cb-launcher { padding: 0 16px; }
}

/* brand accents from the logo */
.stage.hot { background: var(--orange-50); }
.stage.hot .s-name { color: var(--orange-600); }
.nav a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--accent); }
.cb-launcher:hover { background: var(--accent); }
.wz.now { border-color: var(--accent); }
.page-head h1 { color: var(--ink); }

/* ---------- Small phones: keep the top bar inside the screen ---------- */
@media (max-width: 600px) {
  .topbar { gap: 8px; }
  .cmd { flex: 1 1 auto; width: auto; min-width: 0; }
  .topbar-right { gap: 6px; flex-shrink: 0; }
  .topbar-right .btn-sm { padding: 0 8px; }
  .page-head .sub { overflow-wrap: anywhere; }
}
