:root {
  --ink: #2b2d30;
  --muted: #6b655d;
  --line: #e3d8c6;
  --bg: #ffffff;
  --card: #f7f1e7;
  --accent: #c2410c;
  --accent-soft: #fbe3cf;
  --amber: #b7791f;
  --amber-soft: #f8edd9;
  --grey-soft: #ebe2d3;
  --danger: #b42318;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

/* Shell */
.app { position: relative; height: 100vh; height: 100dvh; overflow: hidden; }
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px var(--accent-soft); flex: none; }
.brand-name { font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.layout { position: absolute; inset: 0; }
.map-wrap { position: absolute; inset: 0; }
.map { position: absolute; inset: 0; }
.map.is-picking { cursor: crosshair; }
.gwe-pin-wrap { background: none; border: none; }
.gwe-pin {
  display: block; width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease;
}
.gwe-pin--now { background: #f97316; }
.gwe-pin--soon { background: #d6a24a; }
.gwe-pin--later { background: #9a8f82; }
.gwe-pin.is-active { transform: scale(1.35); box-shadow: 0 0 0 5px rgba(249, 115, 22, 0.25), 0 2px 8px rgba(0,0,0,.25); }

.locate {
  position: absolute; right: 12px; bottom: calc(46vh + 12px); z-index: 500;
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 10px 14px; font-size: 14px; font-weight: 500; cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}
.pickbar {
  position: absolute; top: 76px; left: 50%; transform: translateX(-50%); z-index: 900;
  display: flex; align-items: center; gap: 12px; white-space: nowrap;
  background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 999px;
  font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.pickbar .link { color: #fff; opacity: 0.85; }

/* Bottom sheet (mobile) */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 800;
  height: 46vh; display: flex; flex-direction: column;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.08);
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 8px auto 4px; flex: none; }
.filters { padding: 4px 16px 8px; display: grid; gap: 8px; flex: none; }
.selects { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
select, input[type="date"], input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input:not([type]) {
  width: 100%; height: 44px; padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; font-size: 16px;
  outline: none;
}
select:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.list-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 6px 18px 4px; font-size: 13px; font-weight: 600; flex: none; }
.muted { color: var(--muted); font-weight: 400; }
.list { overflow-y: auto; padding: 4px 12px 24px; display: grid; gap: 10px; -webkit-overflow-scrolling: touch; }
.empty { padding: 24px 12px; text-align: center; color: var(--muted); }
.empty-action { margin-top: 12px; }
.lock-note { font-size: 12px; font-weight: 600; color: var(--amber); margin-top: 8px; }
.unlock-box { display: grid; gap: 8px; background: var(--amber-soft); border-radius: 12px; padding: 12px; font-size: 14px; }
.sub-badge { font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 6px 10px; border-radius: 999px; white-space: nowrap; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
}
.card:hover { border-color: #d3d8d5; }
.card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-top h3 { font-size: 16px; }
.card-meta { margin-top: 4px; font-size: 13px; color: var(--muted); }
.note { margin: 8px 0 0; font-size: 14px; color: #3b4541; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.badge { flex: none; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge--now { background: var(--accent-soft); color: var(--accent); }
.badge--soon { background: var(--amber-soft); color: var(--amber); }
.badge--later { background: var(--grey-soft); color: #4b5550; }

/* Chips & tags */
.chips { display: flex; gap: 6px; }
.chips--scroll { overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips--scroll::-webkit-scrollbar { display: none; }
.chips--wrap { flex-wrap: wrap; }
.chips--static { flex-wrap: wrap; margin-top: 10px; }
.chip {
  flex: none; height: 34px; padding: 0 12px; border-radius: 4px;
  border: 1px solid var(--line); background: #fff; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.chip.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.tag { font-size: 12px; padding: 4px 9px; border-radius: 999px; background: var(--bg); color: #3b4541; border: 1px solid var(--line); }

/* Buttons */
.btn {
  height: 42px; padding: 0 16px; border-radius: 4px; border: 1px solid var(--line);
  background: #fff; font-size: 14px; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #cfd5d1; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: #9a3412; border-color: #9a3412; }
.btn--sm { height: 36px; padding: 0 14px; font-size: 13px; }
.btn--danger { color: var(--danger); border-color: #f1c7c3; }
.link { background: none; border: none; padding: 0; color: var(--accent); font-size: 13px; font-weight: 500; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.icon-btn { background: none; border: none; font-size: 26px; line-height: 1; cursor: pointer; padding: 4px 8px; color: var(--muted); }
.spacer { flex: 1; }

/* Modal / form */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 2000; background: rgba(15, 20, 18, 0.4);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  width: 100%; max-height: 92dvh; overflow-y: auto; background: #fff;
  border-radius: 22px 22px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  display: grid; gap: 14px; box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { font-size: 20px; }
.modal-foot { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.field > span { font-weight: 500; color: #3b4541; }
.field .hint { font-size: 12px; color: var(--muted); }
.field .link { justify-self: start; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; }
.inline .btn { height: 44px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: #3b4541; }
.check input { margin-top: 2px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.error { font-size: 14px; color: var(--danger); background: #fdf0ef; padding: 10px 12px; border-radius: 10px; }

.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 72px); transform: translateX(-50%);
  z-index: 3000; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px;
  font-size: 14px; max-width: calc(100% - 32px); text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.2);
}

/* Leaflet tweaks */
.leaflet-container { font-family: Inter, system-ui, sans-serif; }
.leaflet-control-attribution { font-size: 10px; }

/* Desktop */
@media (min-width: 900px) {
  .app { height: 100vh; height: 100dvh; }
  .topbar {
    position: relative; height: 64px; padding: 0 20px;
    border-bottom: 1px solid var(--line); background: #fff; backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .layout { top: 64px; }
  .sheet {
    top: 0; right: auto; bottom: 0; width: 390px; height: auto;
    border-radius: 0; box-shadow: none; border-right: 1px solid var(--line); background: #fff;
    padding-bottom: 0;
  }
  .sheet-handle { display: none; }
  .map-wrap { left: 390px; top: 0; bottom: 0; right: 0; }
  .locate { bottom: 16px; right: auto; left: 16px; }
  .pickbar { top: 16px; }
  .leaflet-control-zoom { display: block; }
  .modal-backdrop { align-items: center; }
  .modal { width: min(560px, calc(100% - 32px)); max-height: 90vh; border-radius: 22px; }
  .toast { top: 84px; }
}
@media (max-width: 899px) {
  .leaflet-control-zoom { display: none; }
}
@media (max-width: 380px) {
  .row2 { grid-template-columns: 1fr; }
}

.btn-icon { display: inline-flex; align-items: center; gap: 6px; }
.brand-link { text-decoration: none; color: inherit; }
.brand-logo { width: 28px; height: 28px; border-radius: 8px; flex: none; }
.top-nav { display: none; gap: 20px; align-items: center; }
.top-nav a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; }
.top-nav a:hover { color: var(--ink); }
@media (min-width: 900px) {
  .top-nav { display: flex; margin-left: 28px; }
}

/* Top actions */
.top-actions { display: flex; gap: 8px; align-items: center; flex: none; }

/* Card header */
.card-head { display: flex; align-items: flex-start; gap: 10px; }
.card-head .badge { margin-left: auto; }
.card-title { min-width: 0; flex: 1; }
.card-title h3 { font-size: 16px; line-height: 1.25; }
.logo { width: 42px; height: 42px; border-radius: 10px; object-fit: contain; background: #fff; border: 1px solid var(--line); flex: none; }
.logo--empty { display: flex; align-items: center; justify-content: center; background: var(--grey-soft); border-color: transparent; color: #4b5550; font-weight: 700; font-size: 13px; }
.verified { display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; vertical-align: middle; white-space: nowrap; }
.rating-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; color: #3b4541; }
.stars { display: inline-flex; gap: 1px; }
.star { color: #d4d8d6; font-size: 15px; line-height: 1; }
.star.is-on, .star-btn.is-on { color: #f59e0b; }
.star-btn { background: none; border: none; padding: 2px; font-size: 22px; line-height: 1; color: #d4d8d6; cursor: pointer; }

/* Segmented control */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--bg); border-radius: 12px; padding: 4px; }
.seg button { height: 38px; border: none; background: transparent; border-radius: 9px; font-size: 14px; font-weight: 500; cursor: pointer; color: var(--muted); }
.seg button.is-on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* Owned companies & media */
.owned { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 8px; }
.owned-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.owned-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.media-panel { display: grid; gap: 14px; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.media-panel p { margin: 0; font-size: 14px; }
.media-block { display: grid; gap: 8px; }
.field-label { font-size: 13px; font-weight: 600; color: #3b4541; }
.media-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.thumb { position: relative; width: 84px; height: 84px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: none; background: rgba(15,20,18,.75); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; }
.file-btn { cursor: pointer; }

/* Detail modal */
.modal--wide { max-width: 640px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.gallery { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.gallery img { height: 120px; width: auto; max-width: 180px; border-radius: 12px; object-fit: cover; flex: none; border: 1px solid var(--line); }
.gallery .gallery-logo { height: 120px; width: 120px; object-fit: contain; background: #fff; }
.block { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.block-head h3 { font-size: 16px; }
.item { display: grid; gap: 4px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item p { margin: 0; font-size: 14px; color: #2b332f; white-space: pre-wrap; }
.item-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.form-mini { display: grid; gap: 8px; }
.form-mini textarea, .modal textarea { width: 100%; border-radius: 12px; border: 1px solid var(--line); padding: 10px 12px; font-size: 16px; resize: vertical; outline: none; }
.form-mini textarea:focus, .modal textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.claim { display: grid; gap: 8px; background: var(--bg); border-radius: 12px; padding: 12px; }
.claim p { margin: 0; }
.small { font-size: 13px; }
.muted.small { font-size: 13px; }
.modal .card-actions { margin-top: 0; }
