:root {
  color-scheme: dark;
  --bg: #08090a;
  --bg-2: #0e1012;
  --panel: #15181b;
  --panel-2: #1d2125;
  --line: #2b3136;
  --text: #ffffff;
  --muted: #98a2a8;
  --silver: #c9d1d6;
  --teal: #1ec8c8;
  --teal-dim: #0f8f8f;
  --lime: #b6f43a;
  --lime-dim: #8fd200;
  --warn: #ff7a7a;
  --gold: #ffd35c;
  --topbar-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
small { font-size: .78rem; }

/* ===== Top bar ===== */
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 1rem; padding: 0 1rem;
  background: #000; border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(30,200,200,.18); position: relative; z-index: 1200;
}
.brand { display: flex; align-items: center; gap: .55rem; }
.brand-text { font-weight: 800; letter-spacing: .12em; font-size: 1.05rem; text-transform: uppercase; white-space: nowrap; }
.brand .accent { color: var(--bg); background: var(--lime); padding: .05rem .4rem; border-radius: 5px; letter-spacing: .08em; }
.brand .puck {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  background: radial-gradient(circle at 35% 30%, var(--teal), #0a4f4f);
  box-shadow: 0 0 0 2px rgba(255,255,255,.15), 0 0 12px rgba(30,200,200,.55);
}
.topnav { margin-left: auto; display: flex; align-items: center; gap: .4rem; }
.nav-link {
  background: transparent; color: var(--silver); border: 1px solid transparent;
  padding: .55rem .8rem; border-radius: 9px; font-size: .9rem; font-weight: 600; white-space: nowrap;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.primary { color: var(--bg); background: var(--lime); font-weight: 800; }
.nav-link.primary:hover { background: var(--lime-dim); color: #000; }
.auth-link { color: var(--teal); border-color: var(--teal-dim); }
.auth-link:hover { background: rgba(30,200,200,.1); color: var(--teal); }
.icon-btn { background: transparent; border: 0; color: var(--silver); font-size: 1.3rem; width: 44px; height: 44px; border-radius: 9px; }
.icon-btn:hover { background: rgba(255,255,255,.07); color: #fff; }

/* ===== Layout ===== */
.layout { display: flex; height: calc(100% - var(--topbar-h)); }
.sidebar { width: 410px; max-width: 44vw; flex-shrink: 0; background: var(--bg-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.map-wrap { flex: 1; position: relative; }
#map { position: absolute; inset: 0; background: #050607; }
.sheet-handle { display: none; }

/* ===== Search ===== */
.searchbar { display: flex; gap: .5rem; padding: .85rem; border-bottom: 1px solid var(--line); }
.searchbar input { flex: 1; background: var(--panel); border: 1px solid var(--line); color: var(--text); padding: .75rem .85rem; border-radius: 11px; font-size: 1rem; }
.searchbar input::placeholder { color: #6b7378; }
.searchbar input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(30,200,200,.15); }
.searchbar .icon-btn { background: var(--teal); color: #00201f; border-radius: 11px; flex-shrink: 0; }

.list-controls { display: flex; align-items: center; justify-content: space-between; padding: .65rem .85rem; border-bottom: 1px solid var(--line); }
.result-count { color: var(--muted); font-size: .82rem; font-weight: 600; }
.chip { background: var(--panel-2); color: var(--silver); border: 1px solid var(--line); padding: .5rem .8rem; border-radius: 999px; font-size: .82rem; font-weight: 600; }
.chip:hover { border-color: var(--teal); color: var(--teal); }

/* ===== Location list ===== */
.location-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.loc-card { padding: .95rem 1rem; border-bottom: 1px solid var(--line); cursor: pointer; border-left: 3px solid transparent; transition: background .12s, border-color .12s; }
.loc-card:hover { background: var(--panel); }
.loc-card.active { background: var(--panel); border-left-color: var(--lime); }
.loc-card h3 { font-size: 1.02rem; font-weight: 700; }
.loc-card .addr { color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.loc-card .meta { display: flex; gap: .5rem; align-items: center; margin-top: .6rem; flex-wrap: wrap; }
.badge { background: rgba(30,200,200,.12); color: var(--teal); font-size: .74rem; font-weight: 700; padding: .18rem .55rem; border-radius: 6px; border: 1px solid rgba(30,200,200,.25); }
.badge.pink { background: rgba(182,244,58,.14); color: var(--lime); border-color: rgba(182,244,58,.3); }
.stars { color: var(--gold); font-size: .82rem; letter-spacing: 1px; }
.dist { color: var(--silver); font-size: .76rem; margin-left: auto; font-weight: 600; }
.empty { padding: 2.5rem 1.2rem; text-align: center; color: var(--muted); line-height: 1.7; }
.empty b { color: var(--lime); }

/* ===== Map FAB / legend / locate ===== */
.map-fab { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 600; background: var(--teal); color: #00201f; border: 0; padding: .6rem 1.1rem; border-radius: 999px; font-weight: 700; font-size: .85rem; box-shadow: 0 4px 16px rgba(0,0,0,.5); display: none; }
.map-fab.show { display: block; }
.loc-fab { position: absolute; right: 14px; bottom: 70px; z-index: 600; width: 48px; height: 48px; border-radius: 50%; background: var(--panel-2); color: var(--teal); border: 1px solid var(--line); font-size: 1.4rem; box-shadow: 0 4px 14px rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; }
.loc-fab:hover { border-color: var(--teal); }
.map-legend { position: absolute; bottom: 16px; left: 14px; z-index: 600; background: rgba(8,9,10,.82); border: 1px solid var(--line); padding: .45rem .75rem; border-radius: 10px; display: flex; gap: .8rem; font-size: .76rem; color: var(--silver); backdrop-filter: blur(6px); }
.map-legend .dot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: .3rem; vertical-align: middle; }
.dot-1 { background: var(--silver); } .dot-2 { background: var(--teal); } .dot-3 { background: var(--lime); }

/* ===== Marker pins (rounded count-chips) ===== */
.pin { min-width: 24px; height: 24px; padding: 0 5px; border-radius: 7px; border: 1.5px solid rgba(255,255,255,.9); box-shadow: 0 2px 8px rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; }
.pin span { font-size: .72rem; font-weight: 800; }
.pin.c1 { background: var(--silver); color: #1a1f22; }
.pin.c2 { background: var(--teal); color: #00201f; }
.pin.c3 { background: var(--lime); color: #182300; }

/* ===== Panels & modals ===== */
.panel { position: fixed; top: var(--topbar-h); right: 0; bottom: 0; width: 450px; max-width: 92vw; background: var(--bg-2); border-left: 1px solid var(--line); z-index: 1100; transform: translateX(105%); transition: transform .25s ease; overflow-y: auto; }
.panel[aria-hidden="false"] { transform: translateX(0); }
.panel-inner { padding: 1.3rem; }
.panel-close { position: absolute; top: .5rem; right: .7rem; background: rgba(0,0,0,.3); border: 0; color: var(--silver); font-size: 1.6rem; line-height: 1; width: 40px; height: 40px; border-radius: 50%; z-index: 5; }
.panel-close:hover { color: #fff; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.72); z-index: 1300; display: none; align-items: flex-start; justify-content: center; padding: 4vh 1rem; overflow-y: auto; }
.modal[aria-hidden="false"] { display: flex; }
.modal-inner { position: relative; background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 1.6rem; width: 520px; max-width: 100%; box-shadow: 0 24px 60px rgba(0,0,0,.6); }
.modal-inner.narrow { width: 380px; text-align: center; }
.modal h2, .panel h2 { margin-bottom: 1rem; font-size: 1.3rem; }

/* ===== Forms ===== */
form label { display: block; margin-bottom: .9rem; font-size: .82rem; font-weight: 700; color: var(--muted); }
form input, form select, form textarea { width: 100%; margin-top: .35rem; background: var(--panel); border: 1px solid var(--line); color: var(--text); padding: .75rem .8rem; border-radius: 10px; font-size: 1rem; font-weight: 400; }
form input:focus, form select:focus, form textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(30,200,200,.13); }
.hint { display: block; margin-top: .3rem; color: var(--muted); font-weight: 400; }
.linkbtn { background: none; border: 0; color: var(--teal); font-size: .78rem; text-decoration: underline; padding: 0; }
.guest-name { border-color: var(--teal-dim) !important; }

.tables-editor { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .85rem; margin: .4rem 0 1rem; }
.tables-editor-head { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; font-weight: 700; color: var(--text); margin-bottom: .6rem; }
.table-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .55rem; }
.table-row input, .table-row select { margin: 0; }
.table-row .brand-sel { flex: 1 1 46%; min-width: 0; }
.table-row .cond { flex: 1 1 36%; min-width: 0; }
.table-row .brand-other { flex: 1 1 100%; }
.table-row .del { flex: 0 0 40px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); border-radius: 8px; }
.table-row .del:hover { color: var(--warn); border-color: var(--warn); }

/* Confirmation checkboxes */
.confirm-box { background: rgba(182,244,58,.05); border: 1px solid rgba(182,244,58,.22); border-radius: 12px; padding: .8rem .9rem; margin-bottom: 1rem; }
.check { display: flex; align-items: flex-start; gap: .6rem; margin: 0 0 .65rem; font-size: .86rem; font-weight: 500; color: var(--silver); cursor: pointer; }
.check:last-child { margin-bottom: 0; }
.check input { width: 20px; height: 20px; margin: 0; flex-shrink: 0; accent-color: var(--lime); cursor: pointer; }
.check span { line-height: 1.35; }

.primary-btn { width: 100%; background: var(--lime); color: #142000; border: 0; padding: .9rem; border-radius: 11px; font-weight: 800; font-size: 1.02rem; margin-top: .3rem; }
.primary-btn:hover { background: var(--lime-dim); }
.primary-btn:disabled { opacity: .45; cursor: default; }
.ghost-btn { width: 100%; background: transparent; color: var(--silver); border: 1px solid var(--line); padding: .8rem; border-radius: 11px; font-weight: 600; margin-top: .6rem; }
.ghost-btn:hover { color: var(--teal); border-color: var(--teal); }
.status { font-size: .85rem; color: var(--teal); min-height: 1.1rem; margin-bottom: .4rem; }
.status.error { color: var(--warn); }
.muted { color: var(--muted); font-size: .9rem; margin-bottom: 1rem; line-height: 1.5; }

/* ===== Detail content ===== */
.detail-head h2 { margin-bottom: .25rem; }
.detail-addr { color: var(--muted); font-size: .9rem; margin-bottom: .55rem; }
.detail-section { margin: 1.3rem 0; }
.detail-section h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--teal); margin-bottom: .65rem; }
.table-item { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--lime); border-radius: 10px; padding: .65rem .8rem; margin-bottom: .5rem; }
.table-item .t-name { font-weight: 700; }
.table-item .t-meta { color: var(--muted); font-size: .82rem; margin-top: .2rem; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: pointer; border: 1px solid var(--line); }
.photo-upload { display: inline-block; margin-top: .5rem; }
.rating-input { display: flex; gap: .3rem; font-size: 1.9rem; color: #3a4145; margin-bottom: .5rem; }
.rating-input span { cursor: pointer; }
.rating-input span.on { color: var(--gold); }
.comment-item { border-top: 1px solid var(--line); padding: .6rem 0; }
.comment-item .c-head { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); }
.comment-item .c-stars { color: var(--gold); }
.feed .feed-item { padding: .75rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.feed .feed-item b { color: var(--lime); }
.feed .feed-item .f-when { color: var(--muted); font-size: .78rem; margin-top: .15rem; }

/* ===== Toast ===== */
.toast { position: fixed; bottom: calc(24px + var(--safe-b)); left: 50%; transform: translateX(-50%) translateY(40px); background: var(--panel-2); color: #fff; border: 1px solid var(--teal-dim); padding: .8rem 1.2rem; border-radius: 11px; font-size: .92rem; z-index: 2000; opacity: 0; transition: all .25s; pointer-events: none; box-shadow: 0 6px 24px rgba(0,0,0,.5); max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== Mobile: full-screen map + bottom sheet ===== */
@media (max-width: 760px) {
  .layout { position: relative; display: block; }
  .map-wrap { position: absolute; inset: 0; }
  .loc-fab { bottom: calc(46vh + 12px); transition: bottom .28s ease; }
  body.sheet-expanded .loc-fab { bottom: calc(88vh + 12px); }
  .map-legend { display: none; }

  .brand-text { font-size: .9rem; letter-spacing: .06em; }
  .nav-link .lbl { display: none; }
  .nav-link { padding: .55rem .65rem; font-size: 1rem; }
  .nav-link.primary { font-size: .85rem; }
  .nav-link.primary .lbl { display: inline; }
  .auth-link { font-size: .82rem; }

  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: 100%; max-width: 100%;
    height: 46vh; z-index: 800; border-right: 0; border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.55);
    transition: height .28s ease; padding-bottom: var(--safe-b);
  }
  body.sheet-expanded .sidebar { height: 88vh; }
  .sheet-handle { display: block; width: 100%; background: transparent; border: 0; padding: .7rem 0 .35rem; position: relative; }
  .sheet-handle::before { content: ""; display: block; width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto; }
  .searchbar { padding: .35rem .85rem .7rem; }

  .panel { top: 0; width: 100%; max-width: 100%; }
  .modal { padding: 0; align-items: stretch; }
  .modal-inner { border-radius: 0; width: 100%; min-height: 100%; padding: 1.4rem 1.2rem calc(1.6rem + var(--safe-b)); }
  .modal-inner.narrow { width: 100%; }
}
