/* ── Stats Grid ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    transition: transform .2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; font-weight: 700;
}
.stat-value { font-size: 28px; font-weight: 700; color: #1a1a2e; }
.stat-label { font-size: 13px; color: #999; margin-top: 2px; }

/* ── Section ── */
.section { margin-bottom: 24px; }
.section-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px; flex-wrap: wrap; gap: 12px;
}
.section-header h3 { font-size: 16px; color: #1a1a2e; }
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.header-actions input[type="text"] {
    padding: 8px 12px; border: 1px solid #d9d9d9; border-radius: 6px;
    font-size: 13px; width: 200px; outline: none;
}
.header-actions input[type="text"]:focus { border-color: #e94560; }
.header-actions select {
    padding: 8px 12px; border: 1px solid #d9d9d9; border-radius: 6px;
    font-size: 13px; outline: none; background: #fff;
}

/* ── Card ── */
.card {
    background: #fff; border-radius: 12px; padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.table-card { padding: 0; overflow-x: auto; }

/* ── Charts ── */
.charts-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.chart-card {
    background: #fff; border-radius: 12px; padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.chart-card h4 { font-size: 14px; color: #555; margin-bottom: 16px; }
.bar-chart {
    display: flex; align-items: flex-end; gap: 8px; height: 160px; padding-top: 10px;
}
.bar-item {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    height: 100%; justify-content: flex-end;
}
.bar-fill {
    width: 100%; background: linear-gradient(180deg, #e94560 0%, #3742fa 100%);
    border-radius: 4px 4px 0 0; min-height: 4px; transition: height .5s;
}
.bar-label { font-size: 11px; color: #999; margin-top: 6px; }
.bar-value { font-size: 11px; color: #555; font-weight: 600; }

/* ── Ranking ── */
.ranking-list { max-height: 200px; overflow-y: auto; }
.ranking-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 0; border-bottom: 1px solid #f0f0f0; font-size: 13px;
}
.ranking-item:last-child { border-bottom: none; }
.rank-badge {
    width: 24px; height: 24px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.rank-1 { background: #ffd700; }
.rank-2 { background: #c0c0c0; }
.rank-3 { background: #cd7f32; }
.rank-num {
    width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
    font-size: 12px; color: #999; flex-shrink: 0;
}
.rank-user { flex-shrink: 0; font-weight: 500; }
.rank-token { flex: 1; color: #999; font-family: monospace; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-count { font-weight: 600; color: #e94560; flex-shrink: 0; }

/* ── Form ── */
.form-row {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px; margin-bottom: 16px;
}
.form-group { display: flex; flex-direction: column; }
.form-group label { font-size: 13px; color: #555; font-weight: 500; margin-bottom: 6px; }
.form-group input[type="text"],
.form-group input[type="number"] {
    padding: 10px 12px; border: 1px solid #d9d9d9; border-radius: 8px;
    font-size: 14px; outline: none; transition: border-color .2s;
}
.form-group input:focus { border-color: #e94560; box-shadow: 0 0 0 3px rgba(233,69,96,.1); }
.input-with-shortcuts { display: flex; flex-direction: column; gap: 6px; }
.input-with-shortcuts input { width: 100%; }
.shortcut-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.form-actions {
    display: flex; align-items: center; gap: 16px; justify-content: flex-end;
}
.checkbox-label {
    font-size: 13px; color: #555; display: flex; align-items: center; gap: 6px; cursor: pointer;
}

/* ── Result Box ── */
.result-box {
    margin-top: 16px; padding: 16px; background: #f6ffed; border: 1px solid #b7eb8f;
    border-radius: 8px; font-size: 13px;
}
.result-box code {
    background: #fff; padding: 4px 8px; border-radius: 4px;
    font-size: 13px; border: 1px solid #eee; word-break: break-all;
}
.batch-tokens { margin-top: 12px; max-height: 200px; overflow-y: auto; }
.batch-token-item {
    padding: 6px 0; border-bottom: 1px solid #f0f0f0;
    display: flex; align-items: center; gap: 8px; font-size: 13px;
}
.batch-token-item code { flex: 1; }

/* ── Table ── */
.data-table {
    width: 100%; border-collapse: collapse; font-size: 13px;
}
.data-table thead { background: #fafafa; }
.data-table th {
    padding: 12px 16px; text-align: left; font-weight: 600;
    color: #555; border-bottom: 2px solid #f0f0f0; white-space: nowrap;
}
.data-table td {
    padding: 10px 16px; border-bottom: 1px solid #f5f5f5;
    max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.data-table tbody tr:hover { background: #fafafa; }
.token-cell {
    font-family: monospace; cursor: pointer; color: #3742fa;
    padding: 2px 6px; border-radius: 4px; transition: background .2s;
}
.token-cell:hover { background: #e8f4fd; }
.status-badge {
    padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 500;
}
.status-active { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
.status-suspended { background: #f5f5f5; color: #999; border: 1px solid #d9d9d9; }
.status-expired { background: #fff7e6; color: #fa8c16; border: 1px solid #ffd591; }
.text-muted { color: #ccc; }
.action-cell { white-space: nowrap; }
.action-cell .btn { margin-right: 4px; }
.empty-msg { text-align: center; color: #999; padding: 40px 0; }

/* ── Modal ── */
.modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.45); display: flex; align-items: center;
    justify-content: center; z-index: 1000;
}
.modal-content {
    background: #fff; border-radius: 12px; padding: 32px;
    width: 100%; max-width: 420px; box-shadow: 0 12px 40px rgba(0,0,0,.2);
}
.modal-content h3 { margin-bottom: 16px; color: #1a1a2e; }
.token-preview { font-family: monospace; color: #3742fa; margin-bottom: 16px; font-size: 14px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }

/* ── Nav Links ── */
.nav-links { display: flex; gap: 4px; }
.nav-link {
    color: rgba(255,255,255,.7); text-decoration: none;
    padding: 6px 16px; border-radius: 6px; font-size: 14px;
    transition: all .2s;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,.1); }
.nav-link.active { color: #fff; background: rgba(255,255,255,.15); }

/* ── Data Page ── */
.data-query-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.data-query-form .form-group { flex: 1; min-width: 200px; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .charts-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }
    .container { padding: 16px; }
}
