:root {
  color-scheme: light;
  --ink: #17221d;
  --muted: #6b7770;
  --line: #dfe7e1;
  --paper: #ffffff;
  --canvas: #f3f6f1;
  --green: #176b45;
  --green-soft: #e8f4ed;
  --amber: #b56813;
  --red: #b53a3a;
  --blue: #2f62ae;
  --shadow: 0 16px 45px rgba(29, 52, 40, 0.07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 8% 0%, rgba(231, 241, 219, 0.8), transparent 28rem),
    var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input, select { font: inherit; }

.shell {
  width: min(1600px, calc(100% - 36px));
  margin: 0 auto;
  padding: 36px 0 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 44px); letter-spacing: -0.04em; }
h2 { margin-bottom: 0; font-size: 17px; letter-spacing: -0.01em; }
.subtitle { margin-bottom: 0; color: var(--muted); }

.domain-lock {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid #bcd8c7;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}

.logout-form { display: inline; margin-left: 8px; }
.logout-form button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--green);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.lock-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: #29a46d;
  box-shadow: 0 0 0 4px rgba(41, 164, 109, 0.14);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  box-shadow: var(--shadow);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) repeat(4, minmax(120px, .62fr)) minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
}

.toolbar label,
.pager label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
input[type="search"] {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: #fff;
  color: var(--ink);
}

select:focus,
input[type="search"]:focus {
  border-color: #7eae91;
  box-shadow: 0 0 0 3px rgba(23, 107, 69, 0.1);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.auto-refresh {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  padding-right: 4px;
}

.button,
.pager button {
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.button:hover,
.pager button:hover:not(:disabled) { background: #f7f9f7; }
.button.primary { border-color: var(--green); background: var(--green); color: #fff; }
.button.primary:hover { background: #115b39; }
button:disabled { cursor: not-allowed; opacity: .45; }

.notice {
  margin-top: 14px;
  padding: 12px 15px;
  border: 1px solid #edc9a0;
  border-radius: 12px;
  background: #fff7ec;
  color: #875014;
  font-size: 13px;
}

.notice.error { border-color: #efbbbb; background: #fff1f1; color: #982f2f; }

.cards {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.metric {
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, .86);
}

.metric span,
.metric small { display: block; color: var(--muted); }
.metric span { margin-bottom: 9px; font-size: 12px; font-weight: 700; }
.metric strong { display: block; margin-bottom: 5px; font-size: 26px; letter-spacing: -.04em; }
.metric small { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.analysis-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(420px, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.chart-panel,
.rankings,
.log-panel,
.geo-panel { padding: 18px; }

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.timeline {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 190px;
  padding: 8px 0 24px;
  border-bottom: 1px solid var(--line);
}

.bar {
  position: relative;
  flex: 1 1 0;
  min-width: 2px;
  max-width: 16px;
  border-radius: 4px 4px 1px 1px;
  background: linear-gradient(180deg, #65b587, var(--green));
  opacity: .88;
}

.bar:hover { opacity: 1; filter: saturate(1.25); }

.bar:hover::after {
  content: attr(data-label);
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: calc(100% + 7px);
  transform: translateX(-50%);
  padding: 5px 7px;
  border-radius: 7px;
  background: #15221b;
  color: #fff;
  font-size: 10px;
  white-space: nowrap;
}

.empty { margin: auto; color: var(--muted); font-size: 13px; }

.rankings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.rank-block { min-width: 0; }
.rank-block h2 { margin-bottom: 12px; }
.rank-block ol { margin: 0; padding: 0; list-style: none; }
.rank-block li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid #edf1ee;
  font-size: 12px;
}
.rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-count { color: var(--green); font-weight: 800; }

.geo-panel { margin-bottom: 14px; }
.geo-db-status {
  display: grid;
  gap: 3px;
  justify-items: end;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}
.geo-tables {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.geo-table-block { min-width: 0; }
.geo-table-block h3 {
  margin: 0 0 10px;
  font-size: 14px;
}
.geo-table-wrap { max-height: 430px; }
.geo-table th,
.geo-table td { white-space: nowrap; }
.geo-table td:first-child { min-width: 150px; }
.geo-name { font-weight: 750; }
.geo-code {
  margin-left: 5px;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
}
.geo-share {
  display: inline-block;
  min-width: 42px;
}
.geo-share-bar {
  display: inline-block;
  width: 42px;
  height: 4px;
  margin-left: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ece8;
  vertical-align: middle;
}
.geo-share-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.table-heading { margin-bottom: 13px; }
.pager { display: flex; align-items: end; gap: 8px; }
.pager label { grid-template-columns: auto 74px; align-items: center; }
.pager select { height: 36px; }
.pager button { width: 36px; height: 36px; padding: 0; }
#pageInfo { min-width: 72px; color: var(--muted); text-align: center; font-size: 12px; }

.table-wrap {
  max-height: 640px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th {
  position: sticky;
  z-index: 1;
  top: 0;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: #f8faf8;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
}

td {
  max-width: 420px;
  padding: 10px;
  border-bottom: 1px solid #edf1ee;
  vertical-align: top;
}

tbody tr:hover td { background: #fbfdfb; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 11px; }
.path-link { color: var(--blue); text-decoration: none; }
.path-link:hover { text-decoration: underline; }
.ua-cell { min-width: 220px; color: var(--muted); word-break: break-word; }
.nowrap { white-space: nowrap; }

.status,
.visitor {
  display: inline-flex;
  align-items: center;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}
.s2 { background: #e7f6ed; color: #16704a; }
.s3 { background: #e8effa; color: var(--blue); }
.s4 { background: #fff0e0; color: var(--amber); }
.s5 { background: #fdeaea; color: var(--red); }
.visitor.bot { background: #edf3ff; color: #345e9e; }
.visitor.human { background: #eef1ef; color: #65706a; }
.verify {
  margin-left: 5px;
  padding: 2px 6px;
  border: 1px solid #b8c8bd;
  border-radius: 6px;
  background: #fff;
  color: var(--green);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}
.table-empty { padding: 40px; color: var(--muted); text-align: center; }
.muted { color: var(--muted); font-size: 11px; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 2px 0;
  color: var(--muted);
  font-size: 11px;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 28px 80px rgba(29, 52, 40, .14);
}

.login-card h1 {
  margin-bottom: 10px;
  font-size: 32px;
}

.login-mark {
  float: right;
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
}

.login-form {
  display: grid;
  gap: 15px;
  margin-top: 28px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.login-form input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: #fff;
}

.login-form input:focus {
  border-color: #7eae91;
  box-shadow: 0 0 0 3px rgba(23, 107, 69, .1);
}

.login-form .button { height: 44px; margin-top: 3px; }
.login-error { margin-top: 20px; }
.login-note {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

@media (max-width: 1250px) {
  .toolbar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .toolbar-actions { grid-column: span 3; justify-content: flex-end; }
  .cards { grid-template-columns: repeat(3, 1fr); }
  .analysis-grid { grid-template-columns: 1fr; }
  .geo-tables { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .shell { width: min(100% - 20px, 1600px); padding-top: 22px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .search-field, .toolbar-actions { grid-column: span 2; }
  .toolbar-actions { flex-wrap: wrap; justify-content: flex-start; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .rankings { grid-template-columns: 1fr; }
  .panel-heading.table-heading { align-items: flex-start; flex-direction: column; }
  footer { flex-direction: column; gap: 5px; }
}
