:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #6a7785;
  --line: #dbe2ea;
  --accent: #1677ff;
  --danger: #c2410c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

a {
  color: var(--accent);
  text-decoration: none;
}

input,
select,
textarea,
button {
  border-radius: 6px;
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
}

textarea {
  min-height: 74px;
  resize: vertical;
}

button,
.link-button {
  border: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
}

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

.login-box {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  display: grid;
  gap: 14px;
}

.login-box h1,
.topbar h1 {
  margin: 0;
  font-size: 28px;
}

.login-box p,
.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.topbar,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0;
}

.stats-grid div,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats-grid div {
  padding: 18px;
}

.stats-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stats-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 14px;
  margin-bottom: 14px;
}

.panel {
  padding: 18px;
  margin-bottom: 14px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.panel form {
  display: grid;
  gap: 10px;
}

.form-row,
.filter-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.filter-form {
  grid-template-columns: minmax(220px, 1fr) 140px auto;
  width: min(640px, 100%);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.check input {
  width: auto;
}

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

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

th,
td {
  border-top: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 650;
}

small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

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

.actions form {
  display: inline;
}

.actions button {
  min-height: 30px;
  padding: 6px 9px;
  background: #eef4ff;
  color: #0958d9;
}

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

.mini-columns h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.metric-line,
.event-line,
.kv {
  margin: 8px 0;
  color: var(--muted);
  line-height: 1.5;
}

.metric-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.metric-line form {
  display: inline-flex;
}

.metric-line button {
  min-height: 30px;
  padding: 6px 9px;
}

.bulkbar {
  display: grid;
  grid-template-columns: 180px auto;
  gap: 10px;
  width: min(340px, 100%);
  margin-bottom: 10px;
}

.row-check {
  width: auto;
}

.compact table {
  font-size: 13px;
}

@media (max-width: 760px) {
  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .stats-grid,
  .panel-grid,
  .mini-columns,
  .form-row,
  .filter-form,
  .bulkbar {
    grid-template-columns: 1fr;
  }
}
