/*
 * Document ABD follows EVA's solid operational workbench.
 * Mint identifies scope and editable state; solid emerald marks the next action.
 * One-level surfaces keep search, selected target, files, and metadata easy to scan.
 */
body > .app-shell #documentAbdPanel {
  margin-top: 16px !important;
  padding: 0 !important;
  overflow: hidden;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important;
  background: var(--bg-panel) !important;
  box-shadow: var(--shadow-sm) !important;
}

body > .app-shell #documentAbdPanel .hidden {
  display: none !important;
}

body > .app-shell .document-abd-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

body > .app-shell .document-abd-header h3,
body > .app-shell .document-abd-section-heading h4,
.document-abd-dialog__header h3 {
  margin: 0 !important;
  color: var(--text-primary, #14231c) !important;
  font-weight: 700 !important;
  letter-spacing: -0.018em !important;
  text-transform: none !important;
}

body > .app-shell .document-abd-header h3 {
  margin-top: 2px !important;
  font-size: 1.05rem !important;
  line-height: 1.3 !important;
}

body > .app-shell .document-abd-header p,
body > .app-shell .document-abd-section-heading p,
.document-abd-dialog__header p {
  margin: 3px 0 0;
  color: var(--text-muted, #61756b) !important;
  font-size: 0.75rem;
  line-height: 1.5;
}

body > .app-shell .document-abd-eyebrow,
.document-abd-dialog .document-abd-eyebrow {
  display: block;
  color: var(--brand-strong, #176d4e) !important;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.075em;
  line-height: 1.2;
  text-transform: uppercase;
}

body > .app-shell .document-abd-header__hint {
  flex: 0 0 auto;
  padding-top: 2px;
  color: var(--text-muted, #61756b);
  font-size: 0.72rem;
  line-height: 1.4;
}

body > .app-shell .document-abd-search {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  padding: 14px 16px 10px;
  background: var(--bg-panel-2, #f7faf8);
}

body > .app-shell .document-abd-search label {
  display: grid;
  min-width: 0;
  gap: 5px;
}

body > .app-shell .document-abd-search label > span,
body > .app-shell .document-abd-field > span {
  color: var(--text-secondary, #33473e);
  font-size: 0.71rem;
  font-weight: 650;
  line-height: 1.35;
}

body > .app-shell .document-abd-control,
body > .app-shell #documentAbdPanel .document-abd-control {
  width: 100%;
  min-width: 0;
  min-height: 44px !important;
  padding: 9px 11px !important;
  border: 1px solid var(--border-strong, #b9cec4) !important;
  border-radius: var(--r-md, 8px) !important;
  background: var(--bg-input, #fff) !important;
  color: var(--text-primary, #14231c) !important;
  font-size: 0.82rem !important;
  line-height: 1.35;
  box-shadow: none !important;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

body > .app-shell #documentAbdPanel .document-abd-control::placeholder {
  color: var(--text-muted, #61756b) !important;
  opacity: 1;
}

body > .app-shell #documentAbdPanel .document-abd-control:focus-visible,
body > .app-shell #documentAbdPanel .document-abd-button:focus-visible,
.document-abd-dialog :is(button, a):focus-visible {
  outline: 2px solid var(--brand, #23966c) !important;
  outline-offset: 2px !important;
  box-shadow: none !important;
}

body > .app-shell .document-abd-button,
.document-abd-dialog .document-abd-button {
  display: inline-flex;
  min-height: 44px !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 13px !important;
  border-radius: var(--r-md, 8px) !important;
  font-size: 0.78rem !important;
  font-weight: 650 !important;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
  box-shadow: none !important;
  transform: none !important;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
}

body > .app-shell .document-abd-button--primary,
.document-abd-dialog .document-abd-button--primary {
  border: 1px solid var(--brand-strong, #176d4e) !important;
  background: var(--brand-strong, #176d4e) !important;
  color: #fff !important;
}

body > .app-shell .document-abd-button--primary:hover:not(:disabled),
.document-abd-dialog .document-abd-button--primary:hover:not(:disabled) {
  border-color: var(--brand-strong, #176d4e) !important;
  background: var(--brand-strong, #176d4e) !important;
  color: #fff !important;
}

body > .app-shell .document-abd-button--secondary,
.document-abd-dialog .document-abd-button--secondary {
  border: 1px solid var(--border-strong, #b9cec4) !important;
  background: #fff !important;
  color: var(--text-secondary, #33473e) !important;
}

body > .app-shell .document-abd-button--secondary:hover:not(:disabled),
.document-abd-dialog .document-abd-button--secondary:hover:not(:disabled) {
  border-color: #8eaa9d !important;
  background: var(--brand-soft-2, #f0f8f4) !important;
  color: var(--text-primary, #14231c) !important;
}

body > .app-shell #documentAbdPanel .document-abd-button:disabled,
.document-abd-dialog .document-abd-button:disabled {
  border-color: var(--border, #d9e5df) !important;
  background: #edf2ef !important;
  color: #788981 !important;
  cursor: not-allowed;
}

body > .app-shell .document-abd-search__results {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 10px;
  padding: 0 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel-2, #f7faf8);
}

body > .app-shell #documentAbdSearchResult {
  flex: 0 0 auto;
  color: var(--text-muted, #61756b);
  font-size: 0.72rem;
  line-height: 1.4;
}

body > .app-shell #documentAbdSearchResult[data-state="ready"] {
  color: var(--brand-strong, #176d4e);
  font-weight: 650;
}

body > .app-shell #documentAbdSearchSelect {
  flex: 1 1 auto;
}

body > .app-shell .document-abd-feedback {
  margin: 12px 16px 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md, 8px);
  background: var(--neutral-soft, #f3f6f4);
  color: var(--text-secondary, #33473e);
  font-size: 0.75rem;
  line-height: 1.5;
}

body > .app-shell .document-abd-feedback[data-tone="success"] {
  border-color: #9bcdb8;
  background: #ecf8f2;
  color: #145b43;
}

body > .app-shell .document-abd-feedback[data-tone="warning"] {
  border-color: #dfc591;
  background: #fbf5e9;
  color: #7a521c;
}

body > .app-shell .document-abd-feedback[data-tone="error"] {
  border-color: #e1aeae;
  background: #fceeee;
  color: #9f3030;
}

body > .app-shell .document-abd-feedback[data-tone="info"] {
  border-color: #afcadf;
  background: #edf5fb;
  color: #315f87;
}

body > .app-shell .document-abd-workspace {
  padding: 14px 16px 16px;
}

body > .app-shell .document-abd-target {
  padding: 12px 14px;
  border: 1px solid #bdd9cd !important;
  border-radius: var(--r-md, 8px) !important;
  background: var(--brand-soft-2, #f0f8f4) !important;
  box-shadow: none !important;
}

body > .app-shell .document-abd-target__heading {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 8px;
}

body > .app-shell .document-abd-target__scope {
  flex: 0 0 auto;
  padding: 3px 6px;
  border: 1px solid #a9cebd;
  border-radius: var(--r-sm, 6px);
  background: #fff;
  color: var(--brand-strong, #176d4e);
  font-size: 0.66rem;
  font-weight: 700;
}

body > .app-shell .document-abd-target__heading strong {
  flex: 0 0 auto;
  color: var(--text-primary, #14231c);
  font-size: 0.93rem;
  line-height: 1.35;
}

body > .app-shell .document-abd-target__name {
  min-width: 0;
  overflow: hidden;
  color: var(--text-secondary, #33473e);
  font-size: 0.82rem;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body > .app-shell .document-abd-target__meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 14px;
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid #cee2d9;
}

body > .app-shell .document-abd-target__meta div {
  min-width: 0;
}

body > .app-shell .document-abd-target__meta dt {
  color: var(--text-muted, #61756b);
  font-size: 0.64rem;
  font-weight: 650;
  line-height: 1.3;
}

body > .app-shell .document-abd-target__meta dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  color: var(--text-secondary, #33473e);
  font-size: 0.73rem;
  line-height: 1.45;
}

body > .app-shell .document-abd-workspace__grid {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

body > .app-shell :is(.document-abd-files, .document-abd-metadata) {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-md, 8px) !important;
  background: #fff !important;
  box-shadow: none !important;
}

body > .app-shell .document-abd-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

body > .app-shell .document-abd-section-heading h4 {
  margin-top: 2px !important;
  font-size: 0.9rem !important;
  line-height: 1.35 !important;
}

body > .app-shell .document-abd-file-action {
  display: grid;
  grid-template-columns: minmax(130px, 0.45fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

body > .app-shell .document-abd-file-action__copy {
  display: grid;
  gap: 2px;
}

body > .app-shell .document-abd-file-action__copy strong {
  color: var(--text-primary, #14231c);
  font-size: 0.78rem;
}

body > .app-shell .document-abd-file-action__copy span {
  color: var(--text-muted, #61756b);
  font-size: 0.68rem;
}

body > .app-shell .document-abd-file-picker {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  padding: 8px 11px;
  overflow: hidden;
  border: 1px dashed var(--border-strong, #b9cec4);
  border-radius: var(--r-md, 8px);
  background: var(--bg-panel-2, #f7faf8);
  cursor: pointer;
}

body > .app-shell .document-abd-file-picker:hover {
  border-color: #8eaa9d;
  background: var(--brand-soft-2, #f0f8f4);
}

body > .app-shell .document-abd-file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

body > .app-shell .document-abd-file-picker span:last-child {
  min-width: 0;
  overflow: hidden;
  color: var(--text-secondary, #33473e);
  font-size: 0.73rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body > .app-shell .document-abd-file-picker:focus-within {
  outline: 2px solid var(--brand, #23966c);
  outline-offset: 2px;
}

body > .app-shell .document-abd-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  margin-top: 12px;
}

body > .app-shell .document-abd-field {
  display: grid;
  min-width: 0;
  gap: 5px;
}

body > .app-shell .document-abd-readonly {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  padding: 9px 11px;
  overflow-wrap: anywhere;
  border: 1px solid #dfe7e3;
  border-radius: var(--r-md, 8px);
  background: #f3f6f4;
  color: #566a61;
  font-size: 0.8rem;
  line-height: 1.4;
}

body > .app-shell .document-abd-field--editable .document-abd-control {
  border-color: #9fc8b6 !important;
  background: #fff !important;
}

body > .app-shell .document-abd-savebar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

body > .app-shell .document-abd-savebar > span {
  margin-right: auto;
  color: var(--text-muted, #61756b);
  font-size: 0.7rem;
  line-height: 1.4;
}

body > .app-shell .document-abd-empty {
  display: grid;
  gap: 3px;
  min-height: 72px;
  align-content: center;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md, 8px);
  background: var(--neutral-soft, #f3f6f4);
}

body > .app-shell .document-abd-empty--compact {
  min-height: 0;
  margin-top: 12px;
}

body > .app-shell .document-abd-empty--error {
  border-color: #e1aeae;
  background: #fceeee;
}

body > .app-shell .document-abd-empty strong {
  color: var(--text-primary, #14231c);
  font-size: 0.78rem;
}

body > .app-shell .document-abd-empty span {
  color: var(--text-muted, #61756b);
  font-size: 0.72rem;
  line-height: 1.45;
}

.document-abd-dialog {
  width: min(680px, calc(100% - 24px));
  max-width: 680px;
  margin: auto;
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
}

.document-abd-dialog::backdrop {
  background: rgba(20, 35, 28, 0.46);
}

.document-abd-dialog__surface {
  display: flex;
  max-height: min(82dvh, 760px);
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #b9cec4;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 20px 55px rgba(20, 35, 28, 0.18);
  color: #14231c;
  font-family: "Inter", "Noto Sans", ui-sans-serif, system-ui, sans-serif;
}

.document-abd-dialog__header {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid #d9e5df;
}

.document-abd-dialog__header h3 {
  margin-top: 2px !important;
  font-size: 1rem !important;
  line-height: 1.35 !important;
}

.document-abd-dialog__close {
  display: grid;
  width: 44px;
  min-width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 1px solid #b9cec4;
  border-radius: 8px;
  background: #fff;
  color: #33473e;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.document-abd-dialog__close:hover {
  background: #f0f8f4;
}

.document-abd-dialog__content {
  min-height: 0;
  padding: 14px 16px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.document-abd-dialog .document-abd-empty {
  display: grid;
  min-height: 88px;
  align-content: center;
  gap: 3px;
  padding: 14px;
  border: 1px solid #d9e5df;
  border-radius: 8px;
  background: #f3f6f4;
}

.document-abd-dialog .document-abd-empty strong {
  color: #14231c;
  font-size: 0.78rem;
}

.document-abd-dialog .document-abd-empty span {
  color: #61756b;
  font-size: 0.72rem;
  line-height: 1.45;
}

.document-abd-version-list {
  display: grid;
  gap: 8px;
}

.document-abd-version-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid #d9e5df;
  border-radius: 8px;
  background: #fff;
}

.document-abd-version-row__index {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 6px;
  background: #e6f5ee;
  color: #176d4e;
  font-size: 0.7rem;
  font-weight: 700;
}

.document-abd-version-row__copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.document-abd-version-row__copy strong {
  overflow-wrap: anywhere;
  color: #14231c;
  font-size: 0.76rem;
  line-height: 1.45;
}

.document-abd-version-row__copy span {
  color: #61756b;
  font-size: 0.68rem;
  line-height: 1.4;
}

.document-abd-dialog .document-abd-feedback {
  margin: 0 16px 16px;
  padding: 10px 12px;
  border: 1px solid #d9e5df;
  border-radius: 8px;
  background: #f3f6f4;
  color: #33473e;
  font-size: 0.75rem;
  line-height: 1.5;
}

.document-abd-dialog .document-abd-feedback[data-tone="success"] {
  border-color: #9bcdb8;
  background: #ecf8f2;
  color: #145b43;
}

.document-abd-dialog .document-abd-feedback[data-tone="warning"] {
  border-color: #dfc591;
  background: #fbf5e9;
  color: #7a521c;
}

.document-abd-dialog .document-abd-feedback[data-tone="error"] {
  border-color: #e1aeae;
  background: #fceeee;
  color: #9f3030;
}

.document-abd-dialog .document-abd-feedback[data-tone="info"] {
  border-color: #afcadf;
  background: #edf5fb;
  color: #315f87;
}

.document-abd-dialog__feedback {
  margin: 0 16px 16px !important;
}

@media (max-width: 720px) {
  body > .app-shell .document-abd-header {
    display: grid;
    gap: 8px;
    padding: 14px;
  }

  body > .app-shell .document-abd-header__hint {
    padding: 0;
  }

  body > .app-shell .document-abd-search {
    grid-template-columns: 1fr;
    padding: 12px 14px 10px;
  }

  body > .app-shell .document-abd-search__results {
    display: grid;
    padding: 0 14px 12px;
  }

  body > .app-shell #documentAbdSearchButton,
  body > .app-shell #documentAbdSearchSelect,
  body > .app-shell .document-abd-file-action > .document-abd-button,
  body > .app-shell .document-abd-savebar .document-abd-button,
  .document-abd-version-row .document-abd-button {
    width: 100%;
  }

  body > .app-shell .document-abd-workspace {
    padding: 12px 14px 14px;
  }

  body > .app-shell .document-abd-target__heading {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
  }

  body > .app-shell .document-abd-target__name {
    grid-column: 1 / -1;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  body > .app-shell .document-abd-target__meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body > .app-shell .document-abd-file-action,
  body > .app-shell .document-abd-fields {
    grid-template-columns: 1fr;
  }

  body > .app-shell .document-abd-section-heading,
  body > .app-shell .document-abd-savebar {
    align-items: stretch;
    flex-direction: column;
  }

  body > .app-shell .document-abd-section-heading .document-abd-button {
    align-self: flex-start;
  }

  body > .app-shell .document-abd-savebar > span {
    margin-right: 0;
  }

  .document-abd-dialog {
    width: 100%;
    max-width: 100%;
    margin: auto 0 0;
  }

  .document-abd-dialog__surface {
    max-height: 88dvh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 12px 12px 0 0;
  }

  .document-abd-version-row {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .document-abd-version-row .document-abd-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 420px) {
  body > .app-shell .document-abd-target__meta {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  body > .app-shell #documentAbdPanel *,
  .document-abd-dialog * {
    transition-duration: 0.01ms !important;
  }
}

/* Convert ABD ASTRI -> standar EVA */
body > .app-shell .document-abd-convert {
  display: block;
  padding: 14px 16px;
}

body > .app-shell .document-abd-convert__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

body > .app-shell .document-abd-convert__head .document-abd-file-action__copy {
  min-width: 0;
}

body > .app-shell .document-abd-convert__source {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  color: var(--text-muted, #61756b);
  font-size: 0.68rem;
}

body > .app-shell .document-abd-convert__cta {
  flex: 0 0 auto;
}

body > .app-shell .document-abd-convert__result {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft, #dce8e2);
}

body > .app-shell .document-abd-convert__result-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

body > .app-shell .document-abd-convert__result-head strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary, #14231c);
  font-size: 0.78rem;
  font-weight: 600;
}

body > .app-shell .document-abd-convert__badge {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--brand-soft-2, #f0f8f4);
  color: var(--brand-strong, #1c7a5a);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

body > .app-shell .document-abd-convert__facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0 0;
}

body > .app-shell .document-abd-convert__facts dt {
  color: var(--text-muted, #61756b);
  font-size: 0.62rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

body > .app-shell .document-abd-convert__facts dd {
  margin: 2px 0 0;
  color: var(--text-primary, #14231c);
  font-size: 0.75rem;
  font-weight: 600;
}

body > .app-shell .document-abd-convert__note,
body > .app-shell .document-abd-convert__hint {
  margin: 8px 0 0;
  color: var(--text-muted, #61756b);
  font-size: 0.68rem;
  line-height: 1.45;
}

body > .app-shell .document-abd-convert__hint {
  font-size: 0.64rem;
  opacity: 0.85;
}

body > .app-shell .document-abd-convert__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

@media (max-width: 720px) {
  body > .app-shell .document-abd-convert__head {
    flex-direction: column;
    align-items: stretch;
  }

  body > .app-shell .document-abd-convert__cta,
  body > .app-shell .document-abd-convert__actions .document-abd-button {
    width: 100%;
  }

  body > .app-shell .document-abd-convert__facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
