/* Development pages (HUB-745): logs, API call usage, keys and log drains. Built on the
   Service Keys / Legacy Apps design classes (sk-*, la-*); these add what they have no class for. */

.dv-page {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: 20px 22px 28px;
  border: 1px solid var(--border, #e4e7ec);
  border-radius: 12px;
  background: var(--surface, #fff);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(16, 24, 40, 0.04));
  box-sizing: border-box;
}
@media (max-width: 640px) {
  .dv-page {
    padding: 16px 14px 22px;
    border-radius: 10px;
  }
}
.dv-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border, #e4e7ec);
}
.dv-head h1 {
  margin: 0 0 6px;
  font-size: 24px;
  line-height: 1.3;
  color: var(--text, #101828);
}
.dv-head p {
  max-width: 760px;
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted, #475467);
}
.dv-head-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Logs: app switcher + trace id */
.dv-selector {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.dv-select select {
  height: 40px;
  min-width: 240px;
  padding: 0 12px;
  border: 1px solid var(--border-strong, #d0d5dd);
  border-radius: 7px;
  background: var(--surface, #fff);
  color: var(--text, #101828);
  font: inherit;
  font-size: 13px;
}
.dv-trace {
  flex: 0 1 340px;
}
.dv-trace input,
.dv-route-search input {
  border-left: 1px solid var(--border-strong, #d0d5dd) !important;
  border-radius: 22px !important;
}
.dv-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border: 1px solid var(--border, #e4e7ec);
  border-radius: 10px;
  background: var(--surface-2, #f9fafb);
  font-size: 13px;
  color: var(--text, #101828);
}
.dv-callout--info {
  border-color: var(--info-border, #b2ccff);
  background: var(--info-bg, #eff4ff);
}
.dv-log-table tbody tr {
  cursor: pointer;
}
.dv-log-table tbody tr:hover,
.dv-log-table tbody tr:focus-visible {
  background: var(--surface-hover, #f2f4f7);
  outline: none;
}
.dv-saved {
  margin-left: 8px;
  font-size: 11px;
  color: var(--text-muted, #475467);
}

/* Call drawer */
.dv-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1300;
  background: rgba(16, 24, 40, 0.48);
}
.dv-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(620px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--surface, #fff);
  box-shadow: -8px 0 24px rgba(16, 24, 40, 0.16);
}
.dv-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border, #e4e7ec);
}
.dv-drawer-head svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}
.dv-drawer-head h2 {
  margin: 0;
  font-size: 17px;
}
.dv-drawer-body {
  flex: 1;
  overflow: auto;
  padding: 18px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.dv-facts {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 10px 16px;
  margin: 0;
  font-size: 13px;
}
.dv-facts dt {
  color: var(--text-muted, #475467);
}
.dv-facts dd {
  margin: 0;
  min-width: 0;
  word-break: break-word;
}
.dv-facts--inline {
  margin-top: 16px;
}
.dv-block header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.dv-block h3 {
  margin: 0;
  font-size: 13px;
}
.dv-block pre {
  max-height: 280px;
  overflow: auto;
  margin: 6px 0 0;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-3, #eef1f5);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
}
.dv-note {
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-2, #f9fafb);
  font-size: 13px;
  color: var(--text-muted, #475467);
}

/* Usage */
.dv-meter-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.dv-meter-count {
  margin: 0;
  font-size: 15px;
  color: var(--text-muted, #475467);
}
.dv-meter-count strong {
  font-size: 28px;
  color: var(--text, #101828);
}
.dv-meter {
  height: 10px;
  margin: 14px 0 10px;
  border-radius: 6px;
  background: var(--surface-3, #eef1f5);
  overflow: hidden;
}
.dv-meter span {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: var(--brand, #2456e6);
}
.dv-meter--warning span {
  background: var(--warning, #dc6803);
}
.dv-meter--danger span {
  background: var(--danger, #b42318);
}
.dv-meter-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 12px;
  color: var(--text-muted, #475467);
}
.dv-meter-foot svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  flex: 0 0 14px;
}
.dv-meter-stats {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  margin: 18px 0 0;
}
.dv-meter-stats dt {
  font-size: 12px;
  color: var(--text-muted, #475467);
}
.dv-meter-stats dd {
  margin: 4px 0 0;
  font-size: 15px;
  font-weight: 600;
}
.dv-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}
.dv-cards > .sk-detail-card {
  margin-bottom: 0;
}
.dv-app-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
}
.dv-app-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border, #e4e7ec);
  font-size: 14px;
}
.dv-app-list small {
  display: block;
  font-size: 12px;
  color: var(--text-muted, #475467);
}
.dv-legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted, #475467);
}
.dv-legend i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}
.dv-ok {
  background: var(--brand, #2456e6);
}
.dv-fail {
  background: var(--danger, #b42318);
}
.dv-chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  height: 160px;
}
.dv-chart-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.dv-chart-bar {
  flex: 1;
  width: 100%;
  max-width: 44px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: var(--surface-2, #f9fafb);
  border-radius: 6px;
  overflow: hidden;
}
.dv-chart-bar span {
  display: block;
  width: 100%;
}
.dv-chart-day small {
  font-size: 11px;
  color: var(--text-muted, #475467);
}

/* Keys */
.dv-key-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted, #475467);
}
.dv-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-muted, #98a2b3);
}
.dv-dot--on {
  background: var(--success, #12b76a);
}
.dv-key-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--border-strong, #d0d5dd);
  border-radius: 8px;
  background: var(--surface-2, #f9fafb);
}
.dv-key-box code {
  min-width: 0;
  word-break: break-all;
  font-size: 13px;
}
.dv-pat-form h2 {
  margin: 18px 0 4px;
  font-size: 15px;
}
.dv-pat-form .sk-field input {
  width: 100%;
  max-width: 420px;
}
.dv-perm-grid {
  /* One list, as design personal-access-key.php (was a two-column card grid). */
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 16px;
}
.dv-perm {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
}
.dv-perm input {
  margin-top: 3px;
}
.dv-perm strong {
  display: block;
  font-size: 14px;
}
.dv-perm small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted, #475467);
}
.dv-perm.is-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.dv-sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding: 14px 0 0;
  border-top: 1px solid var(--border, #e4e7ec);
  background: var(--surface, #fff);
}

/* Personal Access Key: long permissions list must scroll inside the panel so the
   generate bar stays reachable and lower checkboxes are not clipped. */
.dv-page.dv-pat {
  max-height: calc(100dvh - var(--header-h, 54px) - 48px);
  overflow: hidden;
}
.dv-page.dv-pat > .dv-pat-form {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin-bottom: 0;
}

/* Log drains */
.dv-hero h2,
.dv-partner h2 {
  margin: 0 0 8px;
  font-size: 16px;
}
.dv-hero ul {
  margin: 0;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-muted, #475467);
}
.dv-partner .btn-crm {
  margin-top: 12px;
}
.dv-sub {
  display: block;
  max-width: 320px;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-muted, #475467);
}
.dv-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.dv-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.dv-form label > span,
.dv-form legend {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
}
.dv-form .input {
  width: 100%;
}
.dv-form fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}
.dv-radio {
  display: flex !important;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
}
.dv-error {
  margin: 0;
  color: var(--danger, #b42318);
  font-size: 13px;
}

@media (max-width: 760px) {
  .dv-head {
    flex-direction: column;
  }
  .dv-select select,
  .dv-trace {
    width: 100%;
    min-width: 0;
    flex: 1 1 100%;
  }
  .dv-facts {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }
  .dv-facts dd {
    margin-bottom: 8px;
  }
  .dv-chart {
    gap: 4px;
  }
}

/* Key and app logs: rows open the call drawer. */
.dv-click-row {
  cursor: pointer;
}
.dv-click-row:hover,
.dv-click-row:focus-visible {
  background: var(--surface-hover, #f2f4f7);
  outline: none;
}

/* HUB-745 (QA #928): at 1280px the logs table (min 700px) ran past its 667px card. Laptop widths
   drop the floor and tighten the cells, so every column shows. */
@media (max-width: 1439.98px) {
  .dv-log-table {
    min-width: 0;
  }
  .dv-log-table th,
  .dv-log-table td {
    padding-inline: 10px;
  }
}
