* { box-sizing: border-box; }

.lookup-header {
  display: grid;
  gap: 7px;
}

.lookup-panel {
  padding: 18px 20px 20px;
  border-bottom: 1px solid rgba(82, 91, 101, 0.72);
  background: var(--panel-2);
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.lookup-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 850;
}

.lookup-field input,
.lookup-field select {
  width: 100%;
  min-height: 42px;
  padding: 11px 12px;
  font-size: 14px;
}

.search-button {
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
  white-space: nowrap;
}

.search-button:disabled {
  cursor: wait;
  opacity: 0.74;
}

.hint-line,
.text-note {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.hint-line {
  margin: 10px 0 0;
}

.message {
  display: none;
  margin-top: 12px;
  border: 1px solid rgba(215, 170, 82, 0.42);
  border-radius: 7px;
  padding: 10px 12px;
  background: rgba(215, 170, 82, 0.08);
  color: #ffe6ad;
  font-size: 12px;
  line-height: 1.45;
}

.message.show { display: block; }

.message.error {
  border-color: rgba(240, 111, 103, 0.55);
  background: rgba(240, 111, 103, 0.09);
  color: #ffd2d2;
}

.page-message {
  margin: 12px 20px 0;
}

.results-shell {
  display: none;
}

.results-shell.show {
  display: block;
}

.summary-band {
  padding: 18px 20px;
  border-bottom: 1px solid rgba(82, 91, 101, 0.72);
  background: #1f252b;
}

.summary-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
}

.identity h2 {
  margin: 0;
  font-size: 27px !important;
  line-height: 1.02 !important;
  overflow-wrap: anywhere;
}

.identity-meta {
  margin-top: 6px;
  color: #b9c0bf;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.45;
}

.status-pill {
  min-width: 96px;
  padding: 7px 10px;
  border: 1px solid rgba(90, 140, 127, 0.52);
  border-radius: 999px;
  background: rgba(90, 140, 127, 0.14);
  color: #d8f1ea;
  text-align: center;
  font-size: 11.5px;
  font-weight: 900;
  text-transform: uppercase;
}

.status-pill.offline {
  border-color: rgba(136, 143, 146, 0.38);
  background: rgba(136, 143, 146, 0.1);
  color: #c1c7c5;
}

.metric-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric,
.lookup-section,
.kv,
.plain-list li,
.inline-row,
.toolbar {
  border: 1px solid rgba(82, 91, 101, 0.72);
  background: #181e24;
}

.metric {
  min-height: 76px;
  padding: 11px 12px;
  border-radius: 7px;
}

.metric-label,
.kv .label {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-value {
  margin-top: 6px;
  color: #f7f2e9;
  font-size: 18px;
  line-height: 1.1;
  font-weight: 900;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.metric-detail {
  margin-top: 5px;
  color: #b9c0bf;
  font-size: 11px;
  line-height: 1.35;
}

.content-grid {
  padding: 18px 20px 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.lookup-section {
  border-radius: 7px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}

.lookup-section.wide {
  grid-column: 1 / -1;
}

.lookup-section h2 {
  margin: 0 !important;
  padding: 10px 12px 9px;
  border-bottom: 1px solid rgba(82, 91, 101, 0.72);
  background: #222930;
  color: #f5ead6 !important;
  font-size: 17px !important;
}

.section-body {
  padding: 12px;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.kv {
  min-height: 58px;
  border-radius: 6px;
  padding: 9px 10px;
}

.kv .value {
  margin-top: 5px;
  color: #f7f2e9;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.plain-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.plain-list li,
.inline-row {
  border-radius: 6px;
  padding: 8px 9px;
  color: #dff2fb;
  font-size: 12px;
  line-height: 1.42;
}

.inline-row strong {
  color: #f7f2e9;
}

.data-table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.data-table.compact {
  min-width: 560px;
}

.data-table th,
.data-table td {
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

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

.data-table th.text-left,
.data-table td.text-left {
  text-align: left;
}

.page-sort-header {
  position: relative;
  padding-right: 24px !important;
  cursor: pointer;
  user-select: none;
}

.page-sort-header::after {
  content: "\2195";
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(215, 170, 82, 0.72);
  font-size: 10px;
  font-weight: 900;
}

.page-sort-header[aria-sort="ascending"]::after {
  content: "\25B2";
  color: #f0c76f;
}

.page-sort-header[aria-sort="descending"]::after {
  content: "\25BC";
  color: #f0c76f;
}

.page-sort-header:focus-visible {
  outline: 2px solid rgba(215, 170, 82, 0.75);
  outline-offset: -3px;
}

.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  margin-top: 10px;
  border: 1px solid rgba(82, 91, 101, 0.58);
  border-radius: 7px;
  padding: 9px;
  background: rgba(19, 24, 29, 0.78);
}

.pagination-status {
  color: #d8e8ef;
  font-size: 12px;
  font-weight: 750;
}

.pagination-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.pagination-button {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 11.5px;
}

.pagination-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pagination-jump,
.pagination-size {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 750;
}

.pagination-jump input,
.pagination-size select {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 11.5px;
}

.pagination-jump input {
  width: 76px;
}

.entity-link {
  color: #f0c76f !important;
  font-weight: 900;
  text-decoration: none;
  border-bottom: 1px solid rgba(215, 170, 82, 0.38);
}

.entity-link:hover {
  color: #fff3cf !important;
  border-bottom-color: rgba(215, 170, 82, 0.82);
}

.guild-head {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  margin-bottom: 11px;
}

.guild-logo {
  width: 64px;
  height: 64px;
  border: 1px solid rgba(82, 91, 101, 0.72);
  border-radius: 7px;
  background: #11161b;
  object-fit: contain;
  padding: 5px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.small-tag {
  padding: 5px 7px;
  border: 1px solid rgba(90, 140, 127, 0.48);
  border-radius: 999px;
  background: rgba(90, 140, 127, 0.13);
  color: #d8f1ea;
  font-size: 11px;
  font-weight: 800;
}

.toolbar {
  margin-bottom: 10px;
  border-radius: 7px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.toolbar .lookup-field input,
.toolbar .lookup-field select {
  min-height: 38px;
  padding: 9px 10px;
  font-size: 12.5px;
}

.ranking-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
  align-items: end;
}

.history-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.85fr);
  gap: 12px;
  align-items: stretch;
}

.chart-card {
  min-height: 250px;
  border: 1px solid rgba(82, 91, 101, 0.72);
  border-radius: 7px;
  padding: 12px;
  background: #151b20;
}

.chart-title {
  color: #f5ead6;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.line-chart {
  width: 100%;
  height: 210px;
  margin-top: 10px;
  display: block;
}

.line-chart .grid-line {
  stroke: rgba(136, 143, 146, 0.28);
  stroke-width: 1;
}

.line-chart .chart-line {
  fill: none;
  stroke: #d7aa52;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-chart .chart-area {
  fill: rgba(215, 170, 82, 0.12);
}

.history-side {
  display: grid;
  gap: 9px;
  align-content: start;
}

.history-table {
  margin-top: 12px;
}

.comment-box {
  max-height: 190px;
  overflow: auto;
  white-space: pre-wrap;
  color: #cfe5f0;
  font-size: 12px;
  line-height: 1.5;
}

.section-loading {
  min-height: 74px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px dashed rgba(215, 170, 82, 0.38);
  border-radius: 7px;
  padding: 12px;
  background: rgba(215, 170, 82, 0.06);
  color: #f4ead7;
}

.section-loading strong {
  display: block;
  font-size: 12.5px;
  line-height: 1.35;
}

.section-loading span:last-child {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}

.loader {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 2px solid rgba(215, 170, 82, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.subheading {
  margin: 13px 0 8px;
  color: #f5ead6;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
}

.source-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.source-grid a {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid rgba(90, 140, 127, 0.48);
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(90, 140, 127, 0.13);
  color: #d8f1ea;
  text-decoration: none;
  font-size: 11.5px;
  font-weight: 850;
}

@media (max-width: 820px) {
  .search-row,
  .summary-top,
  .content-grid,
  .toolbar,
  .ranking-filter-grid,
  .history-layout {
    grid-template-columns: 1fr;
  }

  .metric-grid,
  .kv-grid {
    grid-template-columns: 1fr 1fr;
  }

  .search-button {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .metric-grid,
  .kv-grid {
    grid-template-columns: 1fr;
  }

  .lookup-panel,
  .summary-band,
  .content-grid {
    padding-left: 14px;
    padding-right: 14px;
  }

  .identity h2 {
    font-size: 23px !important;
  }
}
