/* ==========================================================================
   快递单号查询系统 - 全局样式（响应式，无外部依赖，加载快速）
   ========================================================================== */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --warning: #d97706;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --bg: #f3f5f9;
    --white: #ffffff;
    --radius: 10px;
    --shadow: 0 4px 16px rgba(31, 41, 55, .08);
    --shadow-lg: 0 12px 32px rgba(31, 41, 55, .14);
    --sidebar-w: 230px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

.container { width: min(1080px, 92%); margin: 0 auto; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }

/* ---------------- 按钮 ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 18px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: all .15s ease;
    white-space: nowrap;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; filter: brightness(.96); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn-light { background: #f3f4f6; color: var(--text); border-color: var(--border); }
.btn-lg { padding: 12px 28px; font-size: 16px; border-radius: 10px; }
.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn-link {
    background: none; border: none; color: #fff; cursor: pointer;
    font-size: 14px; padding: 8px 12px; width: 100%; text-align: left;
}
.btn-link:hover { background: rgba(255,255,255,.08); }
.btn-text { color: var(--primary); font-size: 14px; }

/* ---------------- 提示条 ---------------- */
.alert {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); color: #166534; border-color: #bbf7d0; }
.alert-error { background: var(--danger-bg); color: #991b1b; border-color: #fecaca; }
.error-list { margin: 6px 0 0; padding-left: 20px; }
.alert-close {
    background: none; border: none; font-size: 20px; line-height: 1;
    cursor: pointer; color: inherit; opacity: .6; padding: 0;
}
.alert-close:hover { opacity: 1; }

/* ==========================================================================
   前台
   ========================================================================== */
.front-body { display: flex; flex-direction: column; min-height: 100vh; }

.site-header {
    background: var(--white);
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
    position: sticky; top: 0; z-index: 20;
}
.header-inner {
    display: flex; align-items: center; justify-content: space-between;
    height: 60px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-icon { font-size: 22px; }
.site-nav a { margin-left: 24px; color: var(--text-muted); font-size: 15px; }
.site-nav a:hover { color: var(--primary); text-decoration: none; }

.main-content { flex: 1; padding: 32px 0; }
.site-footer {
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 18px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}
.site-footer p { margin: 0; }

/* 查询区 */
.query-hero { display: flex; justify-content: center; margin-bottom: 8px; }
.query-card {
    width: min(680px, 100%);
    background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
    color: #fff;
    border-radius: 16px;
    padding: 36px 40px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.query-title { margin: 0 0 8px; font-size: 26px; }
.query-desc { margin: 0 0 24px; opacity: .9; }
.query-form { text-align: left; }
.query-input-group { display: flex; gap: 10px; }
.query-input {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    outline: none;
}
.query-input:focus { box-shadow: 0 0 0 3px rgba(255,255,255,.35); }
.query-form .btn-primary {
    background: #f59e0b;
    color: #1f2937;
    font-weight: 600;
}
.query-form .btn-primary:hover { background: #d97706; }
.form-hint { font-size: 12px; color: var(--text-muted); margin: 8px 2px 0; }
.query-form .form-hint { color: rgba(255,255,255,.85); }

/* 查询结果 */
.result-section { margin-top: 28px; }
.result-heading {
    display: flex; align-items: baseline; gap: 12px;
    font-size: 19px; margin: 0 0 16px;
}
.result-count { font-size: 13px; color: var(--text-muted); font-weight: 400; }

.express-list { display: flex; flex-direction: column; gap: 14px; }
.express-item {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 22px;
    box-shadow: var(--shadow);
    transition: transform .12s ease, box-shadow .12s ease;
}
.express-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.express-item-main { min-width: 0; }
.express-company { display: flex; align-items: center; gap: 10px; font-size: 16px; margin-bottom: 6px; }
.company-logo { width: 28px; height: 28px; object-fit: contain; border-radius: 4px; }
.company-logo-placeholder { font-size: 22px; }
.express-no { color: var(--text); margin-bottom: 4px; }
.tracking-number {
    font-family: "SFMono-Regular", Consolas, Menlo, monospace;
    font-weight: 600; letter-spacing: .3px;
}
.express-meta { font-size: 12px; color: var(--text-muted); }

/* 空状态 */
.empty-state {
    text-align: center;
    background: var(--white);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 56px 20px;
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h2 { margin: 4px 0 8px; }
.empty-state p { color: var(--text-muted); margin: 4px 0; }
.empty-state .btn { margin-top: 16px; }

/* 物流详情 */
.page-back { margin-bottom: 14px; }
.track-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px 30px;
}
.track-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
    padding-bottom: 18px; border-bottom: 1px solid var(--border);
}
.track-company { margin: 0 0 6px; font-size: 22px; }
.track-no { color: var(--text-muted); }
.state-badge {
    background: var(--primary-light); color: var(--primary-dark);
    padding: 4px 12px; border-radius: 999px; font-size: 12px; white-space: nowrap;
}
.track-summary {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 14px; margin: 18px 0 6px;
}
.track-summary dt { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.track-summary dd { margin: 0; font-weight: 500; }
.track-section-title { font-size: 16px; margin: 24px 0 16px; }

.track-notice {
    display: flex; gap: 14px; align-items: flex-start;
    background: #fffbeb; border: 1px solid #fde68a;
    border-radius: var(--radius); padding: 18px;
}
.track-notice-error { background: var(--danger-bg); border-color: #fecaca; }
.notice-icon { font-size: 26px; }
.track-notice p { margin: 2px 0 8px; }

/* 时间线 */
.timeline { list-style: none; margin: 0; padding: 0 0 0 8px; }
.timeline-item { position: relative; padding: 0 0 22px 26px; border-left: 2px solid var(--border); }
.timeline-item:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline-dot {
    position: absolute; left: -7px; top: 4px;
    width: 12px; height: 12px; border-radius: 50%;
    background: #c4c9d4; border: 2px solid #fff;
}
.timeline-item.latest .timeline-dot { background: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); }
.timeline-content { position: relative; }
.timeline-context { margin: 0 0 4px; }
.timeline-time { font-size: 12px; color: var(--text-muted); }
.latest-tag {
    display: inline-block; margin-left: 8px;
    background: var(--primary-light); color: var(--primary-dark);
    font-size: 11px; padding: 1px 8px; border-radius: 999px;
    vertical-align: middle;
}

/* ==========================================================================
   后台登录
   ========================================================================== */
.login-body {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1e3a8a 0%, #4f46e5 100%);
    padding: 20px;
}
.login-wrapper { width: 100%; max-width: 400px; }
.login-card {
    background: var(--white);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 34px 32px;
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand h1 { font-size: 20px; margin: 8px 0 4px; }
.login-brand p { margin: 0; color: var(--text-muted); font-size: 13px; }
.login-footer { text-align: center; margin-top: 18px; font-size: 13px; }

/* ==========================================================================
   后台框架
   ========================================================================== */
.admin-body { background: var(--bg); }
.admin-layout { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: var(--sidebar-w);
    background: #111827;
    color: #d1d5db;
    display: flex; flex-direction: column;
    position: fixed; inset: 0 auto 0 0;
    z-index: 30;
    transition: transform .2s ease;
}
.admin-brand {
    display: flex; align-items: center; gap: 8px;
    padding: 20px 18px; font-size: 16px; font-weight: 700; color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.admin-menu { flex: 1; padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; }
.admin-menu a {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px; border-radius: 8px;
    color: #d1d5db; font-size: 14px;
}
.admin-menu a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.admin-menu a.active { background: var(--primary); color: #fff; }
.menu-icon { font-size: 16px; }
.admin-sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.admin-sidebar-footer a { display: block; padding: 8px 12px; color: #d1d5db; border-radius: 6px; font-size: 14px; }
.admin-sidebar-footer a:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
.admin-sidebar-footer form { margin: 0; }

.admin-main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }
.admin-topbar {
    height: 60px; background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 14px;
    padding: 0 24px; position: sticky; top: 0; z-index: 10;
}
.page-title { font-size: 18px; margin: 0; flex: 1; }
.admin-user { color: var(--text-muted); font-size: 14px; }
.sidebar-toggle {
    display: none; background: none; border: none; font-size: 22px;
    cursor: pointer; color: var(--text); padding: 4px 8px;
}
.admin-content { padding: 24px; }

/* 统计卡片 */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 22px;
}
.stat-card {
    background: var(--white); border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex; align-items: center; gap: 14px;
}
.stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
}
.stat-icon-blue { background: var(--primary-light); }
.stat-icon-green { background: var(--success-bg); }
.stat-icon-orange { background: #fef3c7; }
.stat-icon-purple { background: #ede9fe; }
.stat-label { display: block; font-size: 13px; color: var(--text-muted); }
.stat-number { font-size: 26px; font-weight: 700; }
.stat-card-action a { display: flex; align-items: center; gap: 12px; color: var(--text); width: 100%; }
.stat-card-action a:hover { text-decoration: none; }

/* 面板 / 表格 */
.panel {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.panel-header h2 { margin: 0; font-size: 16px; }
.panel-footer { padding: 14px 22px; border-top: 1px solid var(--border); }
.table-summary { color: var(--text-muted); font-size: 13px; text-align: right; }
.table-wrapper { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.data-table th, .data-table td {
    padding: 12px 14px; text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table th {
    background: #f9fafb; font-size: 13px; color: #374151;
    font-weight: 600; white-space: nowrap;
}
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tr:last-child td { border-bottom: none; }
.empty-row { padding: 40px 0 !important; }

.table-logo { width: 42px; height: 42px; object-fit: contain; border: 1px solid var(--border); border-radius: 6px; padding: 2px; background: #fff; }
.table-logo-placeholder, .mini-logo-placeholder { font-size: 26px; }
.mini-logo { width: 18px; height: 18px; object-fit: contain; vertical-align: middle; margin-right: 4px; }
.company-tag { display: inline-flex; align-items: center; white-space: nowrap; }
.count-badge {
    display: inline-block; min-width: 28px; text-align: center;
    background: var(--primary-light); color: var(--primary-dark);
    border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600;
}
.count-zero { background: #f3f4f6; color: var(--text-muted); }

/* 快递单号待更新状态 */
.pending-no-tag {
    display: inline-block;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    border-radius: 999px;
    padding: 2px 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.optional-tag { color: var(--text-muted); font-weight: 400; font-size: 12px; }
.btn-disabled,
.btn-disabled:hover {
    background: #f3f4f6;
    color: #9ca3af;
    border-color: var(--border);
    cursor: not-allowed;
    filter: none;
}
.address-cell { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phone-cell { white-space: nowrap; }
.action-cell { white-space: nowrap; }
.inline-form { display: inline; }

/* 工具栏 / 搜索 */
.toolbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; margin-bottom: 16px; flex-wrap: wrap;
}
.filter-form { flex: 1; min-width: 280px; }
.filter-fields { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-fields-wide { gap: 8px; }
.filter-fields input, .filter-fields select {
    padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 14px; min-width: 150px; background: #fff;
}
.filter-fields input:focus, .filter-fields select:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}

/* 表单 */
.form-page { max-width: 760px; }
.entity-form { padding: 22px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
.required { color: var(--danger); }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="tel"],
.form-group select,
.form-group textarea,
.login-card input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.login-card input:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-group textarea { resize: vertical; }
.form-actions { display: flex; gap: 10px; margin-top: 24px; }
.current-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.checkbox-label { font-weight: 400 !important; display: inline-flex !important; align-items: center; gap: 6px; }
.form-group input[type="file"] { font-size: 13px; }

/* 分页 */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pagination-info { color: var(--text-muted); font-size: 13px; }
.pagination-links { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pagination-links a, .pagination-links span {
    display: inline-block; min-width: 34px; text-align: center;
    padding: 6px 10px; border-radius: 6px; font-size: 13px;
    border: 1px solid var(--border); background: #fff; color: var(--text);
}
.pagination-links a:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.pagination-links .current { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination-links .disabled { color: #b0b6c0; background: #f9fafb; cursor: not-allowed; }

/* ==========================================================================
   响应式
   ========================================================================== */
@media (max-width: 992px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .track-summary { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .admin-sidebar { transform: translateX(-100%); }
    .admin-sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .admin-main { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .admin-content { padding: 16px; }

    .query-card { padding: 28px 22px; }
    .query-input-group { flex-direction: column; }
    .query-input-group .btn { width: 100%; }

    .express-item { flex-direction: column; align-items: stretch; }
    .express-item-action .btn { width: 100%; }

    .toolbar { flex-direction: column; align-items: stretch; }
    .filter-fields input, .filter-fields select { min-width: 0; flex: 1 1 45%; }
    .toolbar .btn-success { width: 100%; }

    .form-row { grid-template-columns: 1fr; }
    .track-summary { grid-template-columns: 1fr; }
    .track-card { padding: 20px; }
    .main-content { padding: 20px 0; }
    .site-nav a { margin-left: 14px; font-size: 14px; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .filter-fields input, .filter-fields select { flex: 1 1 100%; }
    .data-table { min-width: 640px; }
}
