* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Microsoft YaHei", "PingFang SC", sans-serif; background: #f1f5f9; color: #1f2937; }
button { cursor: pointer; }
.btn { padding: 8px 16px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; font-size: 14px; }
.btn:hover { background: #f3f4f6; }
.btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { color: #dc2626; border-color: #fca5a5; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; padding: 10px; margin-top: 10px; }
.btn-mini { border: none; background: transparent; font-size: 14px; padding: 2px 4px; }
.btn-mini:hover { background: #e5e7eb; border-radius: 4px; }
input, select { padding: 8px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; width: 100%; margin-bottom: 8px; }

/* login */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: #fff; padding: 40px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,.08); width: 360px; }
.login-box h1 { font-size: 20px; text-align: center; margin-bottom: 20px; }
.login-error { color: #dc2626; min-height: 20px; margin-bottom: 8px; font-size: 13px; }

/* main */
.main-wrap { max-width: 1400px; margin: 0 auto; padding: 16px; }
.topbar { display: flex; align-items: center; gap: 16px; background: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.06); margin-bottom: 16px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab { padding: 8px 14px; border: none; background: transparent; border-radius: 6px; font-size: 14px; }
.tab.active { background: #2563eb; color: #fff; }
.userbox { display: flex; align-items: center; gap: 8px; }
.panel { background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }

/* open */
.card-form { max-width: 520px; }
.card-form h2 { margin-bottom: 12px; }
.card-form label { display: block; margin: 8px 0 4px; font-size: 13px; color: #4b5563; }
.quick-amounts { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.qa { padding: 5px 10px; border: 1px solid #d1d5db; border-radius: 6px; background: #f9fafb; }
.qa:hover { background: #e0e7ff; border-color: #2563eb; }
.open-result { margin-top: 16px; padding: 16px; border: 1px solid #86efac; background: #f0fdf4; border-radius: 8px; }
#result-codes { width: 100%; height: 120px; font-family: monospace; }
.result-actions { display: flex; gap: 8px; margin-top: 8px; }

/* filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.filters input, .filters select { width: auto; margin: 0; }
#f-search { flex: 1; min-width: 180px; }
.filter-summary { color: #6b7280; font-size: 13px; margin-left: auto; }
.batch-bar { display: flex; gap: 8px; align-items: center; background: #eff6ff; padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; }
.batch-bar b { color: #2563eb; }

/* table */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { border-bottom: 1px solid #e5e7eb; padding: 7px 8px; text-align: left; white-space: nowrap; }
.tbl th { background: #f9fafb; font-weight: 600; }
.tbl tr:hover { background: #f8fafc; }
.code-cell { font-family: monospace; color: #2563eb; cursor: pointer; }
.st { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; color: #fff; }
.st-unused { background: #22c55e; }
.st-used { background: #3b82f6; }
.st-banned { background: #f97316; }
.st-discard { background: #6b7280; }
.st-deleted { background: #111827; }
.st-expired { background: #ef4444; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 13px; color: #6b7280; }
.pager select { width: auto; margin: 0; }

/* stats */
.scope-row { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.scope-row select { width: auto; margin: 0; }
.period-tabs button { margin-right: 6px; }
.pt.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 16px; text-align: center; }
.stat-card.blue { border-top: 3px solid #3b82f6; }
.stat-card.green { border-top: 3px solid #22c55e; }
.stat-card.orange { border-top: 3px solid #f97316; }
.stat-num { font-size: 24px; font-weight: 700; }
.stat-label { color: #6b7280; font-size: 13px; margin-top: 4px; }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chart-box { height: 260px; border: 1px solid #e5e7eb; border-radius: 10px; padding: 8px; }
.sec-title { font-size: 15px; font-weight: 600; color: #374151; margin: 18px 0 10px; }
.stat-link { margin-top: 6px; font-size: 12px; color: #2563eb; cursor: pointer; user-select: none; }
.stat-link:hover { text-decoration: underline; }
#stat-from, #stat-to { width: auto; margin: 0; }
#stat-apply, #stat-jump-cards { margin: 0; }
#ranking-box { margin-top: 16px; }

/* agents */
.agent-form { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.agent-form input { width: auto; margin: 0; }

/* modal */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 12px; padding: 24px; width: 420px; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal.wide { width: 620px; max-height: 80vh; overflow: auto; }
.modal h3 { margin-bottom: 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.det-row { margin: 6px 0; }
.big-code { font-family: monospace; font-size: 18px; color: #2563eb; font-weight: 700; }
.timeline { margin: 6px 0 0 18px; font-size: 13px; color: #4b5563; }

@media (max-width: 900px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .charts { grid-template-columns: 1fr; }
}
