* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: #f5f5f7; color: #222; }
a { text-decoration: none; color: inherit; }

/* ===== Header / Navbar ===== */
.site-header { position: sticky; top: 0; z-index: 100; background: #fff;
    box-shadow: 0 2px 12px rgba(0,0,0,.07); border-bottom: 1px solid #f0f0f0; }
.nav { display: flex; align-items: center; gap: 20px; max-width: 1180px; margin: 0 auto; padding: 12px 24px; }

.brand { display: flex; align-items: center; gap: 8px; font-size: 21px; font-weight: 800;
    color: #ff5000; white-space: nowrap; letter-spacing: .5px; }
.brand-logo { font-size: 24px; }
.brand-text em { font-style: normal; color: #333; font-weight: 700; }

.searchbar { flex: 1; display: flex; max-width: 560px; height: 42px; }
.searchbar input { flex: 1; padding: 0 18px; border: 2px solid #ff5000; border-right: none;
    border-radius: 21px 0 0 21px; outline: none; font-size: 15px; }
.searchbar input::placeholder { color: #bbb; }
.searchbar button { display: flex; align-items: center; gap: 6px; padding: 0 22px; background: #ff5000;
    color: #fff; border: none; border-radius: 0 21px 21px 0; cursor: pointer; font-size: 15px; font-weight: 600;
    transition: background .15s; }
.searchbar button:hover { background: #e64800; }

.links { display: flex; align-items: center; gap: 18px; }
.links a { color: #444; font-size: 15px; transition: color .15s; }
.links a:hover { color: #ff5000; }
.links-auth, .links-guest { display: flex; align-items: center; gap: 16px; }
.user { color: #888; font-size: 14px; background: #fafafa; padding: 5px 10px; border-radius: 14px; }
.logout-form { display: inline; margin: 0; }
.linkbtn { background: none; border: none; color: #999; cursor: pointer; font-size: 14px; padding: 0; }
.linkbtn:hover { color: #ff5000; }

.btn-sell { display: inline-flex; align-items: center; gap: 5px; background: #ff5000; color: #fff !important;
    padding: 8px 16px; border-radius: 20px; font-weight: 600; transition: background .15s; }
.btn-sell:hover { background: #e64800; color: #fff !important; }
.btn-reg { background: #fff3ee; color: #ff5000 !important; padding: 7px 15px; border-radius: 20px; font-weight: 600; }
.btn-reg:hover { background: #ffe6db; }
.btn-admin { background: #2d2d3a; color: #fff !important; padding: 8px 14px; border-radius: 20px; font-weight: 600; }
.btn-admin:hover { background: #1c1c26; color: #fff !important; }

/* ===== Admin dashboard ===== */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 18px 0 28px; }
.stat { background: #fff; border-radius: 12px; padding: 20px; text-align: center; box-shadow: 0 1px 6px rgba(0,0,0,.06); }
.stat .num { font-size: 30px; font-weight: 800; color: #ff5000; }
.stat .lbl { color: #888; font-size: 13px; margin-top: 4px; }
main h2 { margin: 24px 0 12px; font-size: 18px; }
.admin-table-wrap { overflow-x: auto; background: #fff; border-radius: 10px; box-shadow: 0 1px 6px rgba(0,0,0,.06); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.admin-table th, .admin-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.admin-table th { background: #fafafa; color: #666; font-weight: 600; }
.admin-table a { color: #2b6cb0; }
.mini { width: 42px; height: 42px; object-fit: cover; border-radius: 6px; }
.mini.noimg { display: inline-flex; align-items: center; justify-content: center; background: #eee; color: #bbb; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; background: #eef; color: #556; }
.badge.on { background: #e6f7e9; color: #27ae60; }
.badge.sold { background: #f2f2f2; color: #999; }
.badge.admin { background: #ffe9d6; color: #d35400; }
.ops { display: flex; gap: 6px; }
.ops form { margin: 0; }
.mini-btn { padding: 5px 10px; border: 1px solid #ccc; background: #fff; border-radius: 6px; cursor: pointer; font-size: 13px; white-space: nowrap; }
.mini-btn:hover { border-color: #ff5000; color: #ff5000; }
.mini-btn.danger { border-color: #e0b4b4; color: #c0392b; }
.mini-btn.danger:hover { background: #fde8e8; border-color: #c0392b; }
.muted { color: #ccc; }

/* hamburger (hidden on desktop) */
.navtoggle, .hamburger { display: none; }
.hamburger { flex-direction: column; gap: 5px; cursor: pointer; padding: 6px; }
.hamburger span { display: block; width: 24px; height: 2.5px; background: #ff5000; border-radius: 2px; transition: .2s; }

.container { max-width: 1100px; margin: 20px auto; padding: 0 16px; }
.narrow { max-width: 460px; }

.cats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.cats a { padding: 6px 14px; background: #fff; border-radius: 16px; font-size: 14px; color: #555; }
.cats a.active, .cats a:hover { background: #ff5000; color: #fff; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.card { background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 6px rgba(0,0,0,.06); transition: transform .15s; }
.card:hover { transform: translateY(-3px); }
.thumb { position: relative; aspect-ratio: 1/1; background: #eee; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.noimg { display: flex; align-items: center; justify-content: center; height: 100%; color: #bbb; }
.noimg.big { min-height: 300px; }
.soldtag { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.6); color: #fff; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.soldtag.inline { position: static; display: inline-block; margin-left: 8px; }
.info { padding: 10px 12px; }
.info .title { font-size: 15px; margin-bottom: 6px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.price { color: #ff5000; font-weight: 700; }
.price.big { font-size: 28px; margin: 10px 0; }
.meta { color: #999; font-size: 12px; margin-top: 4px; display: flex; gap: 8px; }

.empty { text-align: center; color: #888; padding: 60px 0; }
.empty a { color: #ff5000; }

.detail { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; align-items: start; }
.detail-img img { width: 100%; border-radius: 10px; background: #fff; }
.detail-info { background: #fff; padding: 24px; border-radius: 10px; }
.detail-info h1 { font-size: 22px; margin-bottom: 8px; }
.attrs { width: 100%; margin: 14px 0; border-collapse: collapse; }
.attrs th { text-align: left; color: #999; font-weight: 400; width: 90px; padding: 6px 0; vertical-align: top; }
.attrs td { padding: 6px 0; }
.desc { white-space: pre-wrap; line-height: 1.7; color: #444; margin-top: 10px; }
.owner-actions { margin-top: 18px; display: flex; gap: 10px; padding: 10px 12px; }
.owner-actions button { padding: 7px 16px; border: 1px solid #ff5000; background: #fff; color: #ff5000; border-radius: 6px; cursor: pointer; }
.owner-actions button.danger { border-color: #d33; color: #d33; }

.form { display: flex; flex-direction: column; gap: 14px; background: #fff; padding: 24px; border-radius: 10px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: #555; }
.form input, .form select, .form textarea { padding: 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 15px; }
.form button { padding: 12px; background: #ff5000; color: #fff; border: none; border-radius: 6px; font-size: 16px; cursor: pointer; }
h1 { margin-bottom: 16px; }
.error { background: #fde8e8; color: #c0392b; padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.ok { background: #e6f7e9; color: #27ae60; padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.hint { margin-top: 14px; color: #888; text-align: center; }
.hint a { color: #ff5000; }
.footer { text-align: center; color: #aaa; padding: 30px 0; font-size: 13px; }
.footer a { color: #ff5000; }

@media (max-width: 760px) {
    .nav { flex-wrap: wrap; gap: 12px; padding: 10px 16px; }
    .brand { font-size: 19px; }
    .brand-text { display: none; }
    .hamburger { display: flex; margin-left: auto; }
    .searchbar { order: 3; width: 100%; max-width: none; flex-basis: 100%; }
    .links { order: 2; }
    /* collapse menu on mobile */
    .links { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 4px; order: 4; }
    .navtoggle:checked ~ .links { display: flex; }
    .navtoggle:checked ~ .hamburger span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
    .navtoggle:checked ~ .hamburger span:nth-child(2) { opacity: 0; }
    .navtoggle:checked ~ .hamburger span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }
    .links-auth, .links-guest { flex-direction: column; align-items: stretch; gap: 4px; width: 100%; }
    .links a, .btn-sell, .btn-reg { padding: 12px 10px; border-radius: 8px; text-align: center; }
    .btn-sell, .btn-reg { justify-content: center; }
    .user { text-align: center; }
    .linkbtn { padding: 12px 10px; }
    .detail { grid-template-columns: 1fr; }
    .stats { grid-template-columns: repeat(2, 1fr); }
}
