/* =====================================================================
   Cyrix Ticketing — black · red · white
   One stylesheet for the signed-in workspace. Only three hues are used:
   black (ink), red (brand) and white, plus neutral tints of black/white.
   No behaviour lives here: every selector targets markup that
   index.html / dashboard.js already produce.

   1  Tokens            6  Request list (table)    11 Notifications
   2  Base              7  Create ticket form      12 Image viewer
   3  Shell             8  Conversation shell      13 Toast & states
   4  Buttons & chips   9  Messages                14 Responsive
   5  Dashboard KPIs    10 Composer
   ===================================================================== */

/* 1 · Tokens ---------------------------------------------------------- */
:root {
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: 'Roboto Mono', ui-monospace, SFMono-Regular, Consolas, monospace;

  --bg: #f3f3f3;
  --card: #ffffff;
  --hover: #f8f8f8;
  --chip: #f0f0f0;
  --input: #ffffff;
  --border: #e5e5e5;
  --border-strong: #cfcfcf;
  --text: #0b0b0b;
  --secondary: #515151;
  --muted: #888888;

  --primary: #dc1f2b;
  --primary-deep: #b3121d;
  --primary-soft: #fdecee;
  --primary-line: #f5c2c6;
  --selected: #fff5f5;
  --ring: rgba(220, 31, 43, .18);

  --ink: #0b0b0b;
  --on-ink: #ffffff;
  --band: #0b0b0b;
  --dot: rgba(11, 11, 11, .075);

  --bubble-out: #fdecee;
  --bubble-out-text: #342326;
  --bubble-out-meta: #786064;
  --receipt-neutral: #71717a;
  --receipt-seen: #007eae;
  --bubble-out-check: #ff5a63;

  --shadow-sm: 0 1px 2px rgba(11, 11, 11, .05);
  --shadow-md: 0 14px 34px -14px rgba(11, 11, 11, .22);
  --shadow-red: 0 10px 22px -10px rgba(220, 31, 43, .75);
  --radius: 20px;
  --topbar-h: 64px;
  --sidebar-w: 244px;
  --conversation-rail-w: 230px;
  --chev: 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='%23858585' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  color-scheme: light;
}
[data-theme=dark] {
  --bg: #090909;
  --card: #141414;
  --hover: #1b1b1b;
  --chip: #222222;
  --input: #191919;
  --border: #282828;
  --border-strong: #3d3d3d;
  --text: #f5f5f5;
  --secondary: #bbbbbb;
  --muted: #8e8e8e;

  --primary: #f23a46;
  --primary-deep: #ff7f88;
  --primary-soft: #2b1215;
  --primary-line: #5c1f25;
  --selected: #1d1214;
  --ring: rgba(242, 58, 70, .3);

  --ink: #f5f5f5;
  --on-ink: #0b0b0b;
  --dot: rgba(255, 255, 255, .05);

  --bubble-out: #352126;
  --bubble-out-text: #f9e9ec;
  --bubble-out-meta: #c6a8ae;
  --receipt-neutral: #a8a8b0;
  --receipt-seen: #53bdeb;
  --bubble-out-check: #ffffff;

  --shadow-sm: none;
  --shadow-md: 0 16px 36px -14px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

/* 2 · Base ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3, h4, p, dl, dd { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
::selection { background: var(--primary); color: #fff; }
input::placeholder, textarea::placeholder { color: var(--muted); }
.material-symbols-outlined { font-family: 'Material Symbols Outlined'; font-weight: 400; font-style: normal; font-size: 20px; line-height: 1; letter-spacing: normal; display: inline-block; white-space: nowrap; word-wrap: normal; direction: ltr; font-feature-settings: 'liga'; -webkit-font-smoothing: antialiased; user-select: none; flex-shrink: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.mono { font-family: var(--mono); }
h1:focus, #create-title:focus, #conversation-page-title:focus { outline: none; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes live { 0% { box-shadow: 0 0 0 0 var(--ring); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }

/* Until the server has confirmed the session nothing private is shown. */
body[data-session-loading] { background: #090909; }
body[data-session-loading] > .sidebar, body[data-session-loading] > .app-shell { display: none; }
.session-loading { min-height: 100vh; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px; padding: 24px; text-align: center; background: radial-gradient(60% 50% at 50% 0%, rgba(220, 31, 43, .22), transparent 70%), #090909; color: #cbcbcb; font-size: 14px; }
.session-loading > .material-symbols-outlined { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 18px; background: linear-gradient(180deg, #ee2f3b, #b3121d); color: #fff; font-size: 26px; box-shadow: var(--shadow-red); animation: live 2s infinite; }

/* 3 · Shell: sidebar, top bar, page frame ------------------------------ */
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: var(--sidebar-w); display: flex; flex-direction: column; background: radial-gradient(120% 55% at 0% 100%, rgba(220, 31, 43, .26), transparent 62%), #090909; color: #a3a3a3; border-right: 1px solid #1d1d1d; }
.brand { display: block; margin: 18px 16px 0; padding: 14px 16px; background: #fff; border-radius: 16px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .06), 0 14px 34px -14px rgba(220, 31, 43, .55); }
.brand img { display: block; width: 100%; height: auto; }
.brand .brand-mark { display: none; }
.sidebar nav { padding: 0 14px; margin-top: 30px; }
.sidebar nav::before { content: 'WORKSPACE'; display: block; margin: 0 14px 12px; font-size: 10px; font-weight: 700; letter-spacing: .18em; color: #606060; }
.nav-item { position: relative; display: flex; align-items: center; gap: 12px; min-height: 46px; margin: 0 0 6px; padding: 0 14px; border-radius: 12px; font-size: 14px; font-weight: 500; color: #a3a3a3; transition: background .15s, color .15s; }
.nav-item > .material-symbols-outlined { font-size: 21px; color: #6f6f6f; transition: color .15s; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item:hover > .material-symbols-outlined { color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(220, 31, 43, .3), rgba(220, 31, 43, .06)); color: #fff; font-weight: 600; }
.nav-item.active > .material-symbols-outlined { color: #ff5a63; }
.nav-item.active::before { content: ''; position: absolute; left: -14px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--primary); box-shadow: 0 0 14px rgba(220, 31, 43, .9); }
.nav-count { margin-left: auto; min-width: 26px; padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, .09); color: #ededed; font-size: 12px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.sidebar-bottom { margin: auto 14px 16px; padding: 14px 16px; border: 1px solid rgba(255, 255, 255, .09); border-radius: 14px; background: rgba(255, 255, 255, .035); color: #ededed; font-size: 13px; font-weight: 600; }
.sidebar-bottom small { display: block; margin: 4px 0 0 18px; color: #898989; font-size: 12px; font-weight: 400; }

.app-shell { margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 32px; background: rgba(11, 11, 11, .94); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); color: #d5d5d5; }
.topbar::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: linear-gradient(90deg, var(--primary), rgba(220, 31, 43, 0) 55%); }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar-title { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; letter-spacing: .01em; color: #fff; white-space: nowrap; }
.topbar-title::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--primary); transform: rotate(45deg); }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--secondary); transition: background .15s, color .15s; }
.icon-button:hover { background: var(--chip); color: var(--text); }
.topbar .icon-button { color: #a3a3a3; }
.topbar .icon-button:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.topbar .menu-button { flex-shrink: 0; border: 1px solid #ffffff24; color: #f4f4f4; }
#notifications-toggle { position: relative; }
.notification-count { position: absolute; top: 1px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; display: grid; place-items: center; border-radius: 999px; background: var(--primary); border: 2px solid #0b0b0b; color: #fff; font-size: 10px; font-weight: 700; line-height: 1; }
.profile { display: flex; align-items: center; gap: 12px; margin-left: 4px; padding-left: 20px; border-left: 1px solid rgba(255, 255, 255, .12); color: #f4f4f4; font-size: 13px; font-weight: 600; line-height: 1.2; }
.profile small { display: block; margin-top: 3px; color: #8e8e8e; font-size: 11px; font-weight: 500; }
.profile-toggle { display: flex; align-items: center; gap: 12px; padding: 3px; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.profile-toggle:hover { background: rgba(255, 255, 255, .08); }
.profile-actions { position: fixed; inset: var(--topbar-h) 16px auto auto; margin: 0; padding: 8px; border: 1px solid var(--border); border-radius: 14px; background: var(--card); color: var(--text); box-shadow: var(--shadow-sm); }
.password-change-dialog { width: min(440px, calc(100% - 32px)); padding: 0; border: 1px solid var(--border); border-radius: 16px; background: var(--card); color: var(--text); }
.password-change-dialog::backdrop { background: rgba(0, 0, 0, .55); }
.password-fields { display: grid; gap: 14px; }
.password-fields h2, .password-fields label, .password-fields p { margin: 0; }
.password-fields #new-password-help { margin-top: -8px; color: var(--muted); font-size: 12px; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(180deg, #ee2f3b, #b3121d); color: #fff; font-size: 13px; font-weight: 700; letter-spacing: .02em; box-shadow: 0 0 0 2px #0b0b0b, 0 0 0 3px rgba(255, 255, 255, .2); }
#logout { margin-left: 4px; }

main { max-width: 1440px; margin: 0 auto; padding: 30px 36px 24px; }
#dashboard-view, #create-view, #conversation-view { animation: rise .35s ease backwards; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--muted); }
.breadcrumb .material-symbols-outlined { font-size: 16px; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb > span:last-child { color: var(--text); font-weight: 600; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 20px; margin: 22px 0 26px; }
.eyebrow { display: inline-flex; align-items: center; gap: 10px; font-size: 11px; font-weight: 700; letter-spacing: .16em; color: var(--primary); }
.eyebrow::before { content: ''; width: 20px; height: 2px; border-radius: 2px; background: var(--primary); }
h1 { margin: 10px 0 8px; font-size: 36px; font-weight: 800; letter-spacing: -.035em; line-height: 1.08; }
.title-dot { color: var(--primary); }
.page-heading p { color: var(--secondary); font-size: 14px; line-height: 1.5; }
.heading-actions { display: flex; flex-shrink: 0; gap: 10px; }
.page-footer { display: flex; justify-content: space-between; gap: 16px; padding: 24px 4px 4px; color: var(--muted); font-size: 12px; }
.page-footer > span:first-child { display: flex; align-items: center; gap: 7px; }
.page-footer .material-symbols-outlined { font-size: 16px; color: var(--primary); }
.footer-dot { padding: 0 2px; }

/* 4 · Buttons & chips -------------------------------------------------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 20px; border: 1px solid transparent; border-radius: 999px; font-size: 14px; font-weight: 600; white-space: nowrap; transition: transform .15s, box-shadow .15s, background .15s, color .15s, border-color .15s, filter .15s; }
.button .material-symbols-outlined { font-size: 19px; }
.button.primary { color: #fff; background: linear-gradient(180deg, #ee2f3b, #c6141f); box-shadow: var(--shadow-red), inset 0 1px 0 rgba(255, 255, 255, .22); }
.button.primary:hover:not(:disabled) { filter: brightness(1.07); transform: translateY(-1px); }
.button.primary:active:not(:disabled) { transform: translateY(0); filter: brightness(.95); }
.button.secondary { background: var(--card); border-color: var(--border-strong); color: var(--text); box-shadow: var(--shadow-sm); }
.button.secondary:hover:not(:disabled) { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }

.badge { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px 5px 10px; border: 1px solid var(--primary-line); border-radius: 999px; background: var(--primary-soft); color: var(--primary-deep); font-size: 12px; font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge:not(.closed)::before { animation: live 2s infinite; }
.badge.closed { background: var(--chip); border-color: var(--border-strong); color: var(--secondary); }
.badge.closed::before { animation: none; }

.ticket-ref { display: inline-block; padding: 3px 8px; border-radius: 6px; background: var(--primary-soft); color: var(--primary-deep); font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.form-error { color: var(--primary-deep); font-size: 13px; font-weight: 500; }
.form-note { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.form-note .material-symbols-outlined { font-size: 17px; color: var(--primary); }

/* 5 · Dashboard KPIs --------------------------------------------------- */
main:has(:is(#dashboard-view, #create-view):not([hidden])) { padding-top: 20px; }
.page-heading.dashboard-heading { align-items: center; gap: 12px; margin: 0 0 16px; }
.dashboard-heading h1 { margin: 0; font-size: clamp(24px, 3vw, 32px); }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.workflow-tracking { margin-bottom: 20px; }
.tracking-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.tracking-toggle { display: none; }
.tracking-filter-wrap { position: relative; flex-shrink: 0; }
.tracking-filter { position: relative; }
.tracking-filter summary { display: flex; align-items: center; gap: 8px; min-width: 160px; min-height: 40px; padding: 4px 8px; list-style: none; border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.tracking-filter summary::-webkit-details-marker { display: none; }
.tracking-filter summary > .material-symbols-outlined:first-child { display: grid; place-items: center; flex: 0 0 28px; width: 28px; height: 28px; border-radius: 8px; background: var(--primary-soft); color: var(--primary-deep); font-size: 18px; }
#tracking-filter-label { display: block; line-height: 1.4; }
.tracking-filter .tracking-filter-chevron { display: grid; place-items: center; width: 26px; height: 26px; margin-left: auto; border-radius: 8px; background: var(--hover); color: var(--secondary); font-size: 18px; transition: transform .15s; }
.tracking-filter summary:hover, .tracking-filter[open] summary { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.tracking-filter[open] .tracking-filter-chevron { transform: rotate(180deg); }
.tracking-filter summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.tracking-filter-options { position: absolute; z-index: 40; top: calc(100% + 8px); right: 0; width: min(280px, calc(100vw - 32px)); padding: 6px; border: 1px solid var(--border); border-radius: 14px; background: var(--card); box-shadow: var(--shadow-md); }
.tracking-filter-options button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border: 1px solid transparent; border-radius: 9px; background: transparent; text-align: left; color: var(--text); }
.tracking-filter-options button + button { margin-top: 4px; }
.tracking-filter-options button:hover { background: var(--hover); }
.tracking-filter-options button[aria-pressed=true] { border-color: var(--primary-line); background: var(--primary-soft); }
.tracking-filter-options button:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.tracking-option-icon { display: grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--secondary); font-size: 19px; }
.tracking-option-copy { flex: 1; min-width: 0; }
.tracking-option-copy strong { display: block; font-size: 12px; font-weight: 600; }
.tracking-option-copy small { display: block; margin-top: 3px; color: var(--secondary); font-size: 10px; }
.tracking-option-check { visibility: hidden; color: var(--primary-deep); font-size: 18px; }
[aria-pressed=true] > .tracking-option-check { visibility: visible; }
.tracking-heading h2 { color: var(--text); font-size: 18px; font-weight: 700; }
.tracking-heading p { margin-top: 4px; color: var(--secondary); font-size: 12px; }
.tracking-flow {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  margin: 0;
  padding: 12px 8px;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}
.tracking-flow li { position: relative; display: grid; grid-template-rows: auto 1fr auto; justify-items: center; gap: 6px; min-width: 0; padding: 0 6px; text-align: center; }
.tracking-node {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border: 1px solid var(--primary-line);
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-size: 21px;
}
.tracking-flow h3 { align-self: center; color: var(--secondary); font-size: 13px; font-weight: 600; }
.tracking-value { color: var(--text); font-size: 28px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.tracking-flow li:not(:last-child)::before, .tracking-flow li:not(:last-child)::after { content: ''; position: absolute; }
.tracking-flow li:not(:last-child)::before { top: 19px; left: calc(50% + 26px); right: calc(-50% + 26px); height: 2px; background: var(--border-strong); }
.tracking-flow li:not(:last-child)::after { top: 16px; right: calc(-50% + 27px); width: 8px; height: 8px; border: solid var(--border-strong); border-width: 2px 2px 0 0; transform: rotate(45deg); }
@media (max-width: 1050px) {
  .tracking-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .tracking-toggle { display: inline-flex; height: 36px; padding: 0 10px; font-size: 12px; }
  .tracking-toggle[aria-expanded=true] .material-symbols-outlined { transform: rotate(180deg); }
  .tracking-filter-wrap { grid-column: 1 / -1; justify-self: start; }
  .workflow-tracking:has(.tracking-toggle[aria-expanded=false]) :is(.tracking-flow, .tracking-filter-wrap, #tracking-description) { display: none; }
  .tracking-flow { grid-template-columns: minmax(0, 1fr); padding: 8px 16px; }
  .tracking-flow li { grid-template: auto / 40px minmax(0, 1fr) auto; align-items: center; justify-items: start; gap: 12px; min-height: 64px; padding: 8px 0; text-align: left; }
  .tracking-flow h3 { min-width: 0; }
  .tracking-value { font-size: 24px; }
  .tracking-flow li:not(:last-child)::before { top: calc(50% + 23px); bottom: calc(-50% + 23px); left: 19px; right: auto; width: 2px; height: auto; }
  .tracking-flow li:not(:last-child)::after { top: auto; bottom: calc(-50% + 24px); left: 16px; right: auto; transform: rotate(135deg); }
}
.summary-card { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 12px 14px; text-align: left; background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-sm); transition: border-color .2s, background .2s; }
.summary-card:hover { border-color: var(--primary); }
.summary-card.selected { background: var(--primary-soft); border-color: var(--primary-line); box-shadow: inset 3px 0 var(--primary); }
.summary-copy { display: grid; justify-items: start; gap: 3px; }
.summary-label { color: var(--secondary); font-size: 13px; font-weight: 700; }
.summary-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--chip); color: var(--secondary); }
.summary-card.selected .summary-icon { background: var(--card); color: var(--primary-deep); }
.summary-value { font-size: 28px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.summary-arrow { margin-left: auto; color: var(--muted); font-size: 16px; }
.summary-card.selected .summary-arrow, .summary-card:hover .summary-arrow { color: var(--primary-deep); }

/* 6 · Request list ----------------------------------------------------- */
.request-section { scroll-margin-top: calc(var(--topbar-h) + 12px); }
.request-section > h2 { margin-bottom: 10px; font-size: 21px; font-weight: 800; letter-spacing: -.025em; }
.requests-card { overflow: hidden; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.list-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 12px; padding: 0 14px 8px; border-bottom: 1px solid var(--border); }
.tabs { display: flex; align-self: stretch; gap: 16px; min-height: 44px; overflow-x: auto; scrollbar-width: none; }
.tab { position: relative; display: flex; align-items: center; gap: 8px; padding: 0; border: 0; background: none; color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; transition: color .15s; }
.tab:hover { color: var(--text); }
.tab span { min-width: 24px; padding: 2px 7px; border-radius: 999px; background: var(--chip); color: var(--secondary); font-size: 11px; font-weight: 700; text-align: center; transition: background .15s, color .15s; }
.tab.active { color: var(--text); }
.tab.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--primary); }
.tab.active span { background: var(--primary); color: #fff; }
.refresh { width: 36px; height: 36px; border: 1px solid var(--border); }
.refresh .material-symbols-outlined { font-size: 19px; }
.requests-card[aria-busy="true"] .refresh .material-symbols-outlined { animation: spin .9s linear infinite; }

.filters { display: flex; flex-wrap: wrap; grid-column: 1 / -1; grid-row: 2; gap: 8px; min-width: 0; }
.list-toolbar .refresh { grid-column: 2; grid-row: 1; }
.filters .search, .filters .filter-select { height: 38px; }
.filters .search { flex-basis: 200px; }
.search { display: flex; align-items: center; flex: 1 1 260px; gap: 10px; min-width: 0; height: 44px; padding: 0 14px 0 16px; background: var(--input); border: 1px solid var(--border); border-radius: 999px; transition: border-color .15s, box-shadow .15s; }
.search > .material-symbols-outlined { color: var(--muted); font-size: 20px; }
.search input { flex: 1; width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 14px; }
.search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
kbd { padding: 2px 7px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px; color: var(--muted); font: 600 11px/1.4 var(--font); }
.filter-select { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 6px 0 16px; background: var(--input); border: 1px solid var(--border); border-radius: 999px; transition: border-color .15s, box-shadow .15s; }
.filter-select > .material-symbols-outlined { color: var(--muted); font-size: 19px; }
.filter-select select { height: 100%; max-width: 160px; padding: 0 30px 0 0; border: 0; outline: 0; background: transparent var(--chev) no-repeat right 12px center; color: var(--text); font-size: 13px; font-weight: 500; text-overflow: ellipsis; cursor: pointer; -webkit-appearance: none; appearance: none; }
.filter-select select option { background: var(--card); color: var(--text); }
.filter-select:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }

@supports (appearance: base-select) and selector(::picker(select)) {
  .filters .filter-select select, .filters .filter-select select::picker(select) { appearance: base-select; }
  .filters .filter-select select { min-width: 0; background: transparent; padding: 0 8px 0 0; }
  .filters .sort-select { --filter-picker-width: 210px; }
  .filters .filter-select select::picker-icon { color: var(--muted); font-size: 12px; }
  .filters .filter-select select:open::picker-icon { transform: rotate(180deg); color: var(--primary-deep); }
  .filters .filter-select select::picker(select) {
    position-area: block-end span-inline-start;
    position-try-fallbacks: flip-inline, flip-block, flip-block flip-inline;
    width: min(var(--filter-picker-width, 330px), calc(100vw - 40px));
    min-width: 0;
    max-height: min(390px, 62dvh);
    margin-block: 6px;
    padding: 6px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--card);
    color: var(--text);
    box-shadow: var(--shadow-md);
  }
  .filters .filter-select option {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 16px;
    gap: 10px;
    min-height: 34px;
    padding: 7px 10px;
    border-radius: 8px;
    line-height: 1.4;
    white-space: normal;
  }
  .filters .filter-select option:first-child { font-weight: 650; }
  .filters .filter-select option:hover { background: var(--hover); }
  .filters .filter-select option:checked { background: var(--primary-soft); color: var(--primary-deep); font-weight: 650; }
  .filters .filter-select option:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
  .filters .filter-select option::checkmark { grid-column: 2; grid-row: 1; align-self: center; }
}
@media (min-width: 1320px) {
  .list-toolbar { grid-template-columns: auto minmax(0, 1fr) auto; min-height: 54px; padding-bottom: 0; }
  .filters { grid-column: 2; grid-row: 1; justify-content: flex-end; flex-wrap: nowrap; }
  .filters .search { flex-basis: 240px; max-width: 460px; }
  .list-toolbar .refresh { grid-column: 3; }
}
.ticket-load-error { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 20px; background: var(--primary-soft); border-bottom: 1px solid var(--primary-line); color: var(--primary-deep); font-weight: 500; }
.ticket-load-error .button { flex-shrink: 0; height: 34px; }

.table-scroll { overflow-x: auto; }
.requests-table { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; text-align: left; }
.requests-table th { padding: 9px 14px; background: var(--hover); border-bottom: 1px solid var(--border); color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.requests-table th:first-child { width: 33%; }
.requests-table th:nth-child(2) { width: 27%; }
.requests-table th:last-child { width: 114px; }
.requests-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--secondary); vertical-align: middle; transition: background .12s; }
.requests-table tbody tr { cursor: pointer; }
.requests-table tbody tr:hover td, .requests-table tbody tr:focus-within td { background: var(--hover); }
.ticket-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; color: var(--text); font-size: 14px; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.ticket-title:hover { color: var(--primary-deep); text-decoration: underline; }
.request-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 3px 8px; margin-top: 4px; }
.ticket-date { color: var(--muted); font-size: 11px; }
.request-stage { display: block; color: var(--text); font-size: 13px; line-height: 1.4; }
.request-flags { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.request-flags:empty { display: none; }
.request-detail-labels { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; }
.request-detail-labels li { max-width: 100%; overflow: hidden; padding: 3px 7px; border: 1px solid var(--border); border-radius: 6px; background: var(--hover); color: var(--secondary); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.request-detail-labels .request-more-details { border-color: transparent; background: transparent; color: var(--muted); font-weight: 700; }
.request-details-empty { color: var(--muted); font-size: 12px; font-weight: 400; }
.request-status { white-space: nowrap; }
.request-row-arrow { margin-left: 4px; color: var(--muted); font-size: 18px; vertical-align: middle; }
.requests-table tr:hover .request-row-arrow { color: var(--primary-deep); }
.table-footer { padding: 10px 14px; color: var(--muted); font-size: 12px; }
.empty-state { padding: 64px 20px; text-align: center; color: var(--muted); }
.empty-state > .material-symbols-outlined { display: inline-grid; place-items: center; width: 64px; height: 64px; margin-bottom: 8px; border-radius: 50%; background: var(--chip); color: var(--secondary); font-size: 30px; }
.empty-state h3 { margin: 8px 0 4px; color: var(--text); font-size: 17px; font-weight: 700; }
.empty-state p { margin-bottom: 18px; font-size: 14px; line-height: 1.6; }

/* 7 · Create ticket form ---------------------------------------------- */
html:has(#create-view:not([hidden])) { scroll-padding: calc(var(--topbar-h) + 12px) 0 calc(100px + env(safe-area-inset-bottom)); }
#create-view { max-width: 1120px; margin-inline: auto; }
.ticket-page-form { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.ticket-items, .ticket-delivery { margin-bottom: 20px; }
#ticket-items { display: grid; gap: 12px; }
.ticket-item { min-width: 0; margin: 0; padding: 12px 16px 16px; border: 1px solid var(--border); border-radius: 14px; }
.ticket-item > legend { padding: 0 6px; color: var(--text); font-size: 14px; font-weight: 800; }
.item-description-row { display: flex; align-items: end; flex-wrap: wrap; gap: 0 10px; }
.item-description-row > label { flex: 1 1 210px; min-width: 0; }
.ticket-item-actions { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.ticket-item-actions .button, .ticket-item-actions .icon-button { min-height: 46px; }
.item-quantity-input { max-width: 180px; }
.ticket-item .image-upload { margin-bottom: 0; }
.ticket-delivery { padding-top: 16px; border-top: 1px solid var(--border); }
.ticket-delivery select { max-width: 310px; }
.ticket-details-heading { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 14px; }
.ticket-details-heading h2 { font-size: 17px; font-weight: 800; letter-spacing: -.02em; }
.ticket-details-heading p { color: var(--muted); font-size: 12px; }
.ticket-details-heading p span { color: var(--primary); }
.quotation-requirements { min-width: 0; margin: 0 0 20px; padding: 0; border: 0; }
.form-fields { padding: 28px; }
.ticket-page-form .form-fields { padding: 20px 24px; }
.ticket-template-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-bottom: 18px; }
.ticket-template-actions .button { height: 36px; padding: 0 12px; font-size: 13px; }
#saved-rfq-status { color: var(--secondary); font-size: 13px; }
.saved-rfq-footer { flex-wrap: wrap; }
#delete-saved-rfq { margin-right: auto; color: var(--primary-deep); }
#saved-rfq-delete-confirmation { overflow-wrap: anywhere; font-size: 13px; }
.saved-rfq-options { min-width: 0; margin: 0; padding: 0; border: 0; }
.saved-rfq-list { display: grid; gap: 6px; max-height: min(40dvh, 300px); overflow-y: auto; padding: 4px; scrollbar-gutter: stable; }
.form-fields .saved-rfq-option { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; margin: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); cursor: pointer; }
.saved-rfq-option:hover { background: var(--hover); }
.saved-rfq-option:has(input:checked) { border-color: var(--primary-line); background: var(--primary-soft); }
.saved-rfq-option:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: -2px; }
.saved-rfq-option input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }
.form-fields .saved-rfq-option span { overflow-wrap: anywhere; color: var(--text); }
.saved-rfq-option small { color: var(--secondary); font-size: 12px; font-weight: 500; white-space: nowrap; }
.saved-rfq-options:disabled .saved-rfq-option { cursor: default; opacity: .65; }
.form-fields label { display: block; margin-bottom: 22px; font-size: 13px; font-weight: 700; letter-spacing: .01em; }
.ticket-page-form .form-fields label { margin-bottom: 12px; }
.form-fields label > span { color: var(--primary); }
.form-fields input:not([type=checkbox]):not([type=file]):not([type=radio]), .form-fields textarea, .form-fields select { display: block; width: 100%; min-height: 46px; margin-top: 8px; padding: 11px 14px; background: var(--input); border: 1px solid var(--border-strong); border-radius: 12px; color: var(--text); font-size: 14px; font-weight: 400; line-height: 1.5; resize: vertical; transition: border-color .15s, box-shadow .15s; }
.form-fields textarea { min-height: 140px; }
.ticket-page-form textarea { min-height: 84px; }
.form-fields input:focus, .form-fields textarea:focus, .form-fields select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-fields select[name=location] { padding-right: 36px; background: var(--input) var(--chev) no-repeat right 14px center; appearance: none; cursor: pointer; }
.item-identifier-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.optional-label { margin-left: 6px; color: var(--muted); font-size: 12px; font-weight: 500; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 28px; background: var(--hover); border-top: 1px solid var(--border); }
.ticket-form-footer { position: sticky; bottom: 0; z-index: 5; padding: 8px 24px max(8px, env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); }
.ticket-form-footer .form-error { margin-bottom: 6px; }
.ticket-form-buttons { display: flex; justify-content: flex-end; gap: 8px; }

.image-upload { margin: 0 0 20px; }
.image-upload h3, .quotation-requirements legend { margin-bottom: 6px; padding: 0; font-size: 16px; font-weight: 800; letter-spacing: -.015em; }
.image-upload > p { margin-bottom: 10px; color: var(--secondary); font-size: 13px; }
.form-fields .image-upload-control { position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0 0 10px; padding: 12px 16px; background: var(--hover); border: 2px dashed var(--border-strong); border-radius: 12px; color: var(--secondary); font-size: 14px; font-weight: 600; cursor: pointer; transition: border-color .15s, background .15s, color .15s; }
.form-fields .image-upload-control:hover { border-color: var(--primary); background: var(--selected); color: var(--primary-deep); }
.form-fields .image-upload-control .material-symbols-outlined { font-size: 26px; color: var(--primary); }
.form-fields .image-upload-control input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; padding: 0; opacity: 0; cursor: pointer; }
.image-upload-control:focus-within { outline: 3px solid var(--ring); outline-offset: 2px; }
.image-previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 170px)); gap: 12px; }
.image-preview { position: relative; min-width: 0; overflow: hidden; background: var(--card); border: 1px solid var(--border); border-radius: 14px; }
.image-previews img { display: block; width: 100%; height: 110px; object-fit: contain; background: var(--hover); }
.image-preview > span { display: block; padding: 8px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.image-preview .icon-button { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; background: var(--ink); color: var(--on-ink); }
.image-preview .icon-button:hover { background: var(--primary); color: #fff; }
.image-preview .icon-button .material-symbols-outlined { font-size: 16px; }

.requirements-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 10px; }
.requirements-heading p { color: var(--secondary); font-size: 13px; }
.requirements-count { padding: 4px 8px; border-radius: 8px; background: var(--primary-soft); color: var(--primary-deep); font-size: 12px; font-weight: 700; }
.requirement-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; }
.custom-requirements { display: grid; gap: 8px; }
.custom-requirements:not(:empty), .add-requirement { margin-top: 12px; }
.custom-requirement { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.form-fields .custom-requirement input[type=text] { margin-top: 0; }
.ticket-page-form .form-fields .requirement-option { display: flex; align-items: center; gap: 10px; min-height: 40px; margin: 0; padding: 7px 10px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; font-weight: 500; cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s; }
.form-fields .requirement-option:hover { border-color: var(--border-strong); background: var(--hover); }
.form-fields .requirement-option input { display: grid; place-content: center; flex: 0 0 20px; width: 20px; height: 20px; min-height: 20px; margin: 0; padding: 0; background: var(--card); border: 1.5px solid var(--border-strong); border-radius: 6px; box-shadow: none; cursor: pointer; -webkit-appearance: none; appearance: none; transition: background .15s, border-color .15s; }
.form-fields .requirement-option input::after { content: ''; width: 5px; height: 10px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg); visibility: hidden; }
.form-fields .requirement-option input:checked { background: var(--primary); border-color: var(--primary); }
.form-fields .requirement-option input:checked::after { visibility: visible; }
.form-fields .requirement-option input:focus { box-shadow: none; }
.form-fields .requirement-option > span { color: var(--secondary); font-size: 13px; line-height: 1.5; }
.form-fields .requirement-option:has(input:checked) { background: var(--primary-soft); border-color: var(--primary-line); box-shadow: inset 3px 0 0 var(--primary); }
.form-fields .requirement-option:has(input:checked) > span { color: var(--text); font-weight: 600; }
.form-fields .requirement-option:has(input:focus-visible) { outline: 3px solid var(--ring); outline-offset: 2px; }
@media (forced-colors: active) { .form-fields .requirement-option input { appearance: auto; } .form-fields .requirement-option input::after { display: none; } }

/* 8 · Conversation shell ---------------------------------------------- */
.conversation-open main { max-width: none; padding: 8px 24px; }
#conversation-view > .breadcrumb { display: none; }
.page-heading.conversation-page-heading { display: grid; grid-template-columns: calc(var(--conversation-rail-w) + 1px) minmax(0, 1fr) auto; align-items: center; gap: 0; min-height: 34px; margin: 0 0 8px; }
.conversation-page-heading h1 { margin: 0; font-size: 24px; }
.conversation-page-heading > .button { grid-area: 1 / 3; height: 34px; padding: 0 18px; font-size: 13px; }
.conversation-layout { display: grid; grid-template-columns: var(--conversation-rail-w) minmax(0, 1fr); height: calc(100dvh - var(--topbar-h) - 58px); min-height: 420px; overflow: hidden; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); }
.conversation-rail { display: flex; flex-direction: column; min-width: 0; overflow: hidden; border-right: 1px solid var(--border); background: var(--card); }
.conversation-rail-heading { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 8px; }
.conversation-rail-heading h2 { font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.conversation-rail-heading > .material-symbols-outlined { color: var(--muted); font-size: 19px; }
.conversation-rail .search { flex: 0 0 auto; height: 36px; margin: 0 10px 8px; background: var(--bg); border-color: transparent; }
.conversation-rail .search input { font-size: 13px; }
#conversation-tickets { flex: 1; min-height: 0; padding: 0 8px 8px; overflow-y: auto; }
.conversation-ticket { display: block; margin: 3px 0; padding: 8px 10px; border-radius: 10px; border: 1px solid transparent; transition: background .15s, border-color .15s; }
.conversation-ticket:hover { background: var(--hover); border-color: var(--border); }
.conversation-ticket.active { background: var(--primary-soft); border-color: var(--primary-line); color: var(--text); box-shadow: inset 3px 0 0 var(--primary); }
.conversation-ticket-top, .conversation-ticket-preview { display: flex; align-items: center; gap: 6px; }
.conversation-ticket-top > strong, .conversation-ticket-preview > span[title] { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-ticket-top > strong { font-size: 13px; font-weight: 600; }
.conversation-ticket-top > time { flex-shrink: 0; color: var(--muted); font-size: 10px; white-space: nowrap; }
.conversation-ticket-preview { margin: 3px 0 5px; min-height: 20px; color: var(--muted); font-size: 12px; }
.conversation-ticket-preview > .material-symbols-outlined { flex-shrink: 0; font-size: 14px; }
.conversation-ticket.active .conversation-ticket-preview { color: var(--secondary); }
.conversation-ticket.has-unread :is(.conversation-ticket-top > strong, .conversation-ticket-preview) { font-weight: 700; color: var(--text); }
.conversation-ticket-flags { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.conversation-ticket .badge { padding: 3px 9px 3px 8px; font-size: 11px; }
.ticket-unread-count { display: inline-grid; place-items: center; flex-shrink: 0; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--primary); color: #fff; font-size: 10px; font-weight: 700; line-height: 1; }
.conversation-rail-empty { padding: 16px; color: var(--muted); font-size: 13px; }

.conversation-main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.conversation-header { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 18px; background: var(--card); border-bottom: 1px solid var(--border); }
.conversation-avatar { display: grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: var(--on-ink); font-size: 12px; font-weight: 700; letter-spacing: .02em; box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--primary); }
.conversation-peer { flex: 1; min-width: 0; }
.conversation-ticket-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.conversation-ticket-title h2 { overflow: hidden; color: var(--text); font-size: 15px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.conversation-ticket-title .badge { flex-shrink: 0; padding: 2px 8px; font-size: 10px; }
.conversation-peer > small { display: block; margin-top: 1px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.conversation-peer .mono { color: var(--primary-deep); font-size: 11px; font-weight: 600; }
.conversation-update-notice { grid-area: 1 / 2; justify-self: start; min-width: 0; max-width: min(440px, calc(100% - 12px)); border: 1px solid var(--border-strong); border-radius: 999px; background: var(--card); color: var(--text); font-size: 12px; font-weight: 600; line-height: 1.5; }
.ticket-update-link { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 10px 14px; border-radius: inherit; }
.ticket-update-link::before { content: ''; flex-shrink: 0; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }
.ticket-update-link > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-update-link:hover > span:first-child { text-decoration: underline; }
.conversation-update-notice .ticket-update-link { padding: 6px 10px; }
.conversation-update-notice .material-symbols-outlined { color: var(--muted); font-size: 14px; }
.conversation-header-actions { display: flex; flex-shrink: 0; align-items: center; gap: 6px; }
.conversation-header-actions:empty { display: none; }
.conversation-header-actions .button { height: 32px; padding: 0 10px; font-size: 12px; }
.workflow-toggle.button { gap: 4px; }
.workflow-toggle .material-symbols-outlined { font-size: 17px; transition: transform .15s; }
.workflow-toggle[aria-expanded=true] .material-symbols-outlined { transform: rotate(180deg); }
.conversation-error { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; background: var(--primary-soft); border-bottom: 1px solid var(--primary-line); color: var(--primary-deep); font-size: 13px; font-weight: 500; }
.conversation-error .button { height: 32px; font-size: 12px; }
.conversation-timeline { flex: 1; min-height: 0; padding: 24px 32px 28px; overflow-y: auto; overscroll-behavior: contain; background-color: var(--bg); background-image: radial-gradient(var(--dot) 1px, transparent 1px); background-size: 18px 18px; }
.conversation-loading, .conversation-start { padding: 18px 10px; color: var(--muted); font-size: 12px; line-height: 1.8; text-align: center; }
.conversation-closed { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; padding: 16px 20px; background: var(--card); border-top: 1px solid var(--border); color: var(--secondary); font-size: 13px; font-weight: 500; text-align: center; }
.conversation-closed .material-symbols-outlined { font-size: 18px; color: var(--primary); }
.new-messages { position: absolute; right: 24px; bottom: 132px; height: 36px; padding: 0 16px; background: var(--ink); border-color: var(--ink); color: var(--on-ink); font-size: 12px; box-shadow: 0 12px 24px -8px rgba(0, 0, 0, .55); }
.new-messages .material-symbols-outlined { color: var(--primary); }
.new-messages:hover:not(:disabled) { background: var(--primary); border-color: var(--primary); color: #fff; }
.new-messages:hover:not(:disabled) .material-symbols-outlined { color: #fff; }

/* 9 · Messages --------------------------------------------------------- */
.conversation-day { width: fit-content; margin: 0 auto 22px; padding: 5px 14px; background: var(--card); border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .04em; }
.chat-message { width: fit-content; max-width: min(74%, 640px); margin: 0 0 14px; }
.chat-message.outgoing { margin-left: auto; }
.chat-message.incoming { margin-right: auto; }
.message-author { display: flex; align-items: center; gap: 8px; margin: 0 4px 6px; color: var(--secondary); font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.outgoing .message-author { justify-content: flex-end; }
.message-author > span { color: var(--muted); font-weight: 500; }
.message-author > .message-handoff { padding: 2px 6px; border: 1px solid var(--primary-line); border-radius: 5px; background: var(--primary-soft); color: var(--primary-deep); font-size: 10px; font-weight: 700; line-height: 1.4; }
.message-bubble { min-width: 110px; padding: 12px 16px 8px; overflow-wrap: anywhere; background: var(--card); border: 1px solid var(--border); border-radius: 18px 18px 18px 6px; box-shadow: var(--shadow-sm); }
.outgoing .message-bubble { background: var(--bubble-out); border-color: var(--primary-line); border-radius: 18px 18px 6px 18px; color: var(--bubble-out-text); box-shadow: var(--shadow-sm); }
.message-text { margin: 0; color: inherit; font-size: 14px; line-height: 1.65; white-space: pre-wrap; }
.message-time { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 6px; color: var(--muted); font-size: 10px; font-weight: 500; }
.outgoing .message-time { color: var(--bubble-out-meta); }
.message-time .material-symbols-outlined { color: var(--bubble-out-check); font-size: 14px; }
.message-time .message-receipt { color: var(--receipt-neutral); }
.message-time .message-receipt.seen { color: var(--receipt-seen); }
.message-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.message-image-attachment { display: block; width: 210px; max-width: 100%; padding: 0; overflow: hidden; background: var(--card); border: 1px solid var(--border); border-radius: 12px; color: var(--text); text-align: left; cursor: zoom-in; transition: border-color .15s, box-shadow .15s; }
.message-image-attachment:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.message-image-attachment img { display: block; width: 100%; height: 150px; object-fit: contain; background: var(--hover); }
.message-image-attachment > span { display: block; padding: 8px 10px; font-size: 11px; overflow-wrap: anywhere; }
.message-document { display: flex; align-items: center; gap: 12px; min-width: 200px; max-width: 100%; padding: 12px 14px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; color: var(--text); transition: border-color .15s, box-shadow .15s; }
.message-document:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.message-document > span:nth-child(2) { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.message-document small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 400; }
.message-document > .material-symbols-outlined { color: var(--muted); }
.message-document > .material-symbols-outlined:first-child { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); }

/* The original RFQ reads as a structured document at the top of the thread. */
.original-request { width: 100%; max-width: min(92%, 720px); }
.chat-message.original-request .message-bubble { padding: 0; overflow: hidden; background: var(--card); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-md); color: var(--text); }
.original-request .request-message-heading { display: flex; align-items: center; gap: 12px; margin: 0; padding: 16px 18px; background: var(--band); color: #fff; border-bottom: 3px solid var(--primary); }
.original-request .request-document-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--primary); color: #fff; font-size: 21px; }
.request-heading-copy { display: flex; flex-direction: column; gap: 3px; }
.request-heading-copy small { color: #ff7b84; font-size: 9px; font-weight: 700; letter-spacing: .16em; }
.request-heading-copy h3 { font-size: 15px; font-weight: 700; }
.original-request .request-message-heading > .mono { margin-left: auto; padding: 5px 9px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .16); border-radius: 7px; color: #fff; font-size: 11px; font-weight: 500; white-space: nowrap; }
.original-request .request-item-description { margin: 0; padding: 20px 20px 16px; font-size: 18px; font-weight: 700; line-height: 1.45; letter-spacing: -.02em; white-space: pre-wrap; overflow-wrap: anywhere; }
.request-item-detail + .request-item-detail { border-top: 1px solid var(--border); }
.request-item-detail h3 { margin: 0; padding: 14px 20px 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.request-item-detail h3 + .request-item-description { padding-top: 5px; }
.original-request .request-message-meta { display: grid; grid-template-columns: minmax(0, 3fr) minmax(90px, 1fr); gap: 10px; margin: 0 20px 18px; padding: 0; border: 0; }
.original-request .request-message-meta > div { min-width: 0; padding: 12px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; }
.request-message-meta dt { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.request-message-meta dt .material-symbols-outlined { font-size: 15px; color: var(--primary); }
.original-request .request-message-meta dd { margin: 0; font-size: 13px; font-weight: 500; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.request-message-meta > div:only-child { grid-column: 1 / -1; }
.request-item-identifiers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0 20px 18px; }
.request-item-identifiers > div { min-width: 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.request-item-identifiers dt { margin-bottom: 8px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.request-item-identifiers dd { margin: 0; color: var(--text); font-size: 13px; font-weight: 500; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.original-request .request-quantity dd { font-size: 24px; font-weight: 800; line-height: 1.1; letter-spacing: -.03em; }
.request-message-images { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; padding: 0 20px 18px; }
.request-message-images .request-image-preview { width: 132px; padding: 0; overflow: hidden; background: var(--card); border: 1px solid var(--border); border-radius: 12px; color: var(--text); text-align: left; cursor: zoom-in; transition: border-color .15s, box-shadow .15s; }
.request-image-preview:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.request-message-images img { display: block; width: 100%; height: 100px; object-fit: contain; background: var(--hover); }
.request-image-preview > span { display: block; padding: 7px 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.original-request .request-message-requirements { margin: 0; padding: 16px 20px 18px; border-top: 1px solid var(--border); }
.request-requirements-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.original-request .request-requirements-heading h3 { margin: 0; font-size: 13px; font-weight: 800; letter-spacing: -.01em; }
.request-requirements-heading > span { padding: 2px 9px; border-radius: 999px; background: var(--ink); color: var(--on-ink); font-size: 10px; font-weight: 700; white-space: nowrap; }
.original-request .request-requirement-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.original-request .request-requirement-tags > span { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px 6px 8px; background: var(--primary-soft); border: 1px solid var(--primary-line); border-radius: 999px; color: var(--text); font-size: 12px; font-weight: 500; line-height: 1.5; }
.original-request .request-requirement-tags > .no-requirements { background: var(--chip); border-color: var(--border); color: var(--muted); padding-left: 12px; }
.original-request .request-requirement-tags > span { max-width: 100%; overflow-wrap: anywhere; }
.request-requirement-tags .material-symbols-outlined { font-size: 16px; color: var(--primary); }
.chat-message.original-request .message-time.request-created { justify-content: flex-start; margin: 0; padding: 10px 20px; background: var(--hover); border-top: 1px solid var(--border); color: var(--muted); font-size: 11px; }
.request-created .material-symbols-outlined { color: var(--muted); font-size: 14px; }

/* 10 · Composer -------------------------------------------------------- */
.message-composer { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: end; gap: 6px 10px; padding: 8px 20px 6px; background: var(--card); border-top: 1px solid var(--border); }
.message-composer textarea { width: 100%; min-width: 0; min-height: 46px; max-height: 140px; padding: 12px 16px; background: var(--bg); border: 1px solid var(--border); border-radius: 16px; color: var(--text); font-size: 14px; line-height: 1.5; resize: vertical; transition: border-color .15s, box-shadow .15s, background .15s; }
.message-composer textarea:focus { outline: none; background: var(--input); border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.message-composer .button { height: 46px; min-width: 96px; }
.reply-tools { display: flex; align-items: center; gap: 4px; min-width: 0; }
.message-type-control { width: 158px; min-width: 0; height: 36px; padding: 0 26px 0 9px; border: 1px solid var(--border-strong); border-radius: 9px; appearance: none; background: var(--input) var(--chev) no-repeat right 8px center; color: var(--text); font: 600 12px/1.2 var(--font); text-overflow: ellipsis; cursor: pointer; }
.message-type-control option { background: var(--card); color: var(--text); }
.message-type-control:disabled { opacity: .6; cursor: default; }
.attach-message { align-self: end; width: 40px; height: 46px; border-radius: 14px; }
.attach-message:hover:not(:disabled) { background: var(--primary-soft); color: var(--primary); }
.message-composer .form-error { grid-column: 1 / -1; margin: 0; }
.quotation-composer-tools { grid-column: 1 / -1; }
.quotation-composer-tools .button { height: 34px; padding: 0 10px; font-size: 12px; }
.quotation-composer-tools .material-symbols-outlined { font-size: 17px; }
.quotation-editor { width: min(850px, calc(100% - 24px)); max-height: 90dvh; padding: 0; border: 1px solid var(--border); border-radius: 18px; background: var(--card); color: var(--text); }
.quotation-editor::backdrop { background: #0009; }
.quotation-editor form { display: flex; flex-direction: column; max-height: 90dvh; }
.quotation-editor-header { padding: 16px 22px; border-bottom: 1px solid var(--border); }
.quotation-editor-header h2 { font-size: 20px; }
.quotation-editor-body { min-height: 0; overflow: auto; padding: 16px 22px; }
.quotation-editor label { display: grid; min-width: 0; gap: 4px; font-size: 12px; font-weight: 700; }
.quotation-editor label :is(input, textarea) { min-width: 0; width: 100%; padding: 7px 9px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--input); color: var(--text); font: 400 14px var(--font); }
.quotation-editor label :is(input, textarea):focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.quotation-editor .quotation-source { margin-bottom: 6px; }
.quotation-editor .quotation-source input { max-width: 400px; }
#quotation-import-status { color: var(--secondary); font-size: 12px; }
.quotation-import-warnings { margin: 10px 0; padding: 8px 10px 8px 28px; border: 1px solid var(--primary-line); border-radius: 9px; background: var(--primary-soft); color: var(--text); font-size: 13px; }
.quotation-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 14px 0 18px; }
.quotation-items-heading { display: flex; justify-content: space-between; align-items: center; }
.quotation-items-heading h3 { font-size: 15px; }
.quotation-items-heading .button { height: 32px; padding: 0 12px; font-size: 12px; }
.quotation-lines { display: grid; gap: 8px; margin: 8px 0 12px; }
.quotation-line { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(72px, 86px) minmax(88px, 106px) minmax(95px, auto) 32px; gap: 8px; align-items: end; padding: 8px; border: 1px solid var(--border); border-radius: 10px; }
.quotation-line-amount { display: grid; gap: 5px; font-size: 13px; overflow-wrap: anywhere; }
.quotation-line-amount small { color: var(--secondary); }
.quotation-line .icon-button { width: 32px; height: 32px; }
.quotation-total { margin: 4px 0 12px; text-align: right; font-weight: 800; }
.quotation-editor #quotation-error { margin: 0; padding: 8px 22px; }
.quotation-editor .dialog-footer { flex-wrap: wrap; padding: 12px 22px; }
#quotation-preview-frame { display: block; width: 100%; height: min(58dvh, 600px); margin-bottom: 8px; border: 1px solid var(--border); }
@media (max-width: 580px) {
  .quotation-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quotation-line { grid-template-columns: repeat(2, minmax(0, 1fr)) 32px; }
  .quotation-line > label:first-child { grid-column: 1 / -1; }
  .quotation-line-amount { grid-column: 1 / 3; }
  .quotation-line .icon-button { grid-column: 3; }
}
.reply-attachments { display: flex; flex-wrap: wrap; grid-column: 1 / -1; gap: 8px; }
.reply-attachment { display: flex; align-items: center; gap: 8px; max-width: 260px; padding: 6px 8px 6px 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; }
.reply-attachment > img { width: 34px; height: 34px; object-fit: cover; border-radius: 8px; }
.reply-attachment > .material-symbols-outlined { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); }
.reply-attachment > span:not(.material-symbols-outlined) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 500; }
.reply-attachment small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.reply-attachment .icon-button { width: 24px; height: 24px; }
.reply-attachment .icon-button span { font-size: 15px; }

/* 11 · Notifications --------------------------------------------------- */
.notifications-panel { position: fixed; inset: 72px 28px auto auto; width: min(420px, calc(100vw - 24px)); max-height: min(640px, calc(100dvh - 90px)); margin: 0; padding: 0; overflow-y: auto; background: var(--card); border: 1px solid var(--border); border-radius: 20px; color: var(--text); box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .45); }
.notifications-heading { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 14px 20px; background: var(--card); border-bottom: 1px solid var(--border); }
.notifications-heading h2 { font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.notifications-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--hover); color: var(--muted); font-size: 12px; font-weight: 500; }
.notification-text-button { padding: 4px 0; border: 0; background: transparent; color: var(--primary); font-size: 12px; font-weight: 700; cursor: pointer; }
.notification-text-button:hover { text-decoration: underline; }
.notification-item { display: flex; align-items: flex-start; gap: 12px; padding: 15px 20px; border-bottom: 1px solid var(--border); transition: background .12s; }
.notification-item:hover { background: var(--hover); }
.notification-item.unread { background: var(--selected); box-shadow: inset 3px 0 0 var(--primary); }
.notification-avatar { display: grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: var(--on-ink); font-size: 11px; font-weight: 700; }
.notification-content { display: block; flex: 1; min-width: 0; }
.notification-item-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px; margin-bottom: 4px; }
.notification-item-heading strong { font-size: 13px; font-weight: 700; }
.notification-item-heading time { color: var(--muted); font-size: 10px; }
.notification-reference { display: block; margin-bottom: 5px; overflow: hidden; color: var(--primary-deep); font-family: var(--mono); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.notification-preview { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; color: var(--secondary); font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.notification-unread-dot { flex: 0 0 8px; width: 8px; height: 8px; margin-top: 9px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.notifications-empty { padding: 40px 20px; color: var(--muted); text-align: center; }
.notifications-empty > .material-symbols-outlined { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--chip); color: var(--secondary); font-size: 28px; }
.notifications-empty p { margin: 12px 0 0; color: var(--text); font-size: 14px; font-weight: 600; }
.notifications-empty small { display: block; margin-top: 4px; font-size: 12px; line-height: 1.6; }
#notification-error { margin: 12px 20px; color: var(--secondary); font-size: 12px; }
#notifications-retry { margin: 0 20px 14px; }

/* 12 · Image viewer (dark in both themes) ------------------------------ */
.image-viewer { --card: #101010; --bg: #090909; --hover: #1b1b1b; --chip: #232323; --border: #2c2c2c; --border-strong: #3e3e3e; --text: #f5f5f5; --secondary: #bbbbbb; --muted: #8e8e8e; --ink: #f5f5f5; --on-ink: #0b0b0b; width: min(1100px, calc(100vw - 40px)); height: min(820px, 88dvh); max-width: none; max-height: 92dvh; padding: 0; overflow: hidden; background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 22px; box-shadow: 0 30px 100px rgba(0, 0, 0, .7); }
.image-viewer[open] { display: flex; flex-direction: column; }
.image-viewer::backdrop { background: rgba(0, 0, 0, .82); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.image-viewer-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.image-viewer-header > div { display: flex; align-items: center; gap: 10px; min-width: 0; }
.image-viewer-header > div > span { color: var(--primary); }
.image-viewer-header h2 { margin: 0; overflow: hidden; font-size: 14px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.image-viewer-stage { display: flex; flex: 1; min-height: 0; padding: 16px; overflow: auto; overscroll-behavior: contain; background: var(--bg); }
.image-viewer-stage img { display: block; flex-shrink: 0; max-width: none; max-height: none; margin: auto; object-fit: contain; }
.image-viewer-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--border); }
.viewer-navigation, .viewer-zoom { display: flex; align-items: center; gap: 8px; }
.viewer-navigation > span, .viewer-zoom > span { min-width: 44px; color: var(--secondary); font-size: 12px; font-weight: 600; text-align: center; }
.viewer-zoom > .button { height: 32px; padding: 0 14px; font-size: 12px; }
.image-viewer button:disabled { cursor: default; opacity: .3; }

/* 13 · Toast ----------------------------------------------------------- */
.toast { position: fixed; top: calc(var(--topbar-h) + 16px); bottom: auto; left: calc(50% + var(--sidebar-w) / 2); z-index: 100; display: flex; align-items: center; gap: 10px; width: max-content; max-width: calc(100vw - 32px); padding: 13px 20px 13px 18px; background: var(--ink); border-radius: 14px; color: var(--on-ink); font-size: 14px; font-weight: 500; box-shadow: 0 22px 44px -14px rgba(0, 0, 0, .55); transform: translateX(-50%); animation: toast-in .25s ease; }
.toast::before { content: ''; flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.toast:has(> .ticket-update-link) { padding: 0; }
.toast:has(> .ticket-update-link)::before { display: none; }
.toast.error { background: var(--primary); color: #fff; }
.toast.error::before { background: #fff; }

/* 14 · Responsive ------------------------------------------------------ */
@media (min-width: 1500px) {
  main { padding: 34px 44px 26px; }
  .summary-value { font-size: 54px; }
  :root { --conversation-rail-w: 250px; }
  .original-request { max-width: min(85%, 780px); }
}
@media (max-width: 1100px) {
  :root { --sidebar-w: 216px; }
  main { padding: 26px 24px 20px; }
  .topbar { padding: 0 24px; }
  :root { --conversation-rail-w: 210px; }
  .conversation-timeline { padding: 20px 18px; }
  .original-request { max-width: 96%; }
}
@media (max-width: 860px) {
  .requirement-options { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (width > 760px) {
  body.sidebar-compact { --sidebar-w: 72px; }
  .sidebar-compact .brand { width: 44px; margin: 14px auto 0; padding: 8px; border-radius: 12px; }
  .sidebar-compact .brand-mark { display: block; }
  .sidebar-compact :is(.brand-logo, .nav-label, .nav-count, .sidebar-bottom),
  .sidebar-compact .sidebar nav::before { display: none; }
  .sidebar-compact .sidebar nav { padding: 0 10px; }
  .sidebar-compact .nav-item { justify-content: center; padding: 0; }
  .sidebar-compact .nav-item.active::before { left: -10px; }
}
@media (max-width: 760px) {
  main:has(:is(#dashboard-view, #create-view):not([hidden])) { padding-top: 14px; }
  .summary-grid { gap: 8px; }
  :root { --sidebar-w: 264px; }
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.is-open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .6); }
  .app-shell { margin-left: 0; }
  .brand { margin-top: calc(var(--topbar-h) + 14px); } /* the top bar sits above the open drawer */
  .toast { left: 50%; }
  .topbar { z-index: 35; padding: 0 16px; }
  .topbar-left, .topbar-right { gap: 8px; }
  .profile { padding-left: 10px; }
  .profile-identity { display: none; }
  main { padding: 20px 16px 16px; }
  h1 { font-size: 28px; }
  .page-heading { align-items: flex-start; margin: 18px 0 20px; }
  .heading-actions .secondary { width: 40px; padding: 0; font-size: 0; gap: 0; }
  .filters .search { flex-basis: 100%; }
  .filter-select { flex: 1; min-width: 0; }
  .filter-select select { width: 100%; max-width: none; }
  .page-footer > span:last-child { display: none; }
  .form-fields { padding: 20px; }
  .ticket-page-form .form-fields { padding: 16px; }
  .ticket-form-footer { padding-inline: 12px; }
  .ticket-form-buttons .button { flex: 1; }
  .create-back { padding-inline: 12px; font-size: 12px; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .request-item-identifiers { grid-template-columns: 1fr; margin-left: 14px; margin-right: 14px; }
  .dialog-footer { padding: 16px 20px; }

  .conversation-open main { padding: 8px 12px; }
  .page-heading.conversation-page-heading { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 8px; }
  .conversation-page-heading h1 { font-size: 22px; }
  .conversation-page-heading > .button { grid-column: 2; padding: 0 14px; font-size: 12px; }
  .conversation-layout { display: flex; flex-direction: column; min-height: 360px; border-radius: 16px; }
  .conversation-rail { display: none; }
  .conversation-main { flex: 1; }
  .conversation-header { gap: 10px; min-height: 52px; padding: 8px 12px; }
  .conversation-update-notice { grid-area: 2 / 1 / auto / -1; max-width: min(100%, 440px); }
  .conversation-avatar { flex-basis: 30px; width: 30px; height: 30px; }
  .conversation-header-actions .button { padding: 0 8px; }
  .conversation-timeline { padding: 18px 12px; }
  .chat-message { max-width: 90%; }
  .original-request { max-width: 100%; }
  .original-request .request-message-heading { flex-wrap: wrap; gap: 10px; padding: 14px; }
  .original-request .request-item-description { padding: 16px 14px 14px; font-size: 16px; }
  .original-request .request-message-meta { margin: 0 14px 14px; }
  .original-request .request-message-requirements { padding: 14px; }
  .request-message-images { padding: 0 14px 14px; }
  .chat-message.original-request .message-time.request-created { padding: 10px 14px; }
  .message-composer { grid-template-columns: minmax(0, 1fr) auto; gap: 5px 6px; padding: 6px 10px; }
  .reply-tools { grid-column: 1 / -1; }
  .reply-tools .attach-message { height: 36px; }
  .message-composer .button { min-width: 46px; width: 46px; padding: 0; }
  .message-composer .button > span:last-child { display: none; }
  .attach-message { width: 34px; }
  .reply-attachment { max-width: 100%; }
  .new-messages { right: 14px; bottom: 124px; }
  .notifications-panel { right: 12px; left: 12px; width: auto; inset-block-start: 68px; }
  .image-viewer { width: calc(100vw - 20px); height: 85dvh; }
  .image-viewer-header { padding: 12px; }
  .image-viewer-footer { padding: 10px 8px; gap: 6px; }
  .viewer-navigation, .viewer-zoom { gap: 3px; }
  .viewer-zoom > .button { padding: 0 10px; }
}
@media (max-width: 980px) {
  .table-scroll { overflow: visible; }
  .requests-table, .requests-table tbody { display: block; }
  .requests-table thead { display: none; }
  .requests-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 8px; padding: 11px 14px; border-bottom: 1px solid var(--border); }
  .requests-table tbody tr:hover, .requests-table tbody tr:focus-within { background: var(--hover); }
  .requests-table td { display: block; min-width: 0; padding: 0; border: 0; }
  .request-identity { grid-column: 1; grid-row: 1; }
  .request-status { grid-column: 2; grid-row: 1; align-self: start; }
  .request-workflow, .request-requirements { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .dashboard-heading .heading-actions { gap: 6px; }
  .dashboard-heading .heading-actions .primary { padding: 0 10px; font-size: 12px; }
  .summary-card { padding: 10px 8px; gap: 4px; }
  .summary-icon { display: none; }
  .summary-label { font-size: 12px; }
  .summary-value { font-size: 24px; }
  .summary-arrow { font-size: 14px; }
}
@media (max-width: 440px) {
  .conversation-header { gap: 8px; }
  .conversation-header { flex-wrap: wrap; }
  .conversation-header-actions { flex-wrap: wrap; margin-left: auto; }
  .conversation-ticket-title { gap: 4px; }
  .conversation-ticket-title h2 { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Shared RFQ workflow: created, accepted, quotation shared, closed. */
.ticket-workflow { padding: 10px 18px; background: var(--card); border-bottom: 1px solid var(--border); overflow-x: auto; flex-shrink: 0; }
.workflow-panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.workflow-panel-heading h2 { font-size: 12px; margin: 0 0 5px; }
.workflow-panel-heading p { font-size: 11px; color: var(--secondary); margin: 0; line-height: 1.5; }
.workflow-panel-heading .button { font-size: 11px; min-height: 32px; padding: 7px 12px; }
.ticket-flow { list-style: none; display: flex; padding: 0; margin: 0; }
.ticket-flow li { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; position: relative; text-align: center; }
.ticket-flow li::before { content: ''; height: 2px; position: absolute; top: 11px; left: -50%; width: 100%; background: var(--border); }
.ticket-flow li:first-child::before { display: none; }
.flow-node { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--border); background: var(--bg); color: var(--muted); font-size: 10px; z-index: 1; }
.flow-node .material-symbols-outlined { font-size: 15px; }
.flow-label { font-size: 10px; margin-top: 7px; color: var(--muted); line-height: 1.5; }
.ticket-flow li > small { display: block; color: var(--muted); font-size: 8px; line-height: 1.5; margin-top: 3px; }
.ticket-flow .complete .flow-node { background: var(--green-bg); color: var(--green); border-color: transparent; }
.ticket-flow .complete::before { background: var(--green); opacity: .3; }
.ticket-flow .complete .flow-label { color: var(--text); font-weight: 600; }
.ticket-flow .current .flow-node { border-color: var(--amber); color: var(--amber); background: var(--amber-bg); box-shadow: 0 0 0 3px var(--card); }
.ticket-flow .current .flow-label { color: var(--amber); font-weight: 600; }
.workflow-history { margin-top: 12px; font-size: 10px; color: var(--secondary); }
.workflow-history summary { cursor: pointer; }
.workflow-history ul { list-style: none; margin: 10px 0 0; padding: 0; }
.workflow-history li { display: flex; gap: 12px; justify-content: space-between; border-top: 1px solid var(--border); padding: 8px 0; font-size: 10px; }
.workflow-history li > span { color: var(--muted); }
@media(max-width:760px) { .workflow-panel-heading { margin-bottom: 14px; flex-wrap: wrap; gap: 9px; } .workflow-panel-heading p { font-size: 10px; } .ticket-flow li > small { font-size: 7px; } .flow-label { font-size: 9px; } .workflow-history li { flex-wrap: wrap; gap: 4px; } }

/* Acceptance starts the visible flow; the PO exchange has separate handoff steps. */
@media(max-width:760px) { .ticket-flow .flow-label { font-size: 8px; } .ticket-flow li > small { font-size: 7px; } }

.flow-message-link { border: 0; background: transparent; color: var(--secondary); font-size: 9px; text-decoration: underline; text-underline-offset: 2px; padding: 4px; margin-top: 2px; }
.workflow-message-highlight .message-bubble { outline: 2px solid var(--muted); outline-offset: 3px; }

/* Keep the progress strip small so the conversation gets the space. */
.ticket-workflow .ticket-flow { margin: 0; }
.ticket-workflow .flow-label { margin-top: 5px; font-size: 10px; }
.ticket-workflow button.flow-node { padding: 0; font-family: inherit; cursor: pointer; }
.ticket-workflow button.flow-node:hover { outline: 2px solid var(--muted); outline-offset: 2px; }
@media(max-width:760px) { .ticket-workflow { padding: 10px 8px; } .ticket-workflow .flow-label { font-size: 8px; } }

/* Explicit neutral connectors stay visible with the shared black/white tokens. */
.ticket-flow li::before { left: calc(-50% + 16px); width: calc(100% - 32px); top: 11px; height: 2px; background: var(--border-strong, var(--muted)); opacity: 1; }
.ticket-flow .complete::before { background: var(--secondary); opacity: .55; }
.ticket-flow .complete .flow-node { background: var(--card); color: var(--text); border: 1px solid var(--border-strong, var(--muted)); }
.flow-time { display: block; color: var(--muted); font-family: var(--mono, 'Roboto Mono', monospace); font-size: 9px; line-height: 1.4; margin-top: 3px; font-variant-numeric: tabular-nums; }
@media(max-width:760px) { .flow-time { font-size: 8px; } }

/* The receiving account accepts a new request before entering the chat. */
.review-request-panel { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--card); }
.review-request-panel h3 { font-size: 14px; margin: 0; }
.review-request-panel p { color: var(--secondary); font-size: 12px; margin: 3px 0 0; }
.review-request-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.review-request-actions .button { min-height: 38px; }
.badge.rejected { background: var(--primary-soft); border-color: var(--primary-line); color: var(--primary-deep); }
.badge.rejected::before { animation: none; }
.rejection-message .message-bubble { border-color: var(--primary-line); }
.rejection-message .message-text { margin-top: 6px; }
#rejection-help, #receipt-help { grid-column: 1 / -1; margin: 0; color: var(--secondary); font-size: 12px; }
@media (max-width: 760px) { .review-request-panel { padding: 10px 12px; } }


.workflow-prompt { display: flex; align-items: flex-start; gap: 10px; margin: 4px 0 20px; padding: 13px 16px; max-width: 660px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--secondary); }
.workflow-prompt > .material-symbols-outlined { color: var(--text); font-size: 20px; margin-top: 1px; }
.workflow-prompt strong { display: block; color: var(--text); font-size: 12px; font-weight: 600; }
.workflow-prompt p { margin: 4px 0 0; font-size: 12px; line-height: 1.6; }
@media(max-width:760px) { .workflow-prompt { padding: 12px; } .workflow-prompt p { font-size: 11px; } }

.conversation-overdue { flex-shrink: 0; border-bottom: 1px solid #e5c692; background: #fff4df; color: #774809; }
.conversation-overdue summary { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 5px 18px; list-style: none; font-size: 12px; cursor: pointer; }
.conversation-overdue summary::-webkit-details-marker { display: none; }
.conversation-overdue summary:focus-visible { outline-offset: -3px; }
.conversation-overdue .material-symbols-outlined { font-size: 16px; }
.overdue-chevron { margin-left: auto; }
.conversation-overdue[open] .overdue-chevron { transform: rotate(180deg); }
.conversation-overdue p { padding: 0 18px 8px 42px; font-size: 12px; }
[data-theme=dark] .conversation-overdue { background: #302719; border-color: #705528; color: #f1d39d; }
@media (max-width: 760px) {
  .conversation-overdue summary { padding-inline: 12px; }
  .conversation-overdue p { padding-inline: 36px 12px; }
}

.ticket-overdue-label { display: inline-flex; align-items: center; gap: 5px; margin-top: 10px; padding: 6px 9px; border-radius: 6px; background: #a64b00; color: #fff; font-size: 11px; font-weight: 800; line-height: 1.5; }
.ticket-overdue-label .material-symbols-outlined { font-size: 17px; }
.conversation-ticket .ticket-overdue-label { padding: 2px 5px; background: #fff0d1; color: #774809; font-size: 10px; font-weight: 700; }
.conversation-ticket .ticket-overdue-label .material-symbols-outlined { font-size: 13px; }
.request-flags .ticket-overdue-label { margin: 0; padding: 3px 6px; }
.request-flags .ticket-overdue-label .material-symbols-outlined { font-size: 14px; }
.request-action-label { display: inline-flex; padding: 3px 6px; border: 1px solid var(--primary-line); border-radius: 6px; background: var(--primary-soft); color: var(--primary-deep); font-size: 11px; font-weight: 700; line-height: 1.5; }
[data-theme=dark] .ticket-overdue-label { background: #edb14c; color: #2b1900; }
[data-theme=dark] .conversation-ticket .ticket-overdue-label { background: #3d2c18; color: #f1d39d; }

/* Keep all eight workflow milestones readable in narrow chats. */
.ticket-workflow .ticket-flow { min-width: 560px; }
.ticket-workflow .ticket-flow.with-timings { min-width: 880px; padding-top: 24px; padding-bottom: 2px; }
.with-timings .flow-timestamp { display: flex; flex-direction: column; gap: 1px; margin-top: 6px; color: var(--secondary); font-size: 10px; font-weight: 400; line-height: 1.5; white-space: nowrap; }
.with-timings .flow-timestamp-empty { color: var(--muted); }
.with-timings .flow-duration { position: absolute; top: -22px; left: 0; transform: translateX(-50%); padding: 2px 6px; border: 1px solid var(--border); border-radius: 5px; background: var(--hover); color: var(--secondary); font-size: 9px; font-weight: 600; line-height: 1.5; white-space: nowrap; }
