/* Design system: Coverage Home Labs / Sisemoet (same tokens as POCARI) */
:root {
  --color-primary: #111111;
  --color-primary-hover: #333333;
  --color-text-body: #374151;
  --color-text-muted: #6B7280;
  --color-bg-page: #F4F7FA;
  --color-surface-white: #FFFFFF;
  --color-accent: #28a745;
  --color-border: rgba(0,0,0,0.12);
  --color-border-input: #d1d5db;
  --color-in: #28a745;
  --color-free: #616161;
  --color-out: #b42318;
  --font-display: "Outfit", sans-serif;
  --font-body: "DM Sans", "Segoe UI", sans-serif;
  --radius-input: 8px;
  --radius-card: 12px;
  --side-w: clamp(300px, 25vw, 380px);
  --peek: 78px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--color-bg-page); color: var(--color-primary);
  font-family: var(--font-body); -webkit-text-size-adjust: 100%; }
button, input { font: inherit; }
[hidden] { display: none !important; }

.app { display: flex; height: 100vh; height: 100dvh; }

/* ---------- side panel (desktop) ---------- */
.side { width: var(--side-w); flex: none; display: flex; flex-direction: column; background: var(--color-surface-white);
  border-right: 1px solid var(--color-border); min-height: 0; }
.sheet-handle { display: none; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: .6rem;
  padding: .8rem 1.1rem .45rem; border-bottom: 1px solid var(--color-border); }
.title { font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; letter-spacing: .02em; margin: 0; line-height: 2rem; }
.sub { font-size: .8rem; font-weight: 300; letter-spacing: .02em; line-height: 1.1rem; margin: 0; color: var(--color-text-muted); }
.scroll { flex: 1; overflow-y: auto; padding: .7rem 1.1rem 1rem; display: flex; flex-direction: column; gap: .65rem;
  -webkit-overflow-scrolling: touch; }

.card { background: var(--color-surface-white); border: 1px solid var(--color-border); border-radius: var(--radius-card);
  padding: .65rem .8rem .75rem; }
.lbl { font-family: var(--font-display); font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .1em;
  color: var(--color-text-body); margin: 0 0 .45rem; }
.lbl-row { display: flex; justify-content: space-between; align-items: baseline; }
.lbl-row b { font-size: .85rem; letter-spacing: .02em; color: var(--color-primary); text-transform: none; }

.fld { display: block; margin-bottom: .45rem; }
.fld span { display: block; font-size: .72rem; color: var(--color-text-muted); margin-bottom: 2px; }
.fld input { width: 100%; min-height: 36px; padding: 6px 10px; border: 1px solid var(--color-border-input); border-radius: var(--radius-input);
  background: #fff; color: var(--color-primary); font-size: .9rem; outline: none; transition: border-color .2s, box-shadow .2s; }
.fld input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(0,0,0,.08); }
.fld input.err { border-color: var(--color-out); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.hint { font-size: .74rem; color: var(--color-text-muted); margin: 0; line-height: 1.1rem; overflow-wrap: anywhere; }
.hint.err { color: var(--color-out); }
.btns { display: grid; grid-template-columns: 1fr auto; gap: .5rem; margin-top: .55rem; }
.btn { min-height: 38px; border: none; border-radius: var(--radius-input); background: var(--color-primary); color: #fff; cursor: pointer;
  font-family: var(--font-display); font-weight: 600; letter-spacing: .06em; transition: background .2s; }
.btn:hover { background: var(--color-primary-hover); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-ghost { display: inline-flex; align-items: center; gap: .35rem; min-height: 38px; padding: 0 .8rem; background: transparent;
  color: var(--color-text-muted); border: 1px solid var(--color-border-input); border-radius: var(--radius-input); cursor: pointer;
  font-family: var(--font-display); font-weight: 600; font-size: .8rem; transition: border-color .2s, color .2s, background .2s; }
.btn-ghost:hover { border-color: var(--color-primary); color: var(--color-primary); }
.btn-ghost[aria-pressed="true"] { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

input[type=range] { width: 100%; accent-color: var(--color-accent); margin: .2rem 0 0; height: 28px; }
.range-ends { display: flex; justify-content: space-between; font-size: .68rem; color: var(--color-text-muted); }

/* result */
.status { display: inline-flex; align-items: center; gap: .4rem; font-family: var(--font-display); font-weight: 700; font-size: 1.05rem;
  letter-spacing: .04em; padding: .2rem .7rem; border-radius: 999px; color: #fff; margin-bottom: .45rem; }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #fff; }
.status.in { background: var(--color-in); }
.status.free { background: var(--color-free); }
.status.free::before { background: transparent; border: 2px solid #fff; width: 7px; height: 7px; }
.status.out { background: var(--color-out); }
.res-name { font-weight: 700; font-size: .9rem; margin: 0 0 .1rem; }
.res { border-collapse: collapse; width: 100%; }
.res td { padding: 0 6px 0 0; font-size: .8rem; line-height: 1.35rem; color: var(--color-text-body); vertical-align: top; }
.res td:first-child { white-space: nowrap; width: 1%; }
.res td:last-child { font-weight: 500; color: var(--color-primary); }
.res .sep td { border-top: 1px solid var(--color-border); padding-top: .25rem; }
.copy { color: var(--color-accent); font-weight: 600; font-size: .74rem; cursor: pointer; margin-left: .4rem; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid #ccc; border-top-color: var(--color-primary); border-radius: 50%;
  animation: sp .7s linear infinite; vertical-align: -2px; margin-right: .4rem; }
@keyframes sp { to { transform: rotate(360deg); } }

.chip { font-family: var(--font-display); font-weight: 700; font-size: .72rem; letter-spacing: .04em; color: #fff; padding: .2rem .6rem;
  border-radius: 999px; white-space: nowrap; margin-bottom: .2rem; max-width: 55%; overflow: hidden; text-overflow: ellipsis; }
.head .chip { display: none; }
.chip.in { background: var(--color-in); } .chip.free { background: var(--color-free); } .chip.out { background: var(--color-out); }

.layers { display: grid; gap: .3rem; }
.chk { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--color-text-body); cursor: pointer; min-height: 26px; }
.chk input { width: 16px; height: 16px; accent-color: var(--color-accent); }
.foot { font-size: .68rem; color: var(--color-text-muted); margin: .2rem 0 0; overflow-wrap: anywhere; }

/* ---------- map ---------- */
.main { flex: 1; min-width: 0; position: relative; padding: .6rem 1.2rem .6rem 1.2rem; }
#map { height: 100%; border-radius: var(--radius-card); border: 1px solid var(--color-border); background: #e5e3df; }
.legend { position: absolute; left: calc(1.2rem + 10px); bottom: calc(.6rem + 28px); z-index: 500; display: flex; flex-wrap: wrap; gap: .3rem .8rem;
  background: rgba(255,255,255,.94); border: 1px solid var(--color-border); border-left: 3px solid var(--color-primary);
  border-radius: var(--radius-input); padding: 5px 10px; font-size: .74rem; color: var(--color-text-body); max-width: calc(100% - 2.4rem - 20px); }
.legend span { display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; }
.legend b { font-family: var(--font-display); font-weight: 600; color: var(--color-primary); }
.sw { display: inline-block; width: 11px; height: 11px; border: 1px solid; }
.ring { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #ffea00; box-shadow: 0 0 0 1px #555; }

/* point marker + permanent tooltip */
.lsd-pt { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1.5px #111, 0 2px 6px rgba(0,0,0,.4); }
.lsd-pt.in { background: var(--color-in); } .lsd-pt.free { background: var(--color-free); } .lsd-pt.out { background: var(--color-out); }
.leaflet-tooltip.lsd-tip { background: #fff; border: none; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.25); padding: 7px 11px;
  font: 500 12px var(--font-body); color: #111; line-height: 1.35; }
.lsd-tip .t-name { font-weight: 700; font-size: 12.5px; }
.lsd-tip .t-st { display: inline-block; margin: 3px 0 2px; font: 700 12px var(--font-display); letter-spacing: .04em; color: #fff;
  padding: 1px 8px; border-radius: 999px; }
.lsd-tip .t-st.in { background: var(--color-in); } .lsd-tip .t-st.free { background: var(--color-free); } .lsd-tip .t-st.out { background: var(--color-out); }
.lsd-tip .t-sub { color: var(--color-text-muted); font-size: 11px; }
.lsd-near-lbl { font: 800 11px Arial, sans-serif; color: #111; white-space: nowrap; transform: translate(-50%, -50%);
  text-shadow: -1.5px -1.5px 0 #fff, 1.5px -1.5px 0 #fff, -1.5px 1.5px 0 #fff, 1.5px 1.5px 0 #fff; display: inline-block; width: max-content; }
.lsd-picking, .lsd-picking .leaflet-interactive { cursor: crosshair !important; }

/* ---------- POCARI map controls (same classes as pocari app.py) ---------- */
.pc-base {display: inline-flex; border: 1px solid #d1d5db; border-radius: 8px; overflow: hidden; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.12);}
.pc-base-btn {height: 30px; padding: 0 .85rem; border: 0; cursor: pointer; font: 600 .78rem 'Outfit', sans-serif; color: #6B7280; background: #fff;}
.pc-base-btn + .pc-base-btn {border-left: 1px solid #d1d5db;}
.pc-base-btn:hover {color: #111;}
.pc-base-btn.active {background: #111; color: #fff;}
.pc-llpop .leaflet-popup-content-wrapper {border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.18);}
.pc-llpop .leaflet-popup-content {margin: 8px 12px;}
.pc-llbox {cursor: pointer; white-space: nowrap; font: 500 14px 'DM Sans', 'Segoe UI', sans-serif; color: #111;}
.pc-ll {font-weight: 600; letter-spacing: .01em;}
.pc-cp {margin-left: 10px; color: #28a745; font-weight: 600; font-size: 12px;}
.pc-ruler-btn {display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; background: #fff; color: #111;
  border-radius: 8px; box-shadow: 0 1px 5px rgba(0,0,0,.35); cursor: pointer;}
.leaflet-container a.pc-ruler-btn {color: #111;}
.pc-ruler-btn:hover {background: #f4f7fa;} .leaflet-container a.pc-ruler-btn.pc-ruler-on, .pc-ruler-btn.pc-ruler-on {background: #111; color: #fff;}
.pc-measuring, .pc-measuring .leaflet-interactive {cursor: crosshair !important;}
.pc-measuring .leaflet-interactive {pointer-events: none !important;}
.pc-measuring .leaflet-pcRuler-pane .leaflet-interactive {pointer-events: auto !important;}
.pc-measuring .leaflet-tooltip-pane {display: none;}
.pc-ruler-wrap {overflow: visible;}
.pc-ruler-label {position: absolute; transform: translate(-50%, -140%); white-space: nowrap; background: #fff; color: #111;
  font: 600 13px 'DM Sans', 'Segoe UI', sans-serif; padding: 4px 9px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,.25);}
.pc-ruler-final, .pc-measuring .pc-ruler-final {cursor: pointer !important;} .pc-ruler-cp {margin-left: 8px; color: #28a745; font-size: 11px;}
.pc-pin-ctl {position: relative;} .pc-pin-wrap {overflow: visible;}
.pc-pin {position: absolute; left: -13px; top: -33px; pointer-events: auto; cursor: pointer;}
.pc-pin span {position: absolute; left: 25px; top: 2px; font: 800 12px Arial, sans-serif; color: #111; white-space: nowrap;
  text-shadow: -1.5px -1.5px 0 #fff, 1.5px -1.5px 0 #fff, -1.5px 1.5px 0 #fff, 1.5px 1.5px 0 #fff;}
.pc-pin-panel {display: none; position: absolute; right: 42px; top: 0; width: 230px; background: #fff; border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,.3); padding: 10px 12px; font: 500 12px 'DM Sans', 'Segoe UI', sans-serif; color: #111;}
.pc-pin-panel.pc-open {display: block;} .pc-pin-title {font-weight: 700; margin-bottom: 6px;}
.pc-pin-in {width: 100%; box-sizing: border-box; padding: 6px 8px; border: 1px solid #bbb; border-radius: 6px; font: inherit;}
.pc-pin-msg {color: #666; font-size: 11px; margin: 4px 0 8px;} .pc-pin-msg.pc-err {color: #d50000;}
.pc-pin-nm {margin-bottom: 6px;}
.pc-pin-name {width: 170px; box-sizing: border-box; padding: 3px 6px; border: 1px solid #ccc; border-radius: 5px; font: 700 13px Arial, sans-serif; margin-bottom: 4px;}
.pc-cmp-row {display: flex; align-items: center; gap: 8px; margin-bottom: 8px; white-space: nowrap;}
.pc-cmp-row .pc-pin-in {width: 100px;}
.pc-cmp-wrap {overflow: visible;}
.pc-cmp-lbl {color: #ffff00; font: bold 10px sans-serif; text-shadow: 0 0 2px #000, 0 0 2px #000; white-space: nowrap; width: max-content;}
.pc-cmp-big {font-size: 13px;}
.pc-cmp-cross {transform: translate(-50%, -50%); color: #ffff00; font: bold 26px sans-serif; text-shadow: 0 0 2px #000;}
.pc-compassing {cursor: crosshair !important;}
.pc-pin-chk {display: flex; gap: 6px; align-items: center; cursor: pointer; margin-bottom: 8px;}
.leaflet-container .pc-pin-clr {color: #d50000; font-size: 11px; text-decoration: none;}
.pc-pin-act {margin-top: 6px; display: flex; gap: 14px;} .leaflet-container .pc-pin-act a {color: #28a745; font-weight: 600; text-decoration: none;}
.leaflet-container .pc-pin-act a[data-a=del] {color: #d50000;} .pc-pinning, .pc-pinning .leaflet-interactive {cursor: crosshair !important;}
.leaflet-tooltip.pc-adm-tip { font: 500 12px var(--font-body); }

/* ---------- phone: full-screen map + bottom sheet ---------- */
@media (max-width: 767px) {
  .app { display: block; }
  .main { position: fixed; inset: 0; padding: 0; }
  #map { border: none; border-radius: 0; }
  .side { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; width: auto; height: 78dvh; height: 78vh;
    border-right: none; border-radius: 16px 16px 0 0; box-shadow: 0 -4px 24px rgba(0,0,0,.18);
    transform: translateY(calc(100% - var(--peek) - env(safe-area-inset-bottom, 0px))); transition: transform .25s ease; touch-action: pan-y; }
  .side.open { transform: translateY(0); }
  .side.dragging { transition: none; }
  .sheet-handle { display: flex; justify-content: center; padding: 8px 0 2px; cursor: grab; touch-action: none; }
  .sheet-handle span { width: 42px; height: 5px; border-radius: 3px; background: #c9cdd2; }
  .head { padding: .2rem 1rem .5rem; touch-action: none; cursor: pointer; }
  .head { align-items: center; }
  .title { font-size: 1.35rem; line-height: 1.6rem; }
  .sub { display: none; }
  .head .chip:not([hidden]) { display: inline-block; font-size: .8rem; padding: .3rem .7rem; max-width: 72%; margin: 0; }
  .scroll { padding: .6rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px)); }
  .fld input { min-height: 42px; font-size: 16px; }   /* 16px: no iOS zoom on focus */
  .btn, .btn-ghost { min-height: 44px; }
  .legend { left: 8px; right: auto; bottom: calc(var(--peek) + 34px); font-size: .7rem; max-width: calc(100% - 16px); }
  .leaflet-bottom { bottom: calc(var(--peek) - 6px); }
  .leaflet-top.leaflet-right { top: env(safe-area-inset-top, 0px); }
  .pc-base-btn { height: 32px; padding: 0 .6rem; }
  .pc-pin-panel { width: 210px; }
}
