/* ========== Reset & Base ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f0f2f5; color: #333; font-size: 14px; }
a { color: #1890ff; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========== Login Page ========== */
.login-wrapper { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.login-box { background: #fff; border-radius: 12px; padding: 40px 36px; width: 400px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
.login-box h1 { text-align: center; margin-bottom: 8px; font-size: 24px; color: #333; }
.login-box .subtitle { text-align: center; color: #999; margin-bottom: 28px; font-size: 13px; }
.login-box .role-tabs { display: flex; gap: 0; margin-bottom: 24px; border-radius: 8px; overflow: hidden; border: 1px solid #d9d9d9; }
.login-box .role-tabs button { flex: 1; padding: 10px; border: none; background: #fafafa; cursor: pointer; font-size: 14px; color: #666; transition: all .2s; }
.login-box .role-tabs button.active { background: #1890ff; color: #fff; }
.login-box .role-tabs button:hover:not(.active) { background: #e6f7ff; }

/* ========== Forms ========== */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; color: #555; font-size: 13px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px 12px; border: 1px solid #d9d9d9; border-radius: 6px; font-size: 14px; transition: border-color .2s; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: #1890ff; box-shadow: 0 0 0 2px rgba(24,144,255,0.1); }
.form-group textarea { resize: vertical; min-height: 80px; }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: 8px 20px; border-radius: 6px; border: 1px solid transparent; cursor: pointer; font-size: 14px; transition: all .2s; }
.btn-primary { background: #1890ff; color: #fff; border-color: #1890ff; }
.btn-primary:hover { background: #40a9ff; }
.btn-success { background: #52c41a; color: #fff; }
.btn-success:hover { background: #73d13d; }
.btn-danger { background: #ff4d4f; color: #fff; }
.btn-danger:hover { background: #ff7875; }
.btn-warning { background: #faad14; color: #fff; }
.btn-warning:hover { background: #ffc53d; }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn + .btn { margin-left: 6px; }

/* ========== Dashboard Layout ========== */
.dashboard { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #001529; color: #fff; position: fixed; top: 0; left: 0; height: 100vh; overflow-y: auto; z-index: 100; }
.sidebar .logo { padding: 20px 16px; font-size: 18px; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,0.1); text-align: center; }
.sidebar .logo small { display: block; font-size: 11px; color: #999; font-weight: 400; margin-top: 4px; }
.sidebar nav { padding: 12px 0; }
.sidebar nav a { display: block; padding: 12px 24px; color: rgba(255,255,255,0.7); font-size: 14px; transition: all .2s; border-left: 3px solid transparent; }
.sidebar nav a:hover { background: rgba(255,255,255,0.05); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: #1890ff; color: #fff; border-left-color: #fff; }
.sidebar .sidebar-footer { position: absolute; bottom: 0; width: 100%; padding: 16px; border-top: 1px solid rgba(255,255,255,0.1); }
.sidebar .sidebar-footer .user-info { font-size: 12px; color: #999; margin-bottom: 8px; }
.sidebar .sidebar-footer .btn-logout { width: 100%; padding: 8px; background: rgba(255,255,255,0.1); color: #fff; border: none; border-radius: 4px; cursor: pointer; }
.sidebar .sidebar-footer .btn-logout:hover { background: rgba(255,255,255,0.2); }

.main-content { flex: 1; margin-left: 220px; padding: 24px; }
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 22px; color: #333; }
.page-header .breadcrumb { font-size: 12px; color: #999; margin-top: 4px; }

/* ========== Stats Cards ========== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.stat-card .stat-label { font-size: 13px; color: #999; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: #333; }
.stat-card .stat-value.money { color: #f5222d; }

/* ========== Cards / Panels ========== */
.card { background: #fff; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); margin-bottom: 20px; }
.card-header { padding: 16px 20px; border-bottom: 1px solid #f0f0f0; display: flex; justify-content: space-between; align-items: center; }
.card-header h3 { font-size: 16px; color: #333; }
.card-body { padding: 20px; }

/* ========== Tables ========== */
.table-toolbar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.table-toolbar input { padding: 8px 12px; border: 1px solid #d9d9d9; border-radius: 6px; font-size: 13px; width: 200px; }
.table-toolbar select { padding: 8px 12px; border: 1px solid #d9d9d9; border-radius: 6px; font-size: 13px; }

table { width: 100%; border-collapse: collapse; }
table thead { background: #fafafa; }
table th { padding: 12px 16px; text-align: left; font-weight: 600; color: #555; font-size: 13px; border-bottom: 1px solid #f0f0f0; white-space: nowrap; }
table td { padding: 12px 16px; border-bottom: 1px solid #f0f0f0; font-size: 13px; }
table tbody tr:hover { background: #f5f5f5; }
.table-actions { white-space: nowrap; }
.table-actions .btn { margin: 2px; }

/* ========== Pagination ========== */
.pagination { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; flex-wrap: wrap; gap: 12px; }
.pagination .page-info { font-size: 13px; color: #999; }
.pagination .page-btns { display: flex; gap: 4px; align-items: center; }
.pagination .page-btns button { padding: 6px 12px; border: 1px solid #d9d9d9; background: #fff; border-radius: 4px; cursor: pointer; font-size: 13px; }
.pagination .page-btns button:hover { border-color: #1890ff; color: #1890ff; }
.pagination .page-btns button.active { background: #1890ff; color: #fff; border-color: #1890ff; }
.pagination .page-btns button:disabled { opacity: 0.5; cursor: not-allowed; }
.pagination .page-size select { padding: 6px 8px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 13px; }

/* ========== Modal ========== */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.45); z-index: 1000; justify-content: center; align-items: center; }
.modal-overlay.show { display: flex; }
.modal { background: #fff; border-radius: 12px; width: 500px; max-height: 80vh; overflow-y: auto; box-shadow: 0 8px 40px rgba(0,0,0,0.2); }
.modal-header { padding: 20px 24px; border-bottom: 1px solid #f0f0f0; display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 16px; }
.modal-header .close-btn { background: none; border: none; font-size: 20px; cursor: pointer; color: #999; }
.modal-header .close-btn:hover { color: #333; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #f0f0f0; text-align: right; }

/* ========== Tags / Badges ========== */
.tag { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; }
.tag-success { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
.tag-danger { background: #fff2f0; color: #ff4d4f; border: 1px solid #ffccc7; }
.tag-warning { background: #fffbe6; color: #faad14; border: 1px solid #ffe58f; }
.tag-info { background: #e6f7ff; color: #1890ff; border: 1px solid #91d5ff; }

/* ========== Toast (居中显示+渐淡) ========== */
.toast-container { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 99999; display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.toast { padding: 14px 28px; border-radius: 10px; color: #fff; margin-bottom: 10px; font-size: 15px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,0.2); animation: toastIn .3s, toastOut .5s 2.5s forwards; min-width: 200px; text-align: center; }
.toast-success { background: rgba(82,196,26,0.95); }
.toast-error { background: rgba(255,77,79,0.95); }
.toast-info { background: rgba(24,144,255,0.95); }
@keyframes toastIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* ========== User Portal ========== */
.user-layout { max-width: 900px; margin: 0 auto; padding: 24px; }
.user-header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; border-radius: 12px; padding: 24px; margin-bottom: 24px; display: flex; justify-content: space-between; align-items: center; }
.user-header .char-info h2 { font-size: 20px; margin-bottom: 4px; }
.user-header .char-info .char-detail { font-size: 13px; opacity: 0.9; }
.user-header .balance { text-align: right; }
.user-header .balance .amount { font-size: 28px; font-weight: 700; }
.user-header .balance .label { font-size: 12px; opacity: 0.8; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.product-card { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); transition: transform .2s; }
.product-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
.product-card .name { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.product-card .price { font-size: 22px; font-weight: 700; color: #f5222d; margin-bottom: 12px; }
.product-card .detail { font-size: 12px; color: #999; margin-bottom: 12px; }
.section-title { font-size: 18px; font-weight: 600; margin: 24px 0 16px; padding-bottom: 8px; border-bottom: 2px solid #1890ff; }

/* ========== Custom Confirm Dialog ========== */
#_confirmOverlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.45); z-index: 9999; justify-content: center; align-items: center; }
.confirm-box { background: #fff; border-radius: 12px; padding: 28px 24px 20px; width: 320px; box-shadow: 0 8px 30px rgba(0,0,0,0.2); text-align: center; animation: confirmIn .2s; }
@keyframes confirmIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.confirm-msg { font-size: 15px; color: #333; margin-bottom: 24px; line-height: 1.6; }
.confirm-btns { display: flex; gap: 12px; }
.confirm-cancel { flex: 1; padding: 10px; border: 1px solid #d9d9d9; background: #fff; border-radius: 8px; font-size: 14px; cursor: pointer; color: #666; transition: all .15s; }
.confirm-cancel:hover { border-color: #999; }
.confirm-ok { flex: 1; padding: 10px; border: none; background: #1890ff; color: #fff; border-radius: 8px; font-size: 14px; cursor: pointer; font-weight: 600; transition: all .15s; }
.confirm-ok:hover { background: #40a9ff; }

/* ========== Tab Bar ========== */
.tab-bar {
    display: flex;
    align-items: center;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    padding: 0 8px;
    min-height: 40px;
    flex-shrink: 0;
    margin-bottom: 16px;
    border-radius: 4px 4px 0 0;
}
.tab-list {
    display: flex;
    flex: 1;
    overflow-x: auto;
    gap: 2px;
}
.tab-list::-webkit-scrollbar { height: 0; }
.tab-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    font-size: 13px;
    white-space: nowrap;
    background: #fafafa;
    color: #666;
    transition: all 0.2s;
}
.tab-item:hover { background: #e6f7ff; }
.tab-item.active {
    background: #fff;
    color: #1890ff;
    border-color: #e8e8e8;
    font-weight: 500;
}
.tab-close {
    margin-left: 6px;
    font-size: 14px;
    color: #999;
    cursor: pointer;
    line-height: 1;
}
.tab-close:hover { color: #ff4d4f; }
.tab-refresh-btn {
    background: none;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    margin-left: 8px;
    flex-shrink: 0;
}
.tab-refresh-btn:hover { color: #1890ff; border-color: #1890ff; }

/* ========== Report Content ========== */
.report-content {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========== Sidebar Groups ========== */
.sidebar nav .nav-group-title { display: block; padding: 10px 24px; color: rgba(255,255,255,0.45); font-size: 12px; font-weight: 600; cursor: pointer; border-left: 3px solid transparent; user-select: none; }
.sidebar nav .nav-group-title:hover { color: rgba(255,255,255,0.7); }
.sidebar nav .nav-group-title::before { content: '▸ '; font-size: 10px; }
.sidebar nav .nav-group-title.open::before { content: '▾ '; }
.sidebar nav .nav-group { display: none; }
.sidebar nav .nav-group.open { display: block; }
.sidebar nav .nav-group a { padding-left: 36px; font-size: 13px; }

/* ========== Mobile Menu Button ========== */
.mobile-menu-btn { display: none; position: fixed; top: 12px; left: 12px; z-index: 200; width: 40px; height: 40px; border-radius: 8px; border: none; background: #001529; color: #fff; font-size: 22px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.2); align-items: center; justify-content: center; }
.sidebar-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); z-index: 99; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .sidebar { display: none; position: fixed; z-index: 101; }
    .sidebar.mobile-open { display: block; }
    .sidebar-overlay.show { display: block; }
    .mobile-menu-btn { display: flex; }
    .main-content { margin-left: 0; padding-top: 60px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .login-box { width: 90%; padding: 24px; }
    table { font-size: 12px; }
    table th, table td { padding: 8px 6px; }
}
