/* ===== 全局样式 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-500: #6B7280;
    --gray-700: #374151;
    --gray-900: #111827;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--gray-900);
}

/* ===== 登录页 ===== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-box h1 {
    text-align: center;
    font-size: 24px;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.login-subtitle {
    text-align: center;
    color: var(--gray-500);
    font-size: 14px;
    margin-bottom: 30px;
}

.login-box .input-group {
    margin-bottom: 20px;
}

.login-box label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.login-box input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s;
}

.login-box input:focus {
    border-color: var(--primary);
}

.captcha-wrapper {
    display: flex;
    gap: 12px;
}

.captcha-wrapper input {
    flex: 1;
}

.captcha-wrapper img {
    width: 120px;
    height: 48px;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid var(--gray-200);
}

.login-hint {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: var(--gray-500);
}

.login-container .btn-primary {
    margin-top: 10px;
}

/* ===== 用户查询页面 ===== */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

.header {
    text-align: center;
    padding: 30px 0;
    color: white;
}

.header h1 {
    font-size: 28px;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.subtitle {
    font-size: 14px;
    opacity: 0.9;
}

.search-box {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.input-group input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    font-size: 16px;
    transition: all 0.3s;
    outline: none;
}

.input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-tip {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: var(--gray-500);
}

/* ===== 按钮 ===== */
.btn-primary {
    width: 100%;
    padding: 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    padding: 10px 20px;
    background: var(--gray-100);
    color: var(--gray-700);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary:hover { background: var(--gray-200); }

.btn-small {
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 14px;
    text-decoration: underline;
}

/* ===== 结果 ===== */
.result-container { margin-top: 20px; }

.express-card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}

.express-info {
    border-bottom: 1px solid var(--gray-200);
    padding-bottom: 16px;
    margin-bottom: 16px;
}

.info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.express-name {
    font-size: 17px;
    font-weight: 700;
    color: var(--primary);
}

.express-no {
    font-size: 13px;
    color: var(--gray-500);
    font-family: monospace;
}

.info-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.delivered { background: #D1FAE5; color: #065F46; }
.status-badge.transit { background: #DBEAFE; color: #1E40AF; }
.status-badge.picked { background: #FEF3C7; color: #92400E; }

.last-update {
    font-size: 11px;
    color: var(--gray-500);
}

/* 时间线 */
.timeline {
    position: relative;
    padding-left: 20px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--gray-200);
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-item::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gray-300);
    border: 2px solid white;
}

.timeline-item.active::before {
    background: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2);
}

.timeline-content .time {
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.timeline-item.active .time {
    color: var(--primary);
    font-weight: 600;
}

.timeline-content .desc {
    font-size: 14px;
    color: var(--gray-900);
    line-height: 1.5;
}

.timeline-content .location {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}

.no-data {
    color: var(--gray-500);
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

/* 无记录/错误/加载 */
.no-record, .error-container, .loading-container {
    background: white;
    border-radius: 16px;
    padding: 40px 24px;
    margin-top: 20px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}

.no-record-icon, .error-icon {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
}

.hint {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 16px;
    margin-bottom: 8px;
}

.hint-list {
    list-style: none;
    text-align: left;
    display: inline-block;
    font-size: 13px;
    color: var(--gray-600);
}

.hint-list li { padding: 4px 0; }

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* 底部 */
.footer {
    text-align: center;
    padding: 30px 20px;
    color: white;
}

.footer p {
    font-size: 13px;
    opacity: 0.9;
    margin-bottom: 8px;
}

.footer a {
    color: white;
    text-decoration: none;
    font-size: 13px;
    opacity: 0.8;
}

/* ===== 后台管理 ===== */
.admin-body { background: var(--gray-100); }

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: white;
    border-radius: 12px;
    margin-bottom: 20px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.admin-header h1 {
    font-size: 20px;
    color: var(--gray-900);
}

.brand {
    padding: 4px 12px;
    background: linear-gradient(135deg, var(--primary), #818CF8);
    color: white;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-right > span {
    color: var(--gray-700);
    font-size: 14px;
}

.btn-back {
    padding: 10px 20px;
    background: var(--gray-100);
    color: var(--gray-700);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s;
}

.btn-back:hover { background: var(--gray-200); }

.admin-content {
    display: flex;
    gap: 20px;
}

.admin-nav {
    width: 180px;
    background: white;
    border-radius: 12px;
    padding: 12px;
    height: fit-content;
    position: sticky;
    top: 20px;
}

.nav-item {
    width: 100%;
    padding: 12px 14px;
    background: transparent;
    border: none;
    border-radius: 8px;
    text-align: left;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--gray-700);
}

.nav-item:hover { background: var(--gray-100); }
.nav-item.active { background: var(--primary); color: white; }

.admin-main {
    flex: 1;
    min-width: 0;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.tab-content > h2 {
    font-size: 18px;
    margin-bottom: 20px;
    color: var(--gray-900);
}

.card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
}

.card h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--gray-900);
}

.card-intro {
    font-size: 14px;
    color: var(--gray-600);
    margin-bottom: 20px;
    line-height: 1.6;
}

/* 上传 */
.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
}

.upload-placeholder p {
    color: var(--gray-700);
    margin-bottom: 8px;
}

.upload-hint {
    color: var(--gray-500);
    font-size: 13px;
}

/* 预览 */
.preview-info {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-200);
}

.preview-info span { color: var(--gray-700); }
.preview-info strong { color: var(--gray-900); }

/* 映射 */
.mapping-section { margin-bottom: 20px; }

.mapping-section h4 {
    font-size: 14px;
    color: var(--gray-700);
    margin-bottom: 12px;
}

.required-tip {
    font-size: 12px;
    color: var(--gray-500);
    font-weight: normal;
}

.mapping-row {
    display: flex;
    gap: 16px;
}

.mapping-item { flex: 1; }

.mapping-item label {
    display: block;
    font-size: 13px;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.mapping-item .required { color: var(--danger); }

.mapping-item select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 14px;
    background: white;
}

.mapping-item select:focus {
    border-color: var(--primary);
    outline: none;
}

/* 表格 */
.table-wrapper {
    overflow-x: auto;
    margin-bottom: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}

th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
}

.btn-group {
    display: flex;
    gap: 12px;
}

/* 进度 */
.progress-info { margin-bottom: 20px; }

.progress-bar-wrapper {
    height: 12px;
    background: var(--gray-200);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #818CF8);
    border-radius: 6px;
    transition: width 0.3s;
    width: 0%;
}

.progress-text {
    text-align: center;
    font-size: 14px;
    color: var(--gray-700);
}

.progress-detail {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
}

.text-success { color: var(--success); font-weight: 600; }
.text-danger { color: var(--danger); font-weight: 600; }

.success-tip {
    padding: 16px;
    background: #D1FAE5;
    color: #065F46;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
}

/* 设置 */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--gray-200);
}

.setting-item:last-of-type { border-bottom: none; }

.setting-info h4 {
    font-size: 15px;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.setting-info p {
    font-size: 13px;
    color: var(--gray-500);
}

.switch {
    position: relative;
    width: 48px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gray-300);
    border-radius: 26px;
    transition: 0.3s;
}

.slider::before {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

input:checked + .slider { background: var(--primary); }
input:checked + .slider::before { transform: translateX(22px); }

/* 表单 */
.form-group { margin-bottom: 20px; }

.form-group > label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* API状态 */
.api-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--gray-100);
    border-radius: 8px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.status-dot.offline {
    background: var(--danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* 筛选 */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.filter-bar input, .filter-bar select {
    padding: 10px 14px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 14px;
}

.filter-bar input { flex: 1; }

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.pagination button {
    padding: 8px 14px;
    border: 1px solid var(--gray-300);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.pagination button:hover { background: var(--gray-100); }
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }

/* 响应式 */
@media (max-width: 768px) {
    .admin-content { flex-direction: column; }
    .admin-nav { width: 100%; display: flex; overflow-x: auto; }
    .nav-item { white-space: nowrap; }
    .filter-bar { flex-direction: column; }
    .mapping-row { flex-direction: column; }
    .header-right .btn-secondary { display: none; }
}

/* 项目卡片头部 */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header h3 {
    margin: 0;
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.modal-close:hover {
    background: var(--danger);
    color: white;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.form-group small {
    display: block;
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}

/* 额外状态样式 */
.status-badge.delivering { background: #FEF3C7; color: #92400E; }
.status-badge.error { background: #FEE2E2; color: #991B1B; }

/* 耗时显示 */
.take-time {
    font-size: 12px;
    color: var(--gray-500);
    margin-left: 8px;
}

/* 更新时间显示 */
.update-time {
    font-size: 12px;
    color: var(--gray-500);
    margin-left: 8px;
}

/* 最新消息提示 */
.last-message {
    background: #EEF2FF;
    border-left: 3px solid var(--primary);
    padding: 10px 12px;
    margin-top: 10px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--gray-700);
    line-height: 1.5;
}

/* 更多提示 */
.more-hint {
    text-align: center;
    padding: 10px;
    color: var(--gray-500);
    font-size: 12px;
    background: var(--gray-100);
    border-radius: 0 0 8px 8px;
}

/* 额外信息标签 */
.extra-info {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.extra-tag {
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--gray-700);
}
