/* Shared modal surfaces and the application detail sheet. */
#dialog {
  --dialog-ink: #1d352d;
  --dialog-muted: #52695f;
  --dialog-line: #d9e1d9;
  --dialog-accent: #1c5945;
  box-sizing: border-box;
  width: min(536px, calc(100vw - 32px));
  max-height: min(88dvh, 860px);
  padding: 0;
  overflow: hidden;
  border: 1px solid #d7dfd7;
  border-radius: 20px;
  color: var(--dialog-ink);
  background: #fdfdfa;
  box-shadow: 0 32px 100px #10291f40, 0 6px 22px #10291f22;
}
#dialog[open] { display: flex; flex-direction: column; }
#dialog::backdrop { background: rgb(17 34 28 / 46%); backdrop-filter: blur(4px); }
#dialog > header {
  flex: none;
  padding: 17px 23px;
  background: #f7f8f3;
  border-bottom: 1px solid var(--dialog-line);
}
#dialog h2 { font-size: 20px; font-weight: 680; letter-spacing: -.03em; }
#dialog-close {
  display: grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 1px solid #d4ded3; border-radius: 10px; color: #40594d;
  background: #fff; line-height: 1; font: 23px/1 Arial,sans-serif;
}
#dialog-close:hover { background: #e9efe7; }
#dialog-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 22px 24px; }
#dialog .btn, #dialog-close, #dialog .remove-service { transition: background-color .16s, border-color .16s, box-shadow .16s; }
#dialog :is(button,a,input,select,textarea):focus-visible { outline: 3px solid #6fae8e; outline-offset: 2px; }
#dialog .fields { gap: 16px; }
#dialog .fields label { color: var(--dialog-ink); font-size: 13px; gap: 7px; }
#dialog .fields :is(input,select,textarea):not([type=checkbox]):not([type=radio]), #dialog .credential-field input {
  box-sizing: border-box; border: 1px solid #c8d4c9; border-radius: 9px;
  background: #fff; color: var(--dialog-ink); font: inherit; padding: 10px 12px;
}
#dialog .fields :is(input,select,textarea):focus, #dialog .credential-field input:focus { border-color: #608d75; }
#dialog .fields textarea { min-height: 78px; }
#dialog .fields .error:empty { display: none; }
#dialog .form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--dialog-line); padding-top: 15px; }
#dialog .btn { border-radius: 9px; padding: 7px 12px; min-height: 35px; font-size: 13px; }
#dialog .btn.primary, #dialog #detail-sso { background: var(--dialog-accent); color: white; border-color: var(--dialog-accent); }
#dialog .btn.primary:hover, #dialog #detail-sso:hover { background: #154432; }
#dialog .service-edit { min-width: 0; border: 1px solid var(--dialog-line); border-radius: 12px; padding: 12px; }
#dialog .service-edit legend { padding: 0 5px; color: #405c4e; font-size: 13px; }
#dialog .service-editor-row { border-radius: 9px; background: #f4f6f0; border-color: #dbe3d9; }
#dialog.service-sheet { width: min(650px, calc(100vw - 32px)); }
#dialog.service-sheet > header { background: none; padding: 0; border: 0; top: 15px; right: 16px; }
#dialog.service-sheet #dialog-close { color: white; background: #274d40; border-color: #698477; }
#dialog.service-sheet #dialog-close:hover { background: #355e4d; }
#dialog.service-sheet #dialog-body { padding: 0; }
#dialog .sheet-cover {
  padding: 23px 64px 23px 25px; min-height: 99px; gap: 15px;
  background: linear-gradient(108deg,#163b2f,#224e3e 68%,#325c48); color: #fff;
}
#dialog .sheet-cover::after, #dialog .sheet-cover::before {
  width: 210px; height: 210px; border-radius: 50%; border-color: #b5c7a630;
  box-shadow: 0 0 0 13px #98b29a0b, 0 0 0 14px #b5c7a620, 0 0 0 29px #98b29a08, 0 0 0 30px #b5c7a618;
  right: -47px; bottom: -143px; transform: none;
}
#dialog .sheet-cover::before { right: 15px; bottom: -166px; }
#dialog .sheet-tile { flex-basis: 48px; height: 48px; font-size: 24px; border-radius: 13px; box-shadow: none; }
#dialog .sheet-topic { color: #d5e5d5; font-size: 12px; }
#dialog .sheet-cover h3 { font-size: clamp(22px,3vw,28px); letter-spacing: -.035em; margin-top: 3px; }
#dialog .sheet-content { padding: 23px 25px; gap: 18px; }
#dialog .sheet-content h4 { font-size: 15px; color: var(--dialog-ink); font-weight: 690; margin: 0; }
#dialog .service-heading { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 9px; }
#dialog .entry-count { font-size: 12px; color: var(--dialog-muted); font-variant-numeric: tabular-nums; }
#dialog .service-search { display: flex; align-items: center; gap: 8px; color: #637a69; background: #f2f5ef; padding: 0 11px; border: 1px solid var(--dialog-line); border-radius: 8px; margin-bottom: 8px; }
#dialog .service-search:focus-within { outline: 2px solid #6fae8e; outline-offset: 1px; }
#dialog .service-search input { min-width: 0; width: 100%; border: 0; background: transparent; color: var(--dialog-ink); padding: 8px 0; font: inherit; font-size: 13px; }
#dialog .service-search input:focus-visible { outline: none; }
#dialog .service-list { border: 1px solid var(--dialog-line); border-radius: 12px; background: white; overflow: auto; max-height: min(32dvh,275px); scrollbar-color: #bdcabc #f4f6f2; }
#dialog .service-list[hidden] { display: none; }
#dialog .entry-row { display: grid; grid-template-columns: 34px minmax(0,1fr) auto; align-items: center; gap: 10px; border: 0; border-radius: 0; background: transparent; padding: 11px 13px; }
#dialog .entry-row + .entry-row { margin: 0; border-top: 1px solid #e7ece5; }
#dialog .entry-row[hidden] { display: none; }
#dialog .entry-icon { width: 34px; height: 34px; border-radius: 9px; font-size: 17px; color: #326550; background: #eaf2e7; }
#dialog .entry-icon.kind-app { background: #eef0f6; color: #556583; }
#dialog .entry-icon.kind-miniapp { background: #e0f1e2; color: #28714d; }
#dialog .entry-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 7px; }
#dialog .entry-name strong { font-size: 14px; font-weight: 660; color: var(--dialog-ink); }
#dialog .entry-type { color: var(--dialog-muted); font-size: 11px; }
#dialog .entry-url { color: var(--dialog-muted); font-size: 12px; line-height: 1.5; }
#dialog .entry-row .service-go { grid-column: auto; justify-self: end; color: #245740; border: 1px solid #cddccc; background: #f2f7ef; font-size: 12px; min-height: 32px; white-space: nowrap; padding: 5px 10px; }
#dialog .service-go:hover { background: #e1efde; }
#dialog .entry-missing,#dialog .service-no-match { color: var(--dialog-muted); font-size: 13px; padding: 12px; margin: 0; background: #f2f5ef; border-radius: 8px; }
#dialog .admin-block { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: start; gap: 6px 12px; padding: 17px 0 0; border-top: 1px solid var(--dialog-line); }
#dialog .admin-destination { grid-column: 1; gap: 5px; color: var(--dialog-muted); font-size: 12px; }
#dialog .admin-destination .icon { flex: none; }
#dialog .sheet-actions { grid-column: 2; grid-row: 1 / span 2; align-self: center; gap: 7px; margin: 0; }
#dialog .sheet-actions .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
#dialog .credential-panel { padding: 14px 15px; border: 1px solid #d4dfd1; border-radius: 12px; background: #f1f5ed; }
#dialog .credential-panel h4 { display: flex; align-items: center; gap: 5px; color: #294b38; }
#dialog .credential-panel h4 .icon { color: #41644d; }
#dialog .credential-panel .btn { min-height: 31px; }
#dialog .credential-head { gap: 8px; }
#dialog .credential-field label,#dialog .credential-status { color: var(--dialog-muted); }
#dialog .sheet-note { padding: 0; background: transparent; }
#dialog .sheet-note h4 { font-size: 12px; color: var(--dialog-muted); font-weight: 550; }
#dialog .sheet-note p { margin-top: 4px; color: #43594d; font-size: 13px; line-height: 1.6; }
@media(max-width: 560px) {
  #dialog, #dialog.service-sheet { width: calc(100vw - 18px); max-height: 92dvh; border-radius: 16px; }
  #dialog-body, #dialog .sheet-content { padding: 16px; }
  #dialog > header { padding: 13px 16px; }
  #dialog .sheet-cover { padding: 19px 56px 19px 16px; gap: 12px; min-height: 87px; }
  #dialog .sheet-tile { flex-basis: 41px; height: 41px; }
  #dialog .entry-row { grid-template-columns: minmax(0,1fr) auto; padding: 10px; }
  #dialog .entry-icon { display: none; }
  #dialog .admin-block { grid-template-columns: minmax(0,1fr); }
  #dialog .sheet-actions { grid-row: auto; grid-column: 1; margin-top: 3px; }
}
@media(prefers-reduced-motion: reduce) {
  #dialog *, #dialog::backdrop { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
