:root {
  --orange: #ff7200;
  --orange-dark: #e65300;
  --admin-sidebar: #2d455b;
  --admin-sidebar-deep: #26394d;
  --admin-accent: #20c49a;
  --admin-bg: #f3f5f7;
  --admin-line: #e1e6eb;
  --text: #222;
  --muted: #667085;
  --line: #cfcfcf;
  --cell: #f7f7f7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 0;
  color: var(--text);
  font-family: "Microsoft YaHei", SimSun, Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

/* Query page, close to bbs.pinggu.org statistics pages */
.site-header {
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.simple-site-header {
  background: transparent;
}

.simple-header-inner {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: min(100% - 32px, 1100px);
  height: 38px;
  margin: 0 auto;
}

.forum-home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 14px;
  border: 1px solid #f2b37d;
  background: #fff;
  color: var(--orange-dark);
  font-weight: 700;
}

.forum-home-link:hover {
  border-color: var(--orange);
  background: #fff7ef;
}

.masthead {
  display: grid;
  grid-template-columns: 180px 1fr 210px;
  align-items: center;
  width: 972px;
  height: 56px;
  margin: 0 auto;
  gap: 18px;
}

.brand {
  display: grid;
  width: 170px;
  height: 48px;
  align-content: center;
  padding-left: 10px;
  border-top: 4px solid var(--orange);
  color: var(--orange);
  line-height: 1.05;
}

.brand strong {
  font-size: 26px;
  font-weight: 700;
}

.brand span {
  color: var(--orange-dark);
  font-size: 13px;
  letter-spacing: 1px;
}

.search-box {
  display: grid;
  grid-template-columns: 1fr 70px;
  height: 34px;
  border: 1px solid #bfbfbf;
}

.search-box input {
  border: 0;
  padding: 0 10px;
  color: #777;
}

.search-box button {
  border: 0;
  border-left: 1px solid #bfbfbf;
  background: #f7f7f7;
  color: #555;
  cursor: pointer;
}

.user-links {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  color: #333;
  font-size: 13px;
}

.orange-nav {
  display: flex;
  width: 972px;
  height: 38px;
  margin: 0 auto;
  background: var(--orange);
}

.orange-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 100px;
  padding: 0 14px;
  border-right: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  font-weight: 700;
}

.orange-nav a.is-active,
.orange-nav a:hover {
  background: var(--orange-dark);
}

.page-shell {
  width: min(100% - 32px, 1100px);
  margin: 0 auto;
}

.preview-shell {
  margin-top: 16px;
  margin-bottom: 28px;
}

.preview-panel {
  min-height: 0;
  padding: 12px 14px 18px;
  border: 1px solid var(--line);
  background: #fff;
}

.preview-panel .section-title {
  height: 40px;
  border-bottom: 1px solid #e6e6e6;
}

.preview-panel .section-title h1 {
  color: #111;
  font-size: 18px;
}

.crumb {
  height: 38px;
  display: flex;
  align-items: center;
  color: #555;
  font-size: 13px;
}

.content-layout {
  display: grid;
  grid-template-columns: 158px 1fr;
  align-items: start;
  border-top: 1px solid var(--line);
}

.side-menu {
  min-height: 530px;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: #eeeeee;
}

.side-menu h2 {
  margin: 0;
  height: 34px;
  padding: 9px 10px 0;
  color: #111;
  font-size: 14px;
}

.side-menu a {
  display: block;
  height: 29px;
  padding: 7px 10px 0;
  border-top: 1px solid #d6d6d6;
  color: #d90000;
  font-size: 13px;
  font-weight: 700;
}

.side-menu a.is-active {
  background: #fff;
  color: var(--orange-dark);
}

.content-panel {
  min-height: 530px;
  padding: 0 0 18px 10px;
  border-right: 1px solid var(--line);
}

.content-panel.preview-panel {
  min-height: 0;
  padding: 12px 14px 18px;
  border: 1px solid var(--line);
  background: #fff;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
}

.section-title h1 {
  margin: 0;
  font-size: 15px;
}

.section-title span {
  color: var(--muted);
  font-size: 13px;
}

.filter-bar {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr 92px;
  gap: 8px;
  align-items: end;
  padding: 8px;
  border: 1px solid var(--line);
  background: #fafafa;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  height: 30px;
  border: 1px solid #bfc7d0;
  padding: 0 7px;
  background: #fff;
  color: var(--text);
}

button {
  height: 30px;
  border: 1px solid var(--orange-dark);
  background: var(--orange);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--orange-dark);
}

.sub-title {
  height: 32px;
  display: flex;
  align-items: center;
  margin-top: 12px;
  font-weight: 700;
}

.chart-frame {
  height: 282px;
  border: 1px solid var(--line);
  background: #fff;
}

.chart-frame svg {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-grid {
  stroke: #e8e8e8;
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke: var(--orange-dark);
  stroke-width: 2.5;
}

.chart-area {
  fill: rgba(255, 114, 0, 0.08);
}

.chart-dot {
  fill: #fff;
  stroke: var(--orange-dark);
  stroke-width: 1.6;
}

.chart-label {
  fill: #777;
  font-size: 12px;
}

.table-scroll {
  max-height: 300px;
  overflow: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-gutter: stable;
}

.data-table,
.admin-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.data-table th,
.data-table td,
.admin-table th,
.admin-table td {
  height: 36px;
  border: 1px solid var(--line);
  padding: 0 8px;
  background: #fff;
  text-align: right;
  word-break: break-word;
}

.data-table th,
.admin-table th {
  background: var(--cell);
  color: #333;
  font-weight: 400;
  text-align: left;
}

.table-scroll .data-table thead th,
.admin-table-wrap .admin-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  box-shadow: 0 1px 0 var(--line);
}

.data-table td:first-child,
.data-table td:nth-child(2),
.admin-table td {
  text-align: left;
}

.empty-row td {
  height: 80px;
  color: var(--muted);
  text-align: center;
}

.extra-metrics {
  margin-top: 14px;
  border: 1px solid var(--line);
  background: #fff;
}

.extra-metrics summary {
  height: 38px;
  padding: 10px 12px 0;
  color: var(--orange-dark);
  cursor: pointer;
  font-weight: 700;
}

.summary-table {
  padding: 0 10px 10px;
}

.compact-table th {
  width: 20%;
}

.compact-table td {
  width: 30%;
  text-align: left;
}

.empty-hint {
  padding: 12px;
  color: var(--muted);
}

.cache-note {
  display: flex;
  align-items: center;
  min-height: 34px;
  margin: 8px 0 0;
  color: #333;
  font-size: 13px;
}

.cache-note::before {
  content: "";
  width: 11px;
  height: 11px;
  margin-right: 7px;
  border-radius: 50%;
  background: #ffd400;
  border: 1px solid #d5ae00;
}

/* Query preview polish */
body:not(.admin-body) {
  background: #f5f6f8;
}

.simple-site-header {
  border-bottom: 0;
  box-shadow: none;
}

.simple-header-inner {
  height: 34px;
}

.forum-home-link {
  height: 28px;
  padding: 0 14px;
  border-color: #f0b27a;
  background: #fff;
  color: var(--orange-dark);
}

.preview-shell {
  width: min(100% - 48px, 1180px);
  margin-top: 10px;
}

.content-panel.preview-panel {
  padding: 18px 20px 22px;
  border-color: #d8dde3;
  background: #fff;
  box-shadow: 0 10px 28px rgba(31, 41, 55, 0.06);
}

.preview-panel .section-title {
  height: 44px;
  border-bottom-color: #e8eaed;
}

.preview-panel .section-title h1 {
  font-size: 20px;
  font-weight: 700;
}

.preview-panel .section-title span {
  min-width: 72px;
  padding: 4px 10px;
  border: 1px solid #e6ebf0;
  background: #f8fafc;
  color: #52616f;
  text-align: center;
}

.query-filter {
  margin-top: 14px;
  padding: 14px;
  border-color: #dde3ea;
  border-top: 3px solid var(--orange);
  background: #fbfcfd;
}

.query-filter .range-presets {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 2px;
}

.range-presets span {
  color: #6b7280;
  font-size: 13px;
}

.range-presets button {
  width: auto;
  height: 28px;
  padding: 0 12px;
  border-color: #d6dde5;
  background: #fff;
  color: #3f4b57;
  font-weight: 400;
}

.range-presets button:hover,
.range-presets button.is-active {
  border-color: var(--orange);
  background: #fff4ea;
  color: var(--orange-dark);
}

.query-filter label {
  color: #4d5d6c;
  font-weight: 700;
}

.query-filter input,
.query-filter select {
  height: 36px;
  border-color: #cbd5df;
  background: #fff;
}

.date-input {
  font-variant-numeric: tabular-nums;
}

.query-filter button {
  height: 36px;
}

.sub-title {
  height: 38px;
  margin-top: 16px;
  color: #1f2933;
  font-size: 16px;
}

.chart-frame {
  height: 300px;
  border-color: #dce1e6;
  background: linear-gradient(180deg, #fff, #fffaf6);
}

.table-scroll {
  border: 1px solid #d8dde3;
  border-bottom: 1px solid #d8dde3;
  background: #fff;
}

.uv-table-scroll {
  max-height: 842px;
}

.data-table th,
.data-table td {
  height: 40px;
  border-color: #d8dde3;
  padding: 0 10px;
}

.data-table th {
  height: 42px;
  background: #f4f6f8;
  color: #2f3b45;
  font-weight: 700;
}

.data-table tbody tr:nth-child(even) td {
  background: #fcfcfd;
}

.data-table tbody tr:hover td {
  background: #fff8f0;
}

.extra-metrics {
  border-color: #d8dde3;
}

.extra-metrics summary {
  height: 42px;
  padding-top: 12px;
  background: #fff;
}

.cache-note {
  min-height: 38px;
  margin-top: 12px;
  padding: 0 2px;
  color: #4b5563;
}

.metric-up {
  color: #d9480f;
  font-weight: 700;
}

.metric-down {
  color: #16794c;
  font-weight: 700;
}

.metric-flat {
  color: #667085;
}

/* Login page */
.login-body {
  min-height: 100vh;
  background: #f5f6f8;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.login-card {
  width: min(100%, 420px);
  padding: 26px 28px 28px;
  border: 1px solid #d8dde3;
  border-top: 4px solid var(--orange);
  background: #fff;
  box-shadow: 0 18px 42px rgba(31, 41, 55, 0.08);
}

.login-forum-link {
  display: inline-flex;
  height: 28px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid #f0b27a;
  color: var(--orange-dark);
  font-weight: 700;
}

.login-title {
  margin-top: 22px;
}

.login-title span {
  color: var(--orange-dark);
  font-weight: 700;
}

.login-title h1 {
  margin: 8px 0 8px;
  color: #111;
  font-size: 22px;
}

.login-title p {
  margin: 0;
  color: #667085;
  line-height: 1.8;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.login-form input {
  height: 40px;
}

.login-form button {
  height: 40px;
}

.login-message {
  min-height: 22px;
  color: #667085;
}

/* Admin page: dark left/right management layout */
.admin-body {
  min-width: 1180px;
  background: var(--admin-bg);
}

.admin-shell {
  min-height: 100vh;
}

.admin-sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  width: 262px;
  overflow-y: auto;
  background: var(--admin-sidebar);
  color: #d8e7f5;
}

.admin-brand {
  display: grid;
  align-content: center;
  height: 46px;
  padding: 0 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  background: var(--admin-sidebar-deep);
}

.admin-brand strong {
  color: #fff;
  font-size: 18px;
}

.admin-brand span {
  color: #b9ccdc;
  font-size: 12px;
}

.admin-nav {
  padding-bottom: 40px;
}

.nav-group-title {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(90deg, rgba(32, 196, 154, 0.9), rgba(32, 196, 154, 0));
  color: #fff;
  font-weight: 700;
}

.admin-nav a {
  display: flex;
  align-items: center;
  height: 34px;
  padding: 0 24px 0 32px;
  color: #c9d9e8;
  font-weight: 700;
}

.admin-nav a::before {
  content: "";
  width: 10px;
  height: 10px;
  margin-right: 10px;
  border-radius: 50%;
  background: #516a80;
}

.admin-nav a.is-active,
.admin-nav a:hover {
  color: #fff;
  background: rgba(0, 0, 0, 0.12);
}

.admin-main {
  min-width: 0;
  margin-left: 262px;
}

.admin-topbar {
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  border-bottom: 1px solid var(--admin-line);
  background: #fff;
}

.hamburger {
  width: 30px;
  height: 22px;
  border: 0;
  border-top: 4px solid #5d7690;
  border-bottom: 4px solid #5d7690;
  background: transparent;
}

.hamburger::before {
  content: "";
  display: block;
  height: 4px;
  margin-top: 5px;
  background: #5d7690;
}

.admin-user {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #333;
}

.topbar-text-button {
  width: auto;
  height: 26px;
  padding: 0 10px;
  border-color: #c8d2dc;
  background: #fff;
  color: #2f536f;
  font-weight: 400;
}

.topbar-text-button:hover {
  background: #eef7fb;
}

.admin-content {
  padding: 16px 24px 42px;
}

.admin-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 62px;
  border-bottom: 1px solid var(--admin-line);
}

.admin-page-head h1 {
  margin: 0;
  color: #486989;
  font-size: 22px;
  font-weight: 400;
}

.head-actions {
  display: flex;
  gap: 6px;
}

.head-actions select {
  width: 220px;
}

.admin-card {
  margin-top: 18px;
  border: 1px solid var(--admin-line);
  background: #fff;
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid var(--admin-line);
}

.card-title h2 {
  margin: 0;
  color: #4e6f90;
  font-size: 16px;
  font-weight: 400;
}

.card-title span {
  color: var(--muted);
  font-size: 13px;
}

.admin-form {
  display: grid;
  gap: 10px;
  align-items: end;
  padding: 14px 16px;
}

.admin-form.five-col {
  grid-template-columns: 1.3fr 0.9fr 0.9fr 0.9fr 0.9fr 96px;
}

.admin-form.four-col {
  grid-template-columns: 1.3fr 0.9fr 0.9fr 1.4fr;
}

.account-form {
  grid-template-columns: repeat(4, minmax(0, 1fr)) 110px;
}

.admin-form button,
.manual-form > button,
.head-actions button {
  border-color: #39a9d6;
  background: #45bde8;
}

.admin-form button:hover,
.manual-form > button:hover,
.head-actions button:hover {
  background: #279dca;
}

.file-field {
  grid-column: span 2;
}

.result-line {
  min-height: 42px;
  margin: 0 16px 16px;
  padding: 12px;
  border: 1px solid #e5edf4;
  background: #fbfcfd;
  color: #4b5563;
}

.sync-note {
  margin: 0 16px 10px;
  padding: 10px 12px;
  border: 1px solid #e7edf3;
  background: #fffdf8;
  color: #5c6470;
  font-size: 13px;
}

.import-guide {
  margin: 0 16px 12px;
  border: 1px solid #dfe7ef;
  background: #fbfcfd;
}

.import-guide-head {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border-bottom: 1px solid #e5edf4;
}

.import-guide-head strong {
  display: block;
  color: #2f536f;
  font-size: 15px;
}

.import-guide-head span,
.template-note {
  color: var(--muted);
  font-size: 13px;
}

.secondary-button {
  width: auto;
  min-width: 116px;
  padding: 0 12px;
  border-color: #c8d2dc;
  background: #fff;
  color: #2f536f;
}

.secondary-button:hover {
  background: #eef7fb;
}

.template-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.template-table th,
.template-table td {
  border: 1px solid #e0e6ec;
  padding: 8px 10px;
  background: #fff;
  text-align: left;
  vertical-align: top;
}

.template-table th {
  background: #f2f6f9;
  color: #33485f;
  font-weight: 700;
}

.template-table th:nth-child(1) {
  width: 22%;
}

.template-table th:nth-child(2) {
  width: 12%;
}

.template-table th:nth-child(3) {
  width: 18%;
}

.template-note {
  padding: 10px 12px;
  border-top: 1px solid #e5edf4;
}

.manual-form {
  display: grid;
  gap: 12px;
  padding-bottom: 16px;
}

.compact-form {
  padding-bottom: 0;
}

.metric-editor-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 0 16px;
}

.manual-form > button {
  width: 110px;
  margin-left: 16px;
}

.admin-table-wrap {
  margin: 0 16px 16px;
  max-height: 280px;
  overflow: auto;
}

.text-action {
  width: 54px;
  height: 24px;
  border: 1px solid #d0d0d0;
  background: #fff;
  color: #d90000;
  font-weight: 400;
}

.text-action:hover {
  background: #fff7f7;
}

.toast {
  position: fixed;
  top: 76px;
  left: 50%;
  z-index: 1000;
  width: max-content;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 14px;
  border: 1px solid #279dca;
  background: #45bde8;
  color: #fff;
  text-align: center;
  white-space: normal;
  box-shadow: 0 10px 28px rgba(39, 157, 202, 0.24);
  opacity: 0;
  transform: translate(-50%, -8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

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

@media (max-width: 1180px) {
  body,
  .admin-body {
    min-width: 0;
  }

  .admin-shell {
    min-height: 100vh;
  }

  .admin-sidebar {
    width: 220px;
  }

  .admin-main {
    margin-left: 220px;
  }

  .masthead,
  .orange-nav,
  .simple-header-inner,
  .page-shell {
    width: 100%;
  }

  .content-layout,
  .filter-bar,
  .admin-form.five-col,
  .admin-form.four-col,
  .metric-editor-grid {
    grid-template-columns: 1fr;
  }

  .content-panel {
    padding: 0 8px 18px;
  }
}
