:root {
  --bg: #0B111B;
  --sidebar: #101824;
  --card: #121D2B;
  --card-2: #172333;
  --border: #233040;
  --text: #ECEDF0;
  --muted: #8F9AAB;
  --gold: #D0B17C;
  --gold-ink: #1A1408;
  --green: #67C8A0;
  --blue: #79A5D3;
  --red: #E08A80;
  --amber: #E2B862;
  --radius: 14px;
  --radius-sm: 10px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; overflow-x: hidden; }
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100dvh; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--border); padding: calc(20px + var(--safe-top)) 14px 20px; position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand img { width: 34px; height: 34px; border-radius: 8px; }
.brand b { display: block; font-size: .95rem; letter-spacing: .04em; }
.brand small { color: var(--gold); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; }
.nav a { display: flex; align-items: center; gap: 10px; white-space: nowrap; padding: 11px 10px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 550; }
.nav a:hover { background: var(--card); color: var(--text); }
.nav a.active { background: var(--card-2); color: var(--text); box-shadow: inset 3px 0 0 var(--gold); }
.nav svg { width: 20px; height: 20px; flex: none; }
.nav .soon { margin-left: auto; font-size: .66rem; white-space: nowrap; color: var(--muted); border: 1px solid var(--border); padding: 1px 6px; border-radius: 99px; }
.nav a.disabled { pointer-events: none; opacity: .55; }
.sidebar .foot { margin-top: auto; padding: 8px; font-size: .8rem; color: var(--muted); }
.main { min-width: 0; padding: calc(24px + var(--safe-top)) 32px 48px; max-width: 1280px; width: 100%; }
.bottomnav { display: none; }

.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar .grow { flex: 1; min-width: 0; }
.topbar .sub { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--blue); font-weight: 550; margin-bottom: 6px; background: none; border: 0; padding: 0; cursor: pointer; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: calc(14px + var(--safe-top)) 16px calc(96px + var(--safe-bottom)); }
  .bottomnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: rgba(16,24,36,.96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + var(--safe-bottom)); }
  .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; color: var(--muted); font-size: .72rem; font-weight: 600; min-height: 48px; }
  .bottomnav a.active { color: var(--gold); }
  .bottomnav svg { width: 22px; height: 22px; }
  h1 { font-size: 1.45rem; }
}

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--border); background: var(--card-2); color: var(--text); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #33455b; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: .875rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.iconbtn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 50%; border: 1px solid var(--border); background: var(--card); cursor: pointer; color: var(--text); }
.iconbtn svg { width: 18px; height: 18px; }

.field { display: grid; gap: 6px; }
.field > span { font-size: .85rem; color: var(--muted); font-weight: 550; }
.field .req { color: var(--gold); }
.input, select.input, textarea.input { width: 100%; min-height: 46px; padding: 10px 14px; background: var(--card-2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 16px; }
textarea.input { min-height: 110px; resize: vertical; }
.input:focus { border-color: var(--gold); outline: none; }
.input::placeholder { color: #5f6b7c; }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; min-width: 0; }
.input-group select.input { flex: 0 0 auto; width: auto; }
.hint { font-size: .8rem; color: var(--muted); }

.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg button, .chip { min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--card-2); color: var(--text); font-weight: 550; font-size: .9rem; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
.seg button:disabled { opacity: .45; cursor: not-allowed; }

.search { position: relative; flex: 1; min-width: 220px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.search .input { padding-left: 42px; border-radius: 999px; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 14px; }
.section-title svg { width: 14px; height: 14px; }
.section-title { font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 650; margin: 22px 4px 8px; display: flex; align-items: center; gap: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: block; color: var(--text); }
.stat b { display: block; font-size: 1.8rem; font-weight: 650; }
.stat span { color: var(--muted); font-size: .88rem; }
.stat.warn b { color: var(--amber); }

/* ---------- listing list ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 12px; }
.filters.collapsed .adv { display: none; }
.filterbtn[aria-expanded="true"] { border-color: var(--gold); color: var(--gold); }
.filterbtn .dot { min-width: 20px; height: 20px; border-radius: 99px; background: var(--gold); color: var(--gold-ink); font-size: .72rem; display: inline-grid; place-items: center; padding: 0 5px; }
@media (max-width: 860px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters.collapsed { display: none; }
}
.count { color: var(--muted); font-size: .88rem; margin: 6px 2px 10px; }
.list { display: grid; gap: 10px; }
.list.gridview { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.lcard { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; color: var(--text); cursor: pointer; min-width: 0; }
.lcard:hover { border-color: #33455b; }
.gridview .lcard { grid-template-columns: minmax(0, 1fr); }
.thumb { position: relative; aspect-ratio: 4/3; border-radius: var(--radius-sm); background: var(--card-2); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .n { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.65); color: #fff; font-size: .72rem; padding: 1px 7px; border-radius: 99px; font-weight: 650; }
.thumb .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #3b4a5e; }
.thumb .ph svg { width: 34px; height: 34px; }
.lbody { min-width: 0; display: grid; gap: 4px; align-content: start; }
.lhead { display: flex; gap: 8px; align-items: flex-start; }
.lhead h3 { font-size: 1rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prices { display: flex; flex-wrap: wrap; gap: 4px 14px; font-weight: 650; font-size: .95rem; }
.prices .tag { color: var(--muted); font-weight: 600; font-size: .78rem; margin-right: 4px; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: 650; padding: 2px 9px; border-radius: 99px; border: 1px solid; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-available { color: var(--green); border-color: rgba(103,200,160,.35); }
.b-rented, .b-sold { color: var(--blue); border-color: rgba(121,165,211,.35); }
.b-own_use, .b-unavailable { color: var(--muted); border-color: var(--border); }
.b-potential { color: var(--gold); border-color: rgba(208,177,124,.35); }
.b-shared { color: var(--blue); border-color: rgba(121,165,211,.35); }
.b-warn { color: var(--amber); border-color: rgba(226,184,98,.35); }
.pill { display: inline-block; font-size: .74rem; font-weight: 650; padding: 2px 9px; border-radius: 99px; background: rgba(208,177,124,.12); color: var(--gold); }

.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 18px 0; }
.empty { text-align: center; padding: 56px 16px; color: var(--muted); }
.empty svg { width: 36px; height: 36px; margin-bottom: 8px; }
.skeleton { background: linear-gradient(90deg, var(--card) 0%, var(--card-2) 50%, var(--card) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--radius); height: 104px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- detail ---------- */
.gallery { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; border-radius: var(--radius); -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.gallery img { height: 260px; width: auto; max-width: 88vw; object-fit: cover; border-radius: var(--radius-sm); scroll-snap-align: start; cursor: zoom-in; background: var(--card-2); }
@media (max-width: 640px) { .gallery img { height: 220px; } }
.rows { display: grid; }
.row { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
.row > span:first-child { color: var(--muted); }
.row > span:last-child { text-align: right; font-weight: 550; overflow-wrap: anywhere; }
.row.sub > span:first-child { padding-left: 14px; font-size: .9rem; }
.unknown { color: var(--muted); font-weight: 400 !important; font-style: italic; }
.private { border-color: rgba(208,177,124,.3); }
.private-head { display: flex; align-items: center; gap: 8px; color: var(--gold); font-size: .8rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; }
.private-head svg { width: 14px; height: 14px; }

.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.94); display: flex; align-items: center; justify-content: center; touch-action: pan-y; }
.lightbox img { max-width: 100vw; max-height: 86dvh; object-fit: contain; }
.lightbox .lb-close { position: absolute; top: calc(12px + var(--safe-top)); right: 12px; }
.lightbox .lb-prev, .lightbox .lb-next { position: absolute; top: 50%; transform: translateY(-50%); }
.lightbox .lb-prev { left: 10px; } .lightbox .lb-next { right: 10px; }
.lightbox .lb-count { position: absolute; bottom: calc(16px + var(--safe-bottom)); color: #ddd; font-size: .9rem; }

/* ---------- photo manager ---------- */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.ptile { position: relative; background: var(--card-2); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.ptile .img { aspect-ratio: 4/3; background: #0e1622; }
.ptile .img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ptile .cover { position: absolute; top: 6px; left: 6px; background: var(--gold); color: var(--gold-ink); font-size: .7rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.ptile .state { position: absolute; top: 6px; right: 6px; font-size: .7rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: rgba(0,0,0,.7); }
.ptile .state.failed { color: var(--red); } .ptile .state.uploading { color: var(--blue); }
.ptile .bar { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--gold); transition: width .2s; }
.ptile .acts { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; }
.ptile .acts button { flex: 1; min-height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); font-size: .78rem; cursor: pointer; padding: 0 4px; }
.ptile .err { padding: 0 8px 6px; color: var(--red); font-size: .75rem; }
.addphoto { aspect-ratio: 4/3; border: 1.5px dashed #3a4b61; border-radius: var(--radius-sm); display: grid; place-items: center; color: var(--muted); cursor: pointer; text-align: center; font-size: .85rem; padding: 8px; background: transparent; }
.addphoto svg { width: 26px; height: 26px; display: block; margin: 0 auto 4px; }

/* ---------- form ---------- */
.form { display: grid; gap: 14px; }
.form .card { display: grid; gap: 14px; }
.savebar { position: sticky; bottom: 0; z-index: 30; display: flex; gap: 10px; align-items: center; padding: 12px 0 calc(12px + var(--safe-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); margin-top: 8px; }
@media (max-width: 860px) { .savebar { bottom: calc(64px + var(--safe-bottom)); padding-bottom: 12px; } }
.savebar .btn.primary { flex: 1; max-width: 420px; }
.savestate { font-size: .88rem; color: var(--muted); }
.savestate.err { color: var(--red); } .savestate.ok { color: var(--green); }
.part { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; display: grid; gap: 10px; background: var(--card-2); }
.linkbtn { background: none; border: 0; color: var(--blue); font-weight: 600; padding: 6px 0; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.calc { display: flex; gap: 18px; flex-wrap: wrap; font-size: .88rem; color: var(--muted); }
.calc b { color: var(--text); font-weight: 600; }
details.card > summary { cursor: pointer; font-weight: 650; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "＋"; color: var(--muted); }
details.card[open] > summary::after { content: "－"; }
details.card[open] > summary { margin-bottom: 4px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + var(--safe-bottom)); z-index: 120; background: #F2F3F5; color: #111; padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: .9rem; box-shadow: 0 8px 30px rgba(0,0,0,.4); max-width: calc(100vw - 32px); text-align: center; }
.toast.err { background: #3a1d1b; color: #ffd2cc; border: 1px solid #6b302a; }
.banner { background: rgba(226,184,98,.1); border: 1px solid rgba(226,184,98,.35); color: var(--amber); padding: 10px 14px; border-radius: var(--radius-sm); font-size: .9rem; margin-bottom: 14px; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login .card { width: 100%; max-width: 400px; display: grid; gap: 16px; padding: 28px 24px; }
.login .logo { width: 64px; height: 64px; border-radius: 14px; margin: 0 auto; display: block; }
.login h1 { text-align: center; font-size: 1.3rem; letter-spacing: .06em; }
.login p { text-align: center; margin: -8px 0 4px; color: var(--muted); font-size: .9rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* compact breakdown price rows (like the reference: one line, details folded) */
.bpart { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; display: grid; gap: 6px; background: var(--card-2); }
.bpart-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 130px 40px; gap: 6px; align-items: center; }
.bpart .input { min-height: 40px; padding: 8px 10px; }
.bpart .bp-kind { width: auto; padding-right: 6px; }
.bpart .iconbtn { width: 36px; height: 36px; color: var(--muted); }
.bp-more > summary { cursor: pointer; font-size: .85rem; color: var(--blue); padding: 2px 2px; list-style: none; }
.bp-more > summary::-webkit-details-marker { display: none; }
.bp-more > summary::after { content: " ›"; }
.bp-more[open] > summary::after { content: " ⌄"; }
.bp-more[open] .grid3 { margin-top: 8px; }
#parts { display: grid; gap: 8px; }
@media (max-width: 640px) {
  .bpart-row { grid-template-columns: minmax(0, 1fr) auto 36px; }
  .bpart-row .bp-label { grid-column: 1 / -1; }
  .bpart-row .bp-amt { grid-column: 1; grid-row: 2; }
  .bpart-row .bp-kind { grid-column: 2; grid-row: 2; }
  .bpart-row .bp-del { grid-column: 3; grid-row: 2; }
}
