/* CRM + mediator portal: same language as the site. Soft-grey canvas, white rounded panels, red for primary and active. */
body.crm { background: var(--canvas); }
.app { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
@media (min-width: 768px) { .app { grid-template-columns: 76px 1fr; } }
@media (min-width: 1280px) { .app { grid-template-columns: 240px 1fr; } }
.side { display: none; position: sticky; top: 0; height: 100vh; padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border); flex-direction: column; gap: 4px; overflow-y: auto; }
@media (min-width: 768px) { .side { display: flex; } }
.side .brand { padding: 6px 8px 18px; }
.side a.nv { position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; text-decoration: none; color: var(--text); font: 500 14px/1.2 var(--font-body); }
.side a.nv:hover { background: var(--surface-2); color: var(--ink); }
.side a.nv.on { background: var(--red-soft); color: var(--red); font-weight: 600; }
.side a.nv.on::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--red); }
.side .grp { font: 600 11px/1 var(--font-body); color: var(--muted); letter-spacing: .06em; text-transform: uppercase; padding: 16px 12px 6px; }
@media (min-width: 768px) and (max-width: 1279px) { .side .lbl, .side .grp, .side .brand span { display: none; } .side a.nv { justify-content: center; } }
.side .count { margin-left: auto; background: var(--red); color: var(--on-red); border-radius: 999px; font-size: 11px; padding: 1px 7px; }
@media (min-width: 768px) and (max-width: 1279px) { .side .count { position: absolute; top: 4px; right: 4px; } }
.main { min-width: 0; padding: 0 0 88px; }
@media (min-width: 768px) { .main { padding-bottom: 32px; } }
.topb { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: rgba(243,244,246,.94); backdrop-filter: blur(8px); }
@media (min-width: 768px) { .topb { padding: 14px 24px; } }
.gsearch { flex: 1; max-width: 520px; position: relative; }
.gsearch input { width: 100%; min-height: 44px; padding: 10px 14px 10px 42px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font: 400 15px/1 var(--font-body); }
.gsearch svg { position: absolute; left: 14px; top: 12px; color: var(--muted); }
.gsearch .res { position: absolute; left: 0; right: 0; top: 50px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); max-height: 60vh; overflow-y: auto; display: none; }
.gsearch .res.open { display: block; }
.gsearch .res a { display: block; padding: 10px 14px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--border); font-size: 14px; }
.gsearch .res a:hover { background: var(--surface-2); }
.gsearch .res small { color: var(--muted); display: block; }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.content { padding: 0 16px; }
@media (min-width: 768px) { .content { padding: 0 24px; } }
.ph-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin: 8px 0 18px; }
.ph-head h1 { font-size: clamp(22px, 2.4vw, 28px); margin: 0; }
.card { background: var(--surface); border-radius: 24px; padding: 20px; }
@media (min-width: 1024px) { .card { padding: 24px; } }
.card h2 { font-size: 17px; display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr; } .g3 { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 768px) { .g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .g4 { grid-template-columns: repeat(4, 1fr); } .g-side { grid-template-columns: 1fr 380px; align-items: start; } }
.tile { background: var(--surface); border-radius: 22px; padding: 18px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--text); }
.tile b { font: 600 clamp(24px, 2.6vw, 32px)/1 var(--font-head); color: var(--ink); font-variant-numeric: tabular-nums; }
.tile span { font-size: 13px; color: var(--muted); }
.tile .ic { color: var(--red); }
.tile.red { background: var(--red-deep); color: rgba(255,255,255,.85); }
.tile.red b, .tile.red .ic { color: #fff; }
.tile.red span { color: rgba(255,255,255,.8); }
.tbl-wrap { overflow-x: auto; border-radius: 18px; border: 1px solid var(--border); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 720px; }
.tbl th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl th a { color: inherit; text-decoration: none; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: #FCFCFD; }
.tbl a.rowlink { color: var(--ink); font-weight: 600; text-decoration: none; }
.tbl a.rowlink:hover { color: var(--red); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar .input { width: auto; min-height: 40px; font-size: 14px; }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: 280px; gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.kcol { background: var(--panel-soft); border-radius: 20px; padding: 12px; min-height: 300px; }
.kcol h3 { font-size: 13px; display: flex; justify-content: space-between; margin: 4px 6px 10px; color: var(--ink); }
.kcol .list { display: grid; gap: 8px; min-height: 60px; }
.kcard { background: var(--surface); border-radius: 14px; padding: 12px; font-size: 13px; cursor: grab; border: 1px solid transparent; text-decoration: none; color: var(--text); display: block; }
.kcard:hover { border-color: var(--border-strong); }
.kcard b { display: block; color: var(--ink); font-size: 14px; }
.kcard.dragging { opacity: .5; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.dot.hot { background: var(--red); } .dot.warm { background: #F59E0B; } .dot.cold { background: #94A3B8; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.timeline li { position: relative; padding: 0 0 16px 24px; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: -6px; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 2px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--red); }
.timeline .when { font-size: 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); word-break: break-word; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 500; font-size: 14px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--red); border-bottom-color: var(--red); }
.edit-map { height: 460px; border-radius: 18px; overflow: hidden; background: #E5E8EC; }
.gmap-crm { display: block; width: 100%; height: 320px; border: 0; border-radius: 14px; background: #E5E8EC; }
.big-map { height: calc(100vh - 170px); min-height: 420px; border-radius: 22px; overflow: hidden; background: #E5E8EC; }
.map-split { grid-template-columns: 1fr; align-items: start; }
@media (min-width: 1100px) { .map-split { grid-template-columns: 1fr 380px; } .map-split .gpanel { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow-y: auto; } }
.gpanel .btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; gap: 4px; }
.seg .chip { min-height: 38px; padding: 6px 14px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); font: 500 14px/1 var(--font-body); color: var(--text); cursor: pointer; }
.seg .chip.on { background: var(--red-soft); color: var(--red); border-color: var(--red); }
.glist { margin-top: 14px; display: grid; gap: 6px; max-height: 360px; overflow-y: auto; }
.glist button { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; text-align: left; width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font: 500 13px/1.3 var(--font-body); color: var(--text); cursor: pointer; }
.glist button.on, .glist button:hover { border-color: var(--red); background: var(--red-soft); }
.glist button b { color: var(--ink); display: block; }
.glist i { width: 10px; height: 10px; border-radius: 50%; }
.area-check { display: flex; flex-wrap: wrap; gap: 12px; font-size: 14px; margin-top: 10px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.thumbs .t { position: relative; border-radius: 12px; overflow: hidden; background: #E5E8EC; aspect-ratio: 4/3; cursor: grab; }
.thumbs .t img { width: 100%; height: 100%; object-fit: cover; }
.thumbs .t .act { position: absolute; inset: auto 6px 6px 6px; display: flex; gap: 4px; justify-content: flex-end; }
.thumbs .t .act button { width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(255,255,255,.92); display: grid; place-items: center; cursor: pointer; }
.thumbs .t.cover { outline: 3px solid var(--red); }
.drop { border: 2px dashed var(--border-strong); border-radius: 16px; padding: 20px; text-align: center; color: var(--muted); background: var(--surface-2); }
.drop.over { border-color: var(--red); background: var(--red-soft); }
.chk { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.chk li { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: 12px; font-size: 14px; }
.chk li.bad { background: var(--red-soft); color: #7A0C1E; }
.chk li.warn { background: var(--warning-soft); color: #7C2D12; }
.chk li.ok { background: var(--success-soft); color: #14532D; }
.chk li.info { background: var(--info-soft); color: #1E3A8A; }
.mbottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.mbottom a, .mbottom button { border: 0; background: none; font-family: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; font-size: 11px; color: var(--muted); text-decoration: none; min-height: 56px; justify-content: center; }
.mbottom a.on { color: var(--red); }
@media (min-width: 768px) { .mbottom { display: none; } }
.toast { position: fixed; right: 16px; bottom: 80px; z-index: 90; max-width: 360px; }
@media (min-width: 768px) { .toast { bottom: 24px; } }
.pre { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 14px; font: 13px/1.5 ui-monospace, Consolas, monospace; max-height: 340px; overflow: auto; }
.chart { width: 100%; height: auto; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 48px; gap: 10px; align-items: center; font-size: 13px; margin-bottom: 8px; }
.bar-row .bar { height: 10px; border-radius: 6px; background: var(--panel-soft); overflow: hidden; }
.bar-row .bar i { display: block; height: 100%; background: var(--red); border-radius: 6px; }
.bar-row .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }
.funnel .bar-row .bar i { background: linear-gradient(90deg, #0A1830, #D9485F); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 420px; }
details.inline > summary { cursor: pointer; list-style: none; }
details.inline > summary::-webkit-details-marker { display: none; }
/* Responsive: phone drawer, stacked tables, no grid overflow */
.grid > *, .g-side > * { min-width: 0; }
.mnav { display: none; flex: 0 0 auto; }
.side-shade { display: none; }
@media (max-width: 767px) {
  .mnav { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--ink); }
  .who .muted { display: none; }
  .side { display: flex; position: fixed; z-index: 60; left: 0; top: 0; bottom: 0; width: min(300px, 84vw); transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  body.side-open .side { transform: none; }
  body.side-open .side-shade { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(15,23,42,.42); }
  body.side-open { overflow: hidden; }
  .toolbar .input, .toolbar select.input { flex: 1 1 140px; width: auto !important; min-width: 0; }
  .toolbar .btn { flex: 0 0 auto; }
  .ph-head > form, .ph-head > .toolbar { width: 100%; }
  .card { border-radius: 20px; padding: 16px; }
  .kv { grid-template-columns: 110px 1fr; }
  .bar-row { grid-template-columns: 96px 1fr 40px; }
  .edit-map { height: 380px; }
  .big-map { height: 62vh; min-height: 360px; }
  .gmap-crm { height: 260px; }
  .kanban { grid-auto-columns: 82vw; scroll-snap-type: x mandatory; }
  .kcol { scroll-snap-align: start; }
  /* Tables become cards: each cell shows its column name (labels added by crm.js) */
  .tbl-wrap.stack { border: 0; background: none; overflow: visible; }
  .tbl-wrap.stack table.tbl { min-width: 0; }
  .tbl-wrap.stack thead { display: none; }
  .tbl-wrap.stack tr { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 10px 14px; margin-bottom: 10px; }
  .tbl-wrap.stack tr:hover td { background: none; }
  .tbl-wrap.stack td { display: block; position: relative; min-height: 30px; padding: 6px 0 6px 106px; border: 0; text-align: left !important; }
  .tbl-wrap.stack td::before { content: attr(data-label); position: absolute; left: 0; top: 8px; width: 96px; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
  .tbl-wrap.stack td[data-label=""] { padding-left: 0; }
  .tbl-wrap.stack td[data-label=""]::before { display: none; }
  .tbl-wrap.stack td:first-child { font-size: 15px; }
  .tbl-wrap.stack td[colspan] { display: block; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .g-side { grid-template-columns: 1fr; }
  .toolbar .input { min-width: 0; }
}
@media print { .side, .topb, .mbottom, .no-print { display: none !important; } .app { display: block; } body { background: var(--surface); } }

/* Map search control (Google imagery maps) */
.map-search { display: flex; background: var(--surface); border-radius: 10px; box-shadow: 0 1px 6px rgba(0,0,0,.25); overflow: hidden; }
.map-search input { width: 290px; max-width: 58vw; border: 0; padding: 9px 12px; font: 400 14px/1.2 var(--font-body); color: var(--text); outline: none; background: var(--surface); }
.map-search button { border: 0; background: var(--red); color: var(--on-red); width: 40px; display: grid; place-items: center; cursor: pointer; }
.leaflet-container .leaflet-control-layers-list { font: 500 13px/1.6 var(--font-body); }

/* Pipeline: ad campaign chips + card tag */
.camp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.camp-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px 6px 12px; border-radius: var(--radius-pill); background: var(--surface); border: 1px solid var(--border); font-size: 12px; font-weight: 600; color: var(--text); text-decoration: none; }
.camp-chip b { background: var(--panel-soft); color: var(--ink); border-radius: var(--radius-pill); padding: 1px 8px; font-size: 11px; }
.camp-chip:hover { border-color: var(--red); color: var(--red); }
.camp-chip.on { background: var(--red); border-color: var(--red); color: var(--on-red); }
.camp-chip.on b { background: rgba(255,255,255,.2); color: var(--on-red); }
.kcard .kcamp { display: flex; align-items: center; gap: 4px; margin-top: 6px; font-size: 11px; font-weight: 600; color: var(--red); background: var(--red-soft); border-radius: 8px; padding: 3px 7px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Heatmaps */
.heat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 16px; margin-top: 16px; align-items: start; }
@media (max-width: 1100px) { .heat-layout { grid-template-columns: 1fr; } }
.heat-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.heat-legend { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-left: auto; }
.heat-legend i, .heat-legend b { width: 60px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #2563eb, #06b6d4, #22c55e, #facc15, #dc2626); }
.heat-legend b { display: none; }
.heat-stage { --k: 1; position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: 14px; background: var(--panel-soft); min-height: 300px; max-height: 2600px; overflow-y: auto; }
.heat-stage iframe, .heat-stage canvas { position: absolute; left: 0; top: 0; transform: scale(var(--k)); transform-origin: 0 0; border: 0; }
.heat-stage iframe { pointer-events: none; background: var(--surface); }
.heat-stage canvas { pointer-events: none; }
.heat-wait { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-weight: 600; }
.seg > a { display: inline-flex; align-items: center; min-height: 38px; padding: 6px 14px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); font: 500 14px/1 var(--font-body); color: var(--text); text-decoration: none; }
.seg > a.on { background: var(--red-soft); color: var(--red); border-color: var(--red); }
