:root {
  --green: #002212;
  --green-2: #0f3322;
  --gold: #ce9a43;
  --bg: #f5f2ea;
  --card: #ffffff;
  --line: #e5dfd2;
  --soft: #efebe2;
  --text: #002212;
  --muted: #4f5b55;
  --ok-bg: #e3eee7;
  --ok: #1c4a31;
  --warn-bg: #fbe9dc;
  --warn: #7a3410;
  --danger: #a12a1a;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: Montserrat, system-ui, sans-serif; font-size: 15px; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
#app { max-width: 640px; margin: 0 auto; min-height: 100vh; padding-bottom: 96px; }
.loading { padding: 40px 20px; color: var(--muted); }

/* Шапка */
.top { background: var(--green); color: #fff; padding: calc(env(safe-area-inset-top) + 20px) 20px 18px; display: flex; flex-direction: column; gap: 14px; }
.top-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { font-size: 11px; font-weight: 600; letter-spacing: 2px; color: var(--gold); }
.top h1 { margin: 2px 0 0; font-family: "Playfair Display", serif; font-size: 26px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: #fff; font-weight: 600; min-height: 44px; background: none; border: 0; padding: 0; cursor: pointer; }
.round { width: 44px; height: 44px; border-radius: 22px; border: 0; background: var(--gold); color: var(--green); display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }

.search { display: flex; align-items: center; gap: 10px; background: var(--green-2); border-radius: 12px; padding: 0 14px; height: 44px; }
.search input { flex: 1; border: 0; background: transparent; color: #fff; outline: none; min-width: 0; }
.search input::placeholder { color: #a9b9b0; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { height: 34px; padding: 0 14px; border-radius: 17px; border: 1px solid #3a5a49; background: transparent; color: #e6ece8; font-size: 13px; font-weight: 500; cursor: pointer; }
.chip.on { background: var(--gold); border-color: var(--gold); color: var(--green); font-weight: 600; }

/* Список */
.list { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.alert { display: flex; align-items: center; gap: 10px; background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 12px 14px; font-size: 13px; font-weight: 600; }
.obj { display: flex; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.thumb { width: 84px; height: 84px; border-radius: 12px; background: #d9d2c3; flex-shrink: 0; display: grid; place-items: center; color: #5e584c; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.obj-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.obj-head { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.obj-addr { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.tag { font-size: 11px; font-weight: 600; padding: 4px 8px; border-radius: 8px; background: var(--soft); color: #3d4743; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; line-height: 1.6; }

/* Форма */
.form { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.section { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.section h2 { margin: 0; font-size: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; min-height: 44px; border: 1px solid #c9c1b0; border-radius: 10px; padding: 10px 12px; background: #fff; }
.field textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg button { min-height: 44px; border-radius: 10px; border: 1px solid #c9c1b0; background: #fff; font-weight: 600; font-size: 13px; cursor: pointer; padding: 0 6px; }
.seg button.on { background: var(--green); border-color: var(--green); color: #fff; }

.btn { min-height: 52px; border-radius: 14px; border: 0; font-weight: 700; font-size: 15px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; }
.btn.main { background: var(--gold); color: var(--green); }
.btn.dark { background: var(--green); color: #fff; }
.btn.line { background: #fff; border: 1px solid #c9c1b0; color: var(--green); }
.btn.danger { background: transparent; color: var(--danger); }
.btn:disabled { opacity: .6; }

/* Картка */
.hero { height: 220px; background: #d9d2c3; display: grid; place-items: center; color: #5e584c; }
.card { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.card h1 { margin: 0; font-family: "Playfair Display", serif; font-size: 24px; }
.price { font-size: 22px; font-weight: 700; }
.muted { color: var(--muted); font-size: 13px; }
.pre { white-space: pre-wrap; line-height: 1.55; font-size: 14px; margin: 0; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.kv span:first-child { color: var(--muted); }
.bar { height: 8px; border-radius: 4px; background: #e2dccf; overflow: hidden; }
.bar div { height: 100%; background: var(--gold); }
.small-btn { height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid #c9c1b0; background: #fff; color: var(--green); font-size: 12px; font-weight: 600; cursor: pointer; }
.sec-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* Фото й відео */
.hero { overflow: hidden; }
.hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.g-item { position: relative; aspect-ratio: 1; border: 0; padding: 0; border-radius: 10px; overflow: hidden; background: #d9d2c3; cursor: pointer; }
.g-item img, .g-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.g-item .play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 22px; text-shadow: 0 1px 6px rgba(0, 0, 0, .6); pointer-events: none; }
.small-btn:disabled { opacity: .5; }

.viewer { position: fixed; inset: 0; background: #000; z-index: 20; display: flex; flex-direction: column; color: #fff; }
.viewer-top { display: flex; justify-content: space-between; align-items: center; padding: calc(env(safe-area-inset-top) + 8px) 8px 8px; font-size: 14px; }
.viewer-top button { width: 44px; height: 44px; border: 0; background: transparent; color: #fff; font-size: 22px; cursor: pointer; }
.v-gap { width: 44px; }
.viewer-stage { flex: 1; min-height: 0; display: grid; place-items: center; }
.viewer-stage img, .viewer-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: 0; background: rgba(0, 0, 0, .35); color: #fff; font-size: 30px; cursor: pointer; }
.viewer-nav.prev { left: 0; border-radius: 0 12px 12px 0; }
.viewer-nav.next { right: 0; border-radius: 12px 0 0 12px; }
.viewer-bottom { display: flex; gap: 10px; padding: 12px 12px calc(env(safe-area-inset-bottom) + 12px); }
.viewer-bottom .btn { flex: 1; min-height: 48px; font-size: 14px; }
.viewer-bottom .btn.line { background: #1c1c1c; border-color: #444; color: #fff; }
.viewer-bottom .btn.danger { background: #3a1410; color: #ffb4a8; }

/* Де виставлено, дзвінки і покази, ідеї */
.stale { color: var(--warn); font-weight: 600; font-size: 13px; }
.small-btn.sure { background: var(--warn-bg); border-color: var(--danger); color: var(--danger); }
.listing { display: flex; align-items: center; gap: 8px; padding: 10px 0 0; border-top: 1px solid var(--line); }
.l-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.l-name { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.add-listing, .add-idea { display: flex; flex-direction: column; gap: 8px; }
.add-idea { flex-direction: row; }
.add-listing input, .add-idea input { width: 100%; min-height: 44px; border: 1px solid #c9c1b0; border-radius: 10px; padding: 10px 12px; background: #fff; min-width: 0; }
.add-idea input { flex: 1; }
.add-listing .btn, .add-idea .btn { min-height: 44px; font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--soft); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.stat b { font-family: "Playfair Display", serif; font-size: 28px; line-height: 1.1; }
.stat small { color: var(--muted); font-size: 12px; }
.ev { display: flex; align-items: center; gap: 10px; padding: 8px 0 0; border-top: 1px solid var(--line); font-size: 14px; }
.ev .muted { flex: 1; }
.idea { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); }
.idea label { flex: 1; display: flex; align-items: center; gap: 10px; min-height: 48px; cursor: pointer; line-height: 1.4; font-size: 14px; }
.idea input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--green); flex-shrink: 0; }
.idea.done span { text-decoration: line-through; color: var(--muted); }

/* Посилання для клієнта й колег */
.share-row { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.share-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.share-btns .small-btn { flex: 1; min-width: 90px; }
.contacts { border-top: 1px solid var(--line); padding-top: 10px; }
.contacts summary { cursor: pointer; font-size: 13px; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.contacts form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.contacts input { width: 100%; min-height: 44px; border: 1px solid #c9c1b0; border-radius: 10px; padding: 10px 12px; background: #fff; }
.contacts .btn { min-height: 44px; font-size: 14px; }
.share-foot { display: flex; gap: 8px; justify-content: flex-end; }

/* Звіт власнику */
.comment { display: flex; flex-direction: column; gap: 8px; }
.comment textarea { width: 100%; border: 1px solid #c9c1b0; border-radius: 10px; padding: 10px 12px; background: #fff; line-height: 1.5; resize: vertical; }
.comment .btn { min-height: 44px; font-size: 14px; }

/* Клієнти */
.obj-addr.wrap { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.35; }
.thumb.ini { background: var(--green); color: var(--gold); font-family: "Playfair Display", serif; font-size: 30px; font-weight: 700; }
.seg.wrap { display: flex; flex-wrap: wrap; }
.seg.wrap button { flex: 1 1 auto; padding: 0 12px; }
.chips2 { display: flex; gap: 8px; flex-wrap: wrap; }
.chips2 .small-btn { flex: 1; min-width: 70px; }
.date-in { width: 100%; min-height: 44px; border: 1px solid #c9c1b0; border-radius: 10px; padding: 10px 12px; background: #fff; min-width: 0; }
.mlist { display: flex; flex-direction: column; gap: 10px; }
.buyer { display: flex; align-items: center; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.buyer:first-of-type { border-top: 0; padding-top: 0; }
.b-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.b-main .tags { margin-top: 0; }

/* Вхід */
.login { min-height: 100vh; background: var(--green); color: #fff; display: flex; flex-direction: column; justify-content: center; padding: 32px 24px; gap: 18px; }
.login h1 { margin: 0; font-family: "Playfair Display", serif; font-size: 30px; }
.login input { height: 52px; border-radius: 12px; border: 0; padding: 0 16px; background: var(--green-2); color: #fff; outline: none; }
.err { color: #ffb4a8; font-size: 14px; min-height: 20px; }

/* Нижнє меню */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 8px 0 calc(env(safe-area-inset-bottom) + 8px); z-index: 5; }
.nav a { min-width: 0; flex: 1; min-height: 44px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: #5e6964; font-weight: 500; }
.nav a.on { color: var(--green); font-weight: 700; }

#toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: var(--green); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 10; max-width: 90vw; }
#toast.show { opacity: 1; }

/* Сьогодні, календар, справи */
.top .sub { margin: 2px 0 0; color: #c9d4ce; font-size: 13px; }
.section.attn { border-color: #e8b99c; }
.trow, .arow { display: flex; align-items: flex-start; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.arow { align-items: center; }
.tcheck { width: 44px; min-height: 44px; margin: -8px 0 -8px -10px; display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.tcheck input, .check input { width: 22px; height: 22px; accent-color: var(--green); }
.tbody { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.tmain { display: flex; flex-direction: column; gap: 2px; }
.ttitle { font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.tmeta { font-size: 12px; color: var(--muted); }
.tlinks { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 12px; }
.tlinks a { font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.trow.done .ttitle { text-decoration: line-through; color: var(--muted); }
.a-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.a-title { font-weight: 700; line-height: 1.35; }
.a-btns { display: flex; gap: 6px; flex-shrink: 0; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; cursor: pointer; }

.cal-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-nav b { font-family: "Playfair Display", serif; font-size: 20px; text-transform: capitalize; }
.cal-nav .small-btn { width: 44px; height: 44px; padding: 0; font-size: 22px; line-height: 1; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-head span { text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); }
.day { min-height: 46px; border: 1px solid transparent; border-radius: 10px; background: none; font-size: 14px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 0; }
.day.today { border-color: var(--gold); font-weight: 700; }
.day.sel { background: var(--green); color: #fff; }
.dots { display: flex; gap: 3px; height: 6px; }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 3px; }
.dot.t { background: var(--gold); }
.dot.t.d { background: #b8b2a3; }
.dot.c { background: #2f7a52; }
.dot.k { background: var(--danger); }
.day.sel .dot.c { background: #7fd0a0; }
.day.sel .dot.k { background: #ff9d8b; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11px; color: var(--muted); }
.legend .dot { margin-right: 4px; }
