/* ========== 鲜冷物流中枢 全局样式 ========== */

:root {
    --primary: #0891b2;
    --primary-dark: #0e7490;
    --primary-light: #e0f7fa;
    --pending: #f59e0b;
    --pending-light: #fef3c7;
    --completed: #0891b2;
    --completed-light: #cffafe;
    --danger: #ef4444;
    --success: #10b981;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --sidebar-bg: #0f172a;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #0891b2;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.08), 0 4px 10px rgba(0,0,0,.04);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-w: 220px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

/* ========== 布局 ========== */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

.sidebar-logo {
    padding: 22px 20px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.logo-icon { font-size: 22px; }
.logo-img { height: 30px; width: auto; display: block; flex-shrink: 0; }

.sidebar-nav { padding: 12px 0; flex: 1; overflow-y: auto; }

.nav-section {
    padding: 16px 20px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-light);
    opacity: .6;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all .15s;
    border-left: 3px solid transparent;
    font-size: 14px;
}

.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active {
    background: rgba(8,145,178,.15);
    color: #fff;
    border-left-color: var(--sidebar-active);
}

.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    background: var(--card-bg);
    padding: 16px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title { font-size: 20px; font-weight: 600; }

.topbar-right { display: flex; align-items: center; gap: 14px; }

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 13px;
}

.user-role {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.role-admin { background: #fef3c7; color: #92400e; }
.role-advanced { background: var(--primary-light); color: var(--primary-dark); }
.role-clerk { background: #ede9fe; color: #6d28d9; }
.role-guest { background: #f1f5f9; color: #475569; }

.btn-logout {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 14px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    transition: all .15s;
}
.btn-logout:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.content { padding: 24px 28px; flex: 1; }

/* ========== 卡片 ========== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ========== 统计卡片 ========== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 18px; margin-bottom: 22px; }

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
}
.stat-card.pending::before { background: var(--pending); }
.stat-card.completed::before { background: var(--completed); }
.stat-card.efficiency::before { background: var(--success); }

.stat-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.stat-value { font-size: 32px; font-weight: 700; }
.stat-card.pending .stat-value { color: var(--pending); }
.stat-card.completed .stat-value { color: var(--completed); }
.stat-card.efficiency .stat-value { color: var(--success); }
.stat-unit { font-size: 14px; color: var(--text-light); font-weight: 400; margin-left: 4px; }

/* ========== 网格布局 ========== */
.grid-2 { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.grid-2-even { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

@media (max-width: 1100px) {
    .grid-2, .grid-2-even { grid-template-columns: 1fr; }
}

/* ========== 表格 ========== */
.table-wrap {
    max-height: 420px;
    overflow-y: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table th {
    background: #f8fafc;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 9px 14px;
    border-bottom: 1px solid #f1f5f9;
}

.data-table tbody tr:hover { background: #f8fafc; }

/* 可点击行：总览原始数据表行可跳转到未发货查询 */
.data-table tbody tr.clickable-row { cursor: pointer; transition: background .12s; }
.data-table tbody tr.clickable-row:hover { background: var(--primary-light); }

.num-pending { color: var(--pending); font-weight: 600; }
.num-completed { color: var(--completed); font-weight: 600; }

/* ========== 人效面板 ========== */
.efficiency-panel { display: flex; flex-direction: column; gap: 16px; }

.efficiency-big {
    text-align: center;
    padding: 24px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, #06b6d4 100%);
    border-radius: var(--radius);
    color: #fff;
}

.efficiency-big .eff-label { font-size: 13px; opacity: .85; margin-bottom: 6px; }
.efficiency-big .eff-value { font-size: 42px; font-weight: 700; }
.efficiency-big .eff-unit { font-size: 14px; opacity: .85; }
.efficiency-big .eff-detail { font-size: 12px; opacity: .7; margin-top: 8px; }

.wh-eff-list { display: flex; flex-direction: column; gap: 8px; }

.wh-eff-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: var(--radius-sm);
}

.wh-eff-name { font-size: 13px; color: var(--text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wh-eff-value { font-size: 15px; font-weight: 700; color: var(--primary); }

/* ========== 图表容器 ========== */
.chart-container { position: relative; width: 100%; }
.chart-container.h300 { height: 300px; }
.chart-container.h360 { height: 360px; }

/* ========== 表单 ========== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 5px; font-weight: 500; }

input[type="text"], input[type="password"], input[type="number"], input[type="time"], input[type="date"], select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    background: #fff;
    transition: border-color .15s;
}

input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(8,145,178,.1); }

.btn {
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: all .15s;
    font-weight: 500;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ========== 登录页 ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #0e7490 50%, #06b6d4 100%);
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px 36px;
    width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}
.login-logo .icon { font-size: 42px; }
.login-logo .title { font-size: 22px; font-weight: 700; color: var(--text); margin-top: 8px; }
.login-logo .subtitle { font-size: 13px; color: var(--text-light); margin-top: 4px; }

.login-error {
    background: #fef2f2;
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid #fecaca;
}

.login-btn { width: 100%; padding: 11px; font-size: 15px; }

/* ========== 提示 ========== */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* ========== 标签 ========== */
.badge { padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-advanced { background: var(--primary-light); color: var(--primary-dark); }
.badge-clerk { background: #ede9fe; color: #6d28d9; }

/* ========== 工具 ========== */
.text-center { text-align: center; }
.text-muted { color: var(--text-light); }
.mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

.refresh-indicator {
    font-size: 12px;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 4px;
}
.refresh-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:.4;} }

/* 滚动条 */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* 物流查询页响应式 */
@media (max-width: 600px) {
    .logistics-page .detail-grid { grid-template-columns: 1fr; }
}

/* ========== 移动端适配（≤768px）电脑端不受影响 ========== */

/* 汉堡按钮：电脑端隐藏，手机端显示 */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}
.menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
    transition: all .2s;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }

/* 遮罩层：电脑端隐藏 */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
}

@media (max-width: 768px) {
    /* 汉堡按钮显示 */
    .menu-toggle { display: flex; }

    /* 侧边栏：默认隐藏，加 .open 类后滑入 */
    .sidebar {
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 100;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar.open ~ .sidebar-overlay { display: block; }

    /* 主内容区全宽 */
    .main { margin-left: 0; }

    /* topbar 紧凑 */
    .topbar { padding: 12px 16px; }
    .page-title { font-size: 17px; }
    .topbar-right { gap: 8px; }
    .user-badge { font-size: 12px; }
    .user-badge .user-name { display: none; }  /* 手机端隐藏用户名只留角色 */
    .btn-logout { padding: 5px 10px; font-size: 12px; }

    /* 内容区减小 padding */
    .content { padding: 16px; }

    /* 统计卡片：单列 */
    .stat-grid { grid-template-columns: 1fr; gap: 12px; }

    /* 所有网格变单列 */
    .grid-2, .grid-2-even { grid-template-columns: 1fr; }

    /* 卡片减小内边距 */
    .card { padding: 16px; }

    /* 表单行：铺满单列（修复签到/未发货查询的 grid 内联样式） */
    .card form > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* 表格横向滚动（table-wrap 已有 overflow，这里确保宽度够用） */
    .table-wrap { max-height: none; }
    table.data-table { min-width: 600px; }

    /* 库存分析表：整体横向滚动 */
    .inv-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .inventory-table { font-size: 12px; }

    /* 图表高度适当缩小 */
    .chart-container.h300 { height: 260px; }
    .chart-container.h360 { height: 300px; }

    /* 签到页快捷填写按钮换行 */
    .quick-fill-btn { font-size: 10px; padding: 3px 7px; }

    /* 签退表单的行内 flex 换行 */
    .signout-form { flex-wrap: wrap !important; }

    /* 顶部统计大数字缩小 */
    .stat-value { font-size: 26px; }
    .efficiency-big .eff-value { font-size: 34px; }

    /* 物流查询页 */
    .logistics-page { margin: 20px 16px; }

    /* 登录页卡片适配 */
    .login-card { width: 92%; padding: 32px 24px; }
}

/* 超窄屏（≤400px）进一步优化 */
@media (max-width: 400px) {
    .stat-value { font-size: 22px; }
    .login-logo .title { font-size: 18px; }
}
