:root {
  --orange: #F88F00;
  --orange-dark: #d97a00;
  --ink: #1B1B1B;
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e6e8eb;
  --muted: #7a808a;
  --text: #23262b;
  --green: #16a34a;
  --profit-pos: #16794a;
  --profit-neg: #b42318;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.05);
  --sidebar-w: 264px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  background: #fff; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--ink); }
.brand .logo {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--ink); color: #fff; display: grid; place-items: center;
  font-weight: 900; font-size: 15px; letter-spacing: -.5px;
}
.brand .logo b { color: var(--orange); }
.brand .logo-img { height: 34px; width: auto; display: block; }
.brand .title { font-size: 15px; }
.brand .title small { display: block; font-weight: 600; color: var(--muted); font-size: 11px; }
.count-pill {
  font-size: 13px; color: var(--muted); font-weight: 600;
  padding: 4px 10px; background: var(--bg); border-radius: 999px; white-space: nowrap;
}
.topbar .spacer { flex: 1; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px;
  padding: 7px 11px; min-width: 180px;
}
.search input { border: none; background: transparent; outline: none; font-size: 14px; width: 100%; color: var(--text); }
.search svg { flex: none; opacity: .5; }
.btn-add {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--orange); color: #fff; border: none; font-weight: 700; font-size: 14px;
  padding: 9px 15px; border-radius: 9px; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(216,122,0,.35);
}
.btn-add:hover { background: var(--orange-dark); }
.hamburger { display: none; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 9px; }

/* ---------- Layout ---------- */
.layout { display: flex; align-items: flex-start; }
.sidebar {
  width: var(--sidebar-w); flex: none;
  position: sticky; top: 51px; align-self: flex-start;
  height: calc(100vh - 51px); overflow-y: auto;
  background: #fff; border-right: 1px solid var(--line);
  padding: 16px 14px 40px;
}
.sidebar h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 6px 8px; }
.sidebar h2:first-child { margin-top: 0; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 9px; border-radius: 8px; font-size: 14px; color: var(--text);
  cursor: pointer; user-select: none;
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: #fff5e8; color: var(--orange-dark); font-weight: 700; }
.nav-item .left { display: flex; align-items: center; gap: 9px; min-width: 0; }
.nav-item .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.nav-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .badge { font-size: 12px; color: var(--muted); font-weight: 600; flex: none; }
.nav-item.active .badge { color: var(--orange-dark); }

.date-row { display: flex; gap: 8px; padding: 4px 6px 8px; }
.date-row label { font-size: 11px; color: var(--muted); display: block; margin-bottom: 3px; }
.date-row input { width: 100%; font-size: 13px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; }
.saved-views { padding: 2px 6px; }
.saved-view { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; border-radius: 7px; font-size: 13px; cursor: pointer; }
.saved-view:hover { background: var(--bg); }
.saved-view .x { color: var(--muted); opacity: 0; }
.saved-view:hover .x { opacity: 1; }
.link-btn { background: none; border: none; color: var(--orange-dark); font-weight: 700; font-size: 13px; padding: 6px 8px; }

/* ---------- Content ---------- */
.content { flex: 1; min-width: 0; padding: 20px 22px 60px; }
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; box-shadow: var(--shadow); cursor: pointer;
  display: flex; flex-direction: column; transition: transform .08s ease, box-shadow .12s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(16,24,40,.10); }
.card .addr { font-weight: 700; font-size: 15px; padding: 13px 14px 10px; color: var(--ink); line-height: 1.3; }
.card .hero { position: relative; aspect-ratio: 16/10; background: #eceef1; overflow: hidden; }
.card .hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .hero .ph {
  width: 100%; height: 100%; display: grid; place-items: center; gap: 6px;
  color: #aab0b8; background: repeating-linear-gradient(135deg,#eef0f3,#eef0f3 12px,#e9ebef 12px,#e9ebef 24px);
  flex-direction: column; text-align:center;
}
.card .hero .ph small { font-size: 11px; }
.card .body { padding: 11px 14px 14px; }
.badge {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 6px;
  margin-bottom: 9px;
}
.card .date { font-size: 13px; font-weight: 600; color: var(--text); }
.card .profit { font-size: 13px; color: var(--muted); margin-top: 5px; }
.card .profit b { color: var(--text); font-weight: 700; }
.card .profit b.pos { color: var(--profit-pos); }
.card .profit b.neg { color: var(--profit-neg); }
.card .foot { border-top: 1px solid var(--line); padding: 8px 14px; font-size: 11px; color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }

/* ---------- Detail ---------- */
.detail-wrap { max-width: 1040px; margin: 0 auto; padding: 22px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; font-size: 14px; margin-bottom: 14px; }
.back:hover { color: var(--orange-dark); }
.detail-head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.detail-head h1 { font-size: 22px; margin: 0; color: var(--ink); flex: 1; min-width: 260px; }
.detail-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 22px; align-items: start; }
.detail-photo { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #eceef1; aspect-ratio: 16/11; }
.detail-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-photo .ph { width: 100%; height: 100%; display: grid; place-items: center; color: #aab0b8; flex-direction: column; gap: 8px;
  background: repeating-linear-gradient(135deg,#eef0f3,#eef0f3 14px,#e9ebef 14px,#e9ebef 28px); }
.upload-btn { display: inline-flex; align-items: center; gap: 7px; margin-top: 10px; font-size: 13px; font-weight: 700;
  color: var(--orange-dark); background: #fff5e8; border: 1px solid #ffe0b8; padding: 8px 13px; border-radius: 9px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 4px 4px; box-shadow: var(--shadow); }
.field { display: grid; grid-template-columns: 150px 1fr; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.field:last-child { border-bottom: none; }
.field .k { color: var(--muted); font-weight: 600; }
.field .v { color: var(--text); word-break: break-word; white-space: pre-wrap; }
.field .v a { color: var(--orange-dark); font-weight: 600; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 2px 8px; font-weight: 700; }
.md { font-size: 14px; line-height: 1.55; }
.md strong { color: var(--ink); }
.md a { color: var(--orange-dark); }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20,22,26,.45); display: grid; place-items: center; z-index: 60; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal h3 { margin: 0; padding: 18px 20px; border-bottom: 1px solid var(--line); font-size: 17px; }
.modal .form { padding: 16px 20px; display: grid; gap: 13px; }
.modal label { font-size: 12px; font-weight: 700; color: var(--muted); display: block; margin-bottom: 5px; }
.modal input, .modal select, .modal textarea { width: 100%; font-size: 14px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; font-family: inherit; }
.modal textarea { min-height: 70px; resize: vertical; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: #fff; }
.btn-secondary { background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 9px 15px; font-weight: 700; font-size: 14px; }
.btn-primary { background: var(--orange); color: #fff; border: none; border-radius: 9px; padding: 9px 17px; font-weight: 700; font-size: 14px; }
.btn-primary:hover { background: var(--orange-dark); }

/* ---------- Responsive ---------- */
.backdrop { display: none; }
@media (max-width: 820px) {
  .sidebar {
    position: fixed; top: 51px; left: 0; z-index: 40; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: 4px 0 20px rgba(0,0,0,.12);
  }
  .sidebar.open { transform: translateX(0); }
  .backdrop.show { display: block; position: fixed; inset: 51px 0 0 0; background: rgba(0,0,0,.3); z-index: 39; }
  .hamburger { display: inline-flex; }
  .brand .title small { display: none; }
  .detail-grid { grid-template-columns: 1fr; }
  .field { grid-template-columns: 120px 1fr; }
  .search { min-width: 0; }
}
@media (max-width: 520px) {
  .brand .title { display: none; }
  .count-pill { display: none; }
  .grid { grid-template-columns: 1fr; }
}
