* { box-sizing: border-box; }
:root {
  --ink: #182233;
  --muted: #657287;
  --line: #d9e0e8;
  --surface: #f4f6f8;
  --panel: #ffffff;
  --nav: #17263a;
  --teal: #006c67;
  --blue: #24527a;
  --amber: #a26300;
  --green: #2d714f;
}
body {
  margin: 0;
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--surface);
  overflow-x: hidden;
}
button, select, input { font: inherit; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  background: var(--nav);
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.14);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 250px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 6px; display: grid; place-items: center;
  background: #f1b24b; color: #162339; font-weight: 800;
}
h1 { margin: 0; font-size: 17px; letter-spacing: 0; }
.brand p { margin: 2px 0 0; color: #bfd0df; font-size: 12px; }
.section-tabs { display: flex; flex-wrap: wrap; gap: 7px; }
.section-tab {
  border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.06); color: #fff;
  height: 34px; padding: 0 12px; border-radius: 5px; cursor: pointer;
}
.section-tab.active { background: #fff; color: var(--ink); border-color: #fff; }
.page { padding: 16px; display: grid; gap: 14px; }
.summary-grid { display: grid; grid-template-columns: repeat(6, minmax(130px, 1fr)); gap: 10px; }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 11px 12px; min-width: 0; }
.metric span { color: var(--muted); font-size: 12px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metric strong { display: block; font-size: 20px; margin-top: 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.content-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; align-items: start; }
.dataset-panel, .toolbar, .actions, .table-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
}
.dataset-panel { padding: 10px; display: grid; gap: 10px; max-height: calc(100vh - 158px); overflow: auto; }
.panel-title { display: grid; gap: 2px; padding: 2px 2px 6px; border-bottom: 1px solid var(--line); }
.panel-title span { color: var(--muted); font-size: 12px; }
.dataset-list { display: grid; gap: 8px; }
.dataset-item {
  width: 100%; min-height: 58px; border: 1px solid var(--line); border-radius: 6px;
  color: var(--ink); background: #fff; padding: 10px; text-align: left; cursor: pointer;
  display: grid; gap: 3px;
}
.dataset-item.active { border-color: var(--teal); box-shadow: inset 3px 0 0 var(--teal); background: #f3fbfa; }
.dataset-item strong { display: block; font-size: 13px; }
.dataset-item span { display: block; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.workspace, .table-panel, .toolbar, .actions { min-width: 0; }
.workspace { display: grid; gap: 10px; align-content: start; }
.toolbar, .actions { padding: 10px; display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
select, input {
  height: 34px; border: 1px solid var(--line); border-radius: 4px; padding: 0 10px;
  min-width: 150px; background: #fff; color: var(--ink);
}
.search-label { flex: 1; min-width: 240px; }
input[type=search] { width: 100%; min-width: 220px; }
button, .button-link {
  height: 34px; border: 1px solid var(--blue); border-radius: 4px; padding: 0 12px;
  background: var(--blue); color: #fff; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
  white-space: nowrap;
}
button.secondary, .button-link.secondary { background: #fff; color: var(--blue); }
button:disabled { opacity: .45; cursor: not-allowed; }
.progress-wrap { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.progress-bar { height: 8px; flex: 1; background: #dfe6ed; border-radius: 999px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0%; background: var(--green); }
.table-meta { padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--muted); }
.table-scroll { overflow: auto; max-height: calc(100vh - 314px); }
table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; }
th, td {
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 7px 9px; max-width: 360px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
th { position: sticky; top: 0; z-index: 1; background: #e9eef3; color: #243b55; font-weight: 700; }
tbody tr:hover { background: #f7fbff; }
td.numberish { text-align: right; font-variant-numeric: tabular-nums; }
.detail-drawer {
  position: fixed; right: 0; top: 0; bottom: 0; width: min(680px, 94vw);
  background: #fff; border-left: 1px solid var(--line); box-shadow: -12px 0 30px rgba(20,35,60,.16);
  transform: translateX(102%); transition: transform .18s ease; z-index: 12; display: grid; grid-template-rows: auto 1fr;
}
.detail-drawer.open { transform: translateX(0); }
.drawer-header { display: flex; justify-content: space-between; align-items: center; padding: 12px; border-bottom: 1px solid var(--line); }
#detailBody { overflow: auto; padding: 12px; display: grid; gap: 8px; }
.detail-row { display: grid; grid-template-columns: 190px 1fr; gap: 10px; border-bottom: 1px solid #eef2f7; padding-bottom: 7px; }
.detail-row span:first-child { color: var(--muted); }
.detail-row span:last-child { white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 1100px) {
  .topbar { grid-template-columns: 1fr; }
  .brand { min-width: 0; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid { grid-template-columns: 1fr; }
  .dataset-panel { max-height: none; }
  .table-scroll { max-height: 70vh; }
}
