.query-page {
  min-height: 100vh;
  overflow: hidden;
}

.query-page-shell {
  display: grid;
  width: min(1500px, 100%);
  height: 100dvh;
  min-height: 100vh;
  grid-template-rows: 58px minmax(0, 1fr);
  margin: 0 auto;
}

.query-page-header {
  display: grid;
  min-width: 0;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  border-bottom: 1px solid var(--rule);
  padding: 8px 14px;
  background: rgba(255, 253, 248, 0.96);
}

.query-page-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-decoration: none;
}

.query-page-brand > span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 5px;
  color: #172229;
  background: #f1b958;
  font-family: var(--display-face);
  font-weight: 800;
}

.query-page-brand strong { font-family: var(--display-face); font-size: 13px; }
.query-page-title { display: flex; min-width: 0; align-items: baseline; gap: 12px; }
.query-page-title .eyebrow,
.query-page-title h1 { margin: 0; }
.query-page-title h1 { font-size: 24px; line-height: 1; }
.query-page-header-actions { display: flex; align-items: center; gap: 8px; }
.query-page-header .credential-query-state {
  width: 260px;
  max-width: 260px;
  justify-content: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.query-page-main {
  display: grid;
  width: 100%;
  min-width: 0;
  min-height: 0;
  grid-template-rows: 114px minmax(0, 1fr);
  gap: 14px;
  margin: 0;
  padding: 14px;
}

.query-page .credential-query-form {
  height: 114px;
  min-height: 114px;
  margin: 0;
  border-radius: 8px;
  padding: 14px;
  overflow: hidden;
}

.query-source-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.query-source-heading .eyebrow,
.query-source-heading h2 { margin: 0; }
.query-source-heading h2 { font-size: 17px; line-height: 1.2; }
.query-source-heading > span { color: var(--ink-muted); font-size: 10px; font-weight: 700; }

.query-page .credential-query-form .field-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.query-page .credential-input-row { display: contents; }
.query-page .credential-input-row input { min-width: 0; }
.query-page .credential-input-row .button { min-width: 76px; }
.query-page .credential-query-workspace {
  height: auto;
  min-height: 0;
  grid-row: 2;
  grid-template-columns: 320px 440px minmax(0, 1fr);
  gap: 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}

.credential-query-account-pane {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fff;
}

.query-page .credential-query-list-pane {
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: #fff;
}

.query-page .credential-query-detail-pane {
  border: 1px solid var(--rule);
  border-radius: 8px;
}

.credential-query-account-pane > header {
  display: flex;
  min-height: 74px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--rule);
  padding: 14px 16px;
  background: var(--paper-deep);
}

.credential-query-account-pane > header > span { color: var(--ink-muted); font-size: 11px; font-weight: 700; }
.credential-query-account-list { min-height: 0; flex: 1 1 auto; overflow-y: auto; }
.credential-account {
  display: grid;
  width: 100%;
  min-height: 68px;
  gap: 5px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  padding: 12px 15px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}
.credential-account:hover { background: #f5f8fb; }
.credential-account[data-selected="true"] { color: #fff; background: #334f70; box-shadow: inset 4px 0 0 #f1b958; }
.credential-account strong { min-width: 0; overflow-wrap: anywhere; font-family: var(--display-face); font-size: 13px; }
.credential-account small { color: var(--ink-muted); font-size: 10px; }
.credential-account[data-status="loading"] small { color: #356ba0; }
.credential-account[data-status="ready"] small { color: #177052; }
.credential-account[data-status="error"] small { color: #ac3529; }
.credential-account[data-selected="true"] small { color: #d7e0e8; }

.query-page #credentialQueryBatchDialog {
  width: min(1472px, calc(100vw - 28px));
  height: min(720px, calc(100dvh - 28px));
  max-width: 1472px;
  max-height: calc(100dvh - 28px);
  overflow: hidden;
}
.credential-query-batch-form {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 18px;
  padding: clamp(22px, 2.5vw, 34px);
}
.credential-query-batch-form .dialog-heading,
.credential-query-batch-form .dialog-actions { margin: 0; }
.credential-query-batch-fields {
  display: grid;
  min-height: 0;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 10px;
}
.credential-query-batch-fields > label { font-size: 12px; font-weight: 700; }
.credential-query-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--rule);
  padding: 10px 12px;
  background: #fff;
}
.credential-query-file input { min-height: 32px; max-width: 420px; }
.credential-query-batch-fields textarea {
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  overflow: auto;
  font-family: Consolas, "Microsoft YaHei", monospace;
  line-height: 1.55;
}
.credential-query-batch-status { min-height: 18px; margin: 0; color: var(--ink-muted); font-size: 11px; }

.query-page #credentialGraphDialog {
  width: min(600px, calc(100vw - 28px));
  max-width: 600px;
  overflow: hidden;
}
.credential-graph-dialog {
  display: grid;
  gap: 22px;
  padding: 26px;
}
.credential-graph-dialog .dialog-heading,
.credential-graph-dialog .dialog-actions { margin: 0; }
.credential-graph-loading {
  min-height: 150px;
  display: grid;
  place-items: center;
  color: var(--ink-muted);
}
.credential-graph-content { display: grid; gap: 16px; }
.credential-graph-account {
  margin: 0;
  color: var(--ink-muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.credential-graph-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 8px;
}
.credential-graph-code-row code {
  display: grid;
  min-height: 54px;
  place-items: center;
  border: 1px solid var(--rule-strong);
  background: var(--paper-deep);
  font-family: var(--display-face);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0;
}
.credential-graph-content > .button { justify-self: start; }
.credential-graph-status {
  min-height: 20px;
  margin: 0;
  color: #356ba0;
  font-size: 12px;
}
.credential-graph-status[data-tone="ready"] { color: #177052; }
.credential-graph-status[data-tone="error"] { color: #ac3529; }

@media (max-width: 1350px) and (min-width: 1081px) {
  .query-page .credential-query-workspace { grid-template-columns: 280px 380px minmax(0, 1fr); }
}

@media (max-width: 1080px) {
  .query-page { overflow: auto; }
  .query-page-shell { display: block; height: auto; }
  .query-page-header { grid-template-columns: auto minmax(0, 1fr); }
  .query-page-title .eyebrow,
  .query-page-header .credential-query-state { display: none; }
  .query-page-header-actions { justify-self: end; }
  .query-page-main { display: block; padding: 12px; }
  .query-page .credential-query-form { margin-bottom: 10px; }
  .query-page .credential-query-form { height: auto; min-height: 0; overflow: visible; }
  .query-page .credential-query-workspace { height: auto; grid-template-columns: 1fr; overflow: visible; }
  .query-page .credential-query-account-pane { min-height: 260px; border: 1px solid var(--rule); }
  .query-page .credential-query-list-pane { min-height: 540px; border: 1px solid var(--rule); }
  .query-page .credential-query-detail-pane { min-height: 520px; }
}

@media (max-width: 560px) {
  .query-page-header { gap: 10px; padding: 8px 12px; }
  .query-page-brand strong { display: none; }
  .query-page-title h1 { font-size: 21px; }
  .query-page .credential-query-form .field-group { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .query-page .credential-input-row input { grid-column: 1 / -1; }
  .query-page .credential-input-row .button { width: 100%; }
  .credential-graph-code-row { grid-template-columns: 1fr; }
}
