/* ═══════════════════════════════════════════════════════════════
   EXTENSIONS — components the prototype has no design for.
   Nothing here invents a new visual language: every rule is assembled
   from the prototype's own parts (tokens, .card, .chip, .banner,
   .hex-avatar, .empty-note) per docs/design-migration-map.md.
   ═══════════════════════════════════════════════════════════════ */

/* ─── skip link + boot fallback ─── */
.skip-link {
  position: fixed; top: 8px; inset-inline-start: 8px; z-index: 300;
  transform: translateY(-200%);
  background: var(--royal); color: #FFFFFF;
  padding: 10px 18px; border-radius: var(--radius-btn);
  font-weight: 600; font-size: .875rem; box-shadow: var(--shadow-raised);
  transition: transform .16s var(--ease);
}
.skip-link:focus-visible { transform: translateY(0); }

/* The sprite host must stay rendered (see index.html) but occupy nothing. */
#sprite-host { position: absolute; width: 0; height: 0; overflow: hidden; }

.boot-message {
  max-width: 560px; margin: 15vh auto; padding: 28px;
  display: flex; flex-direction: column; gap: 12px; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); box-shadow: var(--shadow-raised);
  color: var(--body); font-size: .9375rem; line-height: 1.7;
}
/* `display:flex` above would otherwise beat the UA rule for [hidden]. */
.boot-message[hidden] { display: none; }
.boot-message strong { color: var(--heading); font-size: 1.0625rem; }
.boot-message code { font-family: var(--font-mono); font-size: .8125rem; direction: ltr; }
.boot-cmd {
  background: var(--bg-alt); border: 1px dashed var(--border-strong);
  border-radius: var(--radius-btn); padding: 12px 16px; font-size: .875rem;
}

/* ─── login — one screen for buyers and suppliers ───────────────────────────
   Split layout: the business on one half, the form on the other. Below 900px
   the brand panel collapses to a compact header rather than stacking at full
   height — a login that needs scrolling on a phone is a login people fail. */

.auth-split {
  /* `flex: 1` matters: the login renders into #app, which is `display:flex`
     for the shell layout. Without it the grid is a content-sized flex item and
     the two "halves" come out narrower than the window. */
  flex: 1;
  width: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-section);
}

/* Brand half. Uses --grad-primary, one of the three permitted gradients, and
   stays dark in both themes: it is the logo wall, not a surface. */
.auth-brand {
  position: relative;
  overflow: hidden;
  background: var(--grad-primary);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}
.auth-brand::after {
  /* The hexagon motif, barely there — texture, not decoration. */
  content: "";
  position: absolute;
  inset: 0;
  background: url("../assets/logo.png") center 50% / 620px no-repeat;
  opacity: .05;
  pointer-events: none;
}
.auth-brand-inner {
  position: relative;
  z-index: 1;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.auth-brand-mark {
  width: 76px; height: 76px; flex: none;
  border-radius:50%; overflow:hidden;
  background: #FFFFFF;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.auth-brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.auth-brand-word {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.75rem;
  letter-spacing: .01em;
  line-height: 1.2;
}
.auth-brand-tag {
  font-size: 1rem;
  line-height: 1.8;
  color: rgba(255, 255, 255, .82);
}
.auth-brand-points {
  display: flex; flex-direction: column; gap: 12px;
  margin-top: 8px; padding: 0; list-style: none;
}
.auth-brand-points li {
  display: flex; align-items: center; gap: 10px;
  font-size: .875rem;
  color: rgba(255, 255, 255, .88);
}
.auth-brand-points svg {
  width: 20px; height: 20px; flex: none;
  color: var(--glow-blue);
}

/* Form half. */
.auth-form-panel {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  background: var(--bg);
}
.auth-toolbar {
  position: absolute;
  top: 20px; inset-inline-end: 24px;
  display: flex; align-items: center; gap: 8px;
}
.auth-form-inner {
  width: min(400px, 100%);
  display: flex; flex-direction: column; gap: 14px;
}
.auth-tabs { align-self: stretch; margin-bottom: 4px; }
.auth-tabs button { flex: 1; }

.login-title { font-size: 1.5rem; color: var(--heading); }
.login-lede { font-size: .9375rem; color: var(--body); line-height: 1.75; }
.auth-form-inner form { display: flex; flex-direction: column; gap: 16px; margin-top: 4px; }
.auth-form-inner .field-input { font-size: 1.0625rem; letter-spacing: .02em; }
.auth-form-inner .btn-ghost { align-self: flex-start; padding-inline: 0; }
.login-hint, .login-note {
  font-size: .75rem; color: var(--caption); line-height: 1.7;
}
.login-note { text-align: center; margin-top: 4px; }

@media (max-width: 900px) {
  /* auto/1fr, not two equal rows — the brand is a header here, and an equal
     split would push the form below the fold. */
  .auth-split { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-brand { padding: 28px 24px; }
  .auth-brand-inner { max-width: none; flex-direction: row; align-items: center; gap: 14px; }
  .auth-brand-mark { width: 52px; height: 52px; }
  .auth-brand-word { font-size: 1.25rem; }
  .auth-brand-tag, .auth-brand-points { display: none; }
  .auth-brand::after { background-size: 320px; }
  .auth-form-panel { padding: 28px 20px 48px; align-items: flex-start; }
  .auth-toolbar { top: 14px; inset-inline-end: 16px; }
}

@media (max-width: 420px) {
  .auth-form-panel { padding-top: 56px; }
}

/* ─── supplier application form ─────────────────────────────────────────────
   Lives on the login screen as a third state. It is much taller than a login,
   so the form panel stops vertically centring and scrolls from the top. */
.auth-split.is-applying .auth-form-panel { align-items: flex-start; padding-block: 40px; }
.auth-split.is-applying .auth-brand-inner { max-width: 320px; }

.apply-form { width: min(520px, 100%); gap: 10px; }
.apply-back { align-self: flex-start; padding-inline: 0; }
.apply-back svg { width: 18px; height: 18px; }
html[dir="ltr"] .apply-back svg { transform: scaleX(-1); }

.apply-section {
  margin-top: 18px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font-size: .8125rem; font-weight: 700; color: var(--caption);
}
.apply-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .apply-row { grid-template-columns: 1fr; } }

.apply-form .field-label { display: flex; align-items: center; gap: 6px; }
.apply-form .req { color: var(--error); font-weight: 700; }
.apply-form .opt {
  font-size: .6875rem; font-weight: 500; color: var(--caption);
  margin-inline-start: auto;
}
.field-hint { font-size: .6875rem; color: var(--caption); line-height: 1.6; }

.apply-select { width: 100%; }

.apply-check {
  display: flex; align-items: center; gap: 10px;
  min-height: 44px; font-size: .875rem; color: var(--body); cursor: pointer;
}
.apply-check input { width: 18px; height: 18px; accent-color: var(--royal); flex: none; }

/* the "no account yet?" prompt under the supplier login */
.apply-cta {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; flex-wrap: wrap;
  margin-top: 4px; padding-top: 14px; border-top: 1px dashed var(--border-strong);
  font-size: .8125rem; color: var(--caption);
}

/* confirmation */
.apply-done {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  text-align: center; padding: 24px 0;
}
.apply-done-mark {
  width: 64px; height: 64px; flex: none;
  border-radius:50%; overflow:hidden;
  background: var(--success-bg); color: #1B7A43;
  display: flex; align-items: center; justify-content: center;
}
html[data-theme="dark"] .apply-done-mark { background: rgba(46, 173, 98, .16); color: #4ECB7F; }
.apply-ref {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px; border-radius: var(--radius-btn);
  background: var(--bg-alt); border: 1px dashed var(--border-strong);
  font-size: .875rem; color: var(--body);
}
html[data-theme="dark"] .apply-ref { background: var(--raised); }

/* ─── modal dialog ─── the prototype has none; this is .card + a scrim ─── */
.scrim {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(14, 17, 22, .55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; animation: scrimIn .16s var(--ease) forwards;
}
@keyframes scrimIn { to { opacity: 1; } }
.scrim.out { animation: scrimOut .16s var(--ease) forwards; }
@keyframes scrimOut { to { opacity: 0; } }

.dialog {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); box-shadow: var(--shadow-raised);
  width: min(520px, 100%); max-height: min(86vh, 720px);
  display: flex; flex-direction: column; overflow: hidden;
  animation: dialogIn .2s var(--ease);
}
@keyframes dialogIn { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }
.scrim.out .dialog { animation: dialogOut .16s var(--ease) forwards; }
@keyframes dialogOut { to { opacity: 0; transform: translateY(8px); } }

.dlg-head {
  display: flex; align-items: center; gap: 12px; flex: none;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.dlg-head .dlg-ic {
  width: 40px; height: 40px; flex: none;
  border-radius:50%; overflow:hidden;
  background: var(--grad-primary); color: #FFFFFF;
  display: flex; align-items: center; justify-content: center;
}
.dlg-head .dlg-ic svg { width: 20px; height: 20px; }
.dlg-title { font-size: 1.0625rem; font-weight: 700; color: var(--heading); flex: 1; min-width: 0; }
.dlg-body { padding: 20px; overflow-y: auto; font-size: .9375rem; line-height: 1.75; color: var(--body); }
.dlg-body > * + * { margin-top: 16px; }
.dlg-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap;
  padding: 16px 20px; border-top: 1px solid var(--border); background: var(--bg-section); flex: none;
}
html[data-theme="dark"] .dlg-foot { background: var(--raised); }
.dlg-foot .dlg-spacer { margin-inline-end: auto; }
body.dialog-open { overflow: hidden; }

/* ─── form fields (settings, dialogs) ─── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: .8125rem; font-weight: 600; color: var(--body); }
.field-input, .field-area {
  width: 100%; min-height: 44px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-btn);
  background: var(--bg); color: var(--heading);
  font-family: var(--font-body); font-size: .9375rem; line-height: 1.6;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
html[data-theme="dark"] .field-input, html[data-theme="dark"] .field-area { background: var(--raised); }
.field-area { min-height: 110px; resize: vertical; }
.field-input:focus, .field-area:focus {
  outline: none; border-color: var(--ai-blue); box-shadow: 0 0 0 3px rgba(7, 90, 160, .14);
}
.field-error { font-size: .75rem; color: var(--error); min-height: 1em; }
.field.invalid .field-input, .field.invalid .field-area { border-color: var(--error); }

.file-drop {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 24px; text-align: center;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-card);
  background: var(--bg-section); color: var(--caption); font-size: .8125rem;
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
html[data-theme="dark"] .file-drop { background: var(--raised); }
.file-drop:hover, .file-drop.dragover { border-color: var(--ai-blue); }
.file-drop svg { width: 28px; height: 28px; color: var(--brushed); }
.file-drop input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-name { font-family: var(--font-mono); font-size: .75rem; color: var(--heading); direction: ltr; }

/* ─── loading: skeletons + inline spinner ─── */
.skeleton {
  border-radius: var(--radius-btn);
  background: linear-gradient(90deg, var(--bg-alt) 25%, var(--border) 37%, var(--bg-alt) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s var(--ease) infinite;
}
html[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, var(--raised) 25%, var(--n-700) 37%, var(--raised) 63%);
  background-size: 400% 100%;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.sk-line { height: 14px; margin-bottom: 10px; }
.sk-line:last-child { margin-bottom: 0; width: 60%; }
.sk-card { height: 160px; }
.sk-row { height: 52px; margin-bottom: 2px; }

.loading-note {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 36px 20px; color: var(--caption); font-size: .875rem;
}
.loading-note .profile-ic { color: var(--brushed); }

/* ─── error state — .empty-note with the error hue ─── */
.error-note {
  display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center;
  padding: 40px 20px; color: var(--body); font-size: .875rem;
}
.error-note .en-ic {
  width: 52px; height: 52px; flex: none;
  border-radius:50%; overflow:hidden;
  background: var(--error-bg); color: var(--error);
  display: flex; align-items: center; justify-content: center;
}
html[data-theme="dark"] .error-note .en-ic { background: rgba(217, 54, 62, .16); color: #F0767C; }
.error-note .en-ic svg { width: 24px; height: 24px; }
.error-note .en-title { font-weight: 700; color: var(--heading); font-size: 1rem; }

/* ─── search dropdown: keyboard-active option ─── */
.sr-item[aria-selected="true"] { background: var(--row-hover); }
html[data-theme="dark"] .sr-item[aria-selected="true"] { background: var(--raised); }
.sr-hint { padding: 14px 16px; font-size: .8125rem; color: var(--caption); }

/* ─── notification panel: unread marker + footer link ─── */
.notif-item { align-items: flex-start; }
.notif-item.unread { background: var(--info-bg); }
html[data-theme="dark"] .notif-item.unread { background: rgba(33, 150, 243, .10); }
.notif-item .n-body { min-width: 0; flex: 1; }
.notif-item .n-unread-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--ai-blue);
  flex: none; margin-top: 8px;
}
.notif-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-top: 1px solid var(--border); background: var(--bg-section);
}
html[data-theme="dark"] .notif-foot { background: var(--raised); }
.notif-empty { padding: 28px 16px; text-align: center; font-size: .8125rem; color: var(--caption); }

/* ─── notifications page (case C) ─── */
.notif-list { display: flex; flex-direction: column; }
.notif-row {
  display: flex; align-items: flex-start; gap: 14px; width: 100%; text-align: start;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
  font-size: .875rem; line-height: 1.7; color: var(--body);
  transition: background .14s var(--ease);
}
.notif-row:last-child { border-bottom: none; }
.notif-row:hover { background: var(--row-hover); }
.notif-row.unread .nr-title { font-weight: 600; color: var(--heading); }
.notif-row .nr-ic {
  width: 38px; height: 38px; flex: none; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-section); border: 1px solid var(--border); color: var(--ai-blue);
}
html[data-theme="dark"] .notif-row .nr-ic { background: var(--raised); }
.notif-row .nr-ic svg { width: 18px; height: 18px; }
.notif-row .nr-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 4px; font-size: .75rem; color: var(--caption);
}
.notif-row .nr-time { font-family: var(--font-mono); font-variant-numeric: tabular-nums; direction: ltr; }

/* ─── segmented tabs (notifications filter, account sections) ─── */
.seg {
  display: inline-flex; border: 1px solid var(--border-strong);
  border-radius: var(--radius-chip); overflow: hidden; background: var(--surface);
}
.seg button {
  padding: 8px 16px; min-height: 44px; font-size: .8125rem; font-weight: 600; color: var(--body);
  transition: background .16s var(--ease), color .16s var(--ease);
}
.seg button[aria-selected="true"] { background: var(--royal); color: #FFFFFF; }
html[data-theme="dark"] .seg button[aria-selected="true"] { background: var(--ai-blue); }

/* ─── avatar menu (topbar) ─── */
/* The hexagon itself is 40px (38 on small screens); the button around it keeps
   the 44px minimum target the rest of the chrome uses. */
.avatar-btn {
  border: none; background: none; padding: 0; border-radius: 4px;
  width: 44px; height: 44px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.avatar-menu {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 70;
  width: min(260px, 92vw);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); box-shadow: var(--shadow-raised);
  overflow: hidden; display: none;
}
.avatar-menu.open { display: block; }
.avatar-menu .am-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.avatar-menu .am-name { font-weight: 700; font-size: .875rem; color: var(--heading); }
.avatar-menu .am-role { font-size: .75rem; color: var(--caption); }
.avatar-menu .am-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: start;
  padding: 12px 16px; min-height: 48px; font-size: .875rem; color: var(--body);
  transition: background .14s var(--ease);
}
.avatar-menu .am-item:hover { background: var(--row-hover); }
.avatar-menu .am-item svg { width: 18px; height: 18px; color: var(--brushed); flex: none; }

/* ─── session list (bidding view, when no session is addressed) ─── */
.session-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 16px 0; border-bottom: 1px solid var(--border);
}
.session-row:last-child { border-bottom: none; }
.session-row .sr-ref {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-weight: 600; color: var(--heading); direction: ltr;
}
.session-row .sr-end { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; }

/* ─── toast variants ─── the prototype only had the success form ─── */
.toast-success svg { color: #4ECB7F; }
.toast-info svg { color: var(--glow-blue); }
.toast-warning svg { color: #F5B93C; }
.toast-error svg { color: #F0767C; }
.toast-error { border-inline-start: 3px solid var(--error); }
.toast-warning { border-inline-start: 3px solid var(--warning); }

/* ─── destructive button ─── */
.btn-danger { background: var(--error); color: #FFFFFF; box-shadow: var(--shadow-flat); }
.btn-danger:hover { filter: brightness(1.08); }

/* ─── direction-aware icon helpers ─────────────────────────────────────────
   The prototype flips these with inline `style="transform:scaleX(-1)"`, which
   is wrong in LTR — a chevron pointing "forward" has to follow the writing
   direction, not be hardcoded. */
html[dir="rtl"] .chev-end,
html[dir="ltr"] .flip-end { transform: scaleX(-1); }

/* mic actively recording — the one place the AI glow is a live state */
.z-act.mic.recording {
  box-shadow: 0 0 28px rgba(49, 168, 255, .65);
  animation: recording-pulse 1.4s var(--ease) infinite;
}
@keyframes recording-pulse { 50% { filter: brightness(1.25); } }

/* a chip used as a link keeps chip styling but gains the pointer affordance */
a.chip { text-decoration: none; }
a.chip:hover { filter: brightness(.97); }
html[data-theme="dark"] a.chip:hover { filter: brightness(1.15); }

/* rail quote reference is a link in the port, a span in the prototype */
a.qm-ref:hover, a.sr-ref:hover { color: var(--ai-blue); }

/* ─── print — a quote card and an order breakdown both need to print ─── */
@media print {
  .sidebar, .topbar, .toasts, .sb-overlay, .skip-link,
  .notif-panel, .avatar-menu, .search-results, .scrim { display: none !important; }
  body, .view { background: #FFFFFF; }
  .app { display: block; }
  .view { padding: 0; }
  .card, .table-scroll, .quote-card {
    box-shadow: none;
    border-color: #C4CBD3;
    break-inside: avoid;
  }
  .btn, .row-actions, .filters, .seg, .state-toggle { display: none !important; }
  a[data-link]::after { content: ""; }
}

/* ─── misc production helpers ─── */
.stack { display: flex; flex-direction: column; gap: 20px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.is-busy { opacity: .6; pointer-events: none; }
.btn .btn-spinner {
  width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin .7s linear infinite;
}
