/* ============================================
   快享Claw 后台管理系统 v2
   深色主题 · 青色强调 · 响应式
   ============================================ */

/* ─── Design Tokens ────────────────────────── */
:root {
    --bg-root: #0f1117;
    --bg-main: #161822;
    --bg-card: #1c1f2b;
    --bg-input: #13151e;
    --bg-hover: #222533;
    --bg-sidebar: #141621;
    --border: #252836;
    --border-light: #2a2d3a;
    --accent: #00d4aa;
    --accent-dim: rgba(0,212,170,0.12);
    --accent-glow: rgba(0,212,170,0.25);
    --text: #e2e4e9;
    --text-dim: #9a9eac;
    --text-muted: #5e6272;
    --danger: #ff4971;
    --danger-dim: rgba(255,73,113,0.12);
    --warning: #f0a030;
    --warning-dim: rgba(240,160,48,0.12);
    --success: #2ed573;
    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 2px 12px rgba(0,0,0,0.4);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-mono: "SF Mono", "Fira Code", "Cascadia Code", "JetBrains Mono", monospace;
}

/* ─── Reset ────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; }
body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg-root);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ─── Shell Layout ─────────────────────────── */
.shell {
    min-height: 100vh;
    position: relative;
}

/* ─── Sidebar ──────────────────────────────── */
.sidebar {
    width: 230px;
    min-width: 230px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 24px 22px 22px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.sidebar-brand .brand-icon { font-size: 26px; line-height: 1; }
.sidebar-brand .brand-logo { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.sidebar-brand .brand-text { font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: -0.3px; }
.sidebar-nav {
    flex: 1;
    padding: 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow-y: auto;
}
/* 隐藏滚动条 */
.sidebar-nav::-webkit-scrollbar { width: 0; }
.sidebar-nav { scrollbar-width: none; }
.sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-dim);
    text-decoration: none;
    transition: background 0.14s, color 0.14s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.nav-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.35;
    flex-shrink: 0;
    transition: opacity 0.14s;
}
.nav-item.active .nav-dot { opacity: 1; }

/* ─── Main Area ────────────────────────────── */
.main {
    margin-left: 230px;
    min-height: 100vh;
    width: calc(100% - 230px);
    background: var(--bg-main);
}
.page-top {
    padding: 28px 38px 0;
}
.page-top h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}
.page-body {
    padding: 20px 38px 48px;
}

/* ─── Cards ─────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}
.card-header h3 { font-size: 15px; font-weight: 600; color: var(--text); }
.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}
.card-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 18px;
}

/* ─── Card Body/Footer ────────────────────────── */
.card-body { padding: 0; }
.card-footer {
    padding: 16px 0 0 0;
    border-top: 1px solid var(--border);
    margin-top: 16px;
}

/* ─── Stats Row ─────────────────────────────── */
.stats-row {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}
.stat-box {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    text-align: center;
    box-shadow: var(--shadow);
}
.stat-box .stat-num {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.1;
    font-family: var(--font-mono);
}
.stat-box .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ─── Dashboard stat cards ──────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stats-grid .stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow);
}
.stat-icon { font-size: 30px; flex-shrink: 0; line-height: 1; }
.stat-info { min-width: 0; }
.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}
.stat-value.small { font-size: 13px; font-weight: 500; word-break: break-all; }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ─── Tables ────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table thead th {
    text-align: left;
    padding: 9px 14px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-dim);
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg-hover); }
.data-table .col-id {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 12px;
    width: 50px;
}
.data-table .col-num {
    font-family: var(--font-mono);
    font-size: 12px;
}
.data-table .col-date {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}
.data-table .col-actions {
    white-space: nowrap;
    display: flex;
    gap: 6px;
    align-items: center;
}
.data-table .empty-cell {
    text-align: center;
    color: var(--text-muted);
    padding: 44px 0 !important;
}
/* User table extra */
.mini-bar-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 110px;
}
.mini-bar {
    flex: 1;
    height: 5px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}
.mini-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s;
}
.mini-bar-fill.warn { background: var(--warning); }
.mini-bar-fill.danger { background: var(--danger); }
.mini-bar-pct {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    width: 38px;
    text-align: right;
}

/* ─── Buttons ───────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.14s;
    font-family: var(--font);
}
.btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border-light); }
.btn-primary { background: var(--accent); color: #0a0d13; border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: #00e6b8; opacity: 1; }
.btn-danger { color: var(--danger); border-color: rgba(255,73,113,0.25); }
.btn-danger:hover { background: var(--danger-dim); }
.btn-success { color: var(--success); border-color: rgba(46,213,115,0.25); }
.btn-success:hover { background: rgba(46,213,115,0.1); }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 6px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 5px; }
.btn-dim { color: var(--text-muted); border-color: var(--border); }
.btn-dim:hover { background: var(--bg-hover); color: var(--text); }
.btn-dim.has-profile { color: #6366f1; border-color: rgba(99,102,241,0.3); background: rgba(99,102,241,0.08); }
.btn-dim.has-profile:hover { background: rgba(99,102,241,0.15); color: #6366f1; }

.badge-info { background: rgba(112,161,255,0.12); color: #70a1ff; border: 1px solid rgba(112,161,255,0.25); }

/* ─── Forms ─────────────────────────────────── */
.form-block { max-width: 740px; }
.form-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.form-col2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
}
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field.sm { max-width: 120px; }
.form-field .form-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 14px;
}
.form-group .form-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
}
.form-input,
.form-field input {
    width: 100%;
    padding: 10px 13px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.2s;
}
.form-input:focus,
.form-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-textarea {
    width: 100%;
    padding: 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: var(--font-mono);
    line-height: 1.7;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}
.form-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }
.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-dim);
    user-select: none;
    padding: 4px 0;
}
.form-check input[type="checkbox"] {
    appearance: none;
    width: 18px; height: 18px;
    border: 2px solid var(--border-light);
    border-radius: 4px;
    background: var(--bg-input);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s;
}
.form-check input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: inset 0 0 0 2px var(--bg-input);
}

/* User form overrides */
.user-form-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.user-form-row .form-field { min-width: 130px; }
.user-form-row .form-field.sm { min-width: 100px; }
.user-form-row .form-input { min-width: 0; }

/* ─── Badges ────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 11px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-warn { background: var(--warning-dim); color: var(--warning); }
.badge-ok { background: var(--accent-dim); color: var(--accent); }
.badge-err { background: var(--danger-dim); color: var(--danger); }

/* ─── Status ────────────────────────────────── */
.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
}
.status-dot.on { background: var(--success); box-shadow: 0 0 5px rgba(46,213,115,0.5); }
.status-dot.off { background: var(--text-muted); }

/* ─── Alert ─────────────────────────────────── */
.alert {
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid;
}
.alert-ok { background: var(--accent-dim); color: var(--accent); border-color: rgba(0,212,170,0.2); }
.alert-err { background: var(--danger-dim); color: var(--danger); border-color: rgba(255,73,113,0.2); }

/* ─── Misc ──────────────────────────────────── */
.key-masked {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--bg-input);
    padding: 2px 9px;
    border-radius: 4px;
    color: var(--text-dim);
}
.api-block {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 15px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-dim);
}
.api-block + .api-block { margin-top: 10px; }
.api-method {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.api-method.get { background: var(--accent-dim); color: var(--accent); }
.api-method.post { background: rgba(100,149,237,0.15); color: #6495ed; }
code { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

/* ─── Recharge input ────────────────────────── */
.recharge-input {
    width: 72px;
    min-width: 72px;
    padding: 6px 8px;
    font-size: 12px;
    font-family: var(--font-mono);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    outline: none;
}
.recharge-input:focus { border-color: var(--accent); }
.recharge-form {
    display: flex;
    gap: 4px;
    align-items: center;
}

/* ─── Animations ────────────────────────────── */
@keyframes toastIn {
    from { transform: translateY(-12px) scale(0.96); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

/* ─── Responsive ────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { width: 56px; min-width: 56px; }
    .sidebar .brand-text,
    .sidebar .nav-item span:not(.nav-dot) { display: none; }
    .sidebar .nav-item { justify-content: center; padding: 12px; }
    .sidebar-brand { justify-content: center; padding: 16px 0; }
    .main { margin-left: 56px; }
    .page-body { padding: 16px 20px 36px; }
    .page-top { padding: 20px 20px 0; }
    .stats-grid { grid-template-columns: 1fr; }
    .stats-row { flex-direction: column; }
    .form-row, .user-form-row { flex-direction: column; }
}

/* ─── Modal ────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalIn 0.2s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; color: var(--text); margin: 0; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    line-height: 1;
    transition: all 0.15s;
}
.modal-close:hover { background: var(--bg-primary); color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}
.modal-info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.modal-info-row:last-child { border-bottom: none; }
.modal-info-label { color: var(--text-muted); min-width: 80px; }
.modal-info-value { color: var(--text); font-weight: 500; text-align: right; word-break: break-all; }
.modal-profile-box {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    max-height: 120px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.5;
}

/* file upload area */
.file-upload-area {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 18px 16px;
    border: 2px dashed #c0c8d4;
    border-radius: 10px;
    background: #fafbfc;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    text-align: center;
}
.file-upload-area:hover {
    border-color: var(--primary);
    background: #f0f5ff;
    box-shadow: 0 0 0 3px rgba(24,144,255,0.08);
}
.file-upload-area.has-file {
    border-color: #52c41a;
    background: #f6ffed;
}
.file-upload-area.has-file:hover {
    border-color: #52c41a;
    background: #f0fce8;
    box-shadow: 0 0 0 3px rgba(82,196,26,0.08);
}
.file-upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.file-upload-icon-big {
    font-size: 24px;
    line-height: 1;
}
.file-upload-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.file-upload-desc {
    font-size: 11px;
    color: var(--text-muted);
}
.file-upload-name-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text);
    max-width: 260px;
}
.file-upload-name-tag .name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-upload-name-tag .clear {
    flex-shrink: 0;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: bold;
    font-size: 14px;
    line-height: 1;
}
.file-upload-name-tag .clear:hover { color: var(--danger); }
.file-upload-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}
.file-upload-preview {
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.file-upload-preview img {
    width: 72px;
    height: 72px;
    border-radius: 12px;
    object-fit: cover;
    border: 2px solid var(--border);
    background: #f5f5f5;
}
.file-upload-preview-label {
    font-size: 13px;
    color: var(--text-muted);
}

/* ─── 标签页切换 ─── */
.page-tabs { display:flex; gap:0; border-bottom:2px solid var(--border); }
.page-tabs .tab-item {
    display:inline-block; padding:10px 20px; font-size:14px; font-weight:500;
    color:var(--text-muted); text-decoration:none; border-bottom:2px solid transparent;
    margin-bottom:-2px; transition:all .15s;
}
.page-tabs .tab-item:hover { color:var(--text-primary); }
.page-tabs .tab-item.active {
    color:var(--primary); border-bottom-color:var(--primary);
}

/* action buttons */

/* ─── 分页导航 ─── */
.pagination-bar {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    margin-top: 20px; padding: 16px 0 8px;
}
.pagination-info {
    font-size: 13px; color: var(--text-dim); 
    margin-right: 16px; font-weight: 500;
    letter-spacing: 0.02em;
}
.pagination-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px; padding: 0 10px;
    font-size: 13px; font-weight: 500; color: var(--text-dim); 
    text-decoration: none; border-radius: 8px; 
    background: var(--bg-input); border: 1px solid var(--border);
    transition: all .18s; user-select: none;
}
.pagination-btn:hover { 
    color: var(--text); background: var(--bg-hover); 
    border-color: var(--border-light); 
}
.pagination-btn.active {
    color: #fff; background: var(--accent); border-color: var(--accent);
    font-weight: 600; cursor: default; 
    box-shadow: 0 2px 8px var(--accent-glow);
}
.pagination-dots {
    font-size: 14px; color: var(--text-dim); padding: 0 6px; 
    letter-spacing: 2px; font-weight: 500;
}
