:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #0f766e;
    --bg: #f4f6fb;
    --card: #ffffff;
    --border: #e5e9f2;
    --text: #1f2937;
    --muted: #8a94a6;
    --zebra-odd: #ffffff;
    --zebra-even: #f7f9fc;
    --green: #16a34a;
    --red: #dc2626;
    --amber: #d97706;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(17, 24, 39, .06), 0 1px 2px rgba(17, 24, 39, .04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

.topbar {
    background: linear-gradient(135deg, #1d4ed8, #2563eb 55%, #3b82f6);
    color: #fff;
    padding: 22px 0;
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; }
.nav-link {
    color: #fff; text-decoration: none; font-size: 14px;
    padding: 8px 14px; border: 1px solid rgba(255,255,255,.35); border-radius: 8px;
}
.nav-link:hover { background: rgba(255,255,255,.15); }
.footer-link { color: var(--primary); text-decoration: none; }
.footer-link:hover { text-decoration: underline; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo {
    display: inline-flex; align-items: center; justify-content: center;
    width: 46px; height: 46px; border-radius: 12px;
    background: rgba(255,255,255,.18); font-size: 24px; font-weight: 700;
}
.brand h1 { margin: 0; font-size: 20px; font-weight: 700; }
.brand p { margin: 2px 0 0; font-size: 13px; opacity: .9; }

main { padding: 22px 0 40px; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 22px;
    margin-bottom: 18px;
}
.card-title { margin: 0 0 14px; font-size: 16px; font-weight: 700; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-title-row .card-title { margin-bottom: 14px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid transparent; border-radius: 8px;
    padding: 8px 16px; font-size: 14px; cursor: pointer;
    text-decoration: none; transition: background .15s, border-color .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { filter: brightness(1.08); }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--zebra-even); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }

.search-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search-bar input[type="text"] {
    flex: 1; min-width: 220px; border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 12px; font-size: 14px; color: var(--text);
}
.search-bar .spacer { flex: 1; }

.pagination { display: flex; align-items: center; gap: 10px; justify-content: center; margin-top: 16px; }

textarea#source {
    width: 100%; min-height: 260px; resize: vertical;
    border: 1px solid var(--border); border-radius: 8px;
    padding: 12px 14px; font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 12.5px; line-height: 1.5; color: var(--text);
    background: #fbfcfe; white-space: pre; overflow: auto;
}
textarea#source:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

.hint { margin: 10px 0 0; font-size: 12.5px; color: var(--muted); }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--green); border: 1px solid #bbf7d0; }
.alert-warn { background: #fffbeb; color: var(--amber); border: 1px solid #fde68a; }

.stats { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.stat {
    flex: 1; min-width: 120px; background: var(--card);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column;
}
.stat-num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stat-export { flex: 1.4; flex-direction: row; align-items: center; gap: 10px; justify-content: flex-end; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 860px; }
.data-table thead th {
    text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600;
    padding: 10px 12px; background: #f1f5f9; border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table tbody td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr.shop-row.odd, tr.items-row.odd { background: var(--zebra-odd); }
tr.shop-row.even, tr.items-row.even { background: var(--zebra-even); }

.shop-cell { display: flex; align-items: center; gap: 12px; }
.shop-logo { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); background: #fff; }
.shop-name { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.shop-name a { color: var(--text); text-decoration: none; }
.shop-name a:hover { color: var(--primary); }

.badge {
    display: inline-flex; align-items: center; font-size: 12px; font-weight: 500;
    padding: 1px 8px; border-radius: 999px; white-space: nowrap;
}
.badge-follow { background: #eff6ff; color: var(--primary); }
.badge-tag { background: #f0fdf4; color: var(--green); }
.badge-new { background: #fef3c7; color: #b45309; }
.badge-count { background: #eef2ff; color: var(--primary); }

.items-detail summary { cursor: pointer; font-size: 13px; color: var(--primary); user-select: none; display: inline-flex; align-items: center; gap: 8px; }
.items-detail summary:hover { text-decoration: underline; }
.items-detail summary::marker { color: var(--primary); }

.items-table { width: 100%; border-collapse: collapse; margin-top: 10px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.items-table thead th { text-align: left; font-size: 12px; color: var(--muted); background: #f1f5f9; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.items-table tbody td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.items-table tbody tr:nth-child(even) { background: var(--zebra-even); }
.items-table tbody tr:nth-child(odd) { background: #fff; }
.item-pic { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: #fff; }
.diff-old { color: var(--muted); text-decoration: line-through; font-size: 12px; margin-top: 2px; opacity: .85; }
.diff-img { filter: grayscale(1); opacity: .55; margin-left: 4px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.link { color: var(--primary); text-decoration: none; }
.link:hover { text-decoration: underline; }

.footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 20px 0 30px; }