/* Shared usability layer. Layout only: templates and scripts continue to own
   access, document states, submission and location selection. Screen rules
   leave the established print documents untouched. */
@media screen {
  body#workspace {
    --t0: 12px;
    --t1: 13px;
    --t2: 14px;
    --t3: 15px;
  }

  #workspace .page { padding-top: 24px; }
  #workspace .title,
  #workspace .screen-title {
    margin: 0 0 8px;
    font-size: 28px;
    line-height: 1.25;
    font-weight: 600;
    letter-spacing: -.025em;
  }
  #workspace .subtitle {
    margin-bottom: 20px;
    color: var(--text2);
    font-size: 14px;
    line-height: 1.55;
  }
  #workspace .page > .section {
    margin-top: 0;
    margin-bottom: 20px;
    padding: 20px;
    border-radius: 12px;
  }
  #workspace .section__name {
    margin-bottom: 14px;
    font-size: 18px;
    line-height: 1.35;
  }
  #workspace .field__name {
    margin-bottom: 6px;
    font-size: 14px;
    line-height: 1.35;
  }
  #workspace .field__hint { font-size: 13px; line-height: 1.5; }
  #workspace .field__input {
    min-width: 0;
    min-height: 40px;
    padding-block: 8px;
    font-size: 14px;
    line-height: 1.4;
  }
  #workspace .button { min-height: 40px; font-size: 14px; line-height: 1.35; }
  #workspace .button--primary { font-weight: 600; }
  #workspace .registry th,
  #workspace .registry td {
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.45;
  }
  #workspace .registry th { font-size: 13px; }
  #workspace .registry td .button { min-height: 36px; }
  #workspace .registry td .field__input { min-height: 36px; padding-block: 6px; }
  #workspace .registry td .field__hint { margin-top: 6px; }
  #workspace .registry .number { font-variant-numeric: tabular-nums; }

  /* Help stays a visible link, with a smaller footprint above daily work. */
  #workspace .docs-screen-link {
    justify-content: flex-end;
    gap: 4px 14px;
    margin: 0 0 14px;
    padding: 0;
    min-height: 30px;
    background: transparent;
    border: 0;
    border-radius: 0;
  }
  #workspace .docs-screen-link > span { font-size: 13px; }
  #workspace .docs-screen-link > div { gap: 4px 14px; }
  #workspace .docs-screen-link a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 30px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
  }

  /* Existing GET selectors become one wrapping row. Reference catalogs have
     their own .reference-filters layout, and POST workflows are untouched. */
  #workspace form[method="get"]:not(.reference-filters):has(> label.field) {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 18px;
  }
  #workspace form[method="get"]:not(.reference-filters) > label.field {
    flex: 1 1 240px;
    min-width: 0;
    margin-bottom: 0;
  }
  #workspace form[method="get"]:not(.reference-filters) > label.field:has(input[type="search"]) {
    flex-grow: 2;
  }
  #workspace form[method="get"]:not(.reference-filters):has(> label.field) > .button {
    flex: 0 0 auto;
    align-self: flex-end;
  }
  #workspace form[method="get"]:not(.reference-filters):has(> label.field) > p:has(> button) {
    margin: 0;
    align-self: flex-end;
  }
  #workspace .toolbar { gap: 10px 12px; margin-bottom: 16px; }
  #workspace .toolbar .section__name { margin-bottom: 0; }
  #workspace .toolbar__search { flex: 1 1 260px; max-width: 420px; }
  #workspace .toolbar > select.field__input { flex: 0 1 220px; width: auto; }
  #workspace .pills { gap: 6px; }
  #workspace .pill { min-height: 36px; font-size: 13px; }
  #workspace .screen-actions { display: flex; flex-wrap: wrap; gap: 10px; }

  /* Restore the names already rendered by the permission-filtered menu.
     Object links remain in their existing header tabs; no route is duplicated. */
  @media (min-width: 1100px) {
    #workspace.has-rail { --menu-width: 224px; }
    #workspace.has-rail .menu {
      align-items: stretch;
      padding: 14px 12px;
      overflow: auto;
      scrollbar-width: thin;
    }
    #workspace.has-rail .menu__top {
      justify-content: flex-start;
      margin-bottom: 18px;
    }
    #workspace.has-rail .menu__brand {
      justify-content: flex-start;
      gap: 10px;
      width: 100%;
      min-width: 0;
      height: auto;
      min-height: 44px;
      padding: 6px 8px;
      background: transparent;
      color: var(--workspace-header-text);
    }
    #workspace.has-rail .menu__glyph {
      width: 20px;
      height: 20px;
      background: var(--workspace-header-text);
    }
    #workspace.has-rail .menu__section:not(.tree) {
      width: 100%;
      margin-top: 0;
      margin-bottom: 18px;
    }
    #workspace.has-rail .menu__group {
      position: static;
      width: auto;
      height: auto;
      margin: 0 0 6px;
      padding: 0 10px;
      overflow: visible;
      clip-path: none;
      white-space: normal;
      color: var(--workspace-header-muted);
      font-size: 12px;
      line-height: 1.5;
      letter-spacing: .03em;
    }
    #workspace.has-rail .menu__item {
      justify-content: flex-start;
      gap: 10px;
      width: 100%;
      min-width: 0;
      height: auto;
      min-height: 44px;
      margin-bottom: 4px;
      padding: 9px 10px;
    }
    #workspace.has-rail .menu__body {
      position: static;
      inset: auto;
      transform: none;
      flex: 1 1 auto;
      min-width: 0;
      width: auto;
      max-width: none;
      padding: 0;
      background: transparent;
      color: inherit;
      box-shadow: none;
      font-size: 14px;
      font-weight: 500;
      line-height: 1.35;
      white-space: normal;
      pointer-events: auto;
      opacity: 1;
      visibility: visible;
      transition: none;
    }
    #workspace.has-rail .menu__brand .menu__body { font-size: 16px; font-weight: 600; }
    #workspace.has-rail .menu__body .menu__name { color: inherit; font-size: 14px; }
    #workspace.has-rail .menu__item[aria-current="page"] .menu__name {
      color: var(--workspace-header-text);
      font-weight: 600;
    }
    #workspace.has-rail .menu__item[aria-current="page"]::before {
      left: -6px;
      top: 8px;
      bottom: 8px;
    }
    #workspace.has-rail .menu__count {
      position: static;
      align-self: center;
      min-width: 22px;
      height: 22px;
      padding: 0 6px;
      border: 0;
      font-size: 12px;
    }
    #workspace.has-rail .menu__count[data-error="0"] {
      background: var(--workspace-header-hover);
      color: var(--workspace-header-text);
    }
    #workspace.has-rail .menu__bottom {
      width: 100%;
      margin-top: auto;
      padding: 14px 10px 0;
      text-align: left;
      color: var(--workspace-header-muted);
      border-top-color: var(--workspace-header-hover);
    }
    #workspace.has-rail .menu__bottom-name { display: block; font-size: 13px; }
    #workspace.has-rail .menu__bottom-glyph { display: none; }
    #workspace .object-header__row { min-height: 60px; gap: 16px; padding-inline: 24px; }
    #workspace .object-header__who { flex-basis: 240px; }
    #workspace .object-header__row .tab { padding-inline: 12px; font-size: 14px; }
    #workspace .tabs--second { padding: 6px 24px; }
    #workspace .page:not(.page--narrow) { padding-inline: 24px; }
  }

  @media (max-width: 1099.98px) {
    #workspace .menu__top { gap: 8px; }
    #workspace .menu__brand { flex: 1 1 auto; min-width: 0; font-size: 15px; color: var(--workspace-header-text); }
    #workspace .menu__brand .menu__body { min-width: 0; white-space: normal; }
    #workspace .menu__close { flex: 0 0 40px; width: 40px; min-width: 40px; height: 44px; color: var(--workspace-header-text); }
    #workspace .menu__group, #workspace .menu__bottom { color: var(--workspace-header-muted); }
    #workspace .menu__name { font-size: 15px; }
    #workspace .menu__item { min-height: 44px; }
    #workspace .menu__group { font-size: 12px; }
  }
  @media (max-width: 599px) {
    #workspace .page { padding-top: 18px; }
    #workspace .page > .section { padding: 16px; }
    #workspace .title,
    #workspace .screen-title { font-size: 25px; }
    #workspace .docs-screen-link { justify-content: flex-start; margin-bottom: 12px; }
    #workspace .docs-screen-link a { min-height: 36px; }
    #workspace form[method="get"]:not(.reference-filters) > label.field { flex-basis: 100%; }
    #workspace .toolbar__search { flex-basis: 100%; max-width: none; margin-left: 0; }
    #workspace .toolbar > select.field__input { flex: 1 1 180px; }
    #workspace .field__input { font-size: 16px; }
  }
  @media (any-pointer: coarse) {
    #workspace .button,
    #workspace .pill,
    #workspace .field__input,
    #workspace .registry td .button,
    #workspace .registry td .field__input { min-height: 44px; }
  }
}

/* Requisites lists (work type and material cards) read as a two-column table:
   label on the left, value on the right, one row per field. */
#workspace dl.material-card { display: grid; grid-template-columns: minmax(150px, 240px) 1fr; margin: 0 0 16px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
#workspace dl.material-card > dt, #workspace dl.material-card > dd { margin: 0; padding: 10px 14px; border-bottom: 1px solid var(--line); }
#workspace dl.material-card > dt { background: var(--surface2); color: var(--text2); font-weight: 600; }
#workspace dl.material-card > dd { color: var(--text); overflow-wrap: anywhere; }
#workspace dl.material-card > dt:last-of-type, #workspace dl.material-card > dd:last-of-type { border-bottom: 0; }
@media (max-width: 600px) {
  #workspace dl.material-card { grid-template-columns: 1fr; }
  #workspace dl.material-card > dt { border-bottom: 0; padding-bottom: 2px; }
}
