:root {
  color-scheme: light;
  --bg-start: #ecfdf5;
  --bg-end: #f8fafc;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #e4e7ec;
  --brand: #10b981;
  --brand-dark: #059669;
  --danger: #d92d20;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 15%, rgba(16, 185, 129, 0.13), transparent 30%),
    linear-gradient(145deg, var(--bg-start), var(--bg-end) 56%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

button,
textarea {
  font: inherit;
}

.query-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 36px 18px;
}

.query-card {
  width: min(780px, 100%);
  padding: 34px;
  border: 1px solid rgba(16, 185, 129, 0.12);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 22px 70px rgba(16, 24, 40, 0.12);
  backdrop-filter: blur(12px);
}

.title-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 30px;
}

.title-icon {
  width: 54px;
  height: 54px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 17px;
  color: #ffffff;
  background: linear-gradient(145deg, var(--brand), var(--brand-dark));
  font-size: 24px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(16, 185, 129, 0.24);
}

h1 {
  margin: 0 0 7px;
  font-size: clamp(24px, 4vw, 32px);
  line-height: 1.2;
}

p {
  margin: 0;
}

.title-row p,
.form-footer span {
  color: var(--muted);
  font-size: 14px;
}

form > label {
  display: block;
  margin-bottom: 9px;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 190px;
  resize: vertical;
  padding: 15px 16px;
  border: 1px solid #d0d5dd;
  border-radius: 13px;
  outline: none;
  color: var(--text);
  background: #ffffff;
  line-height: 1.65;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
}

.form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
}

button {
  min-width: 122px;
  padding: 12px 22px;
  border: 0;
  border-radius: 11px;
  color: #ffffff;
  background: linear-gradient(145deg, var(--brand), var(--brand-dark));
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(16, 185, 129, 0.2);
}

button:hover {
  filter: brightness(0.97);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.error-message {
  min-height: 22px;
  margin-top: 12px;
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
}

.hidden {
  display: none;
}

.result-section {
  margin-top: 18px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.summary-grid article {
  padding: 18px;
  border: 1px solid #d1fae5;
  border-radius: 14px;
  background: #f0fdf9;
}

.summary-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.summary-grid strong {
  font-size: 27px;
  color: #047857;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  background: #f9fafb;
  font-size: 13px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

td:last-child,
th:last-child {
  text-align: right;
}

.status-ok {
  color: #047857;
  font-weight: 700;
}

.status-error {
  color: var(--danger);
  font-weight: 700;
}

@media (max-width: 600px) {
  .query-shell {
    place-items: start center;
    padding: 18px 12px;
  }

  .query-card {
    padding: 23px 18px;
    border-radius: 18px;
  }

  .title-row {
    align-items: flex-start;
    margin-bottom: 24px;
  }

  .title-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    font-size: 20px;
  }

  .form-footer {
    align-items: stretch;
    flex-direction: column;
  }

  button {
    width: 100%;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }
}
