/* Shared component geometry: captions, controls and actions use common tracks. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

body {
  background: var(--app-bg);
}

h1 {
  letter-spacing: -1.1px;
  font-size: 38px;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 20px;
  gap: 8px;
  min-height: var(--control-height);
  white-space: normal;
}

button.primary {
  background: var(--action-bg);
  border-color: var(--action-bg);
  color: var(--action-text);
}

button.primary:hover:not(:disabled) {
  background: var(--action-hover);
  border-color: var(--action-hover);
}

input:not([type="checkbox"]):not([type="file"]),
select {
  height: var(--control-height);
  line-height: 22px;
}

input:not([type="checkbox"]):not([type="file"]),
select,
textarea {
  background: var(--field);
  color: var(--ink);
  border-color: var(--border);
}

input::placeholder,
textarea::placeholder {
  color: var(--subtle);
  opacity: 1;
}

select {
  appearance: none;
  padding-right: 38px;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

select option {
  background: var(--field);
  color: var(--ink);
}

input:disabled,
select:disabled,
textarea:disabled {
  background-color: var(--disabled-bg);
  color: var(--disabled-text);
  -webkit-text-fill-color: var(--disabled-text);
  opacity: 1;
}

input[type="checkbox"] {
  appearance: none;
  display: inline-grid;
  place-content: center;
  vertical-align: middle;
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 1.5px solid var(--border-hover);
  border-radius: 5px;
  background: var(--field);
}

input[type="checkbox"]:checked {
  background-color: var(--orange);
  border-color: var(--orange);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%2317130f' stroke-width='2.2'%3E%3Cpath d='m3 7 3 3 5-6'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
}

input[type="checkbox"]:disabled {
  cursor: default;
  opacity: 0.5;
}

.field-label {
  display: block;
  font-size: 12px;
  line-height: 19px;
  font-weight: 550;
  color: var(--muted);
}

.form-grid {
  align-items: start;
  row-gap: 10px;
  column-gap: 18px;
}

.form-grid > label {
  display: grid;
  grid-template-rows: minmax(38px, auto) auto;
  align-content: start;
  gap: 8px;
  min-width: 0;
  margin: 0;
}

.form-grid > label > :is(input, select, textarea) {
  width: 100%;
  min-width: 0;
  align-self: start;
}

.form-grid > label > .field-label {
  align-self: end;
}

@supports (grid-template-rows: subgrid) {
  .form-grid > label {
    grid-row: span 2;
    grid-template-rows: subgrid;
    row-gap: 8px;
  }
}

.actions {
  align-items: center;
  gap: 12px;
}

.actions:has(> label) {
  align-items: flex-end;
}

.actions > label {
  display: grid;
  gap: 8px;
  margin: 0;
}

.actions > button {
  flex: none;
}

#newClientRow > label {
  width: min(360px, 100%);
}

#newClientRow > button {
  height: var(--control-height);
  margin: 0;
  align-self: flex-end;
}

.section-head {
  align-items: center;
  column-gap: 18px;
  row-gap: 14px;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
  margin-bottom: 18px;
}

.section-head > .section-heading {
  margin-bottom: 0;
}

.section-heading h2,
.section-heading h3 {
  margin: 0;
  line-height: 1.3;
  font-size: 21px;
  letter-spacing: -0.55px;
}

.section-overline {
  margin: 0 0 5px !important;
  font-size: 9px !important;
  line-height: 13px;
  letter-spacing: 1.25px;
  color: var(--accent-text) !important;
  font-weight: 600;
}

.section-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: none;
  border: 1px solid var(--accent-border);
  border-radius: 11px;
  background: var(--peach);
  color: var(--accent-text);
}

#detail {
  padding: 0;
  border: 0;
  background: transparent;
}

#detail > .section-head {
  padding: 4px 0 0;
}

#detail > .section-head h2 {
  font-size: 25px;
}

#detailStatus {
  margin: 12px 0 20px;
}

.work-section {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin: 24px 0;
  box-shadow: var(--shadow);
  scroll-margin-top: var(--scroll-offset);
}

#quotePanel,
#replyPanel,
#salesPanel,
#purchasePanel,
#poPanel {
  padding: 24px;
  margin: 24px 0;
  border: 1px solid var(--border);
}

#cardForm {
  padding: 0;
  margin: 0;
  background: transparent;
  border: 0;
}

#assignmentPanel {
  margin-top: 24px;
  background: var(--surface-soft);
}

.editor-form,
#purchaseForm,
#poForm {
  padding: 22px;
  margin: 22px 0;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
}

.work-section > label,
.editor-form > label {
  display: grid;
  gap: 8px;
  margin: 18px 0;
  max-width: 100%;
}

.work-section > label:has(select) {
  width: min(420px, 100%);
}

.work-section .form-grid > label {
  margin: 0;
}

#quoteUploadForm {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto var(--control-height) auto;
  gap: 8px 20px;
  align-items: start;
  justify-items: stretch;
  padding: 20px;
  border: 1px dashed var(--border-hover);
  border-radius: 11px;
  background: var(--surface-soft);
}

#quoteUploadForm > .file-control {
  display: grid;
  grid-column: 1;
  grid-row: 1 / span 3;
  grid-template-rows: subgrid;
  gap: 8px;
  margin: 0;
  max-width: 100%;
  justify-items: start;
}

#quoteUploadForm .file-pick {
  height: var(--control-height);
  min-height: var(--control-height);
  padding: 10px 16px;
  margin: 0;
  line-height: 20px;
}

#quoteUploadForm #uploadQuotes {
  grid-column: 2;
  grid-row: 2;
  align-self: stretch;
  margin: 0;
  height: var(--control-height);
}

#quoteFileSelection {
  align-self: start;
  line-height: 18px;
}

.card {
  padding: 20px;
  box-shadow: var(--shadow);
}

.card h3,
.card h4 {
  font-size: 16px;
  letter-spacing: -0.25px;
  line-height: 1.4;
}

.card button {
  min-height: var(--control-height);
}

#replyItems .card button,
#saleBatches .card button,
#poVersions .card button,
#purchasePanel td button,
#poPanel td button,
.quote-batches td button {
  display: flex;
  align-items: center;
  justify-content: center;
}

#replyItems .card,
#saleBatches .card,
#saleBatchRows .card,
#poVersions .card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

#replyItems .card p,
#saleBatches .card p,
#saleBatchRows .card p,
#poVersions .card p {
  margin: 4px 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 8px;
  min-height: 25px;
  line-height: 16px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
}

.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}

.badge.status-success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-border);
}

.badge.status-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: var(--danger-border);
}

.badge.status-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-color: var(--accent-border);
}

.badge.status-progress {
  background: var(--peach);
  color: var(--accent-text);
  border-color: var(--accent-border);
}

.scroll {
  scrollbar-color: var(--border-hover) var(--surface-soft);
}

th {
  vertical-align: middle;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
}

td {
  vertical-align: middle;
}

td:has(> input[type="checkbox"]:only-child) {
  text-align: center;
  vertical-align: middle;
  min-width: 54px;
}

#salesSelectionHeader,
#poCandidates th:first-child {
  text-align: center;
}

#salesLines input[type="text"],
#poPriceRows input,
#purchaseQuantity {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rfq-list .rfq-actions {
  align-items: stretch;
}

.rfq-list .rfq-actions button {
  width: 100%;
}

.workflow-feedback {
  margin-top: 16px;
  border-radius: 9px;
  line-height: 1.6;
}

.card p.bad {
  color: var(--danger-text);
}

.card p.warn {
  color: var(--warning-text);
}

.brand-mark,
.overview-card-accent,
.overview-card-accent .metric-link {
  color: var(--on-accent);
}

.overview-card-accent .metric-label,
.overview-card-accent .metric-label .icon,
.overview-card-accent p {
  color: var(--on-accent);
}

#upload.primary {
  background: var(--orange);
  color: var(--on-accent);
}

#upload.primary:hover:not(:disabled) {
  background: var(--action-hover);
  border-color: var(--action-hover);
  color: var(--action-text);
}

::selection {
  background: var(--selection);
  color: var(--selection-text);
}

.login-intro {
  background: var(--hero-bg);
  color: var(--hero-text);
}

.login-intro h2 {
  font-size: 42px;
  letter-spacing: -1.5px;
  max-width: 380px;
}

.login-intro > p,
.login-intro .eyebrow,
.login-steps strong {
  color: var(--hero-muted);
}

.login-decoration {
  color: var(--hero-decoration);
}

.overview-card,
.panel,
.quote-files,
.scroll {
  border-color: var(--border);
}

.theme-control {
  position: relative;
  display: block;
  flex: none;
  margin: 0;
}

.theme-control select {
  height: 40px;
  min-height: 40px;
  width: 150px;
  font-size: 12px;
  padding: 8px 30px 8px 36px;
  line-height: 20px;
  border-radius: 9px;
  background-color: var(--surface-soft);
  cursor: pointer;
}

.theme-icon {
  position: absolute;
  z-index: 1;
  left: 11px;
  top: 12px;
  width: 16px;
  height: 16px;
  pointer-events: none;
  color: var(--muted);
}

.theme-icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-icon-moon {
  display: block;
}

:root[data-theme="dark"] .theme-icon-sun {
  display: none;
}

.header-account {
  min-width: 0;
  gap: 12px;
}

#sessionName {
  min-width: 0;
  flex: 0 1 auto;
}

#logout {
  min-height: 40px;
  height: 40px;
  line-height: 20px;
  flex: none;
}

@media (max-width: 980px) {
  .theme-control select {
    width: 142px;
  }
  .header-account {
    gap: 8px;
  }
}

@media (max-width: 700px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-grid > label {
    grid-template-rows: auto auto;
  }
  .section-heading h2,
  .section-heading h3 {
    font-size: 19px;
  }
  .theme-control select {
    width: 42px;
    padding: 8px;
    color: transparent;
    background-image: none;
    font-size: 0;
  }
  .theme-control option {
    font-size: 14px;
    color: var(--ink);
  }
  .theme-icon {
    left: 13px;
    top: 12px;
  }
  .header-account #sessionName {
    display: none;
  }
}

@media (max-width: 480px) {
  .work-section,
  #quotePanel,
  #replyPanel,
  #salesPanel,
  #purchasePanel,
  #poPanel {
    padding: 18px 14px;
    margin: 20px 0;
  }
  .editor-form,
  #purchaseForm,
  #poForm {
    padding: 16px 12px;
  }
  .section-heading {
    gap: 10px;
  }
  .section-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
  }
  .section-heading h2,
  .section-heading h3 {
    font-size: 18px;
  }
  .section-head > button {
    max-width: 100%;
  }
  #newClientRow > label {
    width: 100%;
  }
  #newClientRow > button {
    width: 100%;
  }
  #quoteUploadForm {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px 12px;
    row-gap: 10px;
  }
  #quoteUploadForm > .file-control {
    grid-column: 1;
  }
  #quoteUploadForm #uploadQuotes {
    grid-column: 1;
    grid-row: 4;
    width: 100%;
  }
  #quoteUploadForm .file-pick {
    width: 100%;
    justify-self: stretch;
  }
  #quoteUploadForm > .file-control {
    justify-items: stretch;
  }
  .actions > button {
    flex-shrink: 1;
    max-width: 100%;
  }
  .theme-control select {
    width: 38px;
  }
  .theme-icon {
    left: 11px;
  }
  #logout {
    padding: 7px 9px;
  }
  .app-header {
    gap: 6px;
  }
  .header-account {
    gap: 5px;
  }
  .login-intro h2 {
    font-size: 32px;
    letter-spacing: -0.8px;
    margin-top: 18px;
  }
  .login-panel h1 {
    font-size: 28px;
  }
}

.warn:empty,
.bad:empty {
  display: none;
}

.editor-form > .actions + p.muted,
.editor-form > button + p.muted {
  margin-top: 12px;
}

.upload-activity {
  padding: 24px;
  border: 2px solid var(--orange);
  background: var(--paper);
  border-radius: 12px;
  margin: 16px 0;
}
.upload-activity h3 {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 22px;
}
.activity-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: activity-spin 1s linear infinite;
}
@keyframes activity-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .activity-spinner {
    animation: none;
  }
}
dialog {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  max-width: min(920px, 94vw);
  max-height: 88vh;
  overflow: auto;
}
dialog::backdrop {
  background: #0008;
}
.bulk-check {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bulk-check input {
  width: 22px;
  height: 22px;
}
.theme-options {
  display: flex;
  gap: 4px;
}
.theme-options button {
  padding: 6px 10px;
  min-height: 44px;
  font-size: 12px;
}
.theme-source {
  position: absolute !important;
  opacity: 0;
  pointer-events: none;
  width: 1px !important;
  height: 1px !important;
}
.theme-options [aria-pressed="true"] {
  border-color: var(--orange);
  background: var(--peach);
  color: var(--ink);
}
.date-control {
  display: flex;
  align-items: center;
  gap: 6px;
}
.date-control input {
  min-width: 0;
  flex: 1;
}
.date-control input::-webkit-calendar-picker-indicator {
  display: none;
}
.calendar-open {
  min-width: 44px;
  min-height: 44px;
  font-size: 24px;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(32px, 1fr));
  gap: 4px;
  margin: 16px 0;
}
.calendar-grid > span {
  text-align: center;
}
.calendar-grid button {
  padding: 4px;
  min-height: 40px;
}
.calendar-grid [aria-pressed="true"] {
  border-color: var(--orange);
  background: var(--peach);
}
select {
  background-color: var(--paper);
  color: var(--ink);
}
select option {
  background: var(--paper);
  color: var(--ink);
}
#bulkRows select {
  min-width: 190px;
}
@media (max-width: 600px) {
  .theme-options button {
    padding: 4px;
    font-size: 10px;
  }
  .theme-icon {
    display: none;
  }
  .calendar-dialog {
    padding: 12px;
  }
}

button:active:not(:disabled),
summary:active {
  filter: brightness(0.9);
}
button[data-action-busy] {
  position: relative;
  padding-right: 34px;
  cursor: progress;
}
button[data-action-busy]::after {
  content: "";
  position: absolute;
  right: 10px;
  top: calc(50% - 7px);
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: action-spin 0.7s linear infinite;
}
input[data-action-busy],
select[data-action-busy] {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}
.action-indicator {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--border);
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: 0 4px 18px #0002;
  pointer-events: none;
}
.action-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: action-spin 0.7s linear infinite;
}
.action-indicator[hidden] {
  display: none;
}
@keyframes action-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  button[data-action-busy]::after,
  .action-spinner {
    animation: none;
    border-right-color: currentColor;
  }
}
.action-indicator {
  max-width: calc(100vw - 24px);
}
#poPriceRows small {
  display: block;
  font-size: 11px;
  max-width: 240px;
  white-space: normal;
}

.theme-icon {
  display: none !important;
}
.theme-control {
  position: static;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  max-width: 100%;
}
.theme-options {
  flex-wrap: wrap;
}
.header-account {
  min-width: 0;
}
.actions {
  flex-wrap: wrap;
}
.form-grid > * {
  min-width: 0;
}
.section-head {
  flex-wrap: wrap;
}
.request-form .actions,
.editor-form .actions {
  gap: 10px;
}
input,
select,
textarea {
  max-width: 100%;
}
.supplier-preview-dialog {
  width: 94vw;
  max-width: 1200px;
}
.supplier-preview-dialog .scroll {
  max-height: 65dvh;
  overflow: auto;
}
.supplier-preview-dialog td {
  white-space: pre-wrap;
  min-width: 100px;
}
.supplier-preview-dialog thead th {
  position: sticky;
  top: 0;
  background: var(--paper);
}
