/* ============================================================
   Grandware@once — Apple-Inspired Design System
   ============================================================ */

/* ==================== 全局变量 ==================== */
:root {
    /* Apple 风格配色 */
    --bg-primary: #f5f5f7;
    --bg-secondary: #fafafa;
    --surface: #ffffff;
    --surface-hover: #f9f9fb;
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #aeaeb2;
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --accent-bg: #e8f4fd;
    --success: #30d158;
    --success-bg: #e8f8ed;
    --warning: #ff9f0a;
    --warning-bg: #fff8e5;
    --danger: #ff3b30;
    --danger-bg: #ffeceb;
    --info: #5ac8fa;
    --info-bg: #e8f6fd;
    --purple: #af52de;
    --purple-bg: #f3edf8;
    --border: rgba(0, 0, 0, 0.06);
    --border-strong: rgba(0, 0, 0, 0.1);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --sidebar-width: 240px;
    --topbar-height: 60px;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --transition: 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
    --transition-fast: 0.15s cubic-bezier(0.25, 0.1, 0.25, 1);
    --transition-smooth: 0.35s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* ==================== 暗色模式 ==================== */
[data-theme='dark'] {
    --bg-primary: #1c1c1e;
    --bg-secondary: #242426;
    --surface: #2c2c2e;
    --surface-hover: #323234;
    --text-primary: #f5f5f7;
    --text-secondary: #98989d;
    --text-tertiary: #636366;
    --accent: #0a84ff;
    --accent-hover: #409cff;
    --accent-bg: #152942;
    --success: #30d158;
    --success-bg: #15291a;
    --warning: #ff9f0a;
    --warning-bg: #2b220d;
    --danger: #ff453a;
    --danger-bg: #2b1413;
    --info: #64d2ff;
    --info-bg: #152433;
    --purple: #bf5af2;
    --purple-bg: #291d38;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
}

/* 系统偏好自动切换（无手动设置时跟随系统） */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg-primary: #1c1c1e;
        --bg-secondary: #242426;
        --surface: #2c2c2e;
        --surface-hover: #323234;
        --text-primary: #f5f5f7;
        --text-secondary: #98989d;
        --text-tertiary: #636366;
        --accent: #0a84ff;
        --accent-hover: #409cff;
        --accent-bg: #152942;
        --success: #30d158;
        --success-bg: #15291a;
        --warning: #ff9f0a;
        --warning-bg: #2b220d;
        --danger: #ff453a;
        --danger-bg: #2b1413;
        --info: #64d2ff;
        --info-bg: #152433;
        --purple: #bf5af2;
        --purple-bg: #291d38;
        --border: rgba(255, 255, 255, 0.08);
        --border-strong: rgba(255, 255, 255, 0.14);
        --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
        --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
        --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
    }
}

/* ==================== Reset ==================== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family:
        'Inter',
        -apple-system,
        BlinkMacSystemFont,
        'SF Pro Display',
        'Segoe UI',
        sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: -0.01em;
}

a {
    text-decoration: none;
    color: inherit;
}
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    font-size: inherit;
}
input,
select,
textarea {
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary);
}
::selection {
    background: var(--accent);
    color: #fff;
}

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

/* ==================== 侧边栏 — Apple 浅色风格 ==================== */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: width var(--transition-smooth);
}

.sidebar-header {
    padding: 0 20px;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.logo::before {
    content: 'G';
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: 8px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
}

.logo-text {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    letter-spacing: -0.02em;
}

/* 暂时隐藏切换按钮，保持响应式兼容 */
.sidebar-toggle {
    display: none;
    color: var(--text-secondary);
    font-size: 18px;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 500;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
    position: relative;
}

.nav-item:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-bg);
    color: var(--accent);
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--accent);
    border-radius: 3px;
}

.nav-icon {
    font-size: 18px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
    line-height: 1;
}
.nav-label {
    white-space: nowrap;
}

/* 侧边栏底部 */
.sidebar-footer {
    padding: 12px 16px 16px;
    border-top: 1px solid var(--border);
}

/* 主题切换按钮 */
.sidebar-theme-toggle {
    margin-bottom: 8px;
}

.sidebar-theme-toggle button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    border: 1px solid var(--border);
    transition: all var(--transition-fast);
}

.sidebar-theme-toggle button:hover {
    background: var(--border);
    color: var(--text-primary);
}

.sidebar-theme-toggle button span:first-child {
    font-size: 14px;
}

.cloud-status {
    display: none;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    font-size: 11px;
    color: var(--text-secondary);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.cloud-status:hover {
    background: var(--border);
}

.exchange-rate-info {
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    transition: all var(--transition-fast);
}
.exchange-rate-info:hover {
    background: rgba(0, 0, 0, 0.04);
}

.rate-label {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-bottom: 4px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.rate-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
.rate-source {
    font-size: 10px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* ==================== 主内容区 ==================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==================== 顶部栏 — 毛玻璃 ==================== */
.topbar {
    height: var(--topbar-height);
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

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

/* 公司选择器 */
.company-select {
    padding: 6px 32px 6px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 20px;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236e6e73'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    outline: none;
    transition: all var(--transition-fast);
}
.company-select:hover {
    border-color: var(--accent);
    background: var(--accent-bg);
}
.company-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

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

/* 移动端汉堡菜单按钮（桌面端隐藏） */
.mobile-menu-btn {
    display: none;
}

/* 搜索框 */
.search-box {
    position: relative;
}

.search-input {
    width: 260px;
    padding: 8px 14px 8px 36px;
    border: none;
    border-radius: 20px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    transition: all var(--transition-fast);
}
.search-input::placeholder {
    color: var(--text-tertiary);
}
.search-input:focus {
    outline: none;
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: var(--text-tertiary);
    pointer-events: none;
}

/* 用户信息 */
.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 10px 4px 4px;
    border-radius: 20px;
    transition: background var(--transition-fast);
    position: relative;
}
.user-info:hover {
    background: var(--bg-primary);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #5856d6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.dropdown-arrow {
    font-size: 9px;
    color: var(--text-tertiary);
    transition: transform var(--transition-fast);
}

/* 角色标签 */
.user-role-badge {
    display: inline-block;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.role-admin {
    background: #ffeceb;
    color: #ff3b30;
}
.role-finance {
    background: #e8f4fd;
    color: #0071e3;
}
.role-manager {
    background: #fff8e5;
    color: #ff9f0a;
}
.role-salesperson {
    background: var(--bg-primary);
    color: var(--text-secondary);
}
.role-document {
    background: #f3edf8;
    color: #af52de;
}

/* 用户下拉 */
.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: 300;
    animation: dropdownIn 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
    overflow: hidden;
}

@keyframes dropdownIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text-primary);
    transition: background var(--transition-fast);
}
.dropdown-item:hover {
    background: var(--bg-primary);
}
.dropdown-item.user-detail {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-weight: 600;
}
.dropdown-item.user-detail .text-xs {
    font-weight: 400;
}
.dropdown-divider {
    height: 1px;
    background: var(--border);
}
.dropdown-item.logout-item {
    cursor: pointer;
    color: var(--danger);
}
.dropdown-item.logout-item:hover {
    background: var(--danger-bg);
}

/* ==================== 页面内容区 ==================== */
.page-content {
    padding: 28px;
    flex: 1;
}

/* ==================== 卡片 ==================== */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: box-shadow var(--transition);
    margin-bottom: 16px;
}
.card:hover {
    box-shadow: var(--shadow-sm);
}

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

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.card-body {
    padding: 24px;
}

/* ==================== 统计卡片 ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    box-shadow: var(--shadow-xs);
    border: 1px solid var(--border);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle at top right, rgba(0, 113, 227, 0.06), transparent 70%);
    border-radius: 0 0 0 80px;
    pointer-events: none;
}

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

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

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}
.stat-icon.blue {
    background: var(--accent-bg);
    color: var(--accent);
}
.stat-icon.green {
    background: var(--success-bg);
    color: #30b350;
}
.stat-icon.orange {
    background: var(--warning-bg);
    color: var(--warning);
}
.stat-icon.red {
    background: var(--danger-bg);
    color: var(--danger);
}
.stat-icon.cyan {
    background: var(--info-bg);
    color: #2eaadc;
}
.stat-icon.purple {
    background: var(--purple-bg);
    color: var(--purple);
}

.stat-label {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    font-size: 30px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.stat-sub {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 6px;
}

.stat-trend {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    font-weight: 600;
}
.stat-trend.up {
    color: #30b350;
}
.stat-trend.down {
    color: var(--danger);
}

/* ==================== 按钮 ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    transition: all var(--transition-fast);
    border: none;
    white-space: nowrap;
    letter-spacing: -0.01em;
    cursor: pointer;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
}
.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 113, 227, 0.35);
}
.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
}
.btn-secondary:hover {
    background: var(--surface);
    border-color: rgba(0, 0, 0, 0.15);
    box-shadow: var(--shadow-xs);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.3);
}
.btn-danger:hover {
    background: #e0352b;
    box-shadow: 0 4px 16px rgba(255, 59, 48, 0.35);
}

.btn-warning {
    background: var(--warning);
    color: #fff;
    box-shadow: 0 2px 8px rgba(255, 159, 10, 0.3);
}
.btn-warning:hover {
    background: #e89000;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
    border-radius: 16px;
}
.btn-icon {
    padding: 7px 9px;
}

.btn-outline-danger {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 4px 12px;
    font-size: 12px;
    border-radius: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-outline-danger:hover {
    background: var(--danger);
    color: #fff;
}

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

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.form-label .required {
    color: var(--danger);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 14px;
    transition: all var(--transition-fast);
}
.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-tertiary);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
    background: var(--surface);
}
.form-input:hover:not(:focus),
.form-textarea:hover:not(:focus) {
    border-color: rgba(0, 0, 0, 0.15);
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

/* 表单分区标题 */
.form-section-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    padding: 12px 0;
    margin: 24px 0 14px 0;
    border-bottom: 2px solid var(--accent-bg);
    letter-spacing: -0.01em;
}
.form-section-title:first-child {
    margin-top: 0;
}

/* 联系人卡片 */
.contact-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 14px;
    transition: all var(--transition-fast);
}
.contact-card:hover {
    border-color: rgba(0, 0, 0, 0.12);
    box-shadow: var(--shadow-xs);
}
.contact-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.contact-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}

/* 工厂卡片 */
.factory-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
    transition: all var(--transition-fast);
}
.factory-card:hover {
    border-color: rgba(0, 0, 0, 0.12);
    box-shadow: var(--shadow-xs);
}
.factory-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.factory-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}
.form-section-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
}
.form-section-header h3 {
    margin-bottom: 0 !important;
}

.factory-checkbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    max-height: 160px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    background: var(--bg-secondary);
}
.factory-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 8px;
    transition: all var(--transition-fast);
}
.factory-checkbox-item:hover {
    background: var(--accent-bg);
}
.factory-checkbox-item input[type='checkbox'] {
    accent-color: var(--accent);
}

/* ==================== 表格 ==================== */
.table-container {
    overflow-x: auto;
}

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

thead th {
    background: var(--bg-secondary);
    color: var(--text-tertiary);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

tbody td {
    padding: 14px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    color: var(--text-primary);
    font-size: 13px;
}

tbody tr {
    transition: background var(--transition-fast);
}
tbody tr:hover {
    background: rgba(0, 113, 227, 0.03);
}
tbody tr:last-child td {
    border-bottom: none;
}

.checkbox-col {
    width: 44px;
    text-align: center;
}
.checkbox-col input[type='checkbox'] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent);
}

/* 批量操作栏 */
.batch-bar {
    display: none;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    background: var(--accent-bg);
    border: 1px solid rgba(0, 113, 227, 0.15);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--accent);
}
.batch-bar.visible {
    display: flex;
}
.batch-bar .batch-count {
    font-weight: 700;
}

.table-link {
    color: var(--accent);
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition-fast);
}
.table-link:hover {
    opacity: 0.7;
}

/* ==================== 状态标签 ==================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.01em;
}
.badge-success {
    background: var(--success-bg);
    color: #1b8a3d;
}
.badge-warning {
    background: var(--warning-bg);
    color: #b87000;
}
.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}
.badge-info {
    background: var(--info-bg);
    color: #1a8ab5;
}
.badge-default {
    background: var(--bg-primary);
    color: var(--text-secondary);
}
.badge-primary {
    background: var(--accent-bg);
    color: var(--accent);
}

/* ==================== 模态框 ==================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 640px;
    animation: slideUp 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
    overflow: hidden;
}
@keyframes slideUp {
    from {
        transform: translateY(24px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}
.modal-large {
    max-width: 820px;
}

.modal-header {
    padding: 22px 28px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: var(--text-tertiary);
    background: var(--bg-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.modal-close:hover {
    background: var(--border);
    color: var(--text-primary);
}

.modal-body {
    padding: 28px;
    max-height: 65vh;
    overflow-y: auto;
}
.modal-body::-webkit-scrollbar {
    width: 6px;
}
.modal-body::-webkit-scrollbar-track {
    background: transparent;
}
.modal-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

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

/* ==================== Toast 通知 ==================== */
.toast-container {
    position: fixed;
    top: 80px;
    right: 28px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 14px 22px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    font-weight: 500;
    min-width: 300px;
    border: 1px solid var(--border);
    animation: toastIn 0.35s cubic-bezier(0.25, 0.1, 0.25, 1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
@keyframes toastIn {
    from {
        transform: translateX(120%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast::before {
    content: '';
    width: 4px;
    height: 28px;
    border-radius: 2px;
    background: var(--accent);
    flex-shrink: 0;
}
.toast.success::before {
    background: var(--success);
}
.toast.error::before {
    background: var(--danger);
}
.toast.warning::before {
    background: var(--warning);
}

/* ==================== 加载遮罩 ==================== */
#loadingOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 18px;
}
#loadingOverlay .spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== 图表容器 ==================== */
.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 12px;
}
.chart-container {
    position: relative;
    height: 240px;
}

/* ==================== 进度条 ==================== */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--accent);
    transition: width var(--transition-smooth);
}

/* ==================== 筛选栏 ==================== */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.filter-select,
.filter-input {
    padding: 8px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    font-size: 13px;
    background: var(--surface);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}
.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}
.filter-info {
    font-size: 11px;
    color: var(--accent);
    font-weight: 600;
    background: var(--accent-bg);
    padding: 5px 12px;
    border-radius: 16px;
}

/* ==================== 空状态 ==================== */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-tertiary);
}
.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

/* ==================== 详情网格 ==================== */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.detail-item {
    padding: 14px 18px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.detail-label {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-bottom: 4px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.detail-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ==================== 时间线 ==================== */
.timeline {
    position: relative;
    padding-left: 28px;
}
.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
    border-radius: 1px;
}
.timeline-item {
    position: relative;
    padding-bottom: 24px;
}
.timeline-dot {
    position: absolute;
    left: -28px;
    top: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--surface);
    border: 3px solid var(--border-strong);
    transition: all var(--transition-fast);
}
.timeline-dot.done {
    background: var(--success);
    border-color: var(--success);
}
.timeline-dot.current {
    background: var(--accent);
    border-color: var(--accent);
}
.timeline-dot.pending {
    background: var(--text-tertiary);
    border-color: var(--text-tertiary);
}
.timeline-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}
.timeline-date {
    font-size: 12px;
    color: var(--text-tertiary);
}
.timeline-desc {
    color: var(--text-secondary);
    margin-top: 3px;
    font-size: 13px;
}

/* ==================== Apple-Style Login Page ==================== */
.login-page {
    position: fixed;
    inset: 0;
    background: #f5f5f7;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    overflow: hidden;
}

/* 背景装饰 */
.login-page::before {
    content: '';
    position: absolute;
    top: -30%;
    left: -10%;
    width: 60%;
    height: 80%;
    background: radial-gradient(ellipse at center, rgba(0, 113, 227, 0.08), transparent 70%);
    pointer-events: none;
}

.login-page::after {
    content: '';
    position: absolute;
    bottom: -30%;
    right: -10%;
    width: 60%;
    height: 80%;
    background: radial-gradient(ellipse at center, rgba(175, 82, 222, 0.06), transparent 70%);
    pointer-events: none;
}

.login-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border-radius: 28px;
    box-shadow:
        0 0 0 0.5px rgba(0, 0, 0, 0.08),
        0 4px 24px rgba(0, 0, 0, 0.06),
        0 16px 64px rgba(0, 0, 0, 0.06);
    padding: 48px 44px 40px;
    width: 100%;
    max-width: 420px;
    animation: cardIn 0.6s cubic-bezier(0.25, 0.1, 0.25, 1);
    position: relative;
    z-index: 1;
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(32px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 36px;
}

.login-brand-icon {
    width: 52px;
    height: 52px;
    background: var(--accent);
    border-radius: 14px;
    margin: 0 auto 20px;
    box-shadow: 0 4px 20px rgba(0, 113, 227, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 24px;
    font-weight: 700;
}

.login-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.login-subtitle {
    font-size: 15px;
    color: var(--text-tertiary);
    font-weight: 400;
}

.login-btn {
    width: 100%;
    padding: 13px;
    font-size: 15px;
    font-weight: 600;
    justify-content: center;
    margin-top: 24px;
    border-radius: 14px;
    letter-spacing: -0.01em;
}

.login-error {
    background: var(--danger-bg);
    color: var(--danger);
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 59, 48, 0.15);
    font-weight: 500;
}

.login-footer {
    margin-top: 32px;
    text-align: center;
    border-top: 1px solid var(--border);
    padding-top: 24px;
}

.login-footer-image {
    width: 100%;
    max-width: 240px;
    border-radius: 16px;
    margin: 0 auto 16px;
    display: block;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
}

.login-footer-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

/* ==================== 工具类 ==================== */
.flex {
    display: flex;
}
.items-center {
    align-items: center;
}
.justify-between {
    justify-content: space-between;
}
.gap-2 {
    gap: 8px;
}
.gap-3 {
    gap: 12px;
}
.gap-4 {
    gap: 16px;
}
.mb-2 {
    margin-bottom: 8px;
}
.mb-3 {
    margin-bottom: 12px;
}
.mb-4 {
    margin-bottom: 16px;
}
.mb-6 {
    margin-bottom: 24px;
}
.mt-2 {
    margin-top: 8px;
}
.mt-3 {
    margin-top: 12px;
}
.mt-4 {
    margin-top: 16px;
}
.mt-6 {
    margin-top: 24px;
}
.text-right {
    text-align: right;
}
.text-center {
    text-align: center;
}
.text-left {
    text-align: left;
}
.font-bold {
    font-weight: 700;
}
.font-semi {
    font-weight: 600;
}
.text-sm {
    font-size: 13px;
}
.text-xs {
    font-size: 11px;
}
.text-gray {
    color: var(--text-tertiary);
}
.text-success {
    color: #30b350;
}
.text-danger {
    color: var(--danger);
}
.text-warning {
    color: var(--warning);
}
.text-primary {
    color: var(--accent);
}
.cursor-pointer {
    cursor: pointer;
}
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==================== 滚动条 ==================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* ==================== 响应式 — 移动端适配 ==================== */
@media (max-width: 768px) {
    /* 变量覆盖 */
    :root {
        --sidebar-width: 260px;
        --topbar-height: 52px;
    }

    /* 隐藏桌面搜索框 */
    .topbar-right .search-box {
        display: none;
    }

    /* ===== 侧边栏 → 抽屉式 ===== */
    .sidebar {
        width: 260px;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
        box-shadow: none;
        background: #fff;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 40px rgba(0, 0, 0, 0.18);
    }
    .sidebar .nav-label,
    .sidebar .logo-text,
    .sidebar .exchange-rate-info {
        display: flex;
    }

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: var(--bg-primary);
    }
    .sidebar-toggle:hover {
        background: rgba(0, 0, 0, 0.06);
    }

    /* ===== 侧边栏遮罩 ===== */
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.35);
        z-index: 99;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
    .sidebar-overlay.visible {
        opacity: 1;
        pointer-events: auto;
    }

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

    /* ===== 顶栏紧凑 + 汉堡按钮 ===== */
    .topbar {
        padding: 0 14px;
        position: sticky;
    }
    .topbar-left {
        gap: 10px;
    }
    .page-title {
        font-size: 17px;
    }
    .company-select {
        font-size: 12px;
        padding: 5px 28px 5px 10px;
    }
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        border-radius: 50%;
        background: var(--bg-primary);
        flex-shrink: 0;
        transition: background 0.15s;
    }
    .mobile-menu-btn:hover,
    .mobile-menu-btn:active {
        background: rgba(0, 0, 0, 0.08);
    }

    /* 用户信息紧凑 */
    .user-name {
        display: none;
    }
    .user-role-badge {
        display: none;
    }
    .user-info {
        padding: 2px 6px 2px 2px;
    }
    .user-avatar {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    /* ===== 页面内容 ===== */
    .page-content {
        padding: 16px 12px;
    }

    /* ===== 卡片 ===== */
    .card {
        border-radius: 16px;
        margin-bottom: 12px;
    }
    .card-header {
        padding: 14px 16px;
    }
    .card-header .card-title {
        font-size: 14px;
    }
    .card-body {
        padding: 16px;
    }

    /* ===== 统计卡片 ===== */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-bottom: 16px;
    }
    .stat-card {
        padding: 16px 14px;
    }
    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 17px;
        border-radius: 10px;
    }
    .stat-value {
        font-size: 24px;
    }
    .stat-label {
        font-size: 11px;
    }
    .stat-sub {
        font-size: 11px;
    }

    /* ===== 筛选栏 ===== */
    .filter-bar {
        gap: 8px;
        margin-bottom: 14px;
    }
    .filter-select,
    .filter-input {
        padding: 7px 12px;
        font-size: 12px;
        border-radius: 10px;
    }
    #orderSearchInput {
        width: 100% !important;
    }
    .filter-info {
        font-size: 10px;
        padding: 4px 10px;
    }

    /* ===== 表格 ===== */
    .table-container {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
    }
    table {
        font-size: 12px;
    }
    thead th {
        padding: 10px 12px;
        font-size: 10px;
    }
    tbody td {
        padding: 12px;
        font-size: 12px;
    }
    .badge {
        padding: 3px 10px;
        font-size: 10px;
    }

    /* ===== 批量操作 ===== */
    .batch-bar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 14px;
        font-size: 12px;
    }
    .batch-bar .btn {
        padding: 5px 12px;
        font-size: 11px;
    }

    /* ===== 按钮 ===== */
    .btn {
        padding: 8px 16px;
        font-size: 12px;
        border-radius: 18px;
    }

    /* ===== 表单 ===== */
    .form-row,
    .form-row-3 {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .form-group {
        margin-bottom: 14px;
    }
    .form-input,
    .form-select,
    .form-textarea {
        padding: 9px 12px;
        font-size: 13px;
        border-radius: 10px;
    }
    .form-label {
        font-size: 11px;
    }
    .factory-checkbox-grid {
        grid-template-columns: 1fr;
        max-height: 200px;
    }

    /* ===== 模态框 — 底部弹出 ===== */
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
    .modal {
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: 85vh;
        animation: slideUpMobile 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
    }
    @keyframes slideUpMobile {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
    .modal-header {
        padding: 16px 18px;
    }
    .modal-title {
        font-size: 16px;
    }
    .modal-body {
        padding: 20px 18px;
        max-height: 60vh;
    }
    .modal-footer {
        padding: 12px 18px;
        flex-wrap: wrap;
    }
    .modal-footer .btn {
        flex: 1;
    }

    /* ===== 图表 ===== */
    .chart-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .chart-container {
        height: 200px;
    }

    /* ===== 详情网格 ===== */
    .detail-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .detail-item {
        padding: 12px 14px;
    }

    /* ===== Toast 通知 ===== */
    .toast-container {
        top: auto;
        bottom: 16px;
        right: 12px;
        left: 12px;
        gap: 8px;
    }
    .toast {
        min-width: auto;
        font-size: 13px;
        padding: 12px 16px;
    }

    /* ===== 时间线 ===== */
    .timeline {
        padding-left: 24px;
    }
    .timeline::before {
        left: 6px;
    }
    .timeline-dot {
        left: -24px;
        width: 14px;
        height: 14px;
    }

    /* ===== 登录页 ===== */
    .login-card {
        margin: 16px;
        padding: 36px 24px 32px;
        border-radius: 24px;
    }
    .login-title {
        font-size: 22px;
    }
    .login-brand-icon {
        width: 44px;
        height: 44px;
        font-size: 20px;
        border-radius: 12px;
    }
}

/* ==================== 打印 ==================== */
@media print {
    .sidebar,
    .topbar,
    .filter-bar,
    .btn,
    .toast-container {
        display: none !important;
    }
    .main-content {
        margin-left: 0;
    }
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
