/* ================= 全局重置与基础样式 ================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}
body {
    background: #ffffff;
    color: #222;
    padding: 20px;
    max-width: 1400px; /* 放宽最大宽度以容纳多列表格 */
    margin: 0 auto;
}

/* ================= 顶部栏与 Logo ================= */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}
.title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}
.header-logo {
    height: 36px;
    width: auto;
}
.title {
    font-size: 22px;
    font-weight: 600;
    color: #1954b8;
}

/* ================= 模块 Tab 导航 ================= */
.admin-tabs {
    display: flex;
    border-bottom: 1px solid #eef1f5;
    margin-bottom: 24px;
}
.tab-item {
    padding: 12px 20px;
    font-size: 15px;
    color: #666;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}
.tab-item:hover {
    color: #1954b8;
}
.tab-item.active {
    color: #1954b8;
    font-weight: 600;
    border-bottom-color: #1954b8;
}

/* ================= 面板切换与工具栏 ================= */
.module-panel {
    display: none;
}
.module-panel.active {
    display: block;
    animation: fadeIn 0.3s;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}
.toolbar {
    margin-bottom: 16px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ================= 按钮通用样式 ================= */
button {
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    border: none;
    transition: 0.2s;
}
.btn-primary {
    background: #1954b8;
    color: #fff;
}
.btn-primary:hover {
    background: #143f8a;
}
.btn-primary:disabled {
    background: #99b5df;
    cursor: not-allowed;
}
.btn-default {
    background: #fff;
    color: #1954b8;
    border: 1px solid #1954b8;
}
.btn-default:hover {
    background: #f0f4fc;
}
.btn-edit {
    background: #fff;
    color: #1954b8;
    border: 1px solid #1954b8;
}
.btn-del {
    background: #d93025;
    color: #fff;
}
.btn-view {
    background: #1954b8;
    color: #fff;
}
.btn-label {
    background: #fff;
    color: #0f7b6c;
    border: 1px solid #0f7b6c;
}
.btn-label:hover {
    background: #eefaf7;
}

/* ================= 表格样式 (电池列表) ================= */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border-radius: 8px;
    background: #fff;
}
#mainTable {
    width: max-content;
    min-width: 100%;
    border-collapse: separate; 
    border-spacing: 0;         
    table-layout: auto;
    border-top: 1px solid #dddddd;
    border-left: 1px solid #dddddd;
}
th, td {
    border: 1px solid #eef1f5;
    padding: 12px 10px;
    font-size: 13px;
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: #fff;
}
th {
    background: #f9fafb;
    color: #1954b8;
    font-weight: bold;
}
.col-auto {
    max-width: 200px;
    white-space: nowrap;
}
.col-action {
    position: sticky;
    right: 0;
    white-space: nowrap;
    min-width: 280px; 
    border-left: 1px solid #dddddd; 
    background: #fff;
    z-index: 10;
}
.action-btn-group {
    display: flex;
    gap: 6px;
}
.import-input {
    display: none;
}

/* ================= 单表单卡片 (厂商信息) ================= */
.single-form-card {
    background: #fff;
    padding: 32px;
    border-radius: 8px;
    max-width: 600px;
    margin: 0 auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid #eef1f5;
}
.card-title {
    font-size: 18px;
    margin-bottom: 24px;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 12px;
}
.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: #555;
    font-weight: 500;
}
.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #d9dee6;
    border-radius: 8px;
    font-size: 14px;
    box-sizing: border-box;
    outline: none;
    transition: border 0.2s;
}
.form-group input:focus,
.form-group textarea:focus {
    border-color: #1954b8;
}
.form-actions {
    text-align: right;
    margin-top: 32px;
}

/* ================= 用户信息与下拉菜单 ================= */
.user-menu-container {
    position: relative;
    user-select: none;
}
.user-info-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
}
.user-info-trigger:hover {
    background: #f0f4fc;
}
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: #eef1f5;
}
.user-name {
    font-size: 14px;
    color: #333;
    font-weight: 500;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dropdown-arrow {
    color: #666;
    transition: transform 0.2s;
}
.user-menu-container.active .dropdown-arrow {
    transform: rotate(180deg);
}

/* 下拉面板 */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 180px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #eef1f5;
    padding: 6px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 100;
}
.user-menu-container.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    transition: background 0.2s;
}
.dropdown-item:hover {
    background: #f5f8fd;
    color: #1954b8;
}
.dropdown-item.logout {
    color: #e53935;
}
.dropdown-item.logout:hover {
    background: #ffebee;
    color: #d32f2f;
}
.dropdown-divider {
    height: 1px;
    background: #eef1f5;
    margin: 6px 0;
}

/* ================= 弹窗通用 (Modal) ================= */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}
.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}
.modal-content {
    background: #fff;
    width: 90%;
    max-width: 500px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    transform: translateY(20px);
    transition: transform 0.3s;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}
.modal-overlay.show .modal-content {
    transform: translateY(0);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #eef1f5;
    flex-shrink: 0;
}
.modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #1954b8;
}
.close-btn {
    font-size: 24px;
    color: #999;
    cursor: pointer;
    line-height: 1;
}
.close-btn:hover {
    color: #e53935;
}
.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}
.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #eef1f5;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-shrink: 0;
}

/* ================= 头像网格 (个人资料弹窗) ================= */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    max-height: 240px;
    overflow-y: auto;
    padding: 4px;
}
.avatar-option {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
    background: #f5f5f5;
}
.avatar-option:hover {
    transform: scale(1.1);
}
.avatar-option.selected {
    border-color: #1954b8;
    box-shadow: 0 0 0 3px rgba(25, 84, 184, 0.2);
}

/* ================= 二维码弹窗 ================= */
#qrcodeModal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}
.qrcode-modal-box {
    background: #fff;
    border-radius: 12px;
    max-width: 420px;
    width: 100%;
    padding: 24px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.btn-modal-close {
    position: absolute;
    right: 16px;
    top: 16px;
    border: none;
    background: transparent;
    font-size: 22px;
    cursor: pointer;
    color: #333;
    padding: 0;
}
.qrcode-modal-title {
    font-size: 18px;
    font-weight: bold;
    color: #222;
    margin-bottom: 16px;
}
#qrcodeContainer {
    margin: 16px auto 24px;
}
#qrcodeContainer img {
    display: block;
    max-width: 100%;
    height: auto;
}
.qrcode-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 6px;
}
.qr-hint {
    min-height: 18px;
    font-size: 12px;
    color: #0f7b6c;
    text-align: center;
    margin-bottom: 6px;
}
.link-text a {
    color: #1954b8;
    cursor: pointer;
    text-decoration: underline;
    font-size: 14px;
}

/* ================= 模板管理专用样式 ================= */
/* 文字链接式操作按钮 */
.link-primary {
    color: #1954b8;
    cursor: pointer;
    margin-right: 12px;
    font-weight: 500;
    font-size: 13px;
}
.link-primary:hover {
    text-decoration: underline;
}
.link-danger {
    color: #e53935;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
}
.link-danger:hover {
    text-decoration: underline;
}

/* 代码编辑器文本框 */
.code-textarea {
    width: 100%;
    height: 350px;
    padding: 12px;
    border: 1px solid #d9dee6;
    border-radius: 8px;
    font-family: "Consolas", "Monaco", "Courier New", monospace;
    font-size: 13px;
    line-height: 1.6;
    background: #fafbfc;
    color: #333;
    resize: vertical;
    outline: none;
}
.code-textarea:focus {
    border-color: #1954b8;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(25, 84, 184, 0.1);
}

/* 模板预览纸张效果 */
.doc-preview-area {
    padding: 10px;
    display: flex;
    justify-content: center;
}
.doc-paper {
    background: #fff;
    width: 100%;
    max-width: 800px;
    padding: 40px;
    min-height: 500px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    border-radius: 4px;
    color: #222;
    line-height: 1.6;
    font-size: 14px;
}
.doc-paper img {
    max-width: 100%;
}

/* ================= 后台厂商 / 护照维护表单 ================= */
.admin-fieldset {
    border: 1px solid #eef1f5;
    border-radius: 10px;
    padding: 12px 14px 14px;
    margin-bottom: 14px;
}
.admin-fieldset legend {
    padding: 0 8px;
    font-size: 13px;
    font-weight: 700;
    color: #1954b8;
}
.admin-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
}
.admin-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.admin-field.is-wide { grid-column: 1 / -1; }
.admin-field label {
    font-size: 12px;
    color: #555;
}
.admin-field input,
.admin-field select,
.admin-field textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d9dee6;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
}
.admin-field textarea {
    resize: vertical;
    font-family: Consolas, "Courier New", monospace;
}
@media (max-width: 720px) {
    .admin-form-grid { grid-template-columns: 1fr; }
}