:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #d9dce1;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #006fbf;
  --accent-dark: #005a99;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

header h1 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--accent);
}

#session-area {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}

#user-label { color: var(--muted); }

#logout-link {
  color: var(--accent);
  text-decoration: none;
}
#logout-link:hover { text-decoration: underline; }

/* Login view */
#login-view {
  display: flex;
  justify-content: center;
  padding-top: 10vh;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem 2.5rem;
  text-align: center;
  max-width: 26rem;
}

/* App layout */
#app-view {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1rem;
  padding: 1rem 1.5rem;
  align-items: start;
}

#sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

#sidebar h2 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

#history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#history-list li {
  padding: 0.45rem 0.5rem;
  border-radius: 5px;
  font-size: 0.88rem;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#history-list li:hover { background: var(--bg); color: var(--accent); }
#history-list li.empty { color: var(--muted); cursor: default; }
#history-list li.empty:hover { background: none; color: var(--muted); }

/* Query form */
#query-form {
  display: flex;
  gap: 0.5rem;
}

#query-input {
  flex: 1;
  padding: 0.65rem 0.8rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

#query-input:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.button {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.button.primary:hover { background: var(--accent-dark); }
.button:disabled { opacity: 0.6; cursor: wait; }

/* Status + cards */
#status {
  margin-top: 1rem;
  padding: 0.7rem 1rem;
  border-radius: 6px;
  font-size: 0.92rem;
}

#status.info { background: #e8f1fb; color: #134e7c; }
#status.error { background: #fdecec; color: #8a1f1f; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-top: 1rem;
}

.card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.endpoint {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.88rem;
  background: var(--bg);
  padding: 0.4rem 0.6rem;
  border-radius: 5px;
  margin: 0 0 0.5rem;
  word-break: break-all;
}

#interp-explanation { margin: 0; }

/* Results */
#results-area { margin-top: 1rem; }

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.results-header h3 { margin: 0; font-size: 1rem; }

.table-wrap {
  overflow: auto;
  max-height: 60vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.86rem;
}

th, td {
  text-align: left;
  padding: 0.45rem 0.7rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  max-width: 28rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

th {
  position: sticky;
  top: 0;
  background: var(--bg);
  font-weight: 600;
}

tr:hover td { background: #fafbfc; }

@media (max-width: 760px) {
  #app-view { grid-template-columns: 1fr; }
}
