/* ============================================================
   common.css - 公共样式文件
   适用于：值班系统、行政系统、损益系统、知识库
   ============================================================ */

/* ===== 1. 全局重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, 'Segoe UI', Roboto, system-ui, sans-serif;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: #f0f4f8;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 10px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: hidden;
}

/* ===== 2. 主容器 ===== */
.app-container {
    max-width: 100%;
    width: 100%;
    background: white;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 20, 40, 0.08);
    padding: 16px 14px 24px;
    margin-top: 10px;
    overflow-x: hidden;
}

/* ===== 3. 顶部栏 ===== */
/* 品牌色：值班系统 - 深蓝 */
.top-bar-brand-blue {
    background: linear-gradient(135deg, #0f2b4f 0%, #1a3a6a 100%);
}
/* 品牌色：行政系统 - 墨绿 */
.top-bar-brand-green {
    background: linear-gradient(135deg, #0d4a3a 0%, #1a6a50 100%);
}
/* 品牌色：损益系统 - 深紫 */
.top-bar-brand-purple {
    background: linear-gradient(135deg, #3d1a6a 0%, #5a2a8a 100%);
}
/* 品牌色：知识库 - 暖橙 */
.top-bar-brand-orange {
    background: linear-gradient(135deg, #8a4a0a 0%, #b86a1a 100%);
}

.top-bar {
    color: #fff;
    padding: 8px 14px;
    border-radius: 10px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.top-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 10px;
    width: 100%;
}

.top-row .brand {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 1 auto;
}

.top-row .brand h2 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    letter-spacing: 0.3px;
}

.top-row .brand .badge {
    background: rgba(255, 255, 255, 0.10);
    padding: 1px 8px;
    border-radius: 12px;
    font-size: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.top-row .brand .admin-badge {
    background: rgba(251, 191, 36, 0.20);
    color: #fbbf24;
    padding: 1px 10px;
    border-radius: 12px;
    font-size: 10px;
    border: 1px solid rgba(251, 191, 36, 0.15);
}

.top-row .login-section {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.top-row .login-section .shop-name {
    font-weight: 600;
    color: #fff;
    background: rgba(255, 255, 255, 0.10);
    padding: 2px 12px;
    border-radius: 12px;
    font-size: 12px;
}

/* 权限标签 */
.perm-badge {
    font-size: 10px;
    padding: 2px 10px;
    border-radius: 10px;
    font-weight: 500;
    white-space: nowrap;
}
.perm-badge.perm-admin {
    background: rgba(239, 68, 68, 0.25);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.20);
}
.perm-badge.perm-view {
    background: rgba(251, 191, 36, 0.20);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.15);
}
.perm-badge.perm-edit {
    background: rgba(52, 211, 153, 0.20);
    color: #6ee7b7;
    border: 1px solid rgba(52, 211, 153, 0.15);
}

.top-row .user-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.top-row .user-actions button {
    border: none;
    border-radius: 4px;
    padding: 2px 10px;
    font-size: 11px;
    cursor: pointer;
    transition: 0.2s;
    color: #fff;
    min-height: 26px;
    white-space: nowrap;
}
.top-row .user-actions button:active {
    transform: scale(0.96);
}
.top-row .user-actions .btn-changepwd {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.12);
}
.top-row .user-actions .btn-changepwd:hover {
    background: rgba(255, 255, 255, 0.25);
}
.top-row .user-actions .btn-admin {
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.20);
}
.top-row .user-actions .btn-admin:hover {
    background: rgba(251, 191, 36, 0.30);
}
.top-row .user-actions .btn-auth {
    background: rgba(139, 92, 246, 0.25);
    border: 1px solid rgba(139, 92, 246, 0.25);
}
.top-row .user-actions .btn-auth:hover {
    background: rgba(139, 92, 246, 0.40);
}
.top-row .user-actions .btn-logout {
    background: rgba(220, 38, 38, 0.70);
}
.top-row .user-actions .btn-logout:hover {
    background: #dc2626;
}
.top-row .user-actions .btn-back {
    background: #8b5cf6;
}
.top-row .user-actions .btn-back:hover {
    background: #7c3aed;
}
.top-row .user-actions .btn-history-top {
    background: #f59e0b;
}
.top-row .user-actions .btn-history-top:hover {
    background: #d97706;
}

.top-row .btn-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.top-row .btn-group .btn {
    padding: 2px 10px;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    font-weight: 500;
    transition: 0.2s;
    color: #fff;
    min-height: 26px;
    white-space: nowrap;
}
.top-row .btn-group .btn:active {
    transform: scale(0.96);
}
.top-row .btn-group .btn-checkall {
    background: #6366f1;
}
.top-row .btn-group .btn-checkall:hover {
    background: #4f46e5;
}
.top-row .btn-group .btn-cancelall {
    background: #8b5cf6;
}
.top-row .btn-group .btn-cancelall:hover {
    background: #7c3aed;
}
.top-row .btn-group .btn-query {
    background: #0ea5e9;
}
.top-row .btn-group .btn-query:hover {
    background: #0284c7;
}

/* ===== 4. 菜单（通用） ===== */
/* 一级菜单 */
.tab-bar {
    display: flex;
    gap: 4px;
    background: #f0f4fa;
    padding: 4px;
    border-radius: 30px;
    margin-bottom: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #c1c9d4 #f0f2f5;
}
.tab-bar::-webkit-scrollbar {
    height: 4px;
    display: block;
}
.tab-bar::-webkit-scrollbar-track {
    background: #f0f2f5;
    border-radius: 2px;
}
.tab-bar::-webkit-scrollbar-thumb {
    background: #c1c9d4;
    border-radius: 2px;
}

.tab-btn {
    border: none;
    background: transparent;
    padding: 6px 14px;
    border-radius: 24px;
    font-weight: 500;
    font-size: 12px;
    color: #3e5f7a;
    cursor: pointer;
    transition: 0.2s;
    text-align: center;
    white-space: nowrap;
    flex-shrink: 0;
    min-height: 32px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.tab-btn i {
    font-size: 12px;
}
.tab-btn:active {
    transform: scale(0.96);
}
.tab-btn.active {
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    color: #0b2b44;
    font-weight: 600;
}

/* 二级菜单 */
.tab-bar-2 {
    display: flex;
    gap: 4px;
    background: #f8fafc;
    padding: 4px 6px;
    border-radius: 10px;
    border: 1px solid #e2eaf2;
    margin-bottom: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #c1c9d4 #f0f2f5;
}
.tab-bar-2::-webkit-scrollbar {
    height: 4px;
    display: block;
}
.tab-bar-2::-webkit-scrollbar-track {
    background: #f0f2f5;
    border-radius: 2px;
}
.tab-bar-2::-webkit-scrollbar-thumb {
    background: #c1c9d4;
    border-radius: 2px;
}

.tab-btn-2 {
    border: none;
    background: transparent;
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 12px;
    color: #4a6a8a;
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
    min-height: 32px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.tab-btn-2 i {
    font-size: 12px;
}
.tab-btn-2:active {
    transform: scale(0.96);
}
.tab-btn-2:hover {
    background: #e8edf4;
}
.tab-btn-2.active {
    background: #1a3a6a;
    color: white;
    box-shadow: 0 2px 6px rgba(26, 58, 106, 0.20);
}
.tab-btn-2.active i {
    color: white;
}

/* 三级菜单 */
.tab-bar-3 {
    display: flex;
    gap: 4px;
    background: #f3f4f6;
    padding: 4px 6px;
    border-radius: 8px;
    margin-bottom: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #c1c9d4 #f0f2f5;
}
.tab-bar-3::-webkit-scrollbar {
    height: 4px;
    display: block;
}
.tab-bar-3::-webkit-scrollbar-track {
    background: #f0f2f5;
    border-radius: 2px;
}
.tab-bar-3::-webkit-scrollbar-thumb {
    background: #c1c9d4;
    border-radius: 2px;
}

.tab-btn-3 {
    border: none;
    background: transparent;
    padding: 6px 14px;
    border-radius: 16px;
    font-weight: 500;
    font-size: 12px;
    color: #6b7280;
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
    min-height: 32px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.tab-btn-3 i {
    font-size: 12px;
}
.tab-btn-3:active {
    transform: scale(0.96);
}
.tab-btn-3:hover {
    background: #e5e7eb;
    color: #374151;
}
.tab-btn-3.active {
    background: #1a3a6a;
    color: white;
    box-shadow: 0 2px 6px rgba(26, 58, 106, 0.18);
}
.tab-btn-3.active i {
    color: white;
}

/* ===== 5. 滑动提示条（左对齐） ===== */
.scroll-hint {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 2px 0 6px 0;
    font-size: 10px;
    color: #9ca3af;
}
.scroll-hint .scroll-text {
    font-size: 10px;
    color: #9ca3af;
    white-space: nowrap;
}
.scroll-hint .scroll-bar-track {
    flex: 1;
    max-width: 120px;
    height: 3px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}
.scroll-hint .scroll-bar-track .scroll-bar-thumb {
    width: 35%;
    height: 100%;
    background: #c1c9d4;
    border-radius: 2px;
    animation: scrollSlide 2.5s ease-in-out infinite alternate;
}
@keyframes scrollSlide {
    0% { transform: translateX(0); }
    100% { transform: translateX(150%); }
}
.scroll-hint.hidden {
    display: none !important;
}

/* ===== 6. 三行信息头 ===== */
.info-header {
    background: #f8fafc;
    border-radius: 8px;
    padding: 8px 14px;
    margin-bottom: 10px;
    border: 1px solid #e2eaf2;
    font-size: 12px;
    color: #1f3f5c;
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.6;
}
.info-header .info-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
}
.info-header .info-row .label {
    font-weight: 500;
    color: #4a6a8a;
}
.info-header .info-row .value {
    font-weight: 600;
    color: #0a2942;
}
.info-header .info-row .divider {
    color: #d6e0ea;
}
.info-header .info-table-name {
    font-size: 13px;
    font-weight: 600;
    color: #0a2942;
}

/* ===== 7. 公共按钮 ===== */
.btn {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    font-size: 12px;
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 32px;
    white-space: nowrap;
}
.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: #1e4f7a;
    color: white;
}
.btn-primary:hover {
    background: #143b5c;
}

.btn-success {
    background: #1e7a5e;
    color: white;
}
.btn-success:hover {
    background: #146349;
}

.btn-danger {
    background: #b13a3a;
    color: white;
}
.btn-danger:hover {
    background: #8f2c2c;
}

.btn-outline {
    background: transparent;
    border: 1px solid #d0ddee;
    color: #1f3f5c;
}
.btn-outline:hover {
    background: #eaf0f8;
}

.btn-sm {
    padding: 4px 12px;
    font-size: 11px;
    min-height: 28px;
}

/* ===== 8. 弹窗（通用） ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 16px;
}
.modal-overlay.show {
    display: flex;
}

.modal-box {
    background: white;
    border-radius: 24px;
    padding: 20px 18px;
    max-width: 860px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2eaf2;
    padding-bottom: 10px;
    margin-bottom: 12px;
    flex-shrink: 0;
}
.modal-header h2 {
    font-size: 18px;
    color: #0a2942;
    display: flex;
    align-items: center;
    gap: 8px;
}
.modal-header .close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #6a89a5;
    cursor: pointer;
    padding: 0 8px;
    transition: 0.2s;
}
.modal-header .close-btn:hover {
    color: #1f3f5c;
    transform: rotate(90deg);
}

/* ===== 9. 表格样式 ===== */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    border: 1px solid #e2eaf2;
    background: white;
    padding: 2px;
}
.table-wrap::-webkit-scrollbar {
    height: 6px;
    display: block;
}
.table-wrap::-webkit-scrollbar-track {
    background: #f0f2f5;
    border-radius: 3px;
}
.table-wrap::-webkit-scrollbar-thumb {
    background: #b0b8c4;
    border-radius: 3px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    min-width: 600px;
}
th {
    padding: 8px 10px;
    border: 1px solid #d6e0ea;
    text-align: center;
    font-weight: 600;
    font-size: 11px;
    background: #e8edf2;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}
td {
    padding: 8px 10px;
    border: 1px solid #eaeff5;
    text-align: center;
    vertical-align: middle;
    font-size: 12px;
}

/* ===== 10. 历史预览弹窗 ===== */
.preview-modal .preview-body {
    flex: 1;
    overflow: auto;
    background: #f5f8fa;
    border-radius: 12px;
    border: 1px solid #e2eaf2;
    padding: 16px 20px;
    min-height: 200px;
    max-height: 55vh;
}
.preview-modal .preview-meta {
    background: #fff;
    padding: 8px 14px;
    border-radius: 8px;
    margin-bottom: 12px;
    border-left: 4px solid #8b5cf6;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
    font-size: 12px;
    color: #1f3f5c;
}
.preview-modal .preview-meta .meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}
.preview-modal .preview-meta .meta-item .label {
    color: #6a89a5;
}
.preview-modal .preview-meta .meta-item .value {
    font-weight: 500;
    color: #0a2942;
}
.preview-modal .preview-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 12px;
    border-top: 1px solid #e2eaf2;
    margin-top: 12px;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.preview-modal .preview-actions .btn {
    padding: 6px 20px;
    font-size: 12px;
}

/* ===== 11. 锁定状态标签 ===== */
.lock-badge {
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}
.lock-badge.draft {
    background: #e8edf2;
    color: #3a4a5a;
}
.lock-badge.editable {
    background: #d1fae5;
    color: #065f46;
}
.lock-badge.locked {
    background: #fde8d0;
    color: #7a4a1a;
}

/* ===== 12. 移动端适配 ===== */
@media (max-width: 768px) {
    body {
        padding: 6px;
    }
    .app-container {
        padding: 10px 8px 16px;
        border-radius: 16px;
    }

    /* 顶部栏 */
    .top-row .brand h2 {
        font-size: 13px;
    }
    .top-row .brand .badge {
        font-size: 9px;
    }
    .top-row .login-section .shop-name {
        font-size: 11px;
    }
    .top-row .user-actions button,
    .top-row .btn-group .btn {
        font-size: 10px;
        padding: 2px 8px;
        min-height: 24px;
    }
    .perm-badge {
        font-size: 9px;
        padding: 1px 8px;
    }

    /* 菜单 */
    .tab-btn {
        font-size: 12px;
        padding: 6px 12px;
        min-height: 44px;
    }
    .tab-btn i {
        font-size: 12px;
    }
    .tab-btn-2 {
        font-size: 12px;
        padding: 6px 12px;
        min-height: 44px;
    }
    .tab-btn-2 i {
        font-size: 12px;
    }
    .tab-btn-3 {
        font-size: 12px;
        padding: 6px 12px;
        min-height: 44px;
    }
    .tab-btn-3 i {
        font-size: 12px;
    }

    /* 表格 */
    table {
        font-size: 11px;
        min-width: 500px;
    }
    th {
        font-size: 10px;
        padding: 6px 8px;
    }
    td {
        font-size: 11px;
        padding: 6px 8px;
    }

    /* 按钮 */
    .btn {
        font-size: 11px;
        padding: 4px 12px;
        min-height: 44px;
    }
    .btn-sm {
        font-size: 10px;
        padding: 4px 10px;
        min-height: 38px;
    }

    /* 弹窗 */
    .modal-box {
        padding: 14px 12px;
        border-radius: 16px;
    }
    .modal-header h2 {
        font-size: 15px;
    }

    /* 信息头 */
    .info-header {
        font-size: 11px;
        padding: 6px 10px;
    }
    .info-header .info-table-name {
        font-size: 12px;
    }

    /* 预览弹窗 */
    .preview-modal .preview-body {
        padding: 12px 14px;
        max-height: 50vh;
        min-height: 150px;
    }
    .preview-modal .preview-meta {
        font-size: 11px;
        padding: 6px 10px;
        gap: 4px 12px;
    }
    .preview-modal .preview-actions .btn {
        font-size: 11px;
        padding: 4px 14px;
        min-height: 38px;
    }
}

@media (max-width: 400px) {
    .top-row .brand h2 {
        font-size: 12px;
    }
    .top-row .login-section .shop-name {
        font-size: 10px;
        padding: 1px 8px;
    }
    .tab-btn {
        font-size: 12px;
        padding: 4px 10px;
        min-height: 40px;
    }
    .tab-btn-2 {
        font-size: 12px;
        padding: 4px 10px;
        min-height: 40px;
    }
    .tab-btn-3 {
        font-size: 12px;
        padding: 4px 10px;
        min-height: 40px;
    }
    table {
        font-size: 10px;
        min-width: 380px;
    }
    th {
        font-size: 9px;
        padding: 4px 6px;
    }
    td {
        font-size: 10px;
        padding: 4px 6px;
    }
    .info-header {
        font-size: 10px;
    }
}