:root {
  --bg: #0f1115;
  --card: #171a21;
  --card2: #1e2230;
  --line: #2a2f3a;
  --fg: #e8eaed;
  --muted: #9aa3b2;
  --accent: #4f8cff;
  --accent2: #35c48a;
  --danger: #ff6b6b;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(15, 17, 21, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 600;
  letter-spacing: 0.5px;
}

.spacer {
  flex: 1;
}

.badge {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--card2);
  color: var(--muted);
  border: 1px solid var(--line);
}

.badge.on {
  color: var(--accent2);
  border-color: rgba(53, 196, 138, 0.4);
}

main {
  padding: 12px;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

h2,
h3 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
}

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

.small {
  font-size: 12px;
}

.field {
  display: block;
  margin-bottom: 10px;
}

.field span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.field.inline {
  margin: 0;
  flex: 1 1 140px;
}

input,
select,
button {
  font: inherit;
  color: var(--fg);
  background: var(--card2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}

input[type="date"] {
  width: auto;
}

select {
  appearance: none;
}

button {
  cursor: pointer;
  width: auto;
  transition: filter 0.15s ease;
}

button:hover {
  filter: brightness(1.15);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button.primary {
  width: 100%;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

button.ghost {
  background: transparent;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.custom {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 220px;
}

.msg {
  min-height: 18px;
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--danger);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.stat .k {
  font-size: 12px;
  color: var(--muted);
}

.stat .v {
  font-size: 20px;
  font-weight: 600;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.stat .v small {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 3px;
}

.chart {
  position: relative;
  height: 240px;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

th,
td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 500;
  position: sticky;
  top: 0;
  background: var(--card);
}

tbody tr:hover {
  background: var(--card2);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 18px;
}
