:root {
  --bg: #f4f6f9; --card: #fff; --text: #1f2937; --muted: #6b7280; --line: #e5e7eb;
  --primary: #2563eb; --primary-dark: #1d4ed8; --danger: #dc2626; --ok: #16a34a;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.topbar { background: #111827; color: #fff; }
.topbar .wrap { display: flex; align-items: center; gap: 24px; height: 52px; }
.brand { color: #fff; font-weight: 600; font-size: 16px; white-space: nowrap; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: #cbd5e1; padding: 6px 12px; border-radius: 6px; }
.nav a.active, .nav a:hover { background: #1f2937; color: #fff; text-decoration: none; }
.userbox { display: flex; align-items: center; gap: 12px; color: #cbd5e1; }
.userbox a { color: #cbd5e1; }
.uname small { margin-left: 4px; background: #2563eb; color: #fff; padding: 1px 6px; border-radius: 10px; font-size: 11px; }
.foot { text-align: center; color: var(--muted); padding: 24px; font-size: 12px; }
main.wrap { padding: 20px 16px 40px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin-bottom: 18px; }
.card.narrow { max-width: 420px; margin: 40px auto; }
.card.narrow-lg { max-width: 720px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 14px; color: var(--muted); margin: 8px 0; }
.muted { color: var(--muted); }
.r { text-align: right; }
.right { float: right; }
.crumbs { color: var(--muted); margin: 0 0 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } .topbar .wrap { gap: 10px; } .nav a { padding: 6px 8px; } }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash.ok { background: #dcfce7; color: #166534; }
.flash.bad { background: #fee2e2; color: #991b1b; }

.stat-row { display: flex; gap: 18px; margin-bottom: 18px; }
.stat { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; text-align: center; }
.stat .num { font-size: 28px; font-weight: 600; color: var(--primary); }
.stat .lbl { color: var(--muted); }

.form label { display: block; margin-bottom: 12px; font-weight: 500; }
.form label em { color: var(--danger); font-style: normal; }
.form input:not([type=checkbox]):not([type=radio]), .form select, .form textarea {
  display: block; width: 100%; margin-top: 4px; padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 6px; font: inherit; background: #fff;
}
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
.form label.chk { display: inline-flex; align-items: center; gap: 6px; font-weight: normal; margin-right: 14px; }
.form.inline-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.form.inline-form label { margin: 0; min-width: 160px; flex: 1; }
.form.inline-form .perm-box, .form.inline-form .btn { flex: 0 0 auto; }
.form.compact label { margin-bottom: 8px; }
.form.compact input, .form.compact select, .form.compact textarea { padding: 5px 8px; }
.filter-form label { min-width: 140px; flex: 0 1 200px; }
.filter-form .spacer { flex: 1; }
.perm-box { display: flex; flex-wrap: wrap; gap: 4px 0; margin: 6px 0; }
.row-title { font-weight: 600; margin: 8px 0 6px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.btn { display: inline-block; padding: 7px 14px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; color: var(--text); cursor: pointer; font: inherit; line-height: 1.3; }
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--danger); border-color: #fca5a5; }
.btn.danger:hover { background: #fee2e2; }
.btn.small { padding: 3px 9px; font-size: 13px; }
.btn[disabled] { opacity: .4; cursor: default; }
button.link { background: none; border: none; color: #cbd5e1; cursor: pointer; font: inherit; padding: 0; }
button.link:hover { text-decoration: underline; }
form.inline, .inline { display: inline-block; margin: 0; }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
.tbl tr:hover td { background: #f9fafb; }
.tbl tr.dim td { opacity: .55; }
.tbl.small th, .tbl.small td { padding: 5px 8px; font-size: 13px; }
.tbl.kv th { width: 140px; text-align: right; }
.tbl-scroll { overflow-x: auto; }
.tbl .actions { white-space: nowrap; }
.tbl .actions form, .tbl .actions .btn { margin-right: 4px; }
.pre { white-space: pre-wrap; margin: 0; font: inherit; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; background: #e0e7ff; color: #3730a3; font-size: 12px; margin-right: 4px; }
.tag.on { background: #dcfce7; color: #166534; }
.tag.off { background: #f3f4f6; color: #9ca3af; text-decoration: line-through; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 12px; }

details.dropdown { position: relative; }
details.dropdown summary { list-style: none; }
details.dropdown summary::-webkit-details-marker { display: none; }
details.dropdown .panel { position: absolute; right: 0; z-index: 10; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 12px 14px; min-width: 280px; margin-top: 4px; text-align: left; white-space: normal; }
details.dropdown .panel.wide { min-width: 340px; }
.numeric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 14px; }
.numeric-card { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.numeric-card .name { font-weight: 600; margin-bottom: 4px; }
.numeric-card .big { font-size: 22px; color: var(--primary); }
.chart-box { min-height: 260px; }
