* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #0f172a;
    --accent: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.3);
    /*--glass-bg: rgba(30, 41, 59, 0.7);*/
    --glass-bg: rgba(30, 41, 59, 0.95);      /* 0.7 → 0.95 */
    --glass-border: rgba(255, 255, 255, 0.1);
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
}

body {
    background: var(--primary);
    color: #e2e8f0;
    min-height: 100vh;
    overflow-x: hidden;
}

.bg-mesh {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
            radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.15) 0px, transparent 50%),
            radial-gradient(at 100% 0%, rgba(168, 85, 247, 0.15) 0px, transparent 50%),
            radial-gradient(at 100% 100%, rgba(56, 189, 248, 0.15) 0px, transparent 50%),
            radial-gradient(at 0% 100%, rgba(168, 85, 247, 0.15) 0px, transparent 50%);
    z-index: -1;
}

.container {
    max-width: 400px;
    min-width: 400px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 玻璃拟态基础 */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
}

/* 更紧凑的下载按钮 */
.btn-download {
    background: var(--accent);
    color: white;
    border: none;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
    height: 24px;                /* 固定高度 */
}

.btn-download:hover {
    background: #0ea5e9;
    transform: translateY(-1px);
}

.btn-download svg {
    width: 12px;
    height: 12px;
}

.glass-card {
    background: rgba(51, 65, 85, 0.4);
    /*background: rgba(51, 65, 85, 0.9);       !* 0.4 → 0.9 *!*/
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.glass-card:hover {
    background: rgba(51, 65, 85, 0.6);
    transform: translateY(-2px);
    border-color: var(--accent-glow);
}

/* 顶部栏 */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 0 0 16px 16px;
    border-top: none;
    border-left: none;
    border-right: none;
}

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

.logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.header h1 {
    font-size: 16px;
    font-weight: 600;
    color: white;
}

.status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #94a3b8;
    margin-top: 2px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-dot.offline {
    background: var(--danger);
    box-shadow: 0 0 8px var(--danger);
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* 主内容 */
.main-content {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-card {
    padding: 16px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: #94a3b8;
}

/* 操作按钮 */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn {
    padding: 12px 20px;
    border-radius: 12px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #0ea5e9);
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.3);
}

.btn-pulse {
    position: relative;
    overflow: hidden;
}

.btn-pulse::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-pulse:active::after {
    width: 300px;
    height: 300px;
}

/* 列表容器 */
.list-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.list-header h3 {
    font-size: 14px;
    font-weight: 500;
    color: #94a3b8;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    margin-left: 16px;
}

.search-box input {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 6px 12px;
    color: white;
    font-size: 13px;
    outline: none;
}

.search-box input:focus {
    border-color: var(--accent);
}

.icon-btn-sm {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

.item-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
    font-size: 14px;
}

/* 物品卡片 */
.item-card {
    padding: 14px;
    max-width: 350px;
    margin-bottom: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.item-info {
    flex: 1;
    min-width: 0;
}

.item-name {
    font-weight: 500;
    color: white;
    font-size: 15px;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 11px;
    color: #64748b;
}

.item-code {
    font-family: monospace;
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
}

.item-warehouse {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    padding: 2px 6px;
    border-radius: 4px;
}

.item-time {
    color: #475569;
}

.item-arrow {
    color: #64748b;
    margin-left: 8px;
}

/* 弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /*//控制弹窗背景*/
    background: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    /*控制弹窗排列模式*/
    flex-direction: column;
}

.modal:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.modal-header {
    padding: 1px;
    /*border-bottom: 1px solid var(--glass-border);*/
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-actions {
    padding: 1px;
    display: flex;
    gap: 12px;
    /*border-top: 1px solid var(--glass-border);*/
}
.modal-content {
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform 0.3s;
}
/*弹窗的顶和底部样式（不显示滚动条，不进行缩放）*/
.modal-content-top-bottom {
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    transform: scale(0.95);
    transition: transform 0.3s;
}


.modal-actions .spacer {
    flex: 1;
}
.modal:not(.hidden) .modal-content {
    transform: scale(1);
}



.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: white;
}

/* 表单 */
.form-group {
    padding: 12px 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 6px;
}

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

.scan-hint {
    color: var(--accent);
    font-size: 11px;
}

.input-glow {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 12px 14px;
    color: white;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.input-glow:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-glow.readonly {
    background: rgba(255, 255, 255, 0.05);
    color: #94a3b8;
}

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

.input-with-btn input {
    flex: 1;
}

.btn-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid var(--accent-glow);
    color: var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: rgba(56, 189, 248, 0.2);
}

.code-display {
    background: rgba(0, 0, 0, 0.2);
    border: 1px dashed var(--glass-border);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
}

.code-display span {
    font-family: monospace;
    font-size: 14px;
    color: var(--accent);
    display: block;
    margin-bottom: 1px;
}

.qr-preview {
    display: flex;
    justify-content: center;
    padding: 8px;
}

.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 12px;
    cursor: pointer;
    margin-top: 8px;
}



/* 扫码弹窗 */
.scan-modal .modal-content {
    max-width: 360px;
}

.scan-container {
    position: relative;
    padding: 20px;
    background: #000;
    border-radius: 12px;
    margin: 0 16px 16px;
}

.scan-viewport {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
}

.scan-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    pointer-events: none;
}

.scan-frame {
    position: absolute;
    inset: 0;
    border: 2px solid var(--accent);
    border-radius: 12px;
    opacity: 0.5;
}

.scan-line {
    position: absolute;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    box-shadow: 0 0 10px var(--accent);
    animation: scan 2s linear infinite;
}

@keyframes scan {
    0% { top: 0; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { top: 100%; opacity: 0; }
}

.scan-hint-text {
    text-align: center;
    color: #64748b;
    font-size: 13px;
    padding-bottom: 16px;
}

/* iOS 安全区域适配 */
@supports (padding-top: env(safe-area-inset-top)) {
    .header {
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .main-content {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}

/* 扫码容器优化 */
.scan-container {
    position: relative;
    padding: 20px;
    background: #000;
    border-radius: 12px;
    margin: 0 16px 16px;
    overflow: hidden;
}

/* iOS 相机预览修复 */
#reader video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    border-radius: 8px;
}

/* 相机权限提示 */
.permission-hint {
    text-align: center;
    padding: 20px;
    color: #94a3b8;
}

.permission-hint button {
    margin-top: 12px;
}

/* Toast 提示 */
.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.toast:not(.hidden) {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.pagination-container {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border-top: 1px solid var(--glass-border);
}

.pagination-info {
    font-size: 12px;
    color: #64748b;
}

.pagination-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.pagination-buttons button {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination-buttons button:hover:not(:disabled) {
    background: rgba(56, 189, 248, 0.1);
    border-color: var(--accent-glow);
}

.pagination-buttons button.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.pagination-buttons button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pagination-buttons span {
    color: #64748b;
    padding: 0 4px;
}

/* 表单标签中的仓库名称样式 */
.form-group label .item-warehouse {
    display: inline-block;
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: normal;
    margin: 0 4px;
    vertical-align: middle;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 默认仓库使用紫色样式（与物品列表一致） */
.form-group label .item-warehouse.default-warehouse {
    background: rgba(168, 85, 247, 0.1);
    color: #a855f7;
}

label span[style*="color: #38bdf8"] {
    display: inline-block;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

/* 默认仓库标签样式 */
.item-warehouse.default-warehouse {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

/* 确认弹窗特殊样式 */
#confirmModal .modal-content {
    animation: modalPop 0.2s ease;
}

@keyframes modalPop {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* 工具类 */
.hidden {
    display: none !important;
}

.w-4 { width: 16px; height: 16px; }
.w-5 { width: 20px; height: 20px; }
.w-6 { width: 24px; height: 24px; }

/* 滚动条 */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}