/* 新趣库存 - Design System */

:root {
    --bg: #f8f9fb;
    --surface: #ffffff;
    --primary: #4f6ef7;
    --primary-hover: #3b5bdb;
    --primary-light: rgba(79,110,247,0.08);
    --danger: #e74c3c;
    --danger-light: rgba(231,76,60,0.08);
    --success: #27ae60;
    --success-light: rgba(39,174,96,0.08);
    --text: #1a1a2e;
    --text-2: #6b7280;
    --text-3: #9ca3af;
    --border: #e5e7eb;
    --shadow: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --r: 14px;
    --r-sm: 10px;
    --r-xs: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro", "PingFang SC", "Hiragino Sans GB", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ---- Nav ---- */
.nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-links { display: flex; gap: 2px; }

.nav-links a {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    text-decoration: none;
    border-radius: var(--r-xs);
    transition: all 0.15s;
}

.nav-links a.active { color: var(--primary); background: var(--primary-light); }
.nav-links a:hover { color: var(--primary); }

/* ---- Layout ---- */
.wrap {
    max-width: 540px;
    margin: 0 auto;
    padding: 16px;
}

/* ---- Cards ---- */
.card {
    background: var(--surface);
    border-radius: var(--r);
    box-shadow: var(--shadow);
    border: 1px solid rgba(0,0,0,0.04);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--r-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-danger { background: var(--danger); color: #fff; }

.btn-ghost {
    background: transparent;
    color: var(--text-2);
    border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

.btn-block { width: 100%; }

.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: var(--r-xs); }
.btn-lg { padding: 14px 24px; font-size: 15px; }

/* ---- Hero ---- */
.hero {
    text-align: center;
    padding: 36px 0 20px;
}

.hero-icon { font-size: 48px; margin-bottom: 12px; }

.hero h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
}

.hero p {
    font-size: 13px;
    color: var(--text-2);
}

/* ---- Upload Area ---- */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--r);
    padding: 28px 16px;
    text-align: center;
    background: var(--surface);
    transition: border-color 0.2s;
}

.upload-zone:active { border-color: var(--primary); }

/* ---- Quick Grid ---- */
.quick-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 20px;
}

.quick-item {
    background: var(--surface);
    border-radius: var(--r);
    padding: 20px 16px;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    border: 1px solid rgba(0,0,0,0.04);
    transition: transform 0.15s;
}

.quick-item:active { transform: scale(0.97); }
.quick-item .qi-icon { font-size: 28px; margin-bottom: 6px; }
.quick-item .qi-label { font-size: 13px; font-weight: 600; }

/* ---- Form ---- */
.section {
    background: var(--surface);
    border-radius: var(--r);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(0,0,0,0.04);
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 10px;
}

.fg { margin-bottom: 10px; }
.fg:last-child { margin-bottom: 0; }

.fg label {
    display: block;
    font-size: 12px;
    color: var(--text-3);
    margin-bottom: 4px;
    font-weight: 500;
}

.fg input,
.fg select,
.fg textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: var(--r-xs);
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.15s;
    font-family: inherit;
    outline: none;
}

.fg input:focus,
.fg select:focus,
.fg textarea:focus {
    border-color: var(--primary);
    background: var(--surface);
}

.fg input::placeholder,
.fg textarea::placeholder { color: var(--text-3); }

.fg textarea {
    min-height: 40px;
    resize: none;
    line-height: 1.5;
}

.fg-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

.fg-row input {
    flex: 1;
    min-width: 0;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: var(--r-xs);
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    outline: none;
}

.fg-row input:focus { border-color: var(--primary); background: var(--surface); }

.fg-row .fn {
    flex: 0 0 80px;
    font-size: 12px;
    color: var(--text-2);
    background: var(--bg);
    padding: 9px 8px;
    border-radius: var(--r-xs);
    border: 1px solid var(--border);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fg-row .fv { flex: 1; }

.low-conf { border-color: var(--danger) !important; background: var(--danger-light) !important; }

.btn-del {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: var(--danger-light);
    color: var(--danger);
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.form-actions .btn { flex: 1; }

.required-mark { color: var(--danger); font-size: 11px; }

/* ---- Preview Image ---- */
.preview-img {
    border-radius: var(--r);
    overflow: hidden;
    margin-bottom: 12px;
    max-height: 45vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.preview-img img {
    width: 100%;
    max-height: 45vh;
    object-fit: contain;
}

/* ---- Multi Preview ---- */
.multi-prev {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 10px;
    background: var(--bg);
    border-radius: var(--r);
    margin-bottom: 12px;
}

.mp-item {
    position: relative;
    flex: 0 0 56px;
    height: 56px;
    border-radius: var(--r-xs);
    overflow: hidden;
    border: 2px solid var(--border);
}

.mp-item img { width: 100%; height: 100%; object-fit: cover; }

.mp-badge {
    position: absolute;
    top: 2px;
    left: 2px;
    background: var(--primary);
    color: #fff;
    font-size: 10px;
    padding: 0 4px;
    border-radius: 6px;
    font-weight: 700;
}

/* ---- Inventory List ---- */
.inv-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

@media (min-width: 640px) {
    .inv-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 900px) {
    .inv-grid { grid-template-columns: repeat(4, 1fr); }
}

.inv-card {
    display: flex;
    flex-direction: column;
    padding: 10px 12px;
    border-radius: var(--r);
    text-decoration: none;
    color: inherit;
    border: 1px solid rgba(0,0,0,0.06);
    transition: transform 0.15s;
    position: relative;
    overflow: hidden;
}

.inv-card::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 60px; height: 60px;
    border-radius: 50%;
    opacity: 0.08;
    pointer-events: none;
}

.inv-card:active { transform: scale(0.97); }

/* Brand colors */
.inv-card[data-brand="vivo"] { background: linear-gradient(135deg, #e8f4fd 0%, #ffffff 60%); border-color: #b3d9f2; }
.inv-card[data-brand="vivo"]::before { background: #4f8fd0; }

.inv-card[data-brand="Xiaomi"], .inv-card[data-brand="小米"] { background: linear-gradient(135deg, #fff4e6 0%, #ffffff 60%); border-color: #ffd9a8; }
.inv-card[data-brand="Xiaomi"]::before, .inv-card[data-brand="小米"]::before { background: #f59e0b; }

.inv-card[data-brand="OPPO"], .inv-card[data-brand="oppo"] { background: linear-gradient(135deg, #f0f0f0 0%, #ffffff 60%); border-color: #d4d4d4; }
.inv-card[data-brand="OPPO"]::before, .inv-card[data-brand="oppo"]::before { background: #17a34a; }

.inv-card[data-brand="OnePlus"], .inv-card[data-brand="一加"] { background: linear-gradient(135deg, #fee2e2 0%, #ffffff 60%); border-color: #fca5a5; }
.inv-card[data-brand="OnePlus"]::before, .inv-card[data-brand="一加"]::before { background: #e74c3c; }

.inv-card[data-brand="HUAWEI"], .inv-card[data-brand="华为"] { background: linear-gradient(135deg, #f3f4f6 0%, #ffffff 60%); border-color: #d1d5db; }
.inv-card[data-brand="HUAWEI"]::before, .inv-card[data-brand="华为"]::before { background: #6b7280; }

.inv-card[data-brand="realme"], .inv-card[data-brand="Realme"] { background: linear-gradient(135deg, #fefce8 0%, #ffffff 60%); border-color: #fde68a; }
.inv-card[data-brand="realme"]::before, .inv-card[data-brand="Realme"]::before { background: #eab308; }

.inv-card[data-brand="Apple"], .inv-card[data-brand="苹果"] { background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 60%); border-color: #e5e7eb; }
.inv-card[data-brand="Apple"]::before, .inv-card[data-brand="苹果"]::before { background: #9ca3af; }

.inv-card[data-brand="Samsung"], .inv-card[data-brand="三星"] { background: linear-gradient(135deg, #f3e8ff 0%, #ffffff 60%); border-color: #d8b4fe; }
.inv-card[data-brand="Samsung"]::before, .inv-card[data-brand="三星"]::before { background: #9333ea; }

.inv-card[data-brand="Motorola"], .inv-card[data-brand="摩托罗拉"] { background: linear-gradient(135deg, #f5f0eb 0%, #ffffff 60%); border-color: #d4b896; }
.inv-card[data-brand="Motorola"]::before, .inv-card[data-brand="摩托罗拉"]::before { background: #92400e; }

.inv-card[data-brand="Nokia"], .inv-card[data-brand="诺基亚"] { background: linear-gradient(135deg, #e8edf5 0%, #ffffff 60%); border-color: #a8b8d8; }
.inv-card[data-brand="Nokia"]::before, .inv-card[data-brand="诺基亚"]::before { background: #1e3a5f; }

.inv-brand {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inv-model {
    font-size: 13px;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inv-spec {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 2px;
}

/* ---- Record Cards ---- */
.rec-card {
    background: var(--surface);
    border-radius: var(--r);
    padding: 12px 14px;
    box-shadow: var(--shadow);
    margin-bottom: 8px;
    border-left: 3px solid;
    border: 1px solid rgba(0,0,0,0.04);
}

.rec-card.in { border-left-color: var(--success); }
.rec-card.out { border-left-color: var(--danger); }

.rec-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.rec-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.rec-tag.in { background: var(--success-light); color: var(--success); }
.rec-tag.out { background: var(--danger-light); color: var(--danger); }

.rec-time { font-size: 11px; color: var(--text-3); }

.rec-title { font-size: 15px; font-weight: 600; margin-bottom: 2px; }

.rec-info { font-size: 12px; color: var(--text-2); }

.rec-extra {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 11px;
    color: var(--text-2);
}

/* ---- Detail ---- */
.detail-card {
    background: var(--surface);
    border-radius: var(--r);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.04);
}

.detail-head {
    padding: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.detail-section {
    padding: 14px;
    border-bottom: 1px solid var(--border);
}

.detail-section:last-child { border-bottom: none; }

.detail-section h3 {
    font-size: 12px;
    color: var(--text-3);
    font-weight: 500;
    margin-bottom: 10px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.detail-item .dl { font-size: 11px; color: var(--text-3); }
.detail-item .dv { font-size: 14px; font-weight: 500; word-break: break-all; }

.detail-img {
    width: 100%;
    max-height: 260px;
    object-fit: contain;
    border-radius: var(--r-sm);
}

/* ---- Status Badge ---- */
.status { font-size: 11px; padding: 3px 10px; border-radius: 10px; font-weight: 600; }
.status-in { background: var(--success-light); color: var(--success); }
.status-out { background: var(--danger-light); color: var(--danger); }

/* ---- Tabs ---- */
.tabs {
    display: flex;
    gap: 3px;
    background: var(--surface);
    border-radius: var(--r-sm);
    padding: 3px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
}

.tab {
    flex: 1;
    padding: 8px;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    cursor: pointer;
    border-radius: var(--r-xs);
    transition: all 0.15s;
}

.tab.active { background: var(--primary); color: #fff; }

/* ---- Filter ---- */
.filter {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.filter input,
.filter select {
    flex: 1;
    min-width: 70px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-xs);
    font-size: 13px;
    background: var(--surface);
    color: var(--text);
    outline: none;
}

.filter input:focus { border-color: var(--primary); }

/* ---- Stats ---- */
.stats {
    font-size: 12px;
    color: var(--text-2);
    margin-bottom: 10px;
}

/* ---- Page Header ---- */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    gap: 8px;
}

.page-head h2 {
    font-size: 18px;
    font-weight: 700;
    flex: 1;
}

.back-btn {
    background: none;
    border: none;
    font-size: 14px;
    color: var(--primary);
    cursor: pointer;
    padding: 4px 6px;
    font-weight: 500;
}

/* ---- Loading ---- */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 36px;
    gap: 10px;
    color: var(--text-2);
    font-size: 13px;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.empty {
    text-align: center;
    padding: 36px;
    color: var(--text-3);
    font-size: 13px;
}

.empty a { color: var(--primary); display: block; margin-top: 6px; }

/* ---- Error ---- */
.error-box {
    background: var(--danger-light);
    border: 1px solid var(--danger);
    border-radius: var(--r);
    padding: 20px;
    text-align: center;
    color: var(--danger);
    font-size: 13px;
}

/* ---- Success ---- */
.success-box {
    background: var(--surface);
    border-radius: var(--r);
    padding: 36px 20px;
    text-align: center;
    box-shadow: var(--shadow);
    margin-top: 32px;
}

.success-box .si { font-size: 56px; margin-bottom: 12px; }
.success-box h2 { font-size: 18px; margin-bottom: 6px; }
.success-box p { color: var(--text-2); font-size: 13px; margin-bottom: 20px; }

/* ---- Pagination ---- */
.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px;
}

.pager button {
    padding: 7px 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--r-xs);
    font-size: 13px;
    cursor: pointer;
}

.pager button:hover { border-color: var(--primary); color: var(--primary); }
.pager .pi { font-size: 13px; color: var(--text-2); }

/* ---- Product Info Card ---- */
.info-card {
    background: var(--surface);
    border-radius: var(--r);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    border-left: 3px solid var(--primary);
}

.info-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.info-card .ir { font-size: 13px; color: var(--text-2); margin-bottom: 3px; }
.info-card .ir span { color: var(--text); font-weight: 500; }

/* ---- Animations ---- */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.anim { animation: fadeUp 0.25s ease-out; }

/* ---- Responsive ---- */
@media (min-width: 768px) {
    .wrap { padding: 20px; }
    .detail-grid { grid-template-columns: 1fr 1fr 1fr; }
}

@media (max-width: 480px) {
    .wrap { padding: 12px; }
    .fg-row .fn { flex: 0 0 70px; font-size: 11px; }
    .fg-row input { font-size: 13px; padding: 8px 10px; }
}

/* ---- Dark Mode ---- */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1117;
        --surface: #161b22;
        --text: #e6edf3;
        --text-2: #8b949e;
        --text-3: #6e7681;
        --border: #21262d;
        --primary-light: rgba(79,110,247,0.15);
        --danger-light: rgba(231,76,60,0.15);
        --success-light: rgba(39,174,96,0.15);
    }

    .nav { background: var(--surface); border-bottom-color: var(--border); }

    input, select, textarea {
        background: var(--bg) !important;
        border-color: var(--border) !important;
        color: var(--text) !important;
    }

    input:focus, select:focus, textarea:focus {
        border-color: var(--primary) !important;
        background: var(--surface) !important;
    }

    input::placeholder, textarea::placeholder { color: var(--text-3) !important; }

    .fg-row .fn { background: var(--bg); border-color: var(--border); color: var(--text-2); }

    .inv-card { border-color: #21262d; }

    .inv-card[data-brand="vivo"] { background: linear-gradient(135deg, #1a2a3a 0%, #161b22 60%); border-color: #2a4a6a; }
    .inv-card[data-brand="Xiaomi"], .inv-card[data-brand="小米"] { background: linear-gradient(135deg, #2a2010 0%, #161b22 60%); border-color: #4a3518; }
    .inv-card[data-brand="OPPO"], .inv-card[data-brand="oppo"] { background: linear-gradient(135deg, #1a2a1a 0%, #161b22 60%); border-color: #2a4a2a; }
    .inv-card[data-brand="OnePlus"], .inv-card[data-brand="一加"] { background: linear-gradient(135deg, #2a1515 0%, #161b22 60%); border-color: #4a2020; }
    .inv-card[data-brand="HUAWEI"], .inv-card[data-brand="华为"] { background: linear-gradient(135deg, #222228 0%, #161b22 60%); border-color: #3a3a42; }
    .inv-card[data-brand="realme"], .inv-card[data-brand="Realme"] { background: linear-gradient(135deg, #2a2a10 0%, #161b22 60%); border-color: #4a4a18; }
    .inv-card[data-brand="Apple"], .inv-card[data-brand="苹果"] { background: linear-gradient(135deg, #1e1e22 0%, #161b22 60%); border-color: #3a3a40; }
    .inv-card[data-brand="Samsung"], .inv-card[data-brand="三星"] { background: linear-gradient(135deg, #221a2e 0%, #161b22 60%); border-color: #3a2a4a; }
    .inv-card[data-brand="Motorola"], .inv-card[data-brand="摩托罗拉"] { background: linear-gradient(135deg, #221c14 0%, #161b22 60%); border-color: #3a2a18; }
    .inv-card[data-brand="Nokia"], .inv-card[data-brand="诺基亚"] { background: linear-gradient(135deg, #141e2e 0%, #161b22 60%); border-color: #1e3050; }
}
