/* 物流CRM - 主样式 */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --warning: #ea580c;
    --danger: #dc2626;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --topbar-height: 56px;
}

* { margin:0; padding:0; box-sizing:border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
}

/* 顶部导航 */
.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-brand {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.topbar-brand span { color: var(--text-secondary); font-weight: 400; font-size: 13px; }
.topbar-nav { display: flex; gap: 4px; }
.topbar-nav a {
    text-decoration: none;
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    transition: all 0.15s;
}
.topbar-nav a:hover, .topbar-nav a.active {
    background: #eff6ff;
    color: var(--primary);
}
.topbar-right { display: flex; align-items: center; gap: 16px; font-size: 13px; }
.topbar-right a { color: var(--text-secondary); text-decoration: none; }
.topbar-right a:hover { color: var(--danger); }

/* 汉堡菜单按钮 - 默认隐藏 */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    color: var(--text);
    font-size: 22px;
    line-height: 1;
    transition: background 0.15s;
}
.hamburger-btn:hover { background: #f1f5f9; }

/* 移动端侧边抽屉 */
.mobile-drawer {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1000;
}
.mobile-drawer.open { display: block; }
.mobile-drawer-backdrop {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    animation: fadeIn 0.2s ease;
}
.mobile-drawer-panel {
    position: absolute;
    top: 0; right: 0;
    width: 280px;
    max-width: 85vw;
    height: 100%;
    background: #fff;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    overflow-y: auto;
    animation: slideInRight 0.25s ease;
}
.mobile-drawer-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.mobile-drawer-header .brand {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
}
.mobile-drawer-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}
.mobile-drawer-close:hover { background: #f1f5f9; }
.mobile-drawer-user {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
}
.mobile-drawer-user .user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}
.mobile-drawer-user .user-info { flex: 1; min-width: 0; }
.mobile-drawer-user .user-name { font-size: 14px; font-weight: 500; }
.mobile-drawer-user .user-role { font-size: 12px; color: var(--text-secondary); }
.mobile-drawer-nav { padding: 8px 0; }
.mobile-drawer-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s;
}
.mobile-drawer-nav a:hover { background: #f1f5f9; }
.mobile-drawer-nav a.active { color: var(--primary); background: #eff6ff; font-weight: 500; }
.mobile-drawer-nav .nav-icon { font-size: 16px; width: 24px; text-align: center; }
.mobile-drawer-divider { height: 1px; background: var(--border); margin: 4px 0; }
.mobile-drawer-section-title { padding: 12px 16px 4px; font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.mobile-drawer-footer { padding: 12px 16px; border-top: 1px solid var(--border); margin-top: auto; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* 主内容 */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* 页面标题 */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 12px;
}
.page-header h1 { font-size: 20px; font-weight: 600; }

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: all 0.15s;
    line-height: 1.4;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-outline { background: #fff; color: var(--text-secondary); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* 卡片 */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    gap: 8px;
}
.card-header h2 { font-size: 15px; font-weight: 600; }
.card-header h3 { font-size: 14px; font-weight: 500; }

/* 统计卡片 */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.stat-card .stat-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.stat-card .stat-value { font-size: 28px; font-weight: 600; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.stat-blue .stat-value { color: var(--primary); }
.stat-green .stat-value { color: var(--success); }
.stat-orange .stat-value { color: var(--warning); }
.stat-red .stat-value { color: var(--danger); }

/* 表格 - 添加滚动容器支持 */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -20px;
    padding: 0 20px;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 600px;
}
th {
    text-align: left;
    padding: 10px 12px;
    background: var(--bg);
    border-bottom: 2px solid var(--border);
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}
td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
tr:hover { background: #f8fafc; }
td a { color: var(--primary); text-decoration: none; }
td a:hover { text-decoration: underline; }

/* 表单 */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text);
}
.form-group .help-text { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
input[type="text"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="email"],
input[type="password"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
textarea { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}
.form-actions {
    display: flex;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* 标签/状态 */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}
.badge-blue { background: #eff6ff; color: var(--primary); }
.badge-green { background: #f0fdf4; color: var(--success); }
.badge-orange { background: #fff7ed; color: var(--warning); }
.badge-red { background: #fef2f2; color: var(--danger); }
.badge-gray { background: #f1f5f9; color: var(--text-secondary); }
.badge-secondary { background: #e2e8f0; color: #64748b; }

/* 信息展示 */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}
.info-item { padding: 8px 0; }
.info-item .info-label { font-size: 12px; color: var(--text-secondary); }
.info-item .info-value { font-size: 14px; margin-top: 2px; }

/* 标签页 */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 500;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* 搜索栏 */
.search-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.search-bar input { width: 240px; }
.search-bar select { width: 140px; }

/* 时间线 */
.timeline { padding-left: 20px; border-left: 2px solid var(--border); }
.timeline-item { padding: 8px 0 8px 16px; position: relative; }
.timeline-item::before {
    content: '';
    position: absolute;
    left: -26px;
    top: 12px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #fff;
}
.timeline-item .timeline-time { font-size: 12px; color: var(--text-secondary); }
.timeline-item .timeline-content { margin-top: 2px; font-size: 13px; }
.timeline-item .timeline-location { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}
.empty-state p { font-size: 14px; margin-bottom: 12px; }

/* 模态框 */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}
.modal h3 { font-size: 16px; font-weight: 600; margin-bottom: 20px; }

/* 两列网格辅助类 */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ========== 响应式 - 平板 (<=1024px) ========== */
@media (max-width: 1024px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .grid-2col { grid-template-columns: 1fr; }
}

/* ========== 响应式 - 手机 (<=768px) ========== */
@media (max-width: 768px) {
    :root { --topbar-height: 52px; }

    .topbar {
        padding: 0 12px;
        gap: 8px;
    }
    .topbar-brand span { display: none; }
    .topbar-brand + .topbar-brand { display: none; }

    /* 隐藏桌面导航和右侧信息 */
    .topbar-nav { display: none; }
    .topbar-right { display: none; }

    /* 显示汉堡菜单 */
    .hamburger-btn { display: flex; }

    .main-content { padding: 12px; }

    /* 统计卡片 - 手机上2列或1列 */
    .stats-row { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-card .stat-value { font-size: 22px; }
    .stat-card .stat-sub { font-size: 11px; }

    /* 表单 */
    .form-row { grid-template-columns: 1fr; }

    /* 搜索栏 */
    .search-bar { gap: 8px; }
    .search-bar input,
    .search-bar select { width: 100%; }
    .search-bar .btn { width: 100%; justify-content: center; }

    /* 页面标题 */
    .page-header {
        flex-wrap: wrap;
    }
    .page-header h1 { font-size: 18px; }

    /* 卡片 */
    .card { padding: 14px; }

    /* 信息网格 */
    .info-grid { grid-template-columns: 1fr 1fr; }

    /* 两列网格 */
    .grid-2col { grid-template-columns: 1fr; }

    /* 表格 */
    .table-wrap { margin: 0 -14px; padding: 0 14px; }
    table { font-size: 12px; }
    th, td { padding: 8px 8px; }

    /* 模态框 */
    .modal {
        width: 96%;
        padding: 16px;
        border-radius: 12px 12px 0 0;
        max-height: 90vh;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0 auto;
    }
    .modal-overlay.show { align-items: flex-end; }

    /* 标签页 */
    .tabs { gap: 0; }
    .tab-btn { padding: 8px 12px; font-size: 12px; }

    /* 时间线 */
    .timeline { padding-left: 16px; }
    .timeline-item { padding-left: 12px; }

    /* AI 助手 - 全屏 */
    #ai-assistant {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
        max-width: none !important;
        max-height: none !important;
    }
    #ai-assistant > div:first-child { border-radius: 0; }
    #ai-fab {
        bottom: 16px !important;
        right: 16px !important;
        width: 48px !important;
        height: 48px !important;
        font-size: 20px !important;
    }

    /* 按钮组在手机上缩小间距 */
    .page-header > div { display: flex; flex-wrap: wrap; gap: 6px; }
}

/* ========== 响应式 - 小手机 (<=480px) ========== */
@media (max-width: 480px) {
    .stats-row { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr; }
    .stat-card { padding: 12px; }
    .stat-card .stat-value { font-size: 20px; }
    .card { padding: 12px; }
    .card-header { flex-wrap: wrap; gap: 6px; }
    .btn { padding: 6px 12px; font-size: 12px; }
    .btn-sm { padding: 3px 8px; font-size: 11px; }
    .main-content { padding: 8px; }
    .page-header h1 { font-size: 16px; }
}
