/* ============================================================
   后台管理样式 - 响应式
   断点：1200px / 992px / 768px / 576px
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    color: #333;
    background: #f0f2f5;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; }
input, select, textarea, button { font-size: 14px; font-family: inherit; }

/* ========== 登录页 ========== */
.login-body {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 50%, #60a5fa 100%);
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.login-container { width: 100%; max-width: 420px; }
.login-box {
    background: #fff; border-radius: 16px;
    padding: 40px 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-icon { font-size: 48px; display: block; margin-bottom: 8px; }
.login-logo h1 { font-size: 22px; color: #1e40af; margin-bottom: 4px; }
.login-logo p { color: #888; font-size: 13px; }
.login-form .form-group { margin-bottom: 18px; }
.login-form label { display: block; margin-bottom: 6px; font-weight: 500; color: #444; font-size: 13px; }
.login-form input {
    width: 100%; padding: 12px 16px;
    border: 1.5px solid #d1d5db; border-radius: 10px;
    font-size: 15px; font-family: inherit;
    transition: all 0.2s;
    min-height: 46px;
}
.login-form input:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.12); }
.login-tip { text-align: center; margin-top: 20px; font-size: 12px; color: #999; line-height: 1.8; }
.login-tip a { color: #3b82f6; }

/* ========== 后台布局 ========== */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: 230px;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: #cbd5e1;
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: #475569 transparent;
}
.admin-sidebar::-webkit-scrollbar { width: 4px; }
.admin-sidebar::-webkit-scrollbar-thumb { background: #475569; border-radius: 2px; }
.admin-logo {
    padding: 20px 18px;
    font-size: 17px; font-weight: 700; color: #fff;
    display: flex; align-items: center; gap: 10px;
    border-bottom: 1px solid #334155;
    min-height: 60px;
}
.admin-logo .logo-icon { font-size: 24px; }
.admin-nav { flex: 1; padding: 12px 0 20px; }
.nav-group-title {
    padding: 14px 20px 6px;
    font-size: 11px; color: #64748b;
    text-transform: uppercase; letter-spacing: 1px;
    font-weight: 600;
}
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 20px;
    color: #cbd5e1; font-size: 14px;
    transition: all 0.15s;
    border-left: 3px solid transparent;
    min-height: 44px;
}
.nav-item:hover { background: #334155; color: #fff; }
.nav-item.active { background: #3b82f6; color: #fff; border-left-color: #60a5fa; box-shadow: 0 2px 8px rgba(59,130,246,0.3); }
.nav-icon { font-size: 17px; width: 22px; text-align: center; flex-shrink: 0; }

.admin-main {
    flex: 1;
    margin-left: 230px;
    display: flex; flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    transition: margin-left 0.3s ease;
}
.admin-topbar {
    height: 60px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    display: flex; align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky; top: 0; z-index: 50;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.sidebar-toggle {
    display: none;
    flex-direction: column;
    justify-content: center; align-items: center;
    gap: 4px;
    width: 40px; height: 40px;
    background: #f3f4f6;
    border: none; border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
}
.sidebar-toggle span {
    display: block; width: 18px; height: 2px;
    background: #374151; border-radius: 2px;
}
.topbar-title { font-size: 17px; font-weight: 600; color: #1f2937; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user { display: flex; align-items: center; gap: 14px; font-size: 13px; color: #555; flex-shrink: 0; }
.admin-username { white-space: nowrap; }
.topbar-link { color: #3b82f6; white-space: nowrap; }
.topbar-link.logout { color: #ef4444; }
.sidebar-overlay {
    display: none;
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 90;
}
.admin-content { flex: 1; padding: 24px; }

/* ========== 按钮 ========== */
.btn {
    display: inline-flex;
    align-items: center; justify-content: center;
    padding: 8px 20px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 13px; font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
    background: none;
    min-height: 38px;
    line-height: 1.2;
    font-family: inherit;
}
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:active { transform: scale(0.98); }
.btn-outline { border-color: #d1d5db; color: #4b5563; background: #fff; }
.btn-outline:hover { border-color: #2563eb; color: #2563eb; background: #eff6ff; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-lg { padding: 11px 28px; font-size: 15px; min-height: 46px; }
.btn-sm { padding: 5px 12px; font-size: 12px; min-height: 30px; }
.btn-block { display: flex; width: 100%; }

/* ========== 面板 ========== */
.panel {
    background: #fff; border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    overflow: hidden;
}
.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 10px;
}
.panel-header h3 { font-size: 16px; font-weight: 600; color: #1f2937; }
.panel-body { padding: 20px; overflow-x: auto; }
.link { color: #3b82f6; font-size: 13px; font-weight: 500; }
.link:hover { text-decoration: underline; }

/* ========== 统计卡片 ========== */
.stat-cards {
    display: grid; grid-template-columns: repeat(4, 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 1px 3px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.stat-card-icon {
    width: 52px; height: 52px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; flex-shrink: 0;
}
.stat-card-icon.blue { background: #dbeafe; }
.stat-card-icon.green { background: #dcfce7; }
.stat-card-icon.orange { background: #fed7aa; }
.stat-card-icon.purple { background: #e9d5ff; }
.stat-card-value { font-size: 22px; font-weight: 700; color: #1f2937; line-height: 1.2; }
.stat-card-label { font-size: 13px; color: #888; margin-top: 4px; }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }

/* ========== 数据表格 ========== */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.data-table th, .data-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    white-space: nowrap;
}
.data-table th {
    background: #f8fafc;
    font-weight: 600; color: #475569;
    white-space: nowrap;
}
.data-table tbody tr { transition: background 0.1s; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table .text-center { text-align: center; }
.data-table .text-primary { color: #2563eb; font-weight: 600; }
.data-table .text-danger { color: #ef4444; }
.data-table td .btn + form, .data-table td .btn + .btn { margin-left: 6px; }
.data-table td form { display: inline; }

/* ========== 徽章 ========== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    color: #fff;
    font-weight: 500;
    white-space: nowrap;
}
.badge-green { background: #10b981; }
.badge-blue { background: #3b82f6; }
.badge-gray { background: #9ca3af; }
.badge-purple { background: #8b5cf6; }
.badge-orange { background: #f59e0b; }
.badge-red { background: #ef4444; }

/* ========== 表单 ========== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; color: #444; font-size: 13px; }
.required { color: #ef4444; }
.form-group input[type="text"], .form-group input[type="password"],
.form-group input[type="number"], .form-group input[type="email"],
.form-group input[type="tel"], .form-group select, .form-group textarea {
    width: 100%;
    padding: 9px 14px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.15s;
    background: #fff;
    min-height: 40px;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.form-group small { display: block; color: #999; font-size: 11px; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 20px; }
.form-group-full { grid-column: 1 / -1; }
.form-inline { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.form-inline .form-group { margin-bottom: 0; }

/* ========== 提示 ========== */
.alert {
    padding: 12px 18px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 13px;
    display: flex; align-items: center;
}
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ========== 筛选栏 ========== */
.filter-bar {
    display: flex; justify-content: space-between; align-items: center;
    background: #fff; border-radius: 10px; padding: 14px 20px;
    margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    flex-wrap: wrap; gap: 10px;
}
.filter-brands { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-tag {
    padding: 6px 16px;
    border-radius: 16px;
    background: #f3f4f6;
    color: #555;
    font-size: 12px;
    transition: all 0.15s;
    cursor: pointer;
    min-height: 32px;
    display: inline-flex; align-items: center;
}
.filter-tag:hover { background: #e5e7eb; }
.filter-tag.active { background: #3b82f6; color: #fff; }
.search-form { display: flex; gap: 8px; }
.search-form input {
    padding: 7px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    width: 200px;
    min-height: 36px;
}
.search-form input:focus { outline: none; border-color: #3b82f6; }

/* ========== 分页 ========== */
.pagination { display: flex; justify-content: center; gap: 5px; margin-top: 20px; flex-wrap: wrap; }
.pagination a, .pagination .current {
    padding: 7px 13px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    color: #555;
    min-width: 34px; text-align: center;
    min-height: 34px;
    display: inline-flex; align-items: center; justify-content: center;
}
.pagination .current { background: #3b82f6; color: #fff; border-color: #3b82f6; font-weight: 600; }
.pagination a:hover { border-color: #3b82f6; color: #3b82f6; }

/* ========== 概览 ========== */
.overview-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.overview-item {
    background: #f8fafc; border-radius: 10px;
    padding: 18px; text-align: center;
}
.overview-label { display: block; font-size: 12px; color: #888; margin-bottom: 6px; }
.overview-value { font-size: 20px; font-weight: 700; color: #1f2937; }

/* ========== 配置组 ========== */
.config-group { margin-bottom: 24px; }
.config-group-title {
    font-size: 15px; color: #1e40af;
    margin-bottom: 14px; padding-bottom: 8px;
    border-bottom: 2px solid #eff6ff;
    font-weight: 600;
}

/* ========== 弹窗 ========== */
.modal {
    display: none;
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center; justify-content: center;
    padding: 20px;
}
.modal.active { display: flex; }
.modal-content {
    background: #fff; border-radius: 14px;
    max-width: 720px; width: 100%;
    max-height: 88vh; overflow-y: auto;
    animation: modalIn 0.2s ease;
}
.modal-lg { max-width: 760px; }
@keyframes modalIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid #f0f0f0;
    display: flex; justify-content: space-between; align-items: center;
    position: sticky; top: 0; background: #fff; z-index: 1;
}
.modal-header h3 { font-size: 17px; font-weight: 600; }
.modal-close {
    background: none; border: none;
    font-size: 26px; color: #999;
    cursor: pointer; line-height: 1;
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
}
.modal-close:hover { background: #f3f4f6; color: #333; }
.modal-body { padding: 24px; }

/* 订单详情 */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; margin-bottom: 18px; }
.detail-item { font-size: 13px; color: #555; line-height: 1.6; }
.detail-full { grid-column: 1 / -1; }
.detail-label { color: #999; }
.status-form { border-top: 1px solid #f0f0f0; padding-top: 18px; margin-top: 8px; }
.status-form .form-group { margin-bottom: 14px; }

/* ========== 后台型号快速选择 combobox ========== */
.admin-combobox { position: relative; width: 100%; }
.admin-combobox input[type="text"] {
    width: 100%;
    padding: 10px 36px 10px 14px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    min-height: 40px;
    cursor: pointer;
    transition: all 0.2s;
}
.admin-combobox input[type="text"]:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.admin-combobox input[type="text"]:not([readonly]) { cursor: text; }
.admin-combobox-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 11px;
    pointer-events: none;
    transition: transform 0.2s;
}
.admin-combobox.open .admin-combobox-arrow { transform: translateY(-50%) rotate(180deg); }
.admin-combobox-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    max-height: 320px;
    overflow-y: auto;
    z-index: 200;
    display: none;
}
.admin-combobox.open .admin-combobox-dropdown { display: block; }
.admin-combobox-option {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    color: #374151;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.admin-combobox-option:last-child { border-bottom: none; }
.admin-combobox-option:hover, .admin-combobox-option.active {
    background: #eff6ff;
    color: #1d4ed8;
}
.admin-combobox-option .option-meta {
    color: #9ca3af;
    font-size: 11px;
    white-space: nowrap;
}
.admin-combobox-option:hover .option-meta, .admin-combobox-option.active .option-meta { color: #60a5fa; }
.admin-combobox-empty { padding: 14px; text-align: center; color: #9ca3af; font-size: 13px; }

/* ========== 批量操作栏 ========== */
.batch-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.batch-select-all {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    font-weight: 500;
}
.batch-select-all input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}
.batch-count {
    font-size: 13px;
    color: #6b7280;
}
.batch-count strong {
    color: #3b82f6;
    font-size: 15px;
}
.batch-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
}
.batch-actions .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.row-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
}
.data-table th input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ========== 权限分配 ========== */
.permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    padding: 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}
.perm-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    padding: 4px 0;
}
.perm-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}
.perm-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: 300px;
}
.perm-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #eff6ff;
    color: #2563eb;
    border-radius: 4px;
    font-size: 11px;
}

/* ============================================================
   响应式断点
   ============================================================ */

/* --- ≤1200px --- */
@media (max-width: 1200px) {
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: repeat(2, 1fr); }
    .overview-grid { grid-template-columns: repeat(2, 1fr); }
}

/* --- ≤992px --- */
@media (max-width: 992px) {
    .admin-sidebar { width: 200px; }
    .admin-main { margin-left: 200px; }
    .admin-logo { font-size: 15px; padding: 16px; }
    .nav-item { padding: 10px 16px; font-size: 13px; }
}

/* --- ≤768px 平板/手机 --- */
@media (max-width: 768px) {
    .admin-sidebar {
        transform: translateX(-100%);
        width: 260px;
        z-index: 200;
        box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    }
    .admin-sidebar.active { transform: translateX(0); }
    .admin-main { margin-left: 0; }
    .sidebar-toggle { display: flex; }
    .sidebar-overlay.active { display: block; }
    .admin-topbar { padding: 0 16px; height: 54px; }
    .topbar-title { font-size: 15px; }
    .admin-username { display: none; }
    .admin-content { padding: 16px; }

    .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .stat-card { padding: 16px; gap: 12px; }
    .stat-card-icon { width: 44px; height: 44px; font-size: 20px; }
    .stat-card-value { font-size: 18px; }
    .stat-card-label { font-size: 12px; }

    .form-grid { grid-template-columns: 1fr; }
    .form-inline { flex-direction: column; align-items: stretch; }
    .form-inline .form-group { width: 100%; }

    .overview-grid { grid-template-columns: 1fr; gap: 12px; }
    .overview-item { padding: 14px; }
    .overview-value { font-size: 18px; }

    .panel-header { padding: 14px 16px; }
    .panel-body { padding: 16px; }

    .filter-bar { flex-direction: column; align-items: stretch; padding: 12px 14px; }
    .search-form { width: 100%; }
    .search-form input { flex: 1; width: auto; }

    .detail-grid { grid-template-columns: 1fr; gap: 8px; }
    .modal-body { padding: 18px; }
    .modal-header { padding: 14px 18px; }

    .login-box { padding: 32px 24px; }
}

/* --- ≤576px 手机 --- */
@media (max-width: 576px) {
    .stat-cards { grid-template-columns: 1fr; }
    .admin-content { padding: 12px; }
    .panel { border-radius: 10px; margin-bottom: 14px; }
    .panel-body { padding: 14px; }
    .data-table th, .data-table td { padding: 10px 12px; font-size: 12px; }
    .btn { padding: 7px 16px; font-size: 12px; min-height: 36px; }
    .btn-lg { padding: 10px 24px; font-size: 14px; min-height: 44px; }
    .pagination a, .pagination .current { padding: 6px 11px; font-size: 12px; min-width: 32px; min-height: 32px; }
    .topbar-user { gap: 10px; font-size: 12px; }
    .topbar-link { font-size: 12px; }
    .login-logo h1 { font-size: 19px; }
    .login-box { padding: 28px 20px; }
}

/* --- ≤400px 小屏手机 --- */
@media (max-width: 400px) {
    .admin-sidebar { width: 240px; }
    .stat-card-value { font-size: 16px; }
    .filter-tag { padding: 5px 12px; font-size: 11px; }
}

/* --- 横屏手机 --- */
@media (max-height: 500px) and (orientation: landscape) {
    .admin-sidebar { overflow-y: auto; }
    .admin-logo { padding: 12px 16px; min-height: auto; }
    .nav-group-title { padding: 8px 16px 4px; }
    .nav-item { padding: 8px 16px; min-height: 36px; }
}

/* --- 打印 --- */
@media print {
    .admin-sidebar, .admin-topbar, .sidebar-toggle, .btn, .pagination { display: none !important; }
    .admin-main { margin-left: 0; }
    .admin-content { padding: 0; }
    .panel { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
    body { background: #fff; }
}
