/* Query log page: only page-specific rules live here, prefixed ql-. */
.ql-page,
.ql-modal-overlay {
  --ql-surface: var(--surface);
  --ql-surface-2: var(--surface-2);
  --ql-line: var(--line);
  --ql-text: var(--text);
  --ql-muted: var(--text-secondary);
  --ql-accent: var(--accent);
}

.ql-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  color: var(--ql-text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Segoe UI", system-ui, sans-serif;
}

.ql-page > * {
  margin-bottom: 0;
}

/* Buttons ----------------------------------------------------------------- */
.ql-copy:focus-visible,
.ql-modal-close:focus-visible {
  outline: 2px solid var(--ql-accent);
  outline-offset: 2px;
}

/* Filters ----------------------------------------------------------------- */
.ql-filter-card .ql-filter-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ql-filter-grid {
  display: grid;
  grid-template-columns: minmax(200px, 2fr) minmax(170px, 1.6fr) minmax(120px, 1fr) minmax(110px, 0.8fr) minmax(110px, 0.8fr);
  gap: 12px;
  align-items: start;
}

.ql-filter-grid .ql-control {
  width: 100%;
}

.ql-filter-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.ql-auto {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ql-muted);
  font-size: 12.5px;
  white-space: nowrap;
}

.ql-auto-hint {
  color: var(--ql-muted);
}

/* Table ------------------------------------------------------------------- */
.ql-table-card {
  min-width: 0;
}

.ql-table-host {
  min-height: 120px;
}

.ql-table-scroll {
  max-height: min(62vh, 680px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--ql-line);
  border-radius: 10px;
  background: var(--ql-surface);
  -webkit-overflow-scrolling: touch;
}

.ql-table-scroll:focus-visible {
  outline: 2px solid var(--ql-accent);
  outline-offset: 1px;
}

.ql-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.ql-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 9px 12px;
  overflow: hidden;
  border-bottom: 1px solid var(--ql-line);
  background: var(--ql-surface-2);
  color: var(--ql-muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ql-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--ql-line);
  vertical-align: middle;
}

.ql-table tbody tr:last-child td {
  border-bottom: 0;
}

.ql-row {
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.ql-row:hover {
  background: rgba(0, 0, 0, 0.025);
  background: color-mix(in srgb, var(--ql-text) 4%, transparent);
}

.ql-row:focus-visible {
  outline: 2px solid var(--ql-accent);
  outline-offset: -2px;
}

.ql-col {
  overflow: hidden;
}

/* Percentages fit all ten columns into the content area at 1440px; the time
   column stays pinned when a narrower viewport must scroll horizontally. */
.ql-col-time {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 14%;
  background: var(--ql-surface);
  box-shadow: 1px 0 0 var(--ql-line);
  white-space: nowrap;
}

.ql-table th.ql-col-time {
  z-index: 3;
  background: var(--ql-surface-2);
}

.ql-row:hover .ql-col-time {
  background: color-mix(in srgb, var(--ql-text) 4%, var(--ql-surface));
}

.ql-col-client {
  width: 11%;
}

.ql-col-domain {
  width: 21%;
}

.ql-col-qtype {
  width: 5.5%;
}

.ql-col-action {
  width: 7%;
  white-space: nowrap;
}

.ql-action {
  display: inline-flex;
  white-space: nowrap;
}

.ql-col-rule {
  width: 12%;
}

.ql-col-upstream {
  width: 9.5%;
}

.ql-col-duration {
  width: 6%;
  white-space: nowrap;
}

.ql-col-cached {
  width: 5%;
}

.ql-col-protocol {
  width: 9%;
}

.ql-align-right {
  text-align: right;
}

.ql-table th.ql-align-right {
  text-align: right;
}

.ql-cell-stack {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.ql-time {
  display: block;
  overflow: hidden;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ql-mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  letter-spacing: -0.01em;
}

.ql-ellipsis {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ql-domain {
  color: var(--ql-text);
}

.ql-client {
  color: var(--ql-text);
}

.ql-sub {
  color: var(--ql-muted);
  font-size: 11.5px;
}

.ql-qtype {
  color: var(--ql-muted);
  font-variant-numeric: tabular-nums;
}

.ql-duration {
  font-variant-numeric: tabular-nums;
}

.ql-dash {
  color: var(--ql-muted);
}

.ql-flag {
  color: var(--ql-muted);
}

.ql-flag-on {
  color: var(--ql-accent);
  font-weight: 600;
}

.ql-protocol {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.ql-encrypted {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--ql-line);
  border-color: color-mix(in srgb, var(--ql-accent) 38%, var(--ql-line));
  border-radius: 999px;
  color: var(--ql-accent);
  font-size: 10.5px;
  line-height: 1.5;
  white-space: nowrap;
}

/* Pagination -------------------------------------------------------------- */
.ql-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding-top: 12px;
}

.ql-pager-info {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  color: var(--ql-muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.ql-pager-total {
  color: var(--ql-text);
  font-weight: 650;
}

.ql-sep {
  color: var(--ql-muted);
  opacity: 0.65;
}

.ql-pager-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* Loading, empty and error states ----------------------------------------- */
.ql-skeleton {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--ql-line);
  border-radius: 10px;
  background: var(--ql-surface);
}

.ql-skeleton-row {
  display: grid;
  grid-template-columns: 1.1fr 1.2fr 2.4fr 0.8fr 1fr;
  gap: 18px;
  align-items: center;
  padding: 13px 12px;
  border-bottom: 1px solid var(--ql-line);
}

.ql-skeleton-row:last-child {
  border-bottom: 0;
}

.ql-skeleton-bar {
  display: block;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(127, 127, 127, 0.1),
    rgba(127, 127, 127, 0.2),
    rgba(127, 127, 127, 0.1)
  );
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--ql-text) 6%, transparent),
    color-mix(in srgb, var(--ql-text) 13%, transparent),
    color-mix(in srgb, var(--ql-text) 6%, transparent)
  );
  background-size: 200% 100%;
  animation: ql-shimmer 1.4s ease-in-out infinite;
}

.ql-skeleton-row .ql-skeleton-bar:nth-child(1) {
  width: 78%;
}

.ql-skeleton-row .ql-skeleton-bar:nth-child(2) {
  width: 64%;
}

.ql-skeleton-row .ql-skeleton-bar:nth-child(3) {
  width: 88%;
}

.ql-skeleton-row .ql-skeleton-bar:nth-child(4) {
  width: 45%;
}

.ql-skeleton-row .ql-skeleton-bar:nth-child(5) {
  width: 58%;
}

.ql-table-host > .empty {
  padding: 38px 12px;
}

.ql-error {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 4px 2px 8px;
}

.ql-error-actions {
  display: flex;
  gap: 8px;
}

@keyframes ql-shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -100% 0;
  }
}

/* Detail modal ------------------------------------------------------------ */
.ql-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.36);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: ql-fade-in 0.14s ease-out;
}

.ql-modal {
  display: flex;
  flex-direction: column;
  width: min(660px, 100%);
  max-height: min(86vh, 760px);
  overflow: hidden;
  border: 1px solid var(--ql-line);
  border-radius: 14px;
  background: var(--ql-surface);
  color: var(--ql-text);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35), 0 0 0 0.5px rgba(0, 0, 0, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Segoe UI", system-ui, sans-serif;
  animation: ql-pop-in 0.16s ease-out;
}

.ql-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--ql-line);
}

.ql-modal-heading {
  min-width: 0;
}

.ql-modal-title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.ql-modal-sub {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  color: var(--ql-muted);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
}

.ql-modal-close {
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ql-muted);
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.ql-modal-close:hover {
  background: var(--ql-surface-2);
  color: var(--ql-text);
}

.ql-modal-body {
  overflow: auto;
  padding: 14px 18px;
}

.ql-modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--ql-line);
}

.ql-modal-hint {
  color: var(--ql-muted);
  font-size: 12px;
}

.ql-detail-grid {
  display: grid;
  margin: 0;
}

.ql-detail-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px solid var(--ql-line);
}

.ql-detail-row:first-child {
  padding-top: 0;
}

.ql-detail-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.ql-detail-row dt {
  color: var(--ql-muted);
  font-size: 12.5px;
}

.ql-detail-row dd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.ql-detail-row dd .ql-mono {
  overflow-wrap: anywhere;
}

.ql-copy {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  padding: 1px 8px;
  border: 1px solid var(--ql-line);
  border-radius: 6px;
  background: transparent;
  color: var(--ql-muted);
  font: inherit;
  font-size: 11.5px;
  line-height: 1.5;
  cursor: pointer;
}

.ql-copy:hover {
  background: var(--ql-surface-2);
  color: var(--ql-text);
}

@keyframes ql-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes ql-pop-in {
  from {
    opacity: 0;
    transform: scale(0.98) translateY(2px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Responsive -------------------------------------------------------------- */
@media (max-width: 1300px) {
  .ql-table th.ql-col-collapsible,
  .ql-table td.ql-col-collapsible {
    display: none;
  }
}

@media (max-width: 960px) {
  .ql-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  /* The shared form-control rule in style.css is more specific than a plain
     descendant selector, so repeat its :not() chain to win at tablet widths. */
  .ql-filter-card .field input,
  .ql-filter-card .field input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  .ql-filter-card .field select {
    font-size: 16px;
  }

  .ql-page .ql-btn,
  .ql-page .ql-copy,
  .ql-page .ql-modal-close,
  .ql-page .ql-pager-actions .btn,
  .ql-copy {
    min-height: 44px;
  }

  .ql-page .ql-copy,
  .ql-copy {
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .ql-page .ql-modal-close {
    width: 44px;
    height: 44px;
  }

  .ql-table th.ql-col-less,
  .ql-table td.ql-col-less {
    display: none;
  }

  .ql-table {
    min-width: 720px;
  }

  .ql-table-scroll {
    max-height: min(58vh, 560px);
  }

  .ql-skeleton-row {
    grid-template-columns: 1.1fr 1.2fr 2.2fr 0.9fr;
  }

  .ql-skeleton-row .ql-skeleton-bar:nth-child(5) {
    display: none;
  }
}

@media (max-width: 560px) {
  .ql-filter-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .ql-filter-actions {
    justify-content: stretch;
  }

  .ql-filter-actions .ql-btn {
    flex: 1;
  }

  .ql-pager {
    align-items: flex-start;
  }

  .ql-pager-actions {
    width: 100%;
    margin-left: 0;
  }

  .ql-pager-actions .ql-btn {
    flex: 1;
  }

  .ql-table {
    min-width: 640px;
  }

  .ql-page .ql-table td {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .ql-modal-overlay {
    align-items: flex-end;
    padding: 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .ql-modal {
    max-height: 90vh;
    border-radius: 14px 14px 12px 12px;
  }

  .ql-detail-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 3px;
  }

  .ql-modal-foot {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .ql-skeleton-bar,
  .ql-modal,
  .ql-modal-overlay {
    animation: none;
  }

  .ql-row {
    transition: none;
  }
}
