:root{
  --bg:#ffffff;
  --text:#111827;
  --muted:#6b7280;
  --line:#e5e7eb;
  --card:#ffffff;
  --shadow:0 8px 22px rgba(0,0,0,.08);
  --radius:16px;

  /* Dropdown background */
  --dropdown-bg:#c4dff4;

  /* Details button colors */
  --details-btn:#4e79a7;
  --details-btn-hover:#c4dff4;

  /* Expanded details output background */
  --details-output-bg: #f7fbff;

  --maxw:1100px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Noto Sans", Arial, "Apple Color Emoji","Segoe UI Emoji";
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}

a{color:#0b5bd3;text-decoration:none}
a:hover{text-decoration:underline}

.sr-only{
  position:absolute!important;
  width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;
}

.site-header{
  position:sticky;top:0;z-index:10;
  background:rgba(255,255,255,.95);
  backdrop-filter:saturate(180%) blur(8px);
  border-bottom:1px solid var(--line);
}

.header-inner{
  max-width:var(--maxw);
  margin:0 auto;
  padding:12px 14px;
  display:flex;
  align-items:center;
  gap:12px;
}

.brand{display:flex;align-items:center;gap:12px;min-width:0}
.brand-logo{height:44px;object-fit:contain}
.brand-text{min-width:0}
.brand-title{
  font-weight:900;
  font-size:14px;
  line-height:1.15;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.brand-subtitle{
  margin-top:2px;
  font-size:12px;
  color:var(--muted);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.menu-toggle{
  margin-left:auto;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:44px;height:44px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#fff;
  cursor:pointer;
}
.menu-toggle:active{transform:translateY(1px)}
.menu-toggle:focus-visible{outline:2px solid #111827;outline-offset:2px}
.menu-toggle-lines{
  width:18px;height:12px;
  display:inline-block;
  position:relative;
}
.menu-toggle-lines::before,
.menu-toggle-lines::after,
.menu-toggle-lines{
  border-top:2px solid #111827;
}
.menu-toggle-lines::before,
.menu-toggle-lines::after{
  content:"";
  position:absolute;left:0;right:0;
}
.menu-toggle-lines::before{top:4px}
.menu-toggle-lines::after{top:8px}

.menu{
  display:none;
  width:100%;
  flex-wrap:wrap;
  gap:10px;
  justify-content:center;
  padding:6px 0 0;
}
.menu.is-open{display:flex}
.menu-btn{
  display:inline-block;
  background:#bbdbf3;
  border:1px solid var(--line);
  border-radius:999px;
  padding:10px 14px;
  font-size:14px;
  font-weight:800;
  color:var(--text);
  line-height:1;
  user-select:none;
  -webkit-user-drag:none;
}
.menu-btn:hover{filter:brightness(.98);text-decoration:none}
.menu-btn:active{transform:translateY(1px)}
.menu-btn:focus-visible{outline:2px solid #111827;outline-offset:2px}

.header-banner{
  display:block;
  max-width:var(--maxw);
  width:calc(100% - 28px);
  margin:0 auto 12px;
  height:auto;
  max-height:220px;
  object-fit:cover;
  border-radius:14px;
  border:1px solid var(--line);
}

.wrap{max-width:var(--maxw);margin:0 auto;padding:18px 14px 40px}

.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:16px;
  margin:16px 0;
}

.card-head{margin:0 0 10px}
.card-divider{height:1px;background:var(--line);margin:16px 0}

.h2{margin:0 0 6px;font-size:16px}
.muted{margin:0;color:var(--muted)}
.small{font-size:12px}

.chart-shell{
  border:1px solid var(--line);
  border-radius:14px;
  padding:10px;
  background:#fff;
  position:relative;
  height:420px;
}

.controls{
  display:grid;
  grid-template-columns:1fr;
  gap:12px;
  align-items:end;
}

.field label{font-size:12px;color:var(--muted);display:block;margin:0 0 6px}

select, button, input{
  width:100%;
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px 12px;
  font-size:14px;
  outline:none;
}

select{ background:var(--dropdown-bg); }
select:disabled, input:disabled{ opacity:.6; cursor:not-allowed; }

#searchBox{ background:#eef7ff; }

.btn{
  background:#fff;
  cursor:pointer;
  font-weight:700;
}
.btn:hover{filter:brightness(.98)}
.btn:active{transform:translateY(1px)}

.status{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
  justify-content:space-between;
  margin-top:14px;
}
.pill{
  font-size:12px;color:var(--muted);
  border:1px solid var(--line);
  border-radius:999px;
  padding:6px 10px;
  background:#fff;
}

.results-header{
  margin:0 0 10px;
  font-size:16px;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#fff;
}

.loading{
  display:flex;gap:10px;align-items:center;justify-content:center;
  padding:18px;border:1px dashed var(--line);border-radius:14px;color:var(--muted);
}
.loading.error{border-style:solid}
.error-label{font-weight:800}

.spinner{
  width:16px;height:16px;border-radius:999px;border:2px solid var(--line);border-top-color:#111827;
  animation:spin 0.8s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}

.results{
  overflow:auto;
  border-radius:14px;
  border:1px solid var(--line);
}

table{
  width:100%;
  border-collapse:separate;border-spacing:0;
  min-width:860px;
  background:#fff;
}
th,td{
  padding:12px 12px;
  border-bottom:1px solid var(--line);
  vertical-align:top;
  font-size:13px;
}
th{
  position:sticky;top:0;background:#fff;
  text-align:left;font-size:12px;color:var(--muted);
  z-index:2;
}
tr:last-child td{border-bottom:none}

.pagination{
  display:flex;flex-wrap:wrap;gap:8px;align-items:center;justify-content:center;
  margin-top:14px;
}
.pagination button{
  width:auto;min-width:42px;padding:8px 12px;border-radius:999px;
}
.pagination button[aria-current="page"]{
  outline:2px solid #111827;
  outline-offset:2px;
}

/* Details */
.details-btn{
  background:var(--details-btn);
  border:1px solid var(--details-btn);
  color:#fff;
  padding:8px 12px;
  border-radius:12px;
  font-weight:800;
  white-space:nowrap;
}
.details-btn:hover{
  background:var(--details-btn-hover);
  border-color:var(--details-btn-hover);
  color:var(--text);
  filter:none;
}
.details-btn:active{transform:translateY(1px)}

.details-row td{
  background:var(--details-output-bg);
  border-bottom:1px solid var(--line);
  padding:12px;
}

.details-panel{
  border:1px solid var(--line);
  border-radius:14px;
  overflow:hidden;
  background:#fff;
}
.details-toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 12px;
  background:#eef7ff;
  border-bottom:1px solid var(--line);
}
.details-title{ font-weight:900; font-size:13px; }
.details-hint{ font-size:12px; color:var(--muted); white-space:nowrap; }

.details-grid{
  display:flex;
  flex-direction:column;
  max-height:420px;
  overflow:auto;
}
.detail-item{
  display:grid;
  grid-template-columns: 240px 1fr;
  gap:10px;
  padding:10px 12px;
  border-bottom:1px solid var(--line);
  background:#fff;
}
.detail-item:nth-child(even){ background:#f7fbff; }
.detail-item:last-child{ border-bottom:none; }

.detail-key{
  font-weight:800;
  color:#0f172a;
  background:#eef7ff;
  border:1px solid var(--line);
  border-radius:12px;
  padding:8px 10px;
  align-self:start;
}
.detail-val{
  background:#fff;
  border:1px solid var(--line);
  border-radius:12px;
  padding:8px 10px;
  overflow-wrap:anywhere;
}
.detail-empty{ color:var(--muted); }

/* Mobile: turn table into cards for readability */
@media (max-width: 760px){
  .header-inner{flex-wrap:wrap}
  .menu-toggle{margin-left:auto}
  .menu{order:10}
  .chart-shell{height:360px}

  table{min-width:0}
  thead{display:none}
  tr{display:block;border-bottom:1px solid var(--line)}
  td{
    display:flex;
    gap:10px;
    justify-content:space-between;
    border-bottom:1px dashed var(--line);
  }
  td::before{
    content:attr(data-label);
    font-weight:800;
    color:#0f172a;
    margin-right:10px;
  }
  td:last-child{border-bottom:none}
  .details-row td{
    display:block;
  }
  .detail-item{grid-template-columns:1fr}
  .details-hint{display:none}
}

/* Desktop layout */
@media (min-width: 860px){
  .menu-toggle{display:none}
  .menu{display:flex;margin-left:auto;width:auto;padding:0}
  .controls{grid-template-columns: 1fr 1fr 1fr auto}
  .field-wide{grid-column:1 / -1}
}

.site-footer{
  border-top:1px solid var(--line);
  color:var(--muted);
  font-size:12px;
  text-align:center;
  padding:18px 14px;
  margin-top:18px;
  background:var(--bg);
}
