/* DAB styles v5 — 2026-03-21 */
/* ── Variables ───────────────────────────────────────── */
:root {
  --navy: #002145;
  --blue: #003262;
  --gold: #fdb515;
  --bg: #eef3f9;
  --surface: #ffffff;
  --text: #0f2033;
  --muted: #3d5a7a;
  --border: #c2d3e5;
  --link: #005a9c;
  --green: #0a5e35;
  --green-bg: #dff0e9;
  --red: #7b1d1d;
  --red-bg: #fce8e8;
}

/* ── Reset ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--link); text-underline-offset: 3px; }
p { margin: 0 0 0.55rem; }
h2 { margin: 0 0 0.55rem; font-size: 1.08rem; font-weight: 700; color: var(--blue); }
h3 { margin: 0 0 0.4rem; font-size: 0.95rem; font-weight: 700; color: var(--blue); }

/* ── Layout ──────────────────────────────────────────── */
.container { max-width: 1160px; margin: 0 auto; padding: 0 1.25rem; }
.muted { color: var(--muted); }

.two-col {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.two-col-about {
  flex: 1 1 0;
  min-width: 0;
}

.two-col-main {
  flex: 3 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stats-row.stats-row-2col { grid-template-columns: repeat(2, 1fr); }

/* ── Header ──────────────────────────────────────────── */
.page-header {
  background: linear-gradient(140deg, var(--navy), var(--blue));
  color: #fff;
  border-bottom: 4px solid var(--gold);
  padding: 1.75rem 0;
  margin-bottom: 1.25rem;
}

.hero-grid {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
}

.hero-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 6px;
}

.page-header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.9rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.15;
}

.subtitle { margin: 0; font-size: 1rem; color: #cce0ff; line-height: 1.5; max-width: 620px; }

.hero-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; padding-top: 0.15rem; }

.btn {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.88rem;
  text-decoration: none;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn-gold { background: var(--gold); color: #1a0e00; }
.btn-outline { color: #e0eeff; border-color: #5080b0; }

/* ── Tab bar ─────────────────────────────────────────── */
.tab-bar {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin-bottom: 1rem;
  background: #dce5f0;
  border-radius: 6px;
  padding: 0.25rem;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

.tab-btn {
  padding: 0.45rem 1rem;
  border: none;
  border-radius: 4px;
  background: transparent;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: #3d5a7a;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab-btn:hover {
  background: #c8d6e8;
  color: #0f2033;
}

.tab-btn.active {
  background: #ffffff;
  color: var(--navy);
  box-shadow: 0 1px 3px rgba(0,30,70,.1);
}

/* ── Cards ───────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,30,70,.07);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
}

/* ── About list ──────────────────────────────────────── */
ul.about-list {
  margin: 0.3rem 0 0.65rem 1.1rem;
  padding: 0;
}
ul.about-list li {
  margin-bottom: 0.3rem;
  line-height: 1.5;
}

/* ── Stats row ───────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin: 0.75rem 0;
}

.stat-box {
  background: #e6eef8;
  border: 1px solid #c0d3e8;
  border-radius: 4px;
  padding: 0.6rem 0.75rem;
}

.stat-label {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #2d4f6e;
}

.stat-value {
  margin: 0.05rem 0 0;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--blue);
  line-height: 1.1;
}

/* ── Tables ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

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

th, td {
  padding: 0.48rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}

thead th { background: #e0eaf6; color: #19324d; font-weight: 700; }
tbody tr:nth-child(even) { background: #f6f9fd; }
tfoot td { font-weight: 700; background: #e8f0fb; border-top: 2px solid var(--border); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

.cell-best { color: var(--green); font-weight: 800; background: var(--green-bg) !important; }
.cell-zero { color: var(--red);   font-weight: 800; background: var(--red-bg)   !important; }

/* ── Table controls ──────────────────────────────────── */
.table-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.8rem;
  align-items: center;
  margin-bottom: 0.8rem;
}

.table-controls label {
  font-weight: 600;
  font-size: 0.88rem;
  color: #1d3a55;
}

/* ── Custom selects ──────────────────────────────────── */
/*
  We use a wrapper so we can draw the caret via ::after.
  The <select> itself gets appearance:none so the browser
  doesn't paint its own arrow.
*/
.sel {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.sel::after {
  content: "";
  position: absolute;
  right: 0.7rem;
  top: 50%;
  translate: 0 -50%;
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #3a5f82;
  pointer-events: none;
}

.sel select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid #8dacc6;
  background: #fff;
  border-radius: 4px;
  padding: 0.42rem 2.2rem 0.42rem 0.65rem;
  font: inherit;
  font-size: 0.88rem;
  color: #0f2033;
  cursor: pointer;
  min-width: 200px;
}

.sel select:focus {
  outline: 2px solid #2f72b8;
  outline-offset: 1px;
  border-color: #2f72b8;
}

/* ── Submission ──────────────────────────────────────── */
ol.steps { margin: 0.3rem 0 0.85rem 1.1rem; padding: 0; }
ol.steps li { margin-bottom: 0.3rem; }

pre.code-block {
  background: #0d2240;
  color: #d4e8ff;
  padding: 0.75rem;
  border-radius: 4px;
  overflow-x: auto;
  margin: 0.5rem 0 0.6rem;
}
pre.code-block code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.83rem;
  line-height: 1.5;
}

/* ── Query explorer ──────────────────────────────────── */
.explorer-card { padding: 0; }

.explorer-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: #f3f7fd;
}

.explorer-bar h2 { margin: 0; font-size: 1rem; }

.explorer-bar .search-wrap {
  margin-left: auto;
  position: relative;
}

.explorer-bar .search-wrap input {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid #8dacc6;
  border-radius: 4px;
  padding: 0.4rem 0.65rem;
  font: inherit;
  font-size: 0.88rem;
  color: #0f2033;
  width: 240px;
  background: #fff;
}

.explorer-bar .search-wrap input:focus {
  outline: 2px solid #2f72b8;
  outline-offset: 1px;
  border-color: #2f72b8;
}

/*
  TWO-COLUMN EXPLORER
  Using a table-style layout as the most reliable cross-browser approach:
  the sidebar is display:inline-block with a fixed width, the main is a
  block that fills remaining space, inside a container that clips overflow.
*/
.explorer-body {
  display: flex;
  flex-direction: row;
  height: 540px;
  overflow: hidden;
}

.explorer-nav {
  width: 210px;
  min-width: 210px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: #f2f7fc;
}

.explorer-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 0.85rem 1rem;
}

/* Dataset nav list */
.ds-list { padding: 0.35rem 0; }

.ds-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0.42rem 0.8rem 0.42rem 0.85rem;
  border: 0;
  border-left: 3px solid transparent;
  background: none;
  text-align: left;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  color: #1a3552;
  cursor: pointer;
}
.ds-btn:hover { background: #e5eef8; }
.ds-btn.active { background: #d8e9f5; border-left-color: var(--blue); font-weight: 700; color: var(--blue); }
.ds-btn-all { font-weight: 600; border-bottom: 1px solid var(--border); }

.ds-count {
  font-size: 0.72rem;
  font-weight: 600;
  color: #6b8caa;
  background: #dde9f5;
  border-radius: 9px;
  padding: 0.08rem 0.42rem;
}

/* Dataset meta */
.ds-meta { margin-bottom: 0.85rem; }
.ds-meta h3 { margin-bottom: 0.35rem; }

.ds-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  margin: 0.4rem 0 0.6rem;
}

.ds-meta-cell {
  border: 1px solid #cddaeb;
  border-radius: 4px;
  padding: 0.38rem 0.5rem;
  background: #f1f7fc;
}

.ds-meta-label {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: #2d4f6e;
}

.ds-meta-val {
  margin: 0.08rem 0 0;
  font-weight: 700;
  font-size: 0.9rem;
  color: #0f2b48;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ds-links { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.55rem; }

.ds-link {
  display: inline-block;
  border: 1px solid #8fb0d0;
  border-radius: 4px;
  padding: 0.22rem 0.48rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #0a3d70;
  text-decoration: none;
  background: #fff;
}

.db-preview-btn {
  border: 1px solid #8fb0d0;
  border-radius: 4px;
  padding: 0.22rem 0.48rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: #0a3d70;
  background: #fff;
  cursor: pointer;
}

.db-preview {
  margin-top: 0.4rem;
  padding: 0.5rem;
  border: 1px solid #b8cede;
  border-radius: 4px;
  background: #f7fbff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.35;
  white-space: pre-wrap;
  max-height: 180px;
  overflow: auto;
}

/* Query list */
.q-count { font-size: 0.83rem; color: var(--muted); margin-bottom: 0.6rem; }

.q-list { display: flex; flex-direction: column; gap: 0.45rem; }

.ds-group-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #3a587a;
  margin: 0.8rem 0 0.3rem;
}

.q-item {
  border: 1px solid #bed0e3;
  border-radius: 4px;
  background: #f9fbff;
  padding: 0.5rem 0.7rem;
}

.q-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.q-pill {
  flex-shrink: 0;
  padding: 0.08rem 0.38rem;
  border-radius: 3px;
  background: #d9e9f6;
  color: #0d3260;
  font-size: 0.73rem;
  font-weight: 800;
}

.q-text-inline {
  color: #0f2a42;
  font-size: 0.88rem;
  line-height: 1.45;
}

.q-link {
  display: inline-block;
  margin-top: 0.3rem;
  font-size: 0.8rem;
  font-weight: 600;
}

/* ── Footer ──────────────────────────────────────────── */
.footer { padding: 0.5rem 0 2rem; color: var(--muted); font-size: 0.85rem; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 960px) {
  .hero-grid { flex-direction: column; }
  .two-col { flex-direction: column; }
  .two-col-about { flex: unset; width: 100%; }
  .two-col-main { flex: unset; width: 100%; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .page-header { padding: 1.2rem 0; }
  .page-header h1 { font-size: 1.35rem; }
  .subtitle { font-size: 0.9rem; }
  .container { padding: 0 0.75rem; }
  h2 { font-size: 0.98rem; }
  .card { padding: 0.85rem 0.9rem; }
  .explorer-body { flex-direction: column; height: auto; overflow: visible; }
  .explorer-nav {
    width: 100%;
    min-width: unset;
    flex-shrink: unset;
    border-right: none;
    border-bottom: 1px solid var(--border);
    height: 160px;
  }
  .explorer-main { height: auto; overflow-y: unset; }
  .explorer-bar { flex-direction: column; align-items: flex-start; gap: 0.5rem; padding: 0.65rem 0.9rem; }
  .explorer-bar .search-wrap { margin-left: 0; width: 100%; }
  .explorer-bar .search-wrap input { width: 100%; }
  .ds-meta-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .table-controls { flex-direction: column; align-items: flex-start; gap: 0.35rem; }
  .table-controls label { margin-top: 0.15rem; }
  .sel select { min-width: unset; width: 100%; }
  .sel { width: 100%; }
  table { font-size: 0.8rem; }
  th, td { padding: 0.38rem 0.45rem; }
  .hero-actions { justify-content: flex-start; }
  .btn { padding: 0.45rem 0.75rem; font-size: 0.82rem; }
  pre.code-block { font-size: 0.76rem; padding: 0.6rem; }
  .q-text-inline { font-size: 0.82rem; }
  .ds-link { font-size: 0.76rem; padding: 0.18rem 0.38rem; }
}

@media (max-width: 400px) {
  .page-header h1 { font-size: 1.15rem; }
  .stats-row-2col { grid-template-columns: 1fr; }
  .ds-meta-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 1.3rem; }
}
