/* =============================================
   千百炼 库存管理系统 — 统一样式
   ============================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --bg-input: #f8fafc;
    --bg-table-header: #f8fafc;
    --bg-table-stripe: #fafbfc;
    --accent: #d97706;
    --accent-hover: #b45309;
    --accent-light: #fffbeb;
    --accent-50: #fff7ed;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-sidebar: #94a3b8;
    --text-sidebar-active: #ffffff;
    --text-white: #ffffff;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --success: #059669;  --success-bg: #ecfdf5;
    --danger: #dc2626;   --danger-bg: #fef2f2;
    --warning: #d97706;  --warning-bg: #fffbeb;
    --info: #2563eb;     --info-bg: #eff6ff;
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
    --shadow: 0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px -1px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --transition: 0.2s ease;
}

html { font-size: 14px; }

body {
    font-family: "Outfit", -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

/* ---- Layout ---- */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 1000;
    overflow-y: auto;
    display: flex; flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex; flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.topbar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 32px;
    position: sticky; top: 0; z-index: 100;
    box-shadow: var(--shadow-sm);
}

.content-area { flex: 1; padding: 28px 32px; }

/* ---- Sidebar ---- */
.sidebar-brand { padding: 24px 24px 20px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.sidebar-brand h2 { color: var(--text-white); font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }
.sidebar-brand .subtitle { color: var(--text-muted); font-size: 0.8rem; margin-top: 2px; }

.sidebar-nav { padding: 16px 12px; flex: 1; }

.sidebar-nav .nav-item {
    display: flex; align-items: center;
    padding: 10px 16px;
    color: var(--text-sidebar);
    border-radius: var(--radius);
    margin-bottom: 2px;
    font-size: 0.93rem; font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}
.sidebar-nav .nav-item:hover { background: var(--bg-sidebar-hover); color: var(--text-sidebar-active); }
.sidebar-nav .nav-item.active { background: var(--accent); color: var(--text-white); }
.sidebar-nav .nav-icon { width: 20px; margin-right: 12px; text-align: center; font-size: 1rem; }

.submenu {
    list-style: none; padding: 0 0 0 48px;
    max-height: 0; overflow: hidden;
    transition: max-height 0.35s ease;
}
.submenu.expanded { max-height: 500px; }
.submenu li a {
    display: block; padding: 7px 12px;
    color: var(--text-sidebar); font-size: 0.85rem;
    border-radius: 4px; transition: all var(--transition);
}
.submenu li a:hover { color: var(--text-white); background: rgba(255,255,255,0.05); }
.submenu li a.active { color: var(--text-white); font-weight: 600; }

.submenu-arrow {
    margin-left: auto;
    font-size: 0.8rem;
    transition: transform 0.2s ease;
    color: var(--text-muted);
}
.has-submenu.open .submenu-arrow {
    transform: rotate(90deg);
}

/* ---- Hamburger Button ---- */
.hamburger-btn {
    display: none;
    background: none; border: none;
    cursor: pointer; padding: 8px;
    flex-direction: column; gap: 5px;
    z-index: 1100;
}
.hamburger-btn span {
    display: block; width: 22px; height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s ease;
}
.hamburger-btn.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger-btn.active span:nth-child(2) { opacity: 0; }
.hamburger-btn.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ---- Overlay for mobile sidebar ---- */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ---- Topbar ---- */
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar .page-title h1 { font-size: 1.25rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; }
.topbar .user-info { display: flex; align-items: center; gap: 16px; font-size: 0.875rem; color: var(--text-secondary); }
.topbar .user-info a {
    color: var(--accent); font-weight: 500;
    padding: 6px 16px; border-radius: var(--radius);
    border: 1px solid var(--accent);
    transition: all var(--transition);
}
.topbar .user-info a:hover { background: var(--accent); color: var(--text-white); }

/* ---- Cards ---- */
.card { background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 24px; }
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap; gap: 12px;
}
.card-header h2, .card-header h3 { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }

/* ---- Tables ---- */
.table-container {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 260px);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    -webkit-overflow-scrolling: touch;
}

table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.875rem; min-width: 800px; }

table thead { background: var(--bg-table-header); position: sticky; top: 0; z-index: 10; }
table th {
    padding: 12px 16px; text-align: left;
    font-weight: 600; color: var(--text-secondary);
    font-size: 0.8rem; text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--border); white-space: nowrap;
}
table td { padding: 12px 16px; border-bottom: 1px solid var(--border-light); color: var(--text-primary); vertical-align: middle; }
table tbody tr { transition: background var(--transition); scroll-margin-top: 56px; }
table tbody tr:hover { background: var(--accent-50); }
table tbody tr:nth-child(even) { background: var(--bg-table-stripe); }
table tbody tr:nth-child(even):hover { background: var(--accent-50); }

.highlight-row { animation: highlightFade 3s ease; }
@keyframes highlightFade { 0% { background: #fef3c7; } 100% { background: transparent; } }

.actions { white-space: nowrap; }
.actions .btn { margin-right: 4px; }

.spec-column { max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 20px; font-size: 0.875rem; font-weight: 600;
    border: none; border-radius: var(--radius); cursor: pointer;
    transition: all var(--transition); gap: 6px;
    white-space: nowrap; font-family: inherit;
}
.btn-primary { background: var(--accent); color: var(--text-white); }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); color: var(--text-white); }
.btn-secondary { background: var(--bg-table-header); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: var(--text-white); }
.btn-danger:hover { background: #b91c1c; color: var(--text-white); }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-ghost { background: transparent; color: var(--accent); padding: 5px 10px; }
.btn-ghost:hover { background: var(--accent-light); color: var(--accent-hover); }

/* 保存按钮 */
.btn-save {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid #a7f3d0;
}
.btn-save:hover {
    background: var(--success);
    color: var(--text-white);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* ---- Forms ---- */
.form-card { background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 32px; max-width: 720px; }
.form-card h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border-light); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-group { display: flex; flex-direction: column; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
    padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 0.9rem; font-family: inherit; background: var(--bg-input);
    transition: all var(--transition); color: var(--text-primary);
}
.form-group input:focus, .form-group select:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.1); background: var(--bg-card);
}
.form-group input::placeholder { color: var(--text-muted); }
.form-actions {
    display: flex; gap: 12px; margin-top: 28px;
    padding-top: 20px; border-top: 1px solid var(--border-light);
}

/* 表单卡片头部 */
.form-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.form-card-header h2 {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.form-card-id {
    font-family: "Menlo", "Courier New", monospace;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-light);
    padding: 4px 12px;
    border-radius: 6px;
}

/* 图片卡片 */
.image-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-input);
}

.image-card-thumb {
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.image-card-thumb img {
    display: block;
    width: 100%;
    max-height: 220px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.image-card-thumb:hover img {
    transform: scale(1.03);
}

.image-card-zoom-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.6rem;
    background: rgba(0,0,0,0.5);
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.image-card-thumb:hover .image-card-zoom-icon {
    opacity: 1;
}

.image-card-btns {
    display: flex;
    border-top: 1px solid var(--border-light);
}

.image-card-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-table-header);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.image-card-btn:not(:last-child) {
    border-right: 1px solid var(--border-light);
}

.image-card-btn:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.image-card-btn-danger:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.image-card-btn-icon {
    font-size: 1rem;
}

/* 图片放大预览弹窗 */
.image-zoom-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 3000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    touch-action: none;
    user-select: none;
    overflow: hidden;
}

.image-zoom-modal.active {
    display: flex;
}

.image-zoom-close {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 2rem;
    color: #fff;
    cursor: pointer;
    z-index: 10;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.image-zoom-close:hover {
    background: rgba(255,255,255,0.15);
}

.image-zoom-level {
    position: absolute;
    top: 16px;
    left: 20px;
    color: rgba(255,255,255,0.7);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: "Menlo", "Courier New", monospace;
    z-index: 10;
}

.image-zoom-hint {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.3);
    font-size: 0.75rem;
    z-index: 10;
    white-space: nowrap;
}

.image-zoom-container {
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    position: relative;
}

.image-zoom-container img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    transform-origin: 0 0;
    user-select: none;
    -webkit-user-drag: none;
    will-change: transform;
}

/* 无图片上传区域 */
.image-upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 28px 20px;
    text-align: center;
    background: var(--bg-input);
    cursor: pointer;
    position: relative;
    transition: all var(--transition);
}

.image-upload-area:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.image-upload-icon {
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.image-upload-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.image-upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* ---- Flash Messages ---- */
.flash-messages { margin-bottom: 20px; }
.flash {
    padding: 12px 20px; border-radius: var(--radius);
    font-size: 0.9rem; font-weight: 500;
    animation: slideDown 0.3s ease; margin-bottom: 8px;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.flash-success { background: var(--success-bg); color: var(--success); border: 1px solid #a7f3d0; }
.flash-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.flash-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #fde68a; }
.flash-info { background: var(--info-bg); color: var(--info); border: 1px solid #bfdbfe; }

/* ---- Inventory ---- */
.inventory-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; align-items: center; }
.inventory-actions form { display: flex; gap: 8px; align-items: center; }
.inventory-actions input[type="text"] {
    padding: 8px 14px; border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 0.875rem; width: 240px; font-family: inherit; transition: border-color var(--transition);
}
.inventory-actions input[type="text"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(217,119,6,0.1); }

.desktop-only-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ---- Upload Modal ---- */
.upload-modal {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 2000;
    justify-content: center; align-items: center;
    padding: 16px;
}
.upload-modal.show { display: flex; }
.upload-modal .modal-box {
    background: var(--bg-card); border-radius: var(--radius-lg);
    padding: 32px; width: 100%; max-width: 480px;
    box-shadow: var(--shadow-lg); animation: modalIn 0.2s ease;
    max-height: 90vh; overflow-y: auto;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

/* ---- Bootstrap Modal Override ---- */
.modal-content { border-radius: var(--radius-lg); border: none; box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--border); padding: 20px 24px; }
.modal-body { padding: 24px; }
.modal-footer { border-top: 1px solid var(--border); padding: 16px 24px; }

/* ---- Footer ---- */
.site-footer {
    text-align: center; padding: 20px 32px;
    font-size: 0.8rem; color: var(--text-muted);
    border-top: 1px solid var(--border-light); margin-top: auto;
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--accent); }
.site-footer img { width: 14px; height: 14px; vertical-align: middle; margin-right: 4px; }

/* ---- Standalone Pages (login, register) ---- */
.standalone-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    background: var(--bg-body);
    background-image:
        radial-gradient(ellipse at 30% 20%, rgba(217, 119, 6, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(5, 150, 105, 0.04) 0%, transparent 50%);
}

.standalone-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border-light);
}

/* 登录头部 */
.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-header h2 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* 登录表单 */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.login-form .form-group {
    display: flex;
    flex-direction: column;
}

.login-form .form-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.login-form .form-group input {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.92rem;
    font-family: inherit;
    background: var(--bg-input);
    transition: all var(--transition);
    color: var(--text-primary);
}

.login-form .form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.1);
    background: var(--bg-card);
}

.login-form .form-group input::placeholder {
    color: var(--text-muted);
}

/* 登录按钮 */
.login-btn {
    width: 100%;
    padding: 13px 20px;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: var(--radius);
    margin-top: 4px;
    letter-spacing: 0.02em;
}

/* 记住密码 & 自动登录 */
.login-options {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 32px;
    padding: 6px 0 2px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.checkbox-custom {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
    background: var(--bg-input);
    position: relative;
}

.checkbox-custom::after {
    content: '';
    display: none;
    width: 5px;
    height: 9px;
    border: 2px solid #fff;
    border-top: 0;
    border-left: 0;
    transform: rotate(45deg);
    position: absolute;
    top: 1px;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
    border-color: var(--accent);
    background: var(--accent);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
    display: block;
}

.checkbox-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    line-height: 1;
}

.checkbox-label:hover .checkbox-custom {
    border-color: var(--accent);
}

/* 注册链接 */
.standalone-card .register-link {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.standalone-card .register-link a {
    font-weight: 600;
}

/* ---- Logs ---- */
.log-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.log-table-container { height: 640px; overflow-y: auto; border-radius: var(--radius); border: 1px solid var(--border); -webkit-overflow-scrolling: touch; }

/* ---- Data Manage ---- */
.data-overview {
    display: flex;
    gap: 16px;
    margin-bottom: 28px;
}

.data-stat {
    flex: 1;
    text-align: center;
    padding: 16px 12px;
    background: var(--bg-table-header);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
}

.data-stat-num {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--accent);
    font-family: "Menlo", "Courier New", monospace;
}

.data-stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}

.data-danger-section {
    border-top: 1px solid var(--border-light);
    padding-top: 24px;
}

.data-danger-section h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--danger);
    margin-bottom: 16px;
}

.data-danger-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    background: var(--danger-bg);
    margin-bottom: 12px;
}

.data-danger-info {
    flex: 1;
    min-width: 0;
}

.data-danger-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.data-danger-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.5;
}


/* ============================================= */
.mobile-cards { display: none; }


/* =============================================
   平板适配
   ============================================= */
@media (max-width: 1024px) {
    :root { --sidebar-width: 220px; }
    .content-area { padding: 20px 24px; }
    .topbar { padding: 0 20px; }
    .inventory-actions input[type="text"] { width: 180px; }
    table { min-width: 700px; }
    .form-card { max-width: 100%; }
}


/* =============================================
   手机适配
   ============================================= */
@media (max-width: 768px) {

    .sidebar { transform: translateX(-100%); width: 280px; }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.3); }
    .main-area { margin-left: 0; }
    .hamburger-btn { display: flex; }

    .topbar { height: 56px; padding: 0 16px; }
    .topbar .page-title h1 { font-size: 1rem; }
    .topbar .user-info { gap: 8px; font-size: 0.8rem; }
    .topbar .user-info a { padding: 5px 10px; font-size: 0.8rem; }

    .content-area { padding: 16px; }
    .card { padding: 16px; border-radius: var(--radius); }
    .card-header { flex-direction: column; align-items: flex-start; gap: 12px; }

    /* 操作栏 */
    .inventory-actions { flex-direction: column; gap: 10px; }
    .inventory-actions form { width: 100%; display: flex; gap: 8px; }
    .inventory-actions form input[type="text"] { flex: 1; min-width: 0; width: auto; padding: 12px 14px; font-size: 0.9rem; }
    .inventory-actions form .btn { flex-shrink: 0; width: auto; padding: 12px 20px; font-size: 0.85rem; }
    .inventory-actions .btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
    .inventory-actions .btn-row .btn { width: 100%; justify-content: center; padding: 12px 14px; font-size: 0.85rem; }
    .desktop-only-actions { display: none !important; }

    .desktop-table { display: none !important; }
    .mobile-cards { display: block; }

    /* 库存卡片 */
    .mobile-card { background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); padding: 14px 16px; margin-bottom: 10px; cursor: pointer; transition: all var(--transition); }
    .mobile-card:active { background: var(--accent-50); border-color: var(--accent); }
    .mobile-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
    .mobile-card-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
    .mobile-card-name { font-size: 0.82rem; font-weight: 600; color: var(--text-primary); line-height: 1.3; white-space: nowrap; flex-shrink: 0; }
    .mobile-card-spec { font-size: 0.88rem; font-weight: 700; color: var(--success); background: var(--success-bg); padding: 2px 10px; border-radius: 4px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
    .mobile-card-qty { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 20px; font-size: 0.8rem; font-weight: 700; white-space: nowrap; flex-shrink: 0; margin-left: 10px; }
    .mobile-card-qty.has-stock { background: var(--accent-light); color: var(--accent); }
    .mobile-card-qty.no-stock { background: var(--danger-bg); color: var(--danger); }
    .mobile-card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
    .mobile-card-tag { display: inline-flex; align-items: center; padding: 3px 10px; background: var(--bg-table-header); border-radius: 6px; font-size: 0.75rem; color: var(--text-secondary); gap: 4px; }
    .mobile-card-tag.tag-id { font-family: "Menlo", "Courier New", monospace; font-size: 0.72rem; color: var(--text-muted); }
    .mobile-card-info { display: flex; justify-content: space-between; align-items: center; padding-top: 10px; border-top: 1px solid var(--border-light); gap: 8px; }
    .mobile-card-log { font-size: 0.72rem; color: var(--text-muted); flex-shrink: 0; }
    .mobile-card-actions { display: flex; gap: 4px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
    .mobile-card-actions .btn { padding: 5px 8px; font-size: 0.72rem; border-radius: 6px; }
    .mobile-hint { text-align: center; padding: 8px; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 8px; }
    /* 手机卡片高亮动画 */
    .mobile-card.highlight-row {
        animation: mobileHighlight 3s ease;
        box-shadow: 0 0 0 2px var(--accent);
    }

    @keyframes mobileHighlight {
        0% { background: #fef3c7; box-shadow: 0 0 0 2px var(--accent); }
        100% { background: var(--bg-card); box-shadow: 0 0 0 2px var(--accent); }
    }

    /* 表单 */
    .form-card { padding: 20px; max-width: 100%; }
    .form-card h2 { font-size: 1.1rem; }
    .form-card-header { flex-direction: row; align-items: center; gap: 10px; }
    .form-card-header h2 { flex-shrink: 0; }
    .form-card-id { font-size: 0.72rem; flex-shrink: 0; }
    .form-grid { grid-template-columns: 1fr; gap: 16px; }
    .form-group input, .form-group select { font-size: 16px; padding: 12px 14px; }

    .form-group input[type="file"] { padding: 10px; border: 2px dashed var(--border); border-radius: var(--radius); background: var(--bg-input); width: 100%; cursor: pointer; }
    .form-group input[type="file"]:active { border-color: var(--accent); background: var(--accent-light); }

    .form-actions { flex-direction: row; flex-wrap: wrap; gap: 8px; }
    .form-actions .btn { flex: 1; min-width: 0; padding: 12px 8px; font-size: 0.82rem; text-align: center; justify-content: center; }
    .form-actions .btn-save { flex: 1.2; }
    .form-danger-zone { display: none; }

    /* 图片卡片 */
    .image-card-thumb img { max-height: 180px; }
    .image-card-zoom-icon { opacity: 0.8; width: 38px; height: 38px; font-size: 1.3rem; }
    .image-card-btn { padding: 12px; font-size: 0.85rem; }
    .image-upload-area { padding: 32px 16px; }

    /* 图片放大弹窗 */
    .image-zoom-container img { max-width: 98vw; max-height: 85vh; }
    .image-zoom-hint { bottom: 16px; font-size: 0.7rem; }
    .image-zoom-level { top: 12px; left: 16px; font-size: 0.78rem; }
    .image-zoom-close { top: 12px; right: 16px; }

    .flash { padding: 10px 14px; font-size: 0.85rem; }

    .upload-modal .modal-box { padding: 20px; margin: 16px; }
    .upload-modal .modal-box input[type="file"] { font-size: 0.85rem; }

    /* 登录页（手机端） */
    .standalone-card { padding: 28px 20px; }
    .standalone-card h2 { font-size: 1.3rem; margin-bottom: 20px; }
    .standalone-card input { font-size: 16px; padding: 12px 14px; }
    .standalone-card .btn { padding: 14px 20px; }
    .login-header h2 { font-size: 1.4rem; }
    .login-options { gap: 16px; }

    .add-category form { flex-direction: column; }
    .add-category input { width: 100%; }

    .log-actions { flex-direction: column; }
    .log-actions .btn { width: 100%; justify-content: center; }
    .log-table-container { height: auto; max-height: 500px; }

    /* 数据管理页 */
    .data-overview { flex-direction: column; gap: 10px; }
    .data-stat { padding: 14px; }
    .data-stat-num { font-size: 1.3rem; }
    .data-danger-card { flex-direction: column; align-items: flex-start; gap: 12px; }
    .data-danger-card form { width: 100%; }
    .data-danger-card .btn { width: 100%; justify-content: center; }

    .site-footer { padding: 16px; font-size: 0.7rem; }

    .modal-dialog { margin: 8px; }
    .modal-header { padding: 16px; }
    .modal-body { padding: 16px; }
    .modal-footer { padding: 12px 16px; }
    .modal-body img { max-height: 60vh !important; }
}


/* =============================================
   小手机
   ============================================= */
@media (max-width: 400px) {
    .topbar { padding: 0 12px; }
    .topbar .user-info span { display: none; }
    .topbar .user-info a { padding: 5px 8px; font-size: 0.75rem; }
    .content-area { padding: 12px; }
    .card { padding: 12px; }
    .mobile-card { padding: 12px; }
    .mobile-card-name { font-size: 0.75rem; }
    .mobile-card-spec { font-size: 0.8rem; padding: 2px 8px; }
    .mobile-card-actions .btn { padding: 4px 6px; font-size: 0.7rem; }
    .form-card { padding: 16px; }
    .login-options { gap: 12px; }
    .checkbox-text { font-size: 0.78rem; }
}
