:root {
  --ink: #16221d;
  --muted: #6e7b75;
  --line: #dce3de;
  --paper: #f4f6f2;
  --panel: #ffffff;
  --green: #176b4d;
  --green-dark: #0e4f38;
  --green-soft: #e4f2ea;
  --amber: #d7a13d;
  --shadow: 0 14px 40px rgba(24, 43, 34, .08);
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% -10%, rgba(215, 161, 61, .12), transparent 28rem),
    var(--paper);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button, input, select { font: inherit; }

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  height: 76px;
  padding: 0 max(24px, calc((100vw - 1440px) / 2));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid rgba(22, 34, 29, .09);
  background: rgba(250, 251, 248, .9);
  backdrop-filter: blur(16px);
}

.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; width: fit-content; }
.brand strong { display: block; font-size: 15px; letter-spacing: .02em; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; letter-spacing: .18em; }

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px 16px 16px 5px;
  color: #fff;
  background: var(--green);
  box-shadow: 0 10px 24px rgba(23, 107, 77, .22);
  font: 700 24px Georgia, serif;
}
.brand-mark.small { width: 39px; height: 39px; border-radius: 12px 12px 12px 4px; font-size: 18px; }

.main-nav { display: flex; height: 100%; gap: 28px; align-items: center; }
.main-nav a { position: relative; color: var(--muted); font-size: 14px; font-weight: 650; text-decoration: none; }
.main-nav a.active { color: var(--ink); }
.main-nav a.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -27px; height: 2px; background: var(--green); }
.topbar form { justify-self: end; }
.logout-button { padding: 8px 14px; color: var(--muted); border: 1px solid var(--line); border-radius: 9px; background: transparent; cursor: pointer; }
.logout-button:hover { color: var(--ink); border-color: #b5c0b9; }

.page-shell { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: 48px 0 70px; }
.hero-row { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 30px; }
.eyebrow { margin: 0 0 10px; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .22em; }
.hero-row h1 { margin: 0; font: 500 clamp(30px, 4vw, 46px)/1.08 Georgia, "Noto Serif SC", serif; letter-spacing: -.025em; }
.hero-row p:not(.eyebrow) { max-width: 700px; margin: 12px 0 0; color: var(--muted); font-size: 14px; }
.live-pill { flex: none; display: flex; align-items: center; gap: 8px; padding: 9px 13px; color: var(--green-dark); border: 1px solid #c7ddd1; border-radius: 99px; background: rgba(255, 255, 255, .65); font-size: 12px; font-weight: 650; }
.live-pill span { width: 7px; height: 7px; border-radius: 50%; background: #36a772; box-shadow: 0 0 0 4px rgba(54, 167, 114, .12); }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stats-grid article { min-height: 132px; padding: 22px 24px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, .74); }
.stats-grid span, .stats-grid small { display: block; color: var(--muted); font-size: 11px; }
.stats-grid strong { display: block; margin: 9px 0 4px; font: 500 31px/1 Georgia, serif; }

.panel { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); }
.filter-panel { margin-bottom: 16px; padding: 19px 20px; box-shadow: none; }
.filter-form { display: grid; grid-template-columns: minmax(240px, 1.45fr) repeat(4, minmax(130px, 1fr)) auto; gap: 12px; align-items: end; }
.filter-form label { min-width: 0; }
.filter-form label > span { display: block; margin: 0 0 7px 2px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .06em; }
.filter-form input, .filter-form select { width: 100%; height: 40px; padding: 0 11px; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; outline: none; background: #fafbf9; font-size: 12px; }
.filter-form input:focus, .filter-form select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 107, 77, .1); }
.filter-actions { height: 40px; display: flex; align-items: center; gap: 12px; }
.filter-actions a { color: var(--muted); font-size: 12px; text-decoration: none; }

.primary-button { width: 100%; height: 46px; display: flex; align-items: center; justify-content: space-between; padding: 0 17px; color: #fff; border: 0; border-radius: 9px; background: var(--green); font-weight: 700; cursor: pointer; }
.primary-button:hover { background: var(--green-dark); }
.primary-button.compact { width: auto; height: 40px; justify-content: center; padding: 0 20px; font-size: 12px; }

.data-panel { overflow: hidden; }
.panel-heading { min-height: 84px; padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0 0 5px; font-size: 15px; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.view-badge { padding: 6px 9px; color: var(--green-dark); border: 1px solid #c9dfd3; border-radius: 6px; background: var(--green-soft); font-size: 9px; font-weight: 800; letter-spacing: .13em; }

.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 1040px; border-collapse: collapse; table-layout: fixed; }
th { padding: 12px 14px; color: #78847e; border-bottom: 1px solid var(--line); background: #f9faf8; font-size: 10px; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
td { padding: 14px; border-bottom: 1px solid #edf0ed; font-size: 12px; vertical-align: middle; }
tbody tr:hover { background: #fafcf9; }
tbody tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { padding-left: 24px; }
th:last-child, td:last-child { padding-right: 24px; }
.referer-cell { width: 34%; }
.referer-link { display: block; overflow: hidden; color: var(--green-dark); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
a.referer-link:hover { text-decoration: underline; }
.host-chip { display: inline-block; max-width: 100%; padding: 4px 7px; overflow: hidden; color: #3e4c45; border: 1px solid #dbe3de; border-radius: 6px; background: #f6f8f5; font: 10px ui-monospace, SFMono-Regular, Consolas, monospace; text-overflow: ellipsis; white-space: nowrap; }
.number-cell { text-align: right; }
.time-cell { color: #55625c; font: 10px ui-monospace, SFMono-Regular, Consolas, monospace; white-space: nowrap; }
.mono-cell { color: #55625c; font: 11px ui-monospace, SFMono-Regular, Consolas, monospace; }
.cell-subtitle { display: block; max-width: 170px; margin-top: 4px; overflow: hidden; color: #96a099; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }

.empty-state { min-height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); }
.empty-state strong { margin-bottom: 6px; color: var(--ink); font: 500 20px Georgia, serif; }
.empty-state span { font-size: 12px; }
.pagination { min-height: 64px; padding: 0 24px; display: flex; align-items: center; justify-content: flex-end; gap: 20px; border-top: 1px solid var(--line); font-size: 11px; }
.pagination a { padding: 8px 11px; border: 1px solid var(--line); border-radius: 7px; text-decoration: none; }
.pagination a.disabled { pointer-events: none; opacity: .38; }
.pagination span { color: var(--muted); }

.login-body { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 20% 10%, rgba(215, 161, 61, .18), transparent 32rem), #eaf0eb; }
.login-shell { width: min(430px, calc(100% - 36px)); }
.login-card { padding: 46px; border: 1px solid rgba(255, 255, 255, .8); border-radius: 22px; background: rgba(255, 255, 255, .88); box-shadow: 0 30px 80px rgba(23, 63, 45, .16); backdrop-filter: blur(14px); }
.login-card .brand-mark { margin-bottom: 32px; }
.login-card h1 { margin: 0; font: 500 33px/1.1 Georgia, "Noto Serif SC", serif; }
.login-lead { margin: 12px 0 27px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.login-form { display: grid; gap: 16px; }
.login-form label { color: var(--muted); font-size: 11px; font-weight: 650; }
.login-form input { width: 100%; height: 44px; margin-top: 7px; padding: 0 13px; border: 1px solid var(--line); border-radius: 9px; outline: none; background: #fafbf9; }
.login-form input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 107, 77, .1); }
.login-form button { margin-top: 7px; }
.alert { margin: -5px 0 20px; padding: 11px 12px; color: #833e2e; border: 1px solid #ebcec3; border-radius: 8px; background: #fff2ed; font-size: 12px; line-height: 1.5; }

@media (max-width: 1180px) {
  .filter-form { grid-template-columns: repeat(3, 1fr); }
  .filter-actions { justify-content: flex-end; }
}

@media (max-width: 760px) {
  .topbar { height: auto; min-height: 70px; padding: 10px 16px; grid-template-columns: 1fr auto; }
  .brand small, .topbar form { display: none; }
  .main-nav { grid-column: 1 / -1; grid-row: 2; height: 34px; justify-content: stretch; gap: 4px; }
  .main-nav a { flex: 1; padding: 8px; border-radius: 7px; background: #edf1ed; text-align: center; }
  .main-nav a.active { color: #fff; background: var(--green); }
  .main-nav a.active::after { display: none; }
  .page-shell { width: min(100% - 24px, 1440px); padding-top: 30px; }
  .hero-row { align-items: start; flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid article { min-height: 112px; padding: 18px; }
  .filter-form { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .filter-actions { grid-column: 1 / -1; }
  .login-card { padding: 34px 28px; }
}

@media (max-width: 430px) {
  .stats-grid { grid-template-columns: 1fr; }
  .filter-form { grid-template-columns: 1fr; }
  .search-field, .filter-actions { grid-column: auto; }
  .filter-actions { justify-content: stretch; }
  .filter-actions .primary-button { flex: 1; }
}
