/* The Data API panels (views/partials/data-api-panel.ejs on the dashboard,
   views/partials/admin-panel-v2/tabs/data-api.ejs on the admin panel). Theme
   tokens only, so they follow all twelve palettes. Every grid and flex item
   can shrink (min-width: 0) and long words wrap, so nothing is wider than a
   320px phone; the code boxes and tables scroll inside themselves. */

.dap [hidden] { display: none !important; }

.dap { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.dap .sk-card { margin: 0; min-width: 0; }
.dap-stack { display: flex; flex-direction: column; gap: 0.7rem; min-width: 0; }
.dap h2 { margin: 0; font-size: 1.15rem; font-weight: 700; color: var(--sk-text); }
.dap h3 { margin: 0; font-size: 1rem; font-weight: 700; color: var(--sk-text); }
.dap h4 { margin: 0; font-size: 0.9rem; font-weight: 700; color: var(--sk-text); }
.dap p, .dap li { color: var(--sk-text-2); line-height: 1.55; overflow-wrap: anywhere; }
.dap p { margin: 0; max-width: 75ch; }
.dap code { overflow-wrap: anywhere; color: var(--sk-text); }
.dap :where(a.dap-link) { color: var(--sk-primary-text); font-weight: 600; }

.dap-note { margin: 0; }
.dap-small { font-size: 0.85rem; color: var(--sk-muted); }
.dap-empty { font-size: 0.9rem; color: var(--sk-muted); }
.dap-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.dap-head { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: flex-start; min-width: 0; }
.dap-head-text { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; flex: 1 1 16rem; }
.dap-icon {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem; border-radius: 10px;
  background: var(--sk-primary-soft); color: var(--sk-primary-text);
}
.dap-plan { flex: 0 0 auto; }

.dap-field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.dap-copy { display: flex; gap: 0.5rem; align-items: stretch; min-width: 0; }
.dap-copy .sk-input { flex: 1 1 auto; min-width: 0; }
.dap-copy .sk-btn { flex: 0 0 auto; }
.dap textarea.sk-input { resize: vertical; min-height: 4.5rem; }

.dap-how > summary { cursor: pointer; color: var(--sk-primary-text); font-weight: 600; width: fit-content; min-height: 2rem; }
.dap-steps { margin: 0.6rem 0; padding-left: 1.25rem; display: flex; flex-direction: column; gap: 0.45rem; }

.dap-code {
  margin: 0; padding: 0.6rem 0.75rem; border-radius: 8px; background: var(--sk-surface-2); color: var(--sk-text);
  font-size: 0.82rem; white-space: pre; overflow: auto; max-width: 100%; min-width: 0;
}
.dap-answer { max-height: 28rem; }
.dap-newkey { border: 1px solid var(--sk-warning); }

.dap-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 1rem; min-width: 0; }
.dap-grid > * { min-width: 0; }

.dap-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.dap-item {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.7rem;
  padding: 0.65rem 0.75rem; border: 1px solid var(--sk-border); border-radius: 10px; min-width: 0;
}
.dap-item-text { display: flex; flex-direction: column; gap: 0.15rem; flex: 1 1 12rem; min-width: 0; }
.dap-item-text strong { color: var(--sk-text); overflow-wrap: anywhere; }
.dap-item-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.dap-form { display: flex; flex-direction: column; gap: 0.7rem; min-width: 0; }
.dap-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 0.2rem; }
.dap-fieldset legend { padding: 0; margin-bottom: 0.2rem; }
.dap-picks { display: flex; flex-direction: column; gap: 0.1rem; padding-left: 1.6rem; }
.dap-check { display: flex; gap: 0.55rem; align-items: center; color: var(--sk-text-2); min-height: 2rem; }
.dap-check span { min-width: 0; overflow-wrap: anywhere; }
.dap-check input { width: 1.1rem; height: 1.1rem; flex: 0 0 auto; accent-color: var(--sk-primary); }
.dap-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.dap-try-params { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 12rem), 1fr)); gap: 0.6rem; }

.dap-row-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; }
.dap-bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.dap-bar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(4rem, 2fr) auto; gap: 0.6rem; align-items: center; }
.dap-bar-label { min-width: 0; overflow-wrap: anywhere; color: var(--sk-text); font-size: 0.85rem; }
.dap-bar-track { height: 0.5rem; border-radius: 999px; background: var(--sk-surface-2); overflow: hidden; }
.dap-bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--sk-primary); }
.dap-bar-value { font-size: 0.82rem; color: var(--sk-text-2); white-space: nowrap; }

/* The admin panel's tab. */
.dap-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 9rem), 1fr)); gap: 0.6rem; }
.dap-tile { padding: 0.7rem 0.8rem; border: 1px solid var(--sk-border); border-radius: 10px; min-width: 0; }
.dap-tile-value { display: block; font-size: 1.35rem; font-weight: 700; color: var(--sk-text); overflow-wrap: normal; }
.dap-tile-label { display: block; font-size: 0.8rem; color: var(--sk-muted); }
.dap-filters { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end; }
.dap-filters .dap-field { flex: 1 1 12rem; }
.dap-table-wrap { overflow-x: auto; min-width: 0; }
.dap-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.dap-table th, .dap-table td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--sk-border); color: var(--sk-text-2); vertical-align: top; }
.dap-table thead th { color: var(--sk-muted); font-weight: 600; font-size: 0.8rem; white-space: nowrap; }
.dap-table td strong { color: var(--sk-text); }
.dap-plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 0.8rem; }
.dap-plan-form { display: flex; flex-direction: column; gap: 0.55rem; padding: 0.75rem; border: 1px solid var(--sk-border); border-radius: 10px; min-width: 0; }
.dap-plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 8rem), 1fr)); gap: 0.5rem; }

@media (max-width: 480px) {
  .dap-copy { flex-direction: column; }
  .dap-bar { grid-template-columns: minmax(0, 1fr) auto; }
  .dap-bar-track { grid-column: 1 / -1; grid-row: 2; }
}
@media (pointer: coarse) {
  .dap .sk-btn { min-height: 44px; }
  .dap .sk-input, .dap .sk-select { font-size: 16px; }
  .dap-check { min-height: 44px; }
}
