/* Desktop operations share the office's local Manrope and light surfaces. */
#desktopAdmin {
  --desk-ink: #25334b;
  --desk-text: #3e4c63;
  --desk-muted: #56657a;
  --desk-line: #dce2ed;
  --desk-rule: #e7ebf2;
  --desk-paper: #fff;
  --desk-tint: #f5f6fb;
  --desk-accent: #5146aa;
  --desk-accent-soft: #eeedfb;
  color: var(--desk-ink);
  font: inherit;
  min-width: 0;
  container-type: inline-size;
}

#desktopAdmin :is(.desktop-heading, .desktop-section-heading, .desktop-report, .desktop-metric, [data-desktop-content]) {
  min-width: 0;
}

#desktopAdmin :is(.desktop-heading h2, .desktop-section-heading h3, [data-desktop-content] > h3, .desktop-report h4, .desktop-preview h3) {
  color: var(--desk-ink);
  margin: 0;
  font-weight: 760;
  line-height: 1.28;
  text-wrap: balance;
}

#desktopAdmin .desktop-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px 20px;
  margin: 20px 0 16px;
}

#desktopAdmin .desktop-heading h2 {
  font-size: clamp(20px, 2.2vw, 26px);
  letter-spacing: -.035em;
}

#desktopAdmin :is(.desktop-heading, .desktop-section-heading, .desktop-report) p,
#desktopAdmin .tiny {
  max-width: 80ch;
  margin: 5px 0 0;
  color: var(--desk-muted);
  font-size: 13px;
  line-height: 1.55;
}

#desktopAdmin [data-desktop-tabs] {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 5px;
  background: #eaeef5;
  border: 1px solid var(--desk-line);
  border-radius: 13px;
}

#desktopAdmin [data-desktop-tabs] button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 7px 13px;
  margin: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--desk-text);
  font: inherit;
  font-size: 13px;
  font-weight: 670;
  line-height: 1.35;
  white-space: nowrap;
  box-shadow: none;
}

#desktopAdmin [data-desktop-tabs] button:hover {
  background: #f7f8fc;
}

#desktopAdmin [data-desktop-tabs] button[aria-pressed="true"] {
  background: var(--desk-paper);
  color: var(--desk-accent);
  border-color: #c9cce3;
  box-shadow: 0 1px 3px #293e6815;
}

#desktopAdmin .desktop-toolbar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 16px 0 20px;
}

#desktopAdmin .desktop-toolbar:not(:has(> :not([hidden]))) {
  display: none;
}

#desktopAdmin [data-desktop-errors-wrap] {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  margin: 0;
  color: var(--desk-text);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

#desktopAdmin [data-desktop-filter] {
  display: flex;
  align-items: end;
  flex: 1 1 320px;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

#desktopAdmin [data-desktop-filter] label {
  flex: 1 1 140px;
  max-width: 420px;
}

#desktopAdmin [data-desktop-refresh] {
  margin-inline-start: auto;
}

#desktopAdmin :is(.desktop-editor label, [data-desktop-filter] label) {
  display: grid;
  gap: 6px;
  min-width: 0;
  margin: 0;
  color: var(--desk-text);
  font-size: 13px;
  line-height: 1.5;
  font-weight: 650;
}

#desktopAdmin :is(input:not([type="checkbox"]), textarea, select) {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid #b5c0d0;
  border-radius: 9px;
  background: var(--desk-paper);
  color: var(--desk-ink);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
}

#desktopAdmin :is(input, textarea)::placeholder {
  color: #647287;
}

#desktopAdmin textarea {
  resize: vertical;
}

#desktopAdmin textarea[name="envelope"] {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

#desktopAdmin .button:not([data-tab]) {
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 680;
  line-height: 1.4;
}

#desktopAdmin .secondary:not([data-tab]) {
  background: var(--desk-paper);
  border-color: #c5ceda;
  color: var(--desk-text);
}

#desktopAdmin .secondary:not([data-tab]):hover:enabled {
  background: var(--desk-tint);
  border-color: #99a6ba;
}

#desktopAdmin .primary {
  background: var(--desk-accent);
  color: white;
  box-shadow: none;
}

#desktopAdmin .primary:hover:enabled {
  background: #443995;
}

#desktopAdmin button:disabled {
  cursor: default;
  opacity: .53;
}

#desktopAdmin .desktop-section-heading,
#desktopAdmin [data-desktop-content] > h3 {
  margin: 20px 0 12px;
}

#desktopAdmin :is(.desktop-section-heading h3, [data-desktop-content] > h3, .desktop-preview h3) {
  font-size: 20px;
  letter-spacing: -.028em;
}

#desktopAdmin [data-desktop-content] > .tiny {
  margin: 0 0 12px;
}

#desktopAdmin [data-desktop-message] {
  margin: 0 0 15px;
  padding: 12px 15px;
  border: 1px solid #d5d9ec;
  border-inline-start: 3px solid #847cbf;
  border-radius: 9px;
  background: #f5f4fc;
  color: #47446a;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

#desktopAdmin [data-desktop-message][data-tone="bad"] {
  border-color: #e8cace;
  border-inline-start-color: #aa4350;
  background: #fff3f4;
  color: #91303d;
}

#desktopAdmin [data-desktop-message][data-tone="good"] {
  border-color: #c6e2d9;
  border-inline-start-color: #298063;
  background: #eff8f4;
  color: #126448;
}

#desktopAdmin .desktop-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(158px, 100%), 1fr));
  gap: 10px;
  margin: 0 0 20px;
}

#desktopAdmin .desktop-metric {
  display: flex;
  flex-direction: column;
  align-items: start;
  gap: 6px;
  padding: 15px 17px;
  border: 1px solid var(--desk-line);
  border-radius: 13px;
  background: var(--desk-paper);
}

#desktopAdmin .desktop-metric > small {
  color: var(--desk-muted);
  font-size: 12px;
  line-height: 1.45;
}

#desktopAdmin .desktop-metric > small:first-child {
  font-weight: 650;
}

#desktopAdmin .desktop-metric > strong {
  color: var(--desk-ink);
  font-size: clamp(23px, 2vw, 32px);
  font-weight: 760;
  letter-spacing: -.045em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

#desktopAdmin .desktop-metrics:has(> :nth-child(3)) > .desktop-metric:first-child {
  background: #f0effb;
  border-color: #d6d3ee;
}

#desktopAdmin .desktop-metrics:has(> :nth-child(3)) > .desktop-metric:first-child > strong {
  color: var(--desk-accent);
}

#desktopAdmin .desktop-reports {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

#desktopAdmin .desktop-report {
  padding: 16px;
  border: 1px solid var(--desk-line);
  border-radius: 15px;
  background: var(--desk-paper);
}

#desktopAdmin .desktop-report h4 {
  font-size: 16px;
  letter-spacing: -.02em;
}

#desktopAdmin .desktop-report .table-wrap {
  margin-top: 12px;
}

#desktopAdmin .desktop-report th:first-child {
  min-width: 115px;
}

#desktopAdmin .desktop-report :is(th, td):last-child:not([colspan]),
#desktopAdmin .desktop-report:has(th:nth-child(6)) :is(th, td):not(:first-child) {
  text-align: end;
}

#desktopAdmin .desktop-report:has(th:nth-child(6)) td:not(:first-child) {
  white-space: nowrap;
}

#desktopAdmin .table-wrap {
  max-width: 100%;
  margin: 0;
  overflow: auto;
  overscroll-behavior-x: contain;
  border: 1px solid var(--desk-line);
  border-radius: 12px;
  background: var(--desk-paper);
  scrollbar-color: #a4afc2 transparent;
}

#desktopAdmin table {
  width: 100%;
  min-width: 0;
  border-collapse: separate;
  border-spacing: 0;
  text-align: start;
  font-variant-numeric: tabular-nums;
}

#desktopAdmin th,
#desktopAdmin td {
  min-width: 0;
  max-width: 340px;
  padding: 11px 13px;
  vertical-align: middle;
  border: 0;
  border-bottom: 1px solid var(--desk-rule);
  text-align: start;
  line-height: 1.45;
}

#desktopAdmin th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f4f6fa;
  color: var(--desk-muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

#desktopAdmin td {
  color: var(--desk-text);
  font-size: 13px;
  overflow-wrap: anywhere;
}

#desktopAdmin tbody tr:last-child > td {
  border-bottom: 0;
}

#desktopAdmin tbody tr:focus-within,
#desktopAdmin tbody tr:hover {
  background: #f8f9fd;
}

#desktopAdmin td[colspan] {
  padding: 23px 15px;
  text-align: center;
  color: var(--desk-muted);
}

#desktopAdmin .desktop-reference {
  color: var(--desk-muted);
  font-size: 12px;
}

#desktopAdmin .desktop-reference summary {
  width: fit-content;
  cursor: pointer;
  color: var(--desk-accent);
  font-weight: 650;
}

#desktopAdmin .desktop-reference code {
  display: block;
  margin-top: 5px;
  padding: 4px 7px;
  border-radius: 5px;
  background: var(--desk-tint);
  color: var(--desk-text);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
}

#desktopAdmin .desktop-fact {
  display: grid;
  gap: 3px;
}

#desktopAdmin :is(.desktop-fact strong, td strong) {
  color: var(--desk-ink);
  font-size: 13px;
  font-weight: 660;
}

#desktopAdmin :is(.desktop-fact small, td small) {
  color: var(--desk-muted);
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
}

#desktopAdmin .desktop-status {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 6px;
  background: #edf0f5;
  color: #475569;
  font-size: 12px;
  font-weight: 680;
  line-height: 1.4;
}

#desktopAdmin .desktop-status::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  align-self: center;
  border-radius: 50%;
  background: currentColor;
}

#desktopAdmin .desktop-status[data-tone="good"] { color: #13644b; background: #e8f5ee; }
#desktopAdmin .desktop-status[data-tone="warn"] { color: #825112; background: #fff3d9; }
#desktopAdmin .desktop-status[data-tone="bad"] { color: #9c3442; background: #fcebef; }

#desktopAdmin .desktop-user-link {
  display: inline-block;
  max-width: 100%;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--desk-accent);
  text-align: start;
  font: inherit;
  font-weight: 680;
  overflow-wrap: anywhere;
  text-decoration: underline;
  text-decoration-color: #b7b3d8;
  text-underline-offset: 3px;
}

#desktopAdmin .desktop-user-link:hover {
  text-decoration-color: currentColor;
}

#desktopAdmin .desktop-customer {
  margin: 0 0 12px;
  color: var(--desk-ink);
  overflow-wrap: anywhere;
}

#desktopAdmin :is(.desktop-customer, [data-desktop-content]) > .desktop-actions h3,
#desktopAdmin .desktop-customer > h3 {
  margin: 0;
  color: var(--desk-ink);
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: -.025em;
}

#desktopAdmin .desktop-customer > .desktop-actions {
  justify-content: space-between;
}

#desktopAdmin .desktop-customer > .tiny {
  margin: 4px 0 14px;
}

#desktopAdmin .desktop-customer > h3 {
  margin: 17px 0 10px;
}

#desktopAdmin .desktop-actions,
#desktopAdmin .desktop-pager {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#desktopAdmin .desktop-metric .desktop-actions {
  margin-top: 6px;
}

#desktopAdmin .desktop-pager {
  justify-content: end;
  gap: 12px;
  margin-top: 12px;
  color: var(--desk-muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

#desktopAdmin .desktop-pager:empty {
  display: none;
}

#desktopAdmin .desktop-editor,
#desktopAdmin .desktop-preview {
  margin: 0 0 15px;
  padding: 15px 18px;
  border: 1px solid var(--desk-line);
  border-radius: 13px;
  background: var(--desk-paper);
}

#desktopAdmin .desktop-editor summary {
  color: var(--desk-accent);
  font-size: 14px;
  font-weight: 720;
  cursor: pointer;
}

#desktopAdmin .desktop-editor form {
  display: grid;
  gap: 14px;
  max-width: 660px;
  margin-top: 16px;
}

#desktopAdmin .desktop-editor form > .button {
  justify-self: start;
}

#desktopAdmin .desktop-actions label,
#desktopAdmin .desktop-editor .desktop-confirm {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin: 0;
  font-size: 13px;
  font-weight: 580;
}

#desktopAdmin input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  padding: 0;
  margin: 0;
  accent-color: var(--desk-accent);
}

#desktopAdmin .desktop-preview {
  border-color: #cecae8;
  border-inline-start: 3px solid #8075bf;
}

#desktopAdmin .desktop-preview h4 {
  margin: 15px 0 4px;
  font-size: 15px;
}

#desktopAdmin .desktop-preview p {
  margin: 5px 0 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#desktopAdmin :is(button, a, summary, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid #5248ae;
  outline-offset: 2px;
}

#desktopAdmin [data-desktop-tabs] button:focus-visible {
  outline-offset: -2px;
}

@container (min-width: 1060px) {
  #desktopAdmin .desktop-reports {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #desktopAdmin .desktop-report:has(th:nth-child(5)),
  #desktopAdmin .desktop-report:only-child {
    grid-column: 1 / -1;
  }
}

@container (max-width: 830px) {
  #desktopAdmin [data-desktop-tabs] {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    scrollbar-color: #a4afc2 transparent;
  }

  #desktopAdmin [data-desktop-tabs] button {
    flex: none;
    min-height: 42px;
  }
}

@container (max-width: 680px) {
  #desktopAdmin .desktop-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  #desktopAdmin .desktop-metric {
    padding: 12px;
  }

  #desktopAdmin .desktop-metric:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  #desktopAdmin .desktop-metric:last-child:nth-child(odd) > strong {
    margin: 0;
  }

  #desktopAdmin .desktop-section-heading h3 {
    font-size: 18px;
  }

  #desktopAdmin .desktop-report {
    padding: 13px;
  }
}

/* Older office markup has no cell labels. Keep native, horizontally
   scrollable tables there, and in reports intended for comparison. */
@media (max-width: 600px) {
  #desktopAdmin .table-wrap:not(:has(td[data-label])),
  #desktopAdmin .desktop-report .table-wrap {
    max-height: 65vh;
    overflow: auto;
    border: 1px solid var(--desk-line);
    border-radius: 10px;
  }

  #desktopAdmin :is(.table-wrap:not(:has(td[data-label])), .desktop-report .table-wrap) table { display: table; }
  #desktopAdmin :is(.table-wrap:not(:has(td[data-label])), .desktop-report .table-wrap) thead {
    position: static;
    display: table-header-group;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
  }
  #desktopAdmin :is(.table-wrap:not(:has(td[data-label])), .desktop-report .table-wrap) tbody { display: table-row-group; }
  #desktopAdmin :is(.table-wrap:not(:has(td[data-label])), .desktop-report .table-wrap) tr {
    display: table-row;
    background: transparent;
  }
  #desktopAdmin :is(.table-wrap:not(:has(td[data-label])), .desktop-report .table-wrap) td {
    display: table-cell;
    padding: 10px !important;
    border-bottom: 1px solid var(--desk-rule) !important;
  }
  #desktopAdmin :is(.table-wrap:not(:has(td[data-label])), .desktop-report .table-wrap) td::before { display: none; }

  #desktopAdmin .table-wrap:has(td[data-label]):not(.desktop-report .table-wrap) {
    background: transparent;
    border: 0;
  }
  #desktopAdmin .table-wrap:has(td[data-label]):not(.desktop-report .table-wrap) tbody tr {
    border-color: var(--desk-line);
    background: var(--desk-paper);
  }
  #desktopAdmin .table-wrap td[data-label]::before {
    margin-bottom: 3px;
    color: var(--desk-muted);
    font-size: 11px;
    font-weight: 650;
  }

  #desktopAdmin .desktop-toolbar { gap: 8px; }
  #desktopAdmin :is(input:not([type="checkbox"]), textarea, select) { font-size: 16px; }
  #desktopAdmin .button:not([data-tab]) { min-height: 42px; }
  #desktopAdmin .desktop-pager { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  #view-desktop, #desktopAdmin * { animation: none; transition: none; scroll-behavior: auto; }
}
