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

:root {
    --primary: #2d5a3d;
    --primary-hover: #1f4530;
    --primary-light: #eef5f0;
    --accent: #c4621a;
    --accent-light: #fdf0e6;
    --danger: #b53a3a;
    --danger-light: #fbe9e9;
    --success: #3a7d4f;
    --success-light: #eaf5ee;
    --text: #1f2e23;
    --text-light: #5a6b60;
    --text-muted: #8a9a90;
    --border: #d8e2db;
    --border-light: #e8efe9;
    --bg: #f5f8f5;
    --card: #ffffff;
    --shadow: 0 1px 3px rgba(45,90,61,0.06);
    --shadow-md: 0 2px 8px rgba(45,90,61,0.08);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-text-size-adjust: 100%;
}

/* ===== 登录页 ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #2d5a3d 0%, #1a3d28 100%);
}

.login-card {
    background: var(--card);
    border-radius: 20px;
    padding: 40px 28px;
    max-width: 360px;
    width: 100%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.login-logo { font-size: 3rem; margin-bottom: 8px; }
.login-card h1 { font-size: 1.3rem; color: var(--primary); margin-bottom: 4px; }
.login-sub { color: var(--text-light); font-size: 0.85rem; margin-bottom: 24px; }

.manual-section { margin-top: 20px; text-align: left; }
.manual-hint { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 8px; }
.manual-row { display: flex; gap: 8px; }
.manual-row input {
    flex: 1; padding: 10px 12px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.85rem; font-family: monospace;
}
.manual-row input:focus { outline: none; border-color: var(--primary); }
.exchange-msg { margin-top: 8px; font-size: 0.82rem; }

code {
    background: var(--bg); padding: 1px 5px;
    border-radius: 4px; font-size: 0.82rem; color: var(--accent);
}

/* ===== 按钮 ===== */
.btn-primary, .btn-outline, .btn-danger, .btn-ghost, .btn-sm, .btn-xs, .btn-block {
    border: none; cursor: pointer;
    font-family: inherit; font-weight: 600;
    transition: all 0.2s; border-radius: var(--radius-sm);
}

.btn-primary {
    background: var(--primary); color: #fff;
    padding: 11px 20px; font-size: 0.9rem;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-outline {
    background: transparent; color: var(--primary);
    border: 1.5px solid var(--primary);
    padding: 8px 14px; font-size: 0.85rem;
}
.btn-outline:hover:not(:disabled) { background: var(--primary-light); }
.btn-outline:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-danger { background: var(--danger); color: #fff; padding: 11px 20px; font-size: 0.9rem; }
.btn-ghost { background: transparent; color: var(--text-light); padding: 6px 10px; font-size: 0.82rem; }
.btn-ghost:hover { color: var(--primary); }
.btn-sm { background: var(--primary-light); color: var(--primary); padding: 6px 12px; font-size: 0.8rem; }
.btn-sm:hover { background: #dceadf; }
.btn-xs { background: transparent; color: var(--text-muted); padding: 4px 8px; font-size: 0.75rem; border: 1px solid var(--border); }
.btn-xs:hover:not(:disabled) { color: var(--primary); border-color: var(--primary); }
.btn-xs:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-block { width: 100%; padding: 14px; font-size: 1rem; }

/* ===== 顶栏 ===== */
.topbar {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.topbar-left { display: flex; align-items: center; gap: 8px; }
.logo { font-size: 1.3rem; }
.topbar-title { font-weight: 700; font-size: 1rem; color: var(--primary); }

.topbar-right { display: flex; align-items: center; gap: 8px; }
.user-chip {
    font-size: 0.82rem; color: var(--text-light);
    display: flex; align-items: center; gap: 4px;
}
.dot { font-size: 0.6rem; }
.dot-premium { color: var(--accent); }

/* ===== 摘要栏 ===== */
.summary-bar {
    display: flex; align-items: center; justify-content: center;
    gap: 12px; padding: 16px;
    background: var(--card);
    margin: 12px 0;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.summary-item { display: flex; flex-direction: column; align-items: center; min-width: 56px; }
.summary-num { font-size: 1.5rem; font-weight: 800; color: var(--text); line-height: 1; }
.summary-total .summary-num { color: var(--primary); }
.summary-label { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }
.summary-x, .summary-eq { font-size: 1.1rem; color: var(--text-muted); font-weight: 600; }

/* ===== 双栏 ===== */
.dual-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.panel {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex; flex-direction: column;
}

.panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
}
.panel-header h2 { font-size: 0.95rem; color: var(--text); }

.panel-toolbar {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-light);
}

.search-input {
    flex: 1; min-width: 0;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.8rem;
    background: var(--bg);
}
.search-input:focus { outline: none; border-color: var(--primary); background: var(--card); }
.search-input:disabled { opacity: 0.5; }

/* ===== 列表 ===== */
.item-list {
    flex: 1; overflow-y: auto;
    max-height: 340px;
    padding: 6px;
}

.empty-state {
    padding: 40px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.loading {
    display: flex; align-items: center; justify-content: center;
    padding: 30px;
}

.spinner {
    width: 24px; height: 24px;
    border: 2.5px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.12s;
    margin-bottom: 2px;
}
.item:hover { background: var(--bg); }
.item:has(input:checked) { background: var(--primary-light); }

.item input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--primary);
    cursor: pointer; flex-shrink: 0;
}

.item-name {
    flex: 1; min-width: 0;
    font-size: 0.84rem; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0; }
.item-text .item-name { font-size: 0.84rem; }
.item-sub { font-size: 0.7rem; color: var(--text-muted); font-family: monospace; }

.item-badge {
    font-size: 0.65rem; font-weight: 700;
    padding: 1px 6px; border-radius: 8px;
    white-space: nowrap; flex-shrink: 0;
}
.badge-inventory { background: #e3edf7; color: #2b5a87; }
.badge-collection { background: #f5e8f0; color: #8b3a6b; }
.badge-owned { background: var(--success-light); color: var(--success); }

/* ===== 设置区 ===== */
.settings-bar {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    margin-bottom: 12px;
}

.setting-row {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 8px;
}
.setting-row:last-of-type { margin-bottom: 4px; }

.setting-tag {
    font-size: 0.78rem; font-weight: 700; color: var(--text-muted);
    width: 36px; flex-shrink: 0;
}

.text-input, .date-input {
    flex: 1;
    padding: 7px 10px;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-size: 0.84rem;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
}
.text-input:focus, .date-input:focus { outline: none; border-color: var(--primary); background: var(--card); }

.setting-hint { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }

/* ===== 底部操作栏 ===== */
.action-bar {
    position: sticky; bottom: 0;
    padding: 12px 16px;
    background: var(--card);
    border-top: 1px solid var(--border-light);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
    z-index: 50;
}

/* ===== 进度区 ===== */
.progress-overlay {
    margin-bottom: 12px;
}

.progress-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    padding: 16px;
}

.progress-header { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }

.progress-ring { position: relative; width: 56px; height: 56px; flex-shrink: 0; }
.progress-pct {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.78rem; font-weight: 800; color: var(--primary);
}

.progress-info { flex: 1; min-width: 0; }
.progress-current {
    font-size: 0.82rem; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-bottom: 4px;
}

.progress-stats { display: flex; gap: 10px; font-size: 0.75rem; }
.stat-ok { color: var(--success); }
.stat-fail { color: var(--danger); }
.stat-total { color: var(--text-muted); }

.progress-bar-line {
    height: 4px; background: var(--bg);
    border-radius: 2px; overflow: hidden;
}
.progress-bar-fill {
    height: 100%; width: 0%;
    background: var(--primary);
    transition: width 0.3s;
}

.rate-info { font-size: 0.72rem; color: var(--text-muted); margin-top: 8px; }

/* ===== 日志 ===== */
.log-section {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
    overflow: hidden;
}

.log-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.85rem; font-weight: 600; color: var(--text);
    border-bottom: 1px solid var(--border-light);
}
.log-chevron { font-size: 0.7rem; transition: transform 0.2s; }
.log-section.collapsed .log-chevron { transform: rotate(-90deg); }
.log-section.collapsed .log-body { display: none; }

.log-body { max-height: 240px; overflow-y: auto; }

.log {
    background: #1a2620;
    color: #c8d8cc;
    padding: 12px 14px;
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 0.74rem;
    line-height: 1.6;
}

.log .success { color: #6abf7e; }
.log .error { color: #e57373; }
.log .info { color: #7fb3d5; }
.log .warn { color: #f0b860; }
.log .highlight { color: #f0c674; font-weight: 700; }

/* ===== 完成栏 ===== */
.done-bar { margin-bottom: 80px; }

/* ===== Toast ===== */
.toast {
    position: fixed; top: 16px; left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}
.toast-error { background: var(--danger); color: #fff; }

/* ===== 滚动条 ===== */
.item-list::-webkit-scrollbar, .log-body::-webkit-scrollbar { width: 4px; }
.item-list::-webkit-scrollbar-thumb, .log-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ===== 移动端 ===== */
@media (max-width: 600px) {
    .dual-panel { grid-template-columns: 1fr; }
    .item-list { max-height: 240px; }
    .summary-bar { gap: 8px; padding: 12px; }
    .summary-num { font-size: 1.2rem; }
    .summary-label { font-size: 0.65rem; }
    .topbar-title { display: none; }
    .progress-overlay { margin-bottom: 12px; }
    .setting-row { flex-wrap: wrap; }
    .text-input, .date-input { font-size: 0.82rem; }
}
