:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #eef2ff;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success: #10b981;
    --success-light: #ecfdf5;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --info: #0ea5e9;
    --info-light: #f0f9ff;
    --sidebar-width: 260px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius-md: 10px;
    --radius-lg: 14px;
}

* {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--bg-main);
    margin: 0;
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
}

/* Sidebar Layout */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: white;
    padding: 24px 0;
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    box-shadow: 4px 0 10px rgba(0,0,0,0.1);
}

.sidebar-logo {
    padding: 0 24px 40px;
    font-size: 1.4rem;
    font-weight: 800;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: -0.5px;
}

.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0 16px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}

.nav-menu::-webkit-scrollbar {
    width: 4px;
}

.nav-menu::-webkit-scrollbar-thumb {
    background-color: #334155;
    border-radius: 4px;
}

.nav-divider {
    margin: 12px 0;
    border-top: 1px solid #334155;
    opacity: 0.5;
}

/* 日历样式 */
.calendar-container {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 24px;
    margin-bottom: 32px;
}

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

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: #e2e8f0;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.calendar-day-head {
    background: #f8fafc;
    padding: 10px;
    text-align: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: #64748b;
}

/* 高亮闪烁动画 */
@keyframes highlight-fade {
    0% { background-color: rgba(99, 102, 241, 0.2); }
    30% { background-color: rgba(99, 102, 241, 0.4); }
    100% { background-color: transparent; }
}

.highlight-row {
    animation: highlight-fade 2s ease-out 3; /* 闪烁3次 */
}

.calendar-day {
    background: white;
    min-height: 100px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.calendar-day.today {
    background: #e0f2fe;
    border: 2px solid #0ea5e9;
    position: relative;
    z-index: 1;
}

.calendar-day.today::before {
    content: "今日";
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.6rem;
    background: #0ea5e9;
    color: white;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 700;
}

.calendar-day.other-month {
    background: #f1f5f9;
    color: #cbd5e1;
}

.day-number {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.day-stat {
    font-size: 0.7rem;
    padding: 4px 6px;
    border-radius: 4px;
    display: block; /* 改为块级，允许换行 */
    line-height: 1.3;
    margin-bottom: 2px;
    word-break: break-all;
}

.day-stat span:first-child {
    font-weight: 700;
    margin-right: 4px;
}

.day-stat span.stat-names {
    opacity: 0.9;
    font-weight: 400;
}

.stat-shipped { background: #dcfce7; color: #166534; }
.stat-overdue { background: #fee2e2; color: #991b1b; }
.stat-runaway { background: #f1f5f9; color: #475569; }

.stat-predict {
    background: #fffbeb;
    color: #d97706;
    border: 1px dashed #fcd34d;
    opacity: 0.9;
}

.stat-done {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #7dd3fc;
}

.calendar-legend {
    display: flex;
    gap: 20px;
    margin-top: 15px;
    font-size: 0.8rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* 物流悬浮窗 */
.tracking-container {
    position: relative;
    display: inline-block;
}

.tracking-tooltip {
    visibility: hidden;
    width: 320px;
    background-color: #ffffff;
    color: #1e293b;
    text-align: left;
    border-radius: 12px;
    padding: 16px;
    position: absolute;
    z-index: 2000;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    font-size: 0.85rem;
    line-height: 1.5;
}

.tracking-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -8px;
    border-width: 8px;
    border-style: solid;
    border-color: #ffffff transparent transparent transparent;
}

.tracking-container:hover .tracking-tooltip {
    visibility: visible;
    opacity: 1;
}

.tracking-status {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
    display: block;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 6px;
}

.tracking-list {
    max-height: 200px;
    overflow-y: auto;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tracking-item {
    padding: 8px 0;
    border-bottom: 1px solid #f8fafc;
}

.tracking-item:last-child {
    border-bottom: none;
}

.tracking-time {
    font-size: 0.75rem;
    color: #94a3b8;
    display: block;
}

.tracking-content {
    display: block;
    color: #475569;
}

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

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

/* 报警闪烁动画 */
@keyframes alarm-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.alarm-active {
    animation: alarm-pulse 2s infinite;
    background: var(--danger) !important;
    color: white !important;
}

.alarm-dot {
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    display: inline-block;
    margin-left: 6px;
    box-shadow: 0 0 8px var(--danger);
    animation: blinker 1.5s linear infinite;
}

@keyframes blinker {
    50% { opacity: 0; }
}

.nav-section-title {
    padding: 12px 16px 4px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-top: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.nav-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.nav-item span:first-child {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 24px 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 40px;
    max-width: calc(100% - var(--sidebar-width));
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.page-title h1 {
    margin: 0;
    font-size: 1.875rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: #0f172a;
}

.page-title p {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 1rem;
}

/* Dashboard Stats */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.stat-sparkline {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    pointer-events: auto;
    z-index: 0;
    opacity: 0.6;
    cursor: pointer;
}

.stat-sparkline path {
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: d 0.3s ease;
}

.trend-mode-label {
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-size: 0.65rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.8);
    padding: 2px 6px;
    border-radius: 4px;
    pointer-events: none;
    z-index: 2;
    font-weight: 600;
}

.trend-tooltip {
    position: absolute;
    padding: 4px 10px;
    background: rgba(15, 23, 42, 0.95);
    color: white;
    font-size: 0.75rem;
    border-radius: 6px;
    pointer-events: none;
    display: none;
    z-index: 100;
    white-space: nowrap;
    transform: translateX(-50%);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    transition: left 0.1s ease, bottom 0.1s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-header, .stat-value {
    position: relative;
    z-index: 1;
    pointer-events: none; /* 允许鼠标穿透到下方的趋势图 */
}

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

.stat-label {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: #0f172a;
}

.stat-value.primary { color: var(--primary); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger { color: var(--danger); }

/* Workbench & Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 32px;
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Modern Table Layout */
.table-wrapper {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

table th {
    background: #f8fafc;
    padding: 16px 20px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    border-bottom: 1px solid var(--border-color);
}

table td {
    padding: 20px;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

table tr:last-child td {
    border-bottom: none;
}

table tr:hover {
    background-color: #f8fafc;
}

/* Badges & UI Elements */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge-outline {
    background: transparent;
    border: 1px solid currentColor;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }

/* Form Controls */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 8px;
}

.form-control {
    height: 44px;
    padding: 0 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    color: var(--text-main);
    background: #fff;
    transition: all 0.2s;
    width: 100%;
}

textarea.form-control {
    height: auto;
    padding: 12px 16px;
    min-height: 100px;
    resize: vertical;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
    outline: none;
}

/* Add specialized form elements */
input[type="text"], 
input[type="url"], 
input[type="date"], 
select, 
textarea {
    display: block;
    width: 100%;
    padding: 10px 14px;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

input[type="text"]:focus, 
input[type="url"]:focus, 
input[type="date"]:focus, 
select:focus, 
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
    outline: none;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 20px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
    gap: 8px;
}

.btn-sm { height: 36px; padding: 0 14px; font-size: 0.875rem; }

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.btn-secondary {
    background: white;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

/* User Badge */
.user-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    font-size: 0.95rem;
    box-shadow: var(--shadow-sm);
}

.avatar-circle {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
}

/* Action Icons */
.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    transition: all 0.2s;
    text-decoration: none;
    background: white;
}

.btn-icon:hover {
    background: #f1f5f9;
    color: var(--primary);
    border-color: var(--primary);
}

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

/* Row States */
.tr-overdue { border-left: 4px solid var(--danger); }
.tr-advertised { background: #f0fdf4; }

/* Toast Notification */
.toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: #1e293b;
    color: white;
    padding: 12px 24px;
    border-radius: 9999px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 3000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-icon {
    font-size: 1.1rem;
}

/* Range Slider Styling */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 5px;
    outline: none;
    margin: 15px 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 0 0 4px var(--primary-light);
    transition: all 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 6px var(--primary-light);
}

/* Animations */
@keyframes pulse-danger {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.pulse-danger {
    animation: pulse-danger 2s infinite;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Alert styles */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    font-weight: 500;
}
.alert-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid #bcf0da;
}

.alert-danger {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid #fecaca;
}

/* Modal Styling */
#modalOverlay {
    backdrop-filter: blur(4px);
    transition: all 0.3s;
}

#checkResult.card {
    border: none;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    body {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        padding: 16px 0;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }

    .sidebar-logo {
        padding: 0 20px 16px;
        margin-bottom: 0;
        justify-content: space-between;
    }

    .nav-menu {
        display: none; /* Default hide on mobile, can be toggled */
        padding: 10px 16px;
    }

    .nav-menu.show {
        display: flex;
    }

    .sidebar-footer {
        display: none;
    }

    .nav-menu.show + .sidebar-footer {
        display: block;
        padding: 16px;
    }

    .main-content {
        margin-left: 0;
        max-width: 100%;
        padding: 20px 16px;
    }

    .top-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        margin-bottom: 24px;
    }

    .top-bar .btn {
        width: 100%;
    }

    .stats-container {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .card {
        padding: 20px;
    }

    .form-group {
        flex-direction: column;
        align-items: stretch !important;
    }

    .btn {
        width: 100%;
    }

    /* Table optimization on mobile */
    table td, table th {
        padding: 12px 10px;
        font-size: 0.85rem;
    }

    .badge {
        padding: 2px 8px;
    }

    /* Mobile Menu Toggle */
    .mobile-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: rgba(255,255,255,0.1);
        border-radius: 8px;
        cursor: pointer;
        color: white;
        font-size: 1.2rem;
    }
}

.mobile-toggle {
    display: none;
}
