:root {
  --bg: #0b0b0c;
  --bg-2: #0f1114;
  --panel: #121419;
  --panel-2: #171a21;
  --panel-3: #1b2028;
  --line: rgba(255,255,255,0.08);
  --line-soft: rgba(255,255,255,0.05);
  --text: #f4f5f7;
  --muted: #99a0ae;
  --muted-2: #7c8391;
  --blue: #2c77ff;
  --blue-hover: #4387ff;
  --green: #20c45a;
  --gold: #d7a93c;
  --danger: #ff7373;
  --radius: 20px;
  --shadow: 0 18px 45px rgba(0,0,0,.35);
  --shadow-soft: 0 8px 28px rgba(0,0,0,.2);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: radial-gradient(circle at top, rgba(44, 119, 255, 0.1), transparent 22%), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.shell {
  min-height: 100vh;
  padding-bottom: 120px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(11, 11, 12, 0.88);
  backdrop-filter: blur(16px);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-image {
  display: block;
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.logo-badge {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(215,169,60,.16), rgba(215,169,60,.36));
  border: 1px solid rgba(215,169,60,.44);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 6px 18px rgba(215,169,60,.12);
  position: relative;
}

.logo-badge::before,
.logo-badge::after {
  content: "";
  position: absolute;
  background: var(--gold);
  border-radius: 50px;
}

.logo-badge::before { width: 14px; height: 2px; top: 17px; left: 11px; }
.logo-badge::after { width: 2px; height: 14px; top: 11px; left: 17px; }

.user-chip,
.balance-chip {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 10px 14px;
  color: var(--text);
  box-shadow: var(--shadow-soft);
}

.balance-chip { font-weight: 700; }
.user-chip { color: var(--muted); }

.page-center {
  max-width: 1180px;
  margin: 0 auto;
  padding: 42px 24px 0;
}

.page-center-home { max-width: 1120px; }
.admin-center { max-width: 1320px; }

.search-hero {
  max-width: 820px;
  margin: 9vh auto 42px;
}

.search-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
}

.search-input-wrap { position: relative; }
.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 18px;
}

.search-input,
.secondary-input,
.limit-input,
select.secondary-input {
  width: 100%;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.07);
  outline: none;
  color: var(--text);
  background: #14171d;
  transition: .16s ease;
}

.search-input {
  min-height: 64px;
  padding: 19px 18px 19px 50px;
}

.secondary-input,
.limit-input,
select.secondary-input {
  min-height: 50px;
  padding: 14px 16px;
}

.search-input:focus,
.secondary-input:focus,
.limit-input:focus,
select.secondary-input:focus {
  border-color: rgba(44,119,255,.66);
  box-shadow: 0 0 0 4px rgba(44,119,255,.12);
}

.primary-btn,
.ghost-btn {
  border: 0;
  border-radius: 18px;
  font-weight: 700;
}

.sauron-btn {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 10px 28px rgba(255, 115, 115, .3);
}

.sauron-btn:hover {
  background: #ff8b8b;
}

.sauron-btn:disabled {
  opacity: .75;
  cursor: not-allowed;
}

.primary-btn {
  min-height: 64px;
  padding: 0 24px;
  background: var(--blue);
  color: white;
  box-shadow: 0 10px 28px rgba(44,119,255,.25);
}
.primary-btn:hover { background: var(--blue-hover); }
.primary-btn:disabled { opacity: .75; cursor: not-allowed; }

.small-btn {
  min-height: 48px;
  padding: 0 18px;
}

.ghost-btn {
  min-height: 50px;
  padding: 0 18px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.controls-row {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.controls-row-home {
  grid-template-columns: 1fr 140px;
}

.controls-row-home-single {
  grid-template-columns: 1fr;
}

.helper-box {
  min-height: 50px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  align-items: center;
  padding: 0 16px;
  color: var(--muted);
}

.helper-text,
.status-line,
.error-line,
.small-meta,
.empty-note {
  font-size: 13px;
  color: var(--muted);
}

.helper-text { margin: 14px 4px 0; }
.error-line { color: var(--danger); }

.section-card,
.data-card {
  border-radius: 24px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.018), rgba(255,255,255,.008));
  box-shadow: var(--shadow);
}

.section-card { padding: 22px; }
.data-card { padding: 20px; }

.section-title {
  margin: 0 0 8px;
  font-size: 22px;
}

.section-subtitle {
  margin: 0;
  color: var(--muted);
}

.history-list {
  margin-top: 18px;
}

.history-item {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
}

.history-item:last-child { border-bottom: 0; }

.icon-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--panel-3);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.history-main {
  font-weight: 600;
  line-height: 1.45;
}

.history-meta {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.history-open {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.empty-box {
  border: 1px dashed var(--line);
  border-radius: 18px;
  padding: 18px;
  color: var(--muted);
  background: rgba(255,255,255,.015);
}

.floating-nav {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 40;
  display: grid;
  grid-auto-flow: column;
  gap: 8px;
  padding: 10px;
  border-radius: 22px;
  background: rgba(24, 27, 34, .76);
  border: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.floating-nav-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.nav-btn {
  min-width: 92px;
  border-radius: 16px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.nav-btn.active,
.nav-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,.05);
}

.nav-icon { font-size: 18px; }

.shell-report {
  padding-left: 0;
}

.sidebar-fixed {
  position: fixed;
  top: 78px;
  left: 0;
  bottom: 0;
  width: 260px;
  padding: 26px 20px 120px;
  border-right: 1px solid var(--line-soft);
  background: rgba(11, 11, 12, 0.92);
  backdrop-filter: blur(16px);
  overflow-y: auto;
}

.sidebar-title {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.sidebar-nav {
  display: grid;
  gap: 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 14px;
  padding: 12px 12px;
  color: var(--muted);
  border: 1px solid transparent;
}

.sidebar-link:hover,
.sidebar-link.active {
  color: var(--text);
  background: var(--panel);
  border-color: var(--line);
}

.sidebar-status {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255,255,255,.22);
}

.sidebar-link.active .sidebar-status { background: var(--green); }

.report-main {
  margin-left: 260px;
  padding: 28px 24px 0;
}

.content-wide {
  max-width: none;
}

.report-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.report-query {
  margin: 0 0 10px;
  font-size: 32px;
  line-height: 1.2;
}

.top-search-compact {
  display: grid;
  grid-template-columns: minmax(260px, 420px) auto;
  gap: 12px;
  align-items: stretch;
}

.summary-grid,
.sections-grid {
  display: grid;
  gap: 16px;
}

.summary-grid {
  margin-top: 18px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
}

.summary-column {
  display: grid;
  gap: 16px;
  align-content: start;
}

.sections-grid {
  margin-top: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }

.summary-item {
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 16px;
}

.summary-head,
.raw-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.summary-label,
.data-card h3 {
  font-weight: 700;
}

.data-card h3 {
  margin: 0 0 14px;
}

.check-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  background: var(--green);
  font-size: 13px;
}

.value-list {
  display: grid;
  gap: 8px;
  color: var(--muted);
  word-break: break-word;
}

.value-chip {
  min-width: 0;
}

.key-value-list {
  display: grid;
  gap: 10px;
}

.key-row {
  display: grid;
  grid-template-columns: minmax(130px, 220px) 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}

.key-row:last-child { border-bottom: 0; }
.key-name { color: var(--muted); }
.key-value { color: var(--text); word-break: break-word; }

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge,
.state-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--panel-3);
}

.state-pill.ok {
  color: #c8ffd9;
  background: rgba(32,196,90,.12);
  border-color: rgba(32,196,90,.22);
}

.state-pill.muted {
  color: var(--muted);
}

.raw-item {
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 16px;
  margin-bottom: 14px;
}

.auth-shell {
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(460px, 100%);
  border-radius: 28px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.022), rgba(255,255,255,.01));
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-logo { margin-bottom: 24px; }
.auth-title { font-size: 28px; font-weight: 800; }
.auth-subtitle { color: var(--muted); margin-top: 6px; }
.auth-form,
.stack-form {
  display: grid;
  gap: 12px;
}
.field-label { color: var(--muted); font-size: 13px; }
.auth-btn { margin-top: 8px; }
.auth-hint { margin-top: 18px; }

.table-wrap {
  overflow: auto;
  border-radius: 16px;
  border: 1px solid var(--line);
}

.table-grid {
  width: 100%;
  border-collapse: collapse;
  min-width: 740px;
}

.table-grid th,
.table-grid td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.table-grid th {
  color: var(--muted);
  font-weight: 600;
  background: rgba(255,255,255,.02);
}

@media (max-width: 1100px) {
  .sidebar-fixed {
    position: static;
    width: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
    padding-bottom: 20px;
  }

  .report-main {
    margin-left: 0;
    padding-top: 20px;
  }

  .shell-report {
    padding-bottom: 150px;
  }
}

@media (max-width: 1279px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .search-bar,
  .top-search-compact,
  .controls-row-home,
  .report-header,
  .sections-grid,
  .admin-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .report-header {
    display: grid;
  }

  .topbar,
  .topbar-right {
    flex-wrap: wrap;
  }

  .span-2,
  .span-3 { grid-column: auto; }

  .floating-nav {
    width: calc(100% - 24px);
    grid-template-columns: repeat(5, 1fr);
    transform: translateX(-50%);
  }

  .nav-btn { min-width: 0; }
}

@media (max-width: 640px) {
  .page-center,
  .report-main { padding-left: 14px; padding-right: 14px; }
  .topbar { padding-left: 14px; padding-right: 14px; }
  .section-card,
  .data-card,
  .auth-card { padding: 16px; }
  .history-item { grid-template-columns: 44px 1fr; }
  .history-open { grid-column: 2; justify-self: start; }
}

/* v4 overrides */
.sidebar-fixed {
  width: 220px;
  padding: 20px 14px 120px;
}

.report-main {
  margin-left: 220px;
  padding: 24px 18px 0;
}

.report-wide {
  max-width: none;
}

.report-header-wide {
  gap: 24px;
}

.top-search-wide {
  grid-template-columns: minmax(640px, 920px) auto;
}

.report-search-input {
  min-width: 0;
}

.sidebar-count {
  margin-left: 6px;
  color: var(--muted-2);
  font-size: 12px;
}

.source-sections {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.source-card {
  overflow: hidden;
}

.source-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.source-head h3 {
  margin: 0;
}

.source-records {
  display: grid;
  gap: 12px;
}

.summary-item-inline {
  justify-self: start;
  width: fit-content;
  max-width: 100%;
}

.single-line-list {
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
}

.single-line-list > div {
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

.toast-notice {
  position: fixed;
  left: 50%;
  top: 28px;
  z-index: 80;
  transform: translate(-50%, -16px);
  opacity: 0;
  border-radius: 16px;
  padding: 14px 18px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(18, 20, 25, .96);
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform .25s ease, opacity .25s ease;
}

.toast-notice.visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (max-width: 1240px) {
  .top-search-wide {
    grid-template-columns: minmax(320px, 1fr) auto;
  }
}

@media (max-width: 1100px) {
  .report-main {
    margin-left: 0;
  }
}

.logo-image {
  width: 40px;
  height: 40px;
  object-fit: contain;
  display: block;
}


.mode-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.mode-chip {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.02);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform .14s ease, border-color .14s ease, background .14s ease, color .14s ease;
}

.mode-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.18);
  color: var(--text);
}

.mode-chip.active {
  background: rgba(111, 180, 255, .12);
  border-color: rgba(111, 180, 255, .34);
  color: var(--text);
}

.mode-icon {
  width: 20px;
  text-align: center;
}

.summary-item-accent {
  background: linear-gradient(180deg, rgba(255,255,255,.03), rgba(111,180,255,.04));
}

.value-chip-compact {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
