@media screen {
  :root {
    --button-shadow: 0 4px 9px #1e293b23, 0 1px 3px #1e293b18;
    --button-pressed-shadow: 0 1px 3px #1e293b23;
    --table-section-gap: 4px;
    --form-dialog-top: max(10px, env(safe-area-inset-top));
    --form-dialog-bottom: max(10px, env(safe-area-inset-bottom));
  }

  :is(#app, .centeroptic-sales, body > .header-choice-popover) :is(button, input:is([type=button],[type=submit],[type=reset]),
    a:is(.btn,.nav-item,.reference-menu-trigger), .reference-local > a):not(
      :disabled, [aria-disabled=true], .reference-navigation-overlay, th *,
      thead *, .centeroptic-calendar *, .data-record-link, .services-edit-row, .expense-photo-link) {
    box-shadow: var(--button-shadow);

    @media (hover: hover) and (prefers-reduced-motion: no-preference) {
      &:not(
        .reference-app .sidebar:has(.reference-primary) :is(.nav-item, .reference-menu-trigger, .reference-navigation-close, .reference-local a),
        .source-header-toolbar .header-change-access, .header-choice-popover button,
        .seller-entry-form button, .core-catalog-choice button) {
        transition: translate 150ms ease, box-shadow 150ms ease, background-color 150ms ease;

        &:hover:not(:active) {
          translate: 0 -2px;
          box-shadow: var(--choice-lift-shadow, var(--button-shadow));
        }
      }
    }
  }

  :is(#app, .centeroptic-sales, body > .header-choice-popover) :is(button, input:is([type=button],[type=submit],[type=reset]),
    a:is(.btn,.nav-item,.reference-menu-trigger), .reference-local > a):not(
      :disabled, [aria-disabled=true], .reference-navigation-overlay, th *,
      thead *, .centeroptic-calendar *, .data-record-link, .services-edit-row, .expense-photo-link):active {
    box-shadow: var(--button-pressed-shadow);
  }

  :is(#app, dialog, .centeroptic-sales)
    :is(button, a, [role="button"], [role="tab"], [role="option"]):is(.active, .selected, [aria-current]:not([aria-current="false"]), [aria-selected="true"], [aria-pressed="true"]) {
    font-weight: 400;
  }

  :is(#app, dialog, .centeroptic-sales)
    table:not([role="grid"], .centeroptic-calendar *, .task-calendar) :is(th, td, th button, th a, td button, td a, td strong, td b) {
    font-weight: 400;
  }

  .reference-app header > h1.section-menu-title {
    max-width: 100%;
    width: var(--reference-sidebar-width);
    margin: 0;
    box-shadow: var(--button-shadow);
  }

  :is(.reference-app, dialog, .centeroptic-sales)
    table:has(> thead):not([role=grid], .centeroptic-calendar *, .task-calendar, .expense-table-scroll *) {
    width: 100%;
    background: transparent;
    border-collapse: separate;
    border-spacing: 0;
    font: var(--ui-text, 14px) system-ui, sans-serif;

    & > :is(thead, tbody, tfoot) > tr > :is(th, td) {
      vertical-align: middle;
      padding: 9px 10px;
      border: 0;
      border-inline-end: 1px solid var(--line);
      border-block-end: 1px solid var(--line);
    }
    & > :is(thead, tbody, tfoot) > tr > :first-child {
      border-inline-start: 1px solid var(--line);
    }
    & > :is(thead, tbody, tfoot) > tr:first-child > :is(th, td) {
      border-block-start: 1px solid var(--line);
    }

    & > thead > tr > :is(th, td) {
      background: var(--choice-fill);
      color: var(--ink, var(--text));
      text-align: center;
      font-size: inherit;
      line-height: 1.35;
    }
    & > thead::after {
      content: "";
      display: table-row;
      height: var(--table-section-gap);
    }
    & > :is(thead, tbody, tfoot) > tr:first-child > :first-child {
      border-start-start-radius: var(--choice-radius);
    }
    & > :is(thead, tbody, tfoot) > tr:first-child > :last-child {
      border-start-end-radius: var(--choice-radius);
    }
    & > :is(thead, tbody, tfoot) > tr:last-child > :first-child {
      border-end-start-radius: var(--choice-radius);
    }
    & > :is(thead, tbody, tfoot) > tr:last-child > :last-child {
      border-end-end-radius: var(--choice-radius);
    }
    & > :is(tbody, tfoot) {
      background: #fff;
      clip-path: inset(0 round var(--choice-radius));
    }
    & > tbody:has(+ tfoot) {
      clip-path: inset(0 round var(--choice-radius) var(--choice-radius) 0 0);
    }
    & > tbody + tfoot {
      clip-path: inset(0 round 0 0 var(--choice-radius) var(--choice-radius));
    }
    & > :is(tbody, tfoot) > tr > :is(th, td) {
      overflow-wrap: anywhere;
    }
    & > tbody:has(+ tfoot) > tr:last-child > :is(th, td),
    & > tbody + tfoot > tr:first-child > :is(th, td) {
      border-radius: 0;
    }
    & > tbody + tfoot > tr:first-child > :is(th, td) {
      border-block-start: 0;
    }
    & > thead button {
      font: inherit;
      color: inherit;
      text-align: inherit;
      box-shadow: none;
      transform: none;
      translate: none;
    }
  }

  :is(.reference-app, dialog, .centeroptic-sales)
    :is(.scroll, .table-wrap, [class$="-scroll"], [class*="-scroll "], [class$="-table-wrap"], [class*="-table-wrap "]):not(.expense-table-scroll, .centeroptic-calendar *):has(> table:only-child:has(> thead):not([role=grid], .task-calendar)) {
    max-width: 100%;
    overflow: auto;
    background: transparent;
    border: 0;
    filter: drop-shadow(0 5px 8px #1e293b1b);
  }

  :is(#app, .centeroptic-sales) :is(th,thead) :is(button,a):is(:hover,:focus-visible,:active) {
    box-shadow: none;
    translate: none;
  }

  dialog:modal:is(#modal, :has(form:not([method=dialog]))) {
    border-radius: var(--choice-panel-radius,22px);
    box-shadow: var(--choice-glass-shadow), 0 20px 54px #1e293b38;
    overscroll-behavior: contain;
  }
  dialog:modal:has(form:not([method=dialog])) {
    max-block-size: calc(100dvh - var(--form-dialog-top) - var(--form-dialog-bottom));
    margin-block: var(--form-dialog-top) var(--form-dialog-bottom);
  }
  dialog.centeroptic-form-dialog {
    box-sizing: border-box;
    width: min(900px, calc(100% - 24px));
    max-height: calc(100dvh - var(--form-dialog-top) - var(--form-dialog-bottom));
    margin: var(--form-dialog-top) auto var(--form-dialog-bottom);
    padding: clamp(14px, 2vw, 22px);
    overflow-y: auto;
  }
  dialog:modal:is(.centeroptic-form-dialog, :has(form:not([method=dialog])))::backdrop {
    background: #1e293b35;
  }
  button.btn.dialog-back { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: var(--ui-text, 14px); }
  button.btn.dialog-back svg { flex-shrink: 0; }
  dialog:modal:is(.centeroptic-form-dialog, :has(form:not([method=dialog])))
    :is(input:not([type=checkbox],[type=radio],[type=hidden]), textarea, select):not(.centeroptic-calendar *) {
    border-radius: var(--choice-radius);
  }
}

@media (forced-colors: active) {
  :root {
    --button-shadow: none;
    --button-pressed-shadow: none;
  }
}

.data-table .staff-column-search {
  grid-column: 3;
  grid-row: 1;
  width: 24px;
  height: 24px;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
}
.data-table .staff-column-search:is(:hover,[aria-pressed="true"],[aria-expanded="true"]) {
  color: var(--primary);
  background: var(--choice-selected);
}
.staff-filter-field:not([hidden])) > .staff-column-search {
  top: 9px;
  margin-top: 0;
}
.staff-filter-field:not([hidden]) {
  display: grid;
  gap: 4px;
  justify-items: stretch;
  max-inline-size: 13rem;
  margin: 4px auto 0;
}
.staff-filter-input {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--choice-radius);
  background: var(--surface, #fff);
}
.staff-filter-field input[type="search"] {
  flex: 1;
  min-inline-size: 0;
  width: 100%;
  height: 28px;
  padding: 4px 0 4px 10px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  font: inherit;
}
.staff-filter-field input::-webkit-search-cancel-button { appearance: none; }
.staff-filter-field [data-clear-staff-filter] {
  flex: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}
.staff-filter-field [data-clear-staff-filter]:hover { background: var(--choice-selected); }
:is(.legal-sort,.licenses-sort,.users-sort-controls) {
  display: grid;
  grid-template-columns: 24px minmax(min-content,auto) 24px;
  justify-content: center;
  align-items: center;
  gap: 4px;
}
:is(.legal-sort,.licenses-sort,.users-sort-controls) > span { grid-column: 1; grid-row: 1; justify-self: center; }
:is(.legal-sort,.licenses-sort,.users-sort-controls) > button { grid-column: 2; grid-row: 1; text-align: center; }
.data-table tbody > tr[data-table-row-id] { cursor: pointer; }
.data-table tbody > tr[data-table-row-id]:is(:hover,:focus-visible) > td,
.expense-control .expense-row:not([aria-disabled=true]):is(:hover,:focus-visible) > td { background: var(--choice-selected); }
.legal-entities-workspace .legal-search[hidden] { display: none; }

.reference-app .btn.directory-archive[aria-pressed="true"] { background: var(--choice-selected); }

.staff-filter-field [data-empty-staff-filter] {
  justify-self: start;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: var(--choice-radius);
  background: var(--surface, #fff);
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.staff-filter-field [data-empty-staff-filter]:is(:hover,[aria-pressed="true"]) { background: var(--choice-selected); }

.btn[data-directory-archive-back][hidden] { display: none; }

/* Keep an editing field's perimeter unchanged across local workspace styles.
   The caret marks text focus, while buttons and non-editable controls retain
   their keyboard focus styles. */
@media screen {
  :where(textarea, input:not([type]), input:is([type="text"], [type="search"], [type="email"],
    [type="password"], [type="tel"], [type="url"], [type="number"], [type="date"],
    [type="datetime-local"], [type="month"], [type="week"], [type="time"])):not([readonly]):focus {
    outline: none !important;
    caret-color: currentColor;
  }
}
