/* ============================================================
   搜集网产品数据分析系统 — 后台设计系统
   参考 qingji admin 风格：深绿侧边栏 + green 主色 + Tailwind 工具类
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: #f1f5f9;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    color: #0f172a;
}

/* ---------- 侧边栏 ---------- */
.sidebar {
    background: #14532d;
    width: 256px;
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s;
}
.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 24px 18px;
}
.sidebar .brand .logo-box {
    width: 38px; height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, #15803d, #14532d);
    display: flex; align-items: center; justify-content: center;
    color: #fff; flex-shrink: 0;
    box-shadow: 0 6px 16px rgba(21,128,61,0.35);
}
.sidebar .brand .brand-name { color: #fff; font-weight: 700; font-size: 20px; line-height: 1.2; margin-top: 5px; }
.sidebar .brand .brand-sub { color: #94a3b8; font-size: 14px; margin-top: 3px; }

.nav { display: flex; flex-direction: column; gap: 4px; padding: 18px 14px 8px 46px; flex: 1; }
.nav-section { color: #475569; font-size: 11px; font-weight: 600; letter-spacing: .05em; padding: 14px 12px 6px; text-transform: uppercase; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    color: #94a3b8;
    font-size: 14px;
    font-weight: 500;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #e2e8f0; }
.nav-item.active {
    background: rgba(21,128,61,0.15);
    color: #4ade80;
    border-left: 3px solid #15803d;
    padding-left: 11px;
}
.nav-item i, .nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

/* 侧边栏底部管理员信息 */
.sidebar-foot {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.07);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-foot .avatar {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: rgba(21,128,61,0.2);
    color: #86efac;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
    flex-shrink: 0;
}
.sidebar-foot .meta { flex: 1; min-width: 0; }
.sidebar-foot .meta .name { color: #e2e8f0; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .meta .role { color: #64748b; font-size: 11px; }
.sidebar-foot .logout {
    color: #64748b; cursor: pointer; transition: color .15s;
    background: none; border: none; display: flex; padding: 6px; border-radius: 8px;
}
.sidebar-foot .logout:hover { color: #f87171; background: rgba(248,113,113,0.1); }

/* ---------- 主区域 ---------- */
.main-wrap { margin-left: 256px; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 30;
}
.topbar .page-title { font-size: 18px; font-weight: 700; color: #0f172a; display: flex; align-items: center; gap: 10px; }
.topbar .page-title .crumb { color: #94a3b8; font-weight: 500; font-size: 13px; }
.topbar .topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar .top-avatar {
    width: 34px; height: 34px; border-radius: 10px;
    background: rgba(21,128,61,0.1); color: #15803d;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
#sidebar-toggle { display: none; color: #64748b; background: none; border: none; cursor: pointer; padding: 6px; border-radius: 8px; }
#sidebar-toggle:hover { background: #f1f5f9; }

.content { flex: 1; padding: 32px; }

/* ---------- 卡片 ---------- */
.stat-card {
    background: #fff;
    border-radius: 16px;
    padding: 22px 24px;
    border: 1px solid #f1f5f9;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat-card .stat-label { color: #94a3b8; font-size: 13px; font-weight: 500; }
.stat-card .stat-value { font-size: 30px; font-weight: 800; color: #0f172a; line-height: 1.1; }
.stat-card .stat-foot { display: flex; align-items: center; gap: 6px; color: #94a3b8; font-size: 12px; margin-top: 4px; }
.stat-card .stat-icon {
    position: absolute; top: 20px; right: 22px;
    width: 42px; height: 42px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
}
.stat-card { position: relative; }
.stat-icon.i-primary { background: rgba(21,128,61,0.12); color: #15803d; }
.stat-icon.i-success { background: rgba(16,185,129,0.12); color: #10b981; }
.stat-icon.i-warning { background: rgba(245,158,11,0.12); color: #f59e0b; }
.stat-icon.i-info    { background: rgba(59,130,246,0.12); color: #3b82f6; }

.panel {
    background: #fff;
    border-radius: 16px;
    border: 1px solid #f1f5f9;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    padding: 24px;
    margin-bottom: 24px;
}
.panel-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 18px; gap: 12px; flex-wrap: wrap;
}
.panel-title { font-size: 16px; font-weight: 700; color: #0f172a; display: flex; align-items: center; gap: 8px; }
.panel-title i, .panel-title svg { color: #15803d; width: 18px; height: 18px; }
.panel-sub { font-size: 13px; color: #94a3b8; margin-top: 2px; }

/* ---------- 表格 ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data-table thead th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0;
    font-size: 12px;
    white-space: nowrap;
}
table.data-table tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
}
table.data-table tbody tr { transition: background .15s; }
table.data-table tbody tr:hover { background: #f8fafc; }
table.data-table tbody tr:last-child td { border-bottom: none; }
.cell-mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; color: #0f172a; font-weight: 600; }
.cell-time { font-size: 13px; white-space: nowrap; }
.cell-remark { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #475569; }
.sel-code { -webkit-user-select: all; user-select: all; cursor: text; }

/* ---------- 徽章 ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge-primary { background: #dcfce7; color: #14532d; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-muted   { background: #f1f5f9; color: #475569; }

/* ---------- 表单 ---------- */
.form-label { display: block; font-size: 13px; font-weight: 500; color: #475569; margin-bottom: 6px; }
.form-input {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 9px 14px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #f8fafc;
    color: #0f172a;
}
.form-input:focus { border-color: #15803d; background: #fff; box-shadow: 0 0 0 3px rgba(21,128,61,0.1); }
.form-input::placeholder { color: #94a3b8; }
select.form-input { cursor: pointer; }
.form-hint { font-size: 12px; color: #94a3b8; margin-top: 6px; }

/* ---------- 按钮 ---------- */
.btn-primary { background: #15803d; color: #fff; border: none; border-radius: 10px; padding: 9px 18px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.btn-primary:hover { background: #166534; }
.btn-primary:active { transform: scale(.98); }
.btn-secondary { background: #f1f5f9; color: #475569; border: none; border-radius: 10px; padding: 9px 18px; font-size: 14px; font-weight: 500; cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: #fee2e2; color: #dc2626; border: none; border-radius: 10px; padding: 7px 14px; font-size: 13px; font-weight: 500; cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn-danger:hover { background: #fecaca; }
.btn-ghost { background: none; border: 1px solid #e2e8f0; color: #475569; border-radius: 10px; padding: 8px 14px; font-size: 13px; cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn-ghost:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.icon-btn {
    width: 32px; height: 32px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; cursor: pointer; transition: all .15s; background: #f1f5f9; color: #475569;
}
.icon-btn:hover { background: #e2e8f0; }
.icon-btn.danger:hover { background: #fee2e2; color: #dc2626; }
.icon-btn.edit:hover { background: #dcfce7; color: #14532d; }
.icon-btn.copy:hover { background: #ecfdf5; color: #059669; }
.icon-btn.warning { background: #fef3c7; color: #d97706; }
.icon-btn.warning:hover { background: #fde68a; }
.icon-btn.success { background: #d1fae5; color: #059669; }
.icon-btn.success:hover { background: #a7f3d0; }

/* ---------- 搜索框 ---------- */
.search-input {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 9px 14px 9px 38px;
    font-size: 14px;
    outline: none;
    background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat 12px center;
    width: 260px;
    transition: all .15s;
    color: #0f172a;
}
.search-input:focus { border-color: #15803d; background-color: #fff; box-shadow: 0 0 0 3px rgba(21,128,61,0.1); }

/* ---------- 模态框 ---------- */
.modal-mask {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.55);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-mask.open { display: flex; }
.modal-box {
    background: #fff;
    border-radius: 20px;
    padding: 28px;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-box h3 { font-size: 17px; font-weight: 700; color: #0f172a; margin: 0 0 18px; display: flex; align-items: center; gap: 8px; }
.modal-box h3 i, .modal-box h3 svg { color: #15803d; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* ---------- Toast ---------- */
.toast {
    position: fixed; top: 24px; right: 24px; z-index: 999;
    padding: 12px 20px; border-radius: 12px; font-size: 14px; font-weight: 500;
    color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    transform: translateX(120%); opacity: 0;
    transition: transform .3s, opacity .3s;
    display: flex; align-items: center; gap: 8px;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast.success { background: #10b981; }
.toast.error { background: #ef4444; }
.toast.info { background: #15803d; }

/* ---------- 空状态 ---------- */
.empty-state { text-align: center; padding: 48px 16px; color: #94a3b8; }
.empty-state .empty-icon {
    width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 16px;
    background: #f1f5f9; color: #cbd5e1; display: flex; align-items: center; justify-content: center;
}
.empty-state h3 { font-size: 16px; color: #475569; margin: 0 0 6px; }
.empty-state p { font-size: 13px; }

/* ---------- 提示条 ---------- */
.alert {
    padding: 13px 16px; border-radius: 12px; margin-bottom: 18px;
    display: flex; align-items: center; gap: 10px; font-size: 14px;
}
.alert-error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.alert-success { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }

/* ---------- 进度条 ---------- */
.progress-track { height: 10px; background: #f1f5f9; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #15803d, #14532d); width: 0%; transition: width .3s; }

/* ---------- 滚动条（全局统一：6px / #C3C3C3 / hover #A3A3A3 / 轨道透明 / 圆角 999） ---------- */
html {
    scrollbar-width: thin;
    scrollbar-color: #C3C3C3 transparent;
}
:is(html, .table-wrap, .modal-box, .custom-scrollbar)::-webkit-scrollbar { width: 6px; height: 6px; }
:is(html, .table-wrap, .modal-box, .custom-scrollbar)::-webkit-scrollbar-track { background: transparent; }
:is(html, .table-wrap, .modal-box, .custom-scrollbar)::-webkit-scrollbar-thumb { background: #C3C3C3; border-radius: 999px; }
:is(html, .table-wrap, .modal-box, .custom-scrollbar)::-webkit-scrollbar-thumb:hover { background: #A3A3A3; }

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-wrap { margin-left: 0; }
    #sidebar-toggle { display: inline-flex; }
    .content { padding: 20px 16px; }
    .topbar { padding: 0 16px; }
    .search-input { width: 160px; }
    .stat-card .stat-icon { display: none; }
    /* 添加会员表单：移动端“添加数据”按钮居右 */
    .add-btn-wrap { width: 100%; text-align: right; }
    /* 最近会员面板：移动端“查看全部会员”链接居右 */
    .view-all-link { margin-left: auto; }
    /* 会员列表工具栏：移动端“导出SHA1”紧贴“全部状态”右侧，搜索框另起一行 */
    .member-toolbar { flex-wrap: wrap; width: 100%; align-items: stretch; }
    .member-toolbar > form[method="get"] { display: contents; }
    .member-toolbar select[name="status"] { order: 1; flex: 0 0 50%; min-width: 0; height: 42px; }
    .member-toolbar > form[method="post"] { order: 2; flex: 1 1 0; min-width: 0; }
    .member-toolbar > form[method="post"] button { width: 100%; height: 42px; }
    .member-toolbar .member-search-wrap { order: 3; flex: 0 0 100%; }
    .member-toolbar .member-search-wrap .search-input { width: 100%; }
    /* 验证记录工具栏：移动端搜索框自适应整行宽度 */
    .logs-toolbar { width: 100%; }
    .logs-toolbar .logs-search-wrap { flex: 0 0 100%; }
    .logs-toolbar .logs-search-wrap .search-input { width: 100%; }
    /* 安装记录工具栏：移动端搜索框自适应整行宽度 */
    .ir-toolbar { width: 100%; }
    .ir-toolbar select[name="product"],
    .ir-toolbar select[name="bits"] { flex: 1 1 0; min-width: 0; }
    .ir-toolbar .ir-search-wrap { flex: 0 0 100%; }
    .ir-toolbar .ir-search-wrap .search-input { width: 100%; }
}
@media (min-width: 769px) {
    .sidebar.open { transform: translateX(0); }
}
