/* ==========================================================================
   Kin Shing — B2B merchant portal
   Loaded only on /b2b routes.
   ========================================================================== */
.b2b-page { background: var(--mist); min-height: 60vh; padding: 36px 0 80px; }
.b2b-page .container { max-width: 1180px; }
.b2b-page h1, .b2b-page h2, .b2b-page h3 { letter-spacing: -.015em; }
.b2b-muted { color: var(--muted); }
.b2b-small { font-size: 12.5px; }

/* top bar / account strip */
.b2b-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 18px 22px; margin-bottom: 18px;
  background: var(--green-900); color: #fff; border-radius: var(--radius-lg);
  position: relative; overflow: hidden;
}
.b2b-bar::after {
  content: ""; position: absolute; right: -40px; top: -70px; width: 230px; height: 230px;
  border: 1px solid rgba(255,255,255,.12); border-radius: 50%;
}
.b2b-bar__id { display: flex; align-items: center; gap: 15px; min-width: 0; position: relative; z-index: 1; }
.b2b-bar__mark {
  width: 42px; height: 42px; flex: none; display: grid; place-items: center;
  border: 1px solid rgba(255,255,255,.24); border-radius: 50%; color: #cbe6b4;
  font-size: 12px; font-weight: 700; letter-spacing: .08em;
}
.b2b-bar__id strong { display: block; font-size: 16px; font-weight: 600; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b2b-bar__id small { display: block; color: rgba(255,255,255,.55); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }
.b2b-bar__actions { display: flex; align-items: center; gap: 10px; position: relative; z-index: 1; }
.b2b-bar__link, .b2b-bar__out {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.22); border-radius: var(--radius);
  color: rgba(255,255,255,.85); font-size: 12.5px; background: transparent;
  transition: background .2s, border-color .2s, color .2s;
}
.b2b-bar__link:hover, .b2b-bar__out:hover { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.4); }
.b2b-bar__out .icon, .b2b-bar__link .icon { width: 14px; height: 14px; }

/* tabs */
.b2b-tabs {
  display: flex; gap: 4px; overflow-x: auto; margin-bottom: 28px;
  border-bottom: 1px solid var(--line); scrollbar-width: none;
}
.b2b-tabs::-webkit-scrollbar { display: none; }
.b2b-tabs a {
  flex: none; padding: 11px 16px 13px; font-size: 13.5px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .2s, border-color .2s;
}
.b2b-tabs a:hover { color: var(--ink); }
.b2b-tabs a.is-active { color: var(--green-700); border-bottom-color: var(--green); }

/* headings */
.b2b-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.b2b-head h1 { font-size: clamp(24px, 3vw, 32px); margin-bottom: 5px; }
.b2b-head p { color: var(--muted); font-size: 13.5px; }
.b2b-head__actions { display: flex; gap: 10px; flex-wrap: wrap; }
.b2b-eyebrow { font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--green); font-weight: 700; margin-bottom: 8px; }

/* flash + alerts */
.b2b-flash { display: grid; gap: 8px; margin-bottom: 18px; }
.b2b-flash__item {
  padding: 11px 15px; border-radius: var(--radius); font-size: 13px;
  border: 1px solid var(--line); background: #fff;
}
.b2b-flash__item--success { border-color: #c8e0b4; background: var(--green-50); color: var(--green-700); }
.b2b-flash__item--error { border-color: #efcfcb; background: #fdf3f2; color: #a32b21; }
.b2b-notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px;
  border: 1px solid #e5dcc0; background: #fbf7ea; border-radius: var(--radius);
  font-size: 13px; color: #6b5a24; margin-bottom: 20px;
}
.b2b-notice .icon { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.b2b-notice a { font-weight: 700; border-bottom: 1px solid currentColor; }

/* stat cards */
.b2b-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.b2b-stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 20px 20px 18px; position: relative;
}
.b2b-stat__label { font-size: 11.5px; color: var(--muted); letter-spacing: .04em; }
.b2b-stat__value { font-size: 32px; font-weight: 600; color: var(--ink); line-height: 1.15; margin: 6px 0 2px; letter-spacing: -.03em; }
.b2b-stat__note { font-size: 11px; color: #8b978f; }
.b2b-stat--accent { background: var(--green); border-color: var(--green); }
.b2b-stat--accent .b2b-stat__label, .b2b-stat--accent .b2b-stat__note { color: rgba(255,255,255,.7); }
.b2b-stat--accent .b2b-stat__value { color: #fff; }

/* panels */
.b2b-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 18px; align-items: start; }
.b2b-panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.b2b-panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.b2b-panel__head h2 { font-size: 15px; }
.b2b-panel__head a { font-size: 12px; font-weight: 600; color: var(--green-700); }
.b2b-panel__body { padding: 20px; }
.b2b-panel__foot { padding: 13px 20px; border-top: 1px solid var(--line); background: #fbfcf9; font-size: 12px; color: var(--muted); }

/* tables */
.b2b-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.b2b-table th {
  text-align: left; padding: 10px 16px; font-size: 10.5px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); background: #fbfcf9; border-bottom: 1px solid var(--line);
  font-weight: 600; white-space: nowrap;
}
.b2b-table td { padding: 13px 16px; border-bottom: 1px solid #eef2ea; vertical-align: middle; }
.b2b-table tbody tr:last-child td { border-bottom: 0; }
.b2b-table tbody tr:hover { background: #fbfdf8; }
.b2b-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.b2b-table .strong { color: var(--ink); font-weight: 600; }
.b2b-table .sub { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.b2b-code { font-size: 11.5px; font-weight: 700; color: var(--green-700); letter-spacing: .02em; }

/* status pills */
.b2b-pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 10.5px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.b2b-pill--pending { background: #fbf3dc; color: #7a5c10; }
.b2b-pill--confirmed { background: #e8f1fb; color: #1e4f86; }
.b2b-pill--processing { background: #e8f1fb; color: #1e4f86; }
.b2b-pill--completed { background: var(--green-50); color: var(--green-700); }
.b2b-pill--cancelled { background: #f2f2f0; color: #6b716c; }
.b2b-pill--neutral { background: #f2f4ef; color: var(--muted); }

/* empty state */
.b2b-empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.b2b-empty .icon { width: 30px; height: 30px; color: var(--green); margin: 0 auto 12px; }
.b2b-empty p { font-size: 13px; margin-bottom: 16px; }

/* buttons (small variants) */
.b2b-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius); border: 1px solid transparent;
  background: var(--green); color: #fff; font-size: 13px; font-weight: 600;
  transition: background .2s, border-color .2s, color .2s;
}
.b2b-btn:hover { background: var(--green-700); }
.b2b-btn .icon { width: 15px; height: 15px; }
.b2b-btn--ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.b2b-btn--ghost:hover { background: #fff; border-color: var(--green); color: var(--green-700); }
.b2b-btn--sm { padding: 7px 12px; font-size: 12px; }
.b2b-btn--block { width: 100%; }

/* login */
.b2b-login { background: var(--green-900); position: relative; overflow: hidden; }
.b2b-login::before {
  content: ""; position: absolute; width: 620px; height: 620px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.09); right: -180px; bottom: -320px;
}
.b2b-login::after {
  content: ""; position: absolute; width: 380px; height: 380px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.06); right: 40px; bottom: -240px;
}
.b2b-login__grid { display: grid; grid-template-columns: 1fr 440px; gap: 72px; align-items: center; padding-top: 78px; padding-bottom: 86px; position: relative; z-index: 1; }
.b2b-login__intro { color: rgba(255,255,255,.78); max-width: 520px; }
.b2b-login__intro .b2b-eyebrow { color: #a9d183; }
.b2b-login__intro h1 { color: #fff; font-size: clamp(32px, 4vw, 46px); line-height: 1.15; margin-bottom: 18px; }
.b2b-login__intro h1 em { font-style: normal; color: #b9dd97; }
.b2b-login__intro > p { font-size: 14.5px; line-height: 1.85; }
.b2b-login__list { display: grid; gap: 14px; margin-top: 30px; }
.b2b-login__list li { display: flex; gap: 12px; align-items: flex-start; font-size: 13.5px; }
.b2b-login__list .icon { width: 18px; height: 18px; color: #a9d183; flex: none; margin-top: 2px; }
.b2b-login__list strong { display: block; color: #fff; font-weight: 600; font-size: 13.5px; }
.b2b-login__list span { color: rgba(255,255,255,.6); font-size: 12.5px; }
.b2b-login__note { margin-top: 30px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.12); font-size: 12px; color: rgba(255,255,255,.5); }
.b2b-login__note a { color: #cbe6b4; border-bottom: 1px solid rgba(203,230,180,.4); }
.b2b-login__card { background: #fff; border-radius: var(--radius-lg); padding: 34px 32px 30px; box-shadow: 0 30px 70px -30px rgba(0,0,0,.55); }
.b2b-login__card h2 { font-size: 23px; margin-bottom: 6px; }
.b2b-login__card > p { font-size: 12.5px; color: var(--muted); margin-bottom: 24px; }
.b2b-login__card .field { margin-bottom: 15px; }
.b2b-login__card .b2b-btn { margin-top: 6px; padding: 12px 16px; font-size: 13.5px; }
.b2b-login__hint { margin-top: 18px; padding: 11px 13px; background: var(--mist); border-radius: var(--radius); font-size: 11.5px; color: var(--muted); line-height: 1.65; }
.b2b-login__hint strong { color: var(--ink); }
.b2b-login__back { display: inline-flex; align-items: center; gap: 6px; margin-top: 18px; font-size: 12px; color: var(--muted); }
.b2b-login__back:hover { color: var(--green-700); }

/* history layout */
.b2b-split { display: grid; grid-template-columns: 360px 1fr; gap: 18px; align-items: start; }
.b2b-lib-list { max-height: 620px; overflow: auto; }
.b2b-lib { display: block; padding: 14px 18px; border-bottom: 1px solid #eef2ea; transition: background .15s; }
.b2b-lib:last-child { border-bottom: 0; }
.b2b-lib:hover { background: #fbfdf8; }
.b2b-lib.is-active { background: var(--green-50); box-shadow: inset 3px 0 0 var(--green); }
.b2b-lib__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.b2b-lib__top strong { font-size: 13px; color: var(--ink); }
.b2b-lib__top span { font-size: 12px; font-weight: 600; color: var(--green-700); }
.b2b-lib__meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 4px; font-size: 11.5px; color: var(--muted); }
.b2b-lib-detail__head { display: flex; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.b2b-lib-detail__head h2 { font-size: 18px; }
.b2b-lib-detail__head p { font-size: 12px; color: var(--muted); margin-top: 3px; }
.b2b-total { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; background: var(--green-50); border-top: 1px solid #dbe8ce; }
.b2b-total span { font-size: 12px; color: var(--green-700); }
.b2b-total strong { font-size: 22px; color: var(--green-900); letter-spacing: -.02em; }

/* order form */
.b2b-order-grid { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.b2b-order-lines td { vertical-align: top; }
.b2b-order-lines .b2b-prod-name { font-weight: 600; color: var(--ink); font-size: 13px; }
.b2b-order-lines .b2b-prod-sku { display: block; font-size: 10.5px; color: var(--muted); letter-spacing: .03em; margin-top: 2px; }
.b2b-qty { width: 76px; padding: 8px 8px; border: 1px solid var(--line-strong); border-radius: var(--radius); font: inherit; font-size: 13px; text-align: right; }
.b2b-qty:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(34,119,0,.1); }
.b2b-price { font-variant-numeric: tabular-nums; white-space: nowrap; }
.b2b-line-total { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); font-weight: 600; }
.b2b-summary { position: sticky; top: 100px; }
.b2b-summary__row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); padding: 4px 0; }
.b2b-summary__row strong { color: var(--ink); }
.b2b-summary__total { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 0; margin-top: 8px; border-top: 1px solid var(--line); }
.b2b-summary__total span { font-size: 12px; color: var(--muted); }
.b2b-summary__total strong { font-size: 26px; color: var(--green-900); letter-spacing: -.03em; }
.b2b-summary .field { margin-bottom: 12px; }
.b2b-summary .field input, .b2b-summary .field textarea { padding: 9px 11px; font-size: 13px; }
.b2b-summary .field textarea { min-height: 68px; }
.b2b-summary__note { font-size: 11px; color: var(--muted); line-height: 1.65; margin: 10px 0 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.b2b-source { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; background: var(--green-50); color: var(--green-700); border-radius: 99px; font-size: 11px; font-weight: 600; margin-bottom: 12px; }

/* order detail */
.b2b-detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; }
.b2b-detail-head h1 { font-size: 26px; }
.b2b-detail-head p { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.b2b-detail-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.b2b-detail-meta div { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; }
.b2b-detail-meta span { display: block; font-size: 10.5px; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; }
.b2b-detail-meta strong { font-size: 13px; color: var(--ink); font-weight: 600; }
.b2b-success { text-align: center; padding: 28px 20px 24px; }
.b2b-success__icon { width: 48px; height: 48px; border-radius: 50%; background: var(--green-50); color: var(--green); display: grid; place-items: center; margin: 0 auto 12px; }
.b2b-success__icon .icon { width: 24px; height: 24px; }
.b2b-success h2 { font-size: 21px; margin-bottom: 5px; }
.b2b-success p { font-size: 12.5px; color: var(--muted); }
.b2b-address { font-size: 13px; line-height: 1.7; color: var(--ink-soft); white-space: pre-line; }

/* account */
.b2b-account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.b2b-account-grid .b2b-panel__body { display: grid; gap: 13px; }
.b2b-account-grid .field input, .b2b-account-grid .field textarea { padding: 9px 11px; font-size: 13px; }
.b2b-account-grid .field textarea { min-height: 76px; }
.b2b-account-grid .b2b-btn { justify-self: start; }

/* responsive */
@media (max-width: 1020px) {
  .b2b-login__grid { grid-template-columns: 1fr 400px; gap: 40px; }
  .b2b-split { grid-template-columns: 320px 1fr; }
  .b2b-order-grid { grid-template-columns: 1fr 300px; }
  .b2b-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .b2b-login__grid { grid-template-columns: 1fr; gap: 32px; padding-top: 50px; padding-bottom: 56px; }
  .b2b-login__intro { max-width: none; }
  .b2b-login__list { display: none; }
  .b2b-login__note { margin-top: 20px; }
  .b2b-login__card { max-width: 480px; }
  .b2b-grid, .b2b-split, .b2b-order-grid, .b2b-account-grid { grid-template-columns: 1fr; }
  .b2b-summary { position: static; }
  .b2b-lib-list { max-height: 360px; }
  .b2b-detail-meta { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px) {
  .b2b-page { padding: 24px 0 56px; }
  .b2b-bar { padding: 15px 16px; align-items: flex-start; }
  .b2b-bar__mark { display: none; }
  .b2b-bar__id strong { font-size: 14px; white-space: normal; }
  .b2b-bar__link { display: none; }
  .b2b-bar__out span { display: none; }
  .b2b-bar__out { padding: 8px; }
  .b2b-tabs { margin-bottom: 20px; }
  .b2b-tabs a { padding: 10px 8px 12px; font-size: 12px; }
  .b2b-head { margin-bottom: 16px; }
  .b2b-head h1 { font-size: 23px; }
  .b2b-stats { gap: 10px; }
  .b2b-stat { padding: 15px; }
  .b2b-stat__value { font-size: 26px; }
  .b2b-login__card { padding: 26px 20px 22px; }
  .b2b-table th, .b2b-table td { padding: 10px 11px; }
  .b2b-table--stack thead { display: none; }
  .b2b-table--stack tbody tr { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .b2b-table--stack tbody td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; text-align: right; }
  .b2b-table--stack tbody td::before { content: attr(data-label); font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; text-align: left; flex: none; }
  .b2b-table--stack tbody td:first-child { display: block; text-align: left; padding-bottom: 7px; }
  .b2b-table--stack tbody td:first-child::before { display: none; }
  .b2b-table--stack .num { text-align: right; }
  .b2b-detail-meta { gap: 9px; }
  .b2b-detail-meta div { padding: 10px 12px; }
  .b2b-order-lines, .b2b-order-lines tbody { display: block; width: 100%; }
  .b2b-order-lines thead { display: none; }
  .b2b-order-lines tbody tr { display: block; padding: 13px 14px; border-bottom: 1px solid var(--line); }
  .b2b-order-lines tbody td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; text-align: right; }
  .b2b-order-lines tbody td::before { content: attr(data-label); font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; text-align: left; flex: none; }
  .b2b-order-lines tbody td:first-child { display: block; text-align: left; padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px dashed var(--line); }
  .b2b-order-lines tbody td:first-child::before { display: none; }
  .b2b-order-lines .b2b-qty { width: 86px; }
  .b2b-total strong { font-size: 19px; }
}
