:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --border: #e3e6ea;
  --text: #1c2024;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #1a1d23;
    --border: #2a2e36;
    --text: #e6e8eb;
    --muted: #9aa0aa;
    --primary: #3b82f6;
    --primary-d: #60a5fa;
    --danger: #f87171;
    --success: #4ade80;
    --warn: #fbbf24;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* Header */
.hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem 1.2rem; background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10; box-shadow: var(--shadow);
}
.hdr-left { display: flex; align-items: center; gap: 1.5rem; }
.logo { font-weight: 700; font-size: 1.1rem; }
.nav { display: flex; gap: .3rem; flex-wrap: wrap; }
.nav a {
  padding: .35rem .7rem; border-radius: 6px; color: var(--text); font-size: .92rem;
}
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: var(--primary); color: #fff; }
.hdr-right { display: flex; align-items: center; gap: .8rem; }
.me { color: var(--muted); font-size: .9rem; }
.badge { font-size: .72rem; padding: .1rem .4rem; border-radius: 4px; background: var(--warn); color: #fff; margin-left: .3rem; }

/* Layout */
.container { max-width: 960px; margin: 0 auto; padding: 1.5rem 1.2rem 4rem; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 1.1rem 1.2rem; margin-bottom: 1.2rem; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 .9rem; font-size: 1.1rem; }
.card h3 { margin: 0 0 .6rem; font-size: .98rem; color: var(--muted); font-weight: 600; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 640px) { .grid-2, .grid-4 { grid-template-columns: 1fr 1fr; } }

/* Stat tile */
.stat { background: var(--bg); border-radius: 8px; padding: .8rem .9rem; }
.stat .label { font-size: .78rem; color: var(--muted); }
.stat .value { font-size: 1.25rem; font-weight: 700; margin-top: .15rem; }
.stat .sub { font-size: .78rem; color: var(--muted); }

/* Forms */
form { display: flex; flex-direction: column; gap: .7rem; }
label { font-size: .85rem; color: var(--muted); }
input, select {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 7px;
  background: var(--card); color: var(--text); font-size: .95rem;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.row { display: flex; gap: .7rem; align-items: end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 120px; }
.row > .btn-static { flex: 0 0 auto; }

.btn {
  padding: .55rem 1rem; border: 1px solid var(--border); border-radius: 7px; cursor: pointer;
  background: var(--card); color: var(--text); font-size: .92rem; transition: .15s;
}
.btn:hover { border-color: var(--primary); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-sm { padding: .3rem .6rem; font-size: .82rem; }

/* Table */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .55rem .5rem; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: .8rem; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--success); } .neg { color: var(--danger); }

/* Tabs */
.tabs { display: flex; gap: .3rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tabs button { padding: .5rem .9rem; background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; color: var(--muted); font-size: .92rem; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Misc */
.muted { color: var(--muted); }
.right { text-align: right; }
.hint { font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.error-msg { color: var(--danger); font-size: .88rem; margin-top: .3rem; }
.success-msg { color: var(--success); font-size: .88rem; margin-top: .3rem; }
.search-list {
  border: 1px solid var(--border); border-radius: 7px; background: var(--card); margin-top: .2rem;
  max-height: 200px; overflow: auto; position: relative; z-index: 5;
}
.search-list div { padding: .5rem .7rem; cursor: pointer; font-size: .9rem; }
.search-list div:hover { background: var(--bg); }
.search-list .sy { color: var(--muted); font-size: .8rem; }

/* Toast */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: #1c2024; color: #fff; padding: .7rem 1.2rem; border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.3); z-index: 100; font-size: .9rem; max-width: 90vw;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--success); }

.auth-wrap { max-width: 380px; margin: 4rem auto; }
.mt0 { margin-top: 0; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
