/* Shared polish for the dealer workspace and the staff panel. */
:root {
  --work-surface: var(--ui-surface);
  --work-border: var(--ui-line);
  --work-accent: #793288;
  --work-radius: 14px;
  --work-gap: clamp(14px, 2vw, 24px);
}

:root.dark { --work-accent: #e0a1e9; }

#app .main, .fi-main { font-variant-numeric: tabular-nums; }

#app .page-heading h1, .fi-header-heading {
  letter-spacing: -.035em;
  text-wrap: balance;
}

#app .page-heading h1 { font-size: clamp(1.75rem, 3.2vw, 2.4rem); }
#app .page-heading p { max-width: 64ch; }
#app .panel, #app .form-panel, .fi-main .fi-section, .fi-main .fi-ta-ctn {
  border-radius: var(--work-radius);
  box-shadow: 0 2px 6px #11111108;
}
.fi-main .fi-section-header { gap: .8rem; }
#app .panel-head h2, .fi-main .fi-section-header-heading { letter-spacing: -.018em; }

#app .topbar, .fi-topbar { box-shadow: 0 1px 6px #11111108; }
#app .job-row, #app .inbox-row { text-decoration: none; }
#app .job-row:hover, #app .inbox-row:hover, .fi-main .fi-ta-row:hover {
  background: color-mix(in srgb, var(--ui-accent) 5%, var(--work-surface));
}
#app :where(.btn, .nav, .job-row, .inbox-row):focus-visible,
.fi-main :where(button, a, input, select, textarea):focus-visible {
  outline: 2px solid var(--work-accent);
  outline-offset: 3px;
}

#app .queue-summary .sum, #app .queue-summary a {
  min-width: 0;
  font-variant-numeric: tabular-nums;
}
#app .nav.active, .fi-sidebar .fi-sidebar-item.fi-active .fi-sidebar-item-btn {
  background: color-mix(in srgb, #d387df 17%, transparent);
}
#app .nav.active svg { color: #e0a1e9; }

#app .job-workspace, .fi-main .staff-job-grid {
  grid-template-columns: minmax(0, 1.55fr) minmax(19rem, 1fr);
  gap: var(--work-gap);
  align-items: start;
}
.job-workspace .detail-main, .job-workspace .detail-side { min-width: 0; }
.job-workspace .job-documents h3 {
  margin: 0;
  padding: 12px 17px 5px;
  font-size: .85rem;
}
.job-documents > div[data-live]:not(:empty) { padding-bottom: 8px; }
.job-documents > div[data-live]:not(:empty) + div[data-live]:not(:empty) {
  border-top: 1px solid var(--work-border);
}
.job-documents .file-row { padding: 9px 16px; gap: 10px; flex-wrap: wrap; }
.job-documents .file-row > svg { flex: none; }
.job-documents .file-info { min-width: 0; flex: 1 1 8rem; }
.job-documents .file-info strong, .staff-files strong { overflow-wrap: anywhere; }
.job-workspace .facts { grid-template-columns: repeat(2,minmax(0,1fr)); }
.job-workspace .facts dd { overflow-wrap: anywhere; }

#app .job-thread, .fi-main .job-thread {
  display: grid;
  gap: 12px;
  max-height: min(58vh, 36rem);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--ui-field-line) transparent;
}
#app .job-thread { padding: 16px; }
.fi-main .job-thread { padding: 2px 3px 4px; }
.job-thread article { min-width: 0; }
#app .job-thread .message, .fi-main .job-thread article {
  border-radius: 11px;
  padding: 10px 13px;
  max-width: min(100%, 40rem);
  justify-self: start;
  width: fit-content;
  background: var(--ui-raised);
  border: 1px solid var(--work-border);
}
#app .job-thread .message.own, .fi-main .job-thread article.from-staff {
  justify-self: end;
  background: var(--ui-tint);
  border-color: var(--ui-tint-line);
}
.job-thread article p { margin: 6px 0 0; max-width: 65ch; overflow-wrap: anywhere; white-space: pre-wrap; }
.thread-meta, .job-thread .message-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.thread-meta time, .job-thread .message-meta time { color: var(--ui-muted); font-size: .75rem; }
.thread-empty { color: var(--ui-muted); font-size: .875rem; margin: 0; }
.job-documents .thread-empty { padding: 4px 17px 8px; }

#app .thread-composer, .fi-main .thread-composer { display: grid; gap: 10px; }
#app .thread-composer { border-top: 1px solid var(--work-border); padding: 15px 16px 16px; }
#app .thread-composer > label, .fi-main .thread-composer > label { font-size: .86rem; font-weight: 650; }
#app .thread-composer textarea, .fi-main .thread-composer textarea {
  width: 100%;
  min-height: 5rem;
  resize: vertical;
  border-radius: 9px;
}
.thread-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.thread-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  border: 1px solid var(--ui-field-line);
  border-radius: 8px;
  padding: 7px 11px;
  cursor: pointer;
  font-size: .86rem;
  font-weight: 600;
}
.thread-picker[hidden], .thread-selection[hidden] { display: none; }
.thread-picker:hover, .thread-file:hover { background: var(--ui-hover); }
.thread-picker:focus-within { outline: 2px solid var(--work-accent); outline-offset: 3px; }
.thread-picker-input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.thread-picker svg, .thread-file svg { width: 17px; height: 17px; flex: none; }
.thread-selection { margin: 0; padding: 0; list-style: none; overflow-wrap: anywhere; font-size: .85rem; }
.thread-composer .upload-feedback:empty, .thread-composer .error:empty { display: none; }

#app .thread-file, .fi-main .thread-file {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  margin-top: 7px;
  padding: 6px 9px;
  border: 1px solid var(--ui-field-line);
  border-radius: 7px;
  background: var(--ui-field);
  color: var(--ui-text);
  text-align: left;
  font-size: .85rem;
}
.thread-file span { overflow-wrap: anywhere; min-width: 0; }
.thread-file small { color: var(--ui-muted); }
#app .thread-reference, .fi-main .thread-reference {
  display: inline-block;
  color: var(--work-accent);
  font-size: .8rem;
  padding: 2px 0;
  background: none;
  border: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}
:is(.job-workspace, .staff-job-grid) [id^="job-"] { scroll-margin-block: 5rem; }
:is(.job-workspace, .staff-job-grid) :is(:target, [tabindex="-1"]:focus) {
  outline: 2px solid var(--work-accent);
  outline-offset: 1px;
}

@media (max-width: 1050px) {
  #app .job-workspace, .fi-main .staff-job-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  #app .page-heading { flex-wrap: wrap; }
  #app .rail nav { scrollbar-width: thin; }
  #app .nav { min-height: 44px; }
  #app .job-thread { padding: 12px; }
  #app .thread-composer { padding: 12px; }
  #app .job-thread .message, .fi-main .job-thread article { max-width: 100%; }
}

#app .queue-summary {
  border: 1px solid var(--work-border);
  border-radius: var(--work-radius);
  background: var(--work-surface);
  overflow: clip;
}
#app .summary-item { position: relative; }
#app .summary-item:hover, #app .summary-item.is-active { background: var(--ui-tint); }
#app .summary-item.is-active::after {
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: var(--work-accent);
  content: "";
}
#app .summary-item:focus-visible { outline-offset: -4px; }
#app .service-option, #app .summary-box { border-radius: var(--work-radius); }
#app .service-option:focus-within { outline: 2px solid var(--work-accent); outline-offset: 3px; }
#app #new-job .form-panel > p { max-width: 65ch; }
#app .toolbar .tabs { gap: 4px; }
#app .toolbar .tab { padding-inline: 9px; }
.fi-main .staff-job-summary {
  border-radius: var(--work-radius);
  padding: clamp(14px,2vw,22px);
}
.fi-main .staff-queue-tabs { gap: clamp(14px,2vw,25px); }
.fi-main .staff-queue-tabs > button { min-height: 44px; }

.auth-page .auth-panel {
  border-radius: var(--work-radius);
  box-shadow: 0 14px 40px #00000015;
}
.auth-page .auth-panel h1 { letter-spacing: -.035em; }
.auth-page .auth-panel h1 + form { margin-top: 22px; }
.auth-page .auth-panel :is(input, .btn):focus-visible {
  outline: 2px solid var(--work-accent);
  outline-offset: 3px;
}
.auth-page .auth-links a { text-underline-offset: .22em; }

#app .job-activity summary {
  padding: 13px 17px;
  font-size: .95rem;
  font-weight: 650;
  cursor: pointer;
}
#app .job-activity[open] summary { border-bottom: 1px solid var(--work-border); }
.workspace-shortcut { display: none; }
#app .workspace-shortcut { display: none; }
@media (max-width: 1050px) {
  #app .workspace-shortcut { display: inline-flex; }
  .staff-return-shortcut {
    display: inline-flex;
    justify-self: start;
    color: var(--work-accent);
    text-decoration: underline;
    text-underline-offset: .22em;
  }
}

/* The job brief is a document header. The controls that change the job sit alongside it. */
.job-overview { min-width: 0; }
.job-overview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
}
.job-identity { min-width: 0; }
#app .job-identity h1, .fi-main .job-identity h2 {
  margin: 0;
  font-size: clamp(1.55rem, 2.6vw, 2.125rem);
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: -.035em;
  overflow-wrap: anywhere;
}
.job-identity p { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px 13px; margin: 6px 0 0; color: var(--ui-muted); }
.job-identity p strong { color: var(--ui-text); font-weight: 650; }
.staff-job-state { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; max-width: 100%; }
.fi-main .job-status-form { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; width: 18.5rem; max-width: 100%; gap: 8px; }
.job-status-label { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.fi-main .job-status-form select { width: auto; max-width: 100%; flex: 1 1 9.5rem; }
.job-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px 18px;
  margin: 18px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--work-border);
}
.job-facts div, .job-brief div { min-width: 0; }
.job-facts dt, .job-brief dt { color: var(--ui-muted); font-size: .8rem; margin-bottom: 3px; }
.job-facts dd, .job-brief dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.job-payment-ref { display: block; }
.job-brief { margin: 13px 0 0; display: grid; gap: 8px; }
.job-brief dd { font-weight: 450; white-space: pre-wrap; max-width: 75ch; }
.job-jump-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 18px;
  border-bottom: 1px solid var(--work-border);
  border-top: 1px solid var(--work-border);
}
#app .job-jump-nav { margin-block: 16px; }
.job-jump-nav :is(a, button) {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  font-size: .875rem;
  font-weight: 650;
  color: var(--work-accent);
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
}
.job-jump-nav :is(a, button):hover { text-decoration: underline; text-underline-offset: 4px; }
.job-jump-nav :is(a, button):focus-visible { outline: 2px solid var(--work-accent); outline-offset: 3px; }
#app .job-workspace.job-section-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
.fi-main .staff-job-grid.job-section-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
.job-section-grid > * { min-width: 0; }
#app .job-section-grid > #job-activity { grid-column: 1 / -1; }
#app .job-section-grid [id^="job-"], .fi-main .job-section-grid [id^="job-"] { scroll-margin-top: 5.5rem; }
.fi-main .job-section-grid #job-activity .staff-activity { max-height: 22rem; overflow: auto; }
.job-overview + [data-live="payment-notice"]:not(:empty) { margin-top: 14px; }

@media (max-width: 1023px) {
  #app .job-workspace.job-section-grid, .fi-main .staff-job-grid.job-section-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .job-facts { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
  .job-overview-header { align-items: flex-start; }
  .staff-job-state, .fi-main .job-status-form { width: 100%; }
  .job-jump-nav { column-gap: 14px; }
  .job-jump-nav :is(a,button) { min-height: 44px; }
}

.vehicle-panel { container-type: inline-size; }
.vehicle-panel-grid {
  display: grid;
  grid-template-areas: "registration" "fields";
  gap: 16px 20px;
}
.vehicle-lookup-enabled { grid-template-areas: "registration" "match" "fields"; }
.vehicle-lookup-enabled:not(:has(.vehicle-match[data-state="found"])) { grid-template-areas: "registration" "fields"; }
.vehicle-registration { grid-area: registration; min-width: 0; }
.vehicle-registration > label { margin-bottom: 6px; font-weight: 650; }
.vehicle-lookup-controls { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; }
.vehicle-lookup-controls input {
  flex: 1 1 9rem;
  min-width: 0;
  min-height: 44px;
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--ui-field-line);
  border-radius: 8px;
  background: var(--ui-field);
  color: var(--ui-text);
  font-weight: 650;
  text-transform: uppercase;
}
.vehicle-lookup-controls .btn { min-height: 44px; }
.vehicle-lookup-controls input:focus-visible { outline: 2px solid var(--work-accent); outline-offset: 2px; }
.vehicle-lookup-icon { display: inline-flex; }
.vehicle-lookup-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
}
@media (prefers-reduced-motion: no-preference) {
  .vehicle-lookup-spinner { animation: vehicle-lookup-spin .7s linear infinite; }
  @keyframes vehicle-lookup-spin { to { transform: rotate(1turn); } }
}
.vehicle-panel [hidden] { display: none !important; }
.vehicle-hint, .vehicle-feedback { margin: 6px 0 0; line-height: 1.45; }
.vehicle-feedback:empty { display: none; }
.vehicle-lookup-error { color: #9f263f; }
:root.dark .vehicle-lookup-error { color: #ff9eac; }
.vehicle-detail-fields { grid-area: fields; min-width: 0; }
.vehicle-panel .vehicle-detail-fields { margin-top: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.vehicle-panel .vehicle-detail-fields .field:has(select) { grid-column: auto; }
.vehicle-match {
  grid-area: match;
  align-self: start;
  min-width: 0;
  border: 1px solid var(--ui-tint-line);
  border-radius: 11px;
  background: var(--ui-tint);
  padding: 14px;
  overflow-wrap: anywhere;
}
.vehicle-match h3 { margin: 0 0 8px; font-size: .86rem; }
.vehicle-match-name { display: block; font-size: 1.05rem; line-height: 1.3; }
.vehicle-match-vrm { display: block; color: var(--ui-muted); margin-top: 3px; font-size: .8rem; font-weight: 650; }
.vehicle-match dl { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 12px 0; }
.vehicle-match dt { color: var(--ui-muted); font-size: .75rem; }
.vehicle-match dd { margin: 0; font-size: .85rem; font-weight: 650; }
.vehicle-match[data-state="idle"] { display: none; }
.vehicle-match [data-match-placeholder] { margin: 0; color: var(--ui-muted); font-size: .85rem; }
.vehicle-match[data-state="found"] { border-color: var(--ui-tint-line); }
@container (min-width: 35rem) {
  .vehicle-panel-grid.vehicle-lookup-enabled:has(.vehicle-match) {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    grid-template-areas: "registration match" "fields fields";
    align-items: start;
  }
  .vehicle-match {
    display: block;
    min-height: 164px;
  }
  .vehicle-match[data-state="idle"] {
    display: block;
    background: var(--ui-raised);
    border-color: var(--work-border);
  }
  .vehicle-lookup-controls .btn { min-width: 155px; }
}

.staff-file-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.staff-file-list-mobile { display: none; }

@media (max-width: 767px) {
  .staff-file-list-mobile { display: inline; white-space: normal; overflow-wrap: anywhere; }
}
