/* ============================================================
   CCTV Planner — styles
   ============================================================ */
:root{
  --bg:#eef1f6;
  --panel:#ffffff;
  --ink:#0f172a;
  --ink-2:#475569;
  --ink-3:#94a3b8;
  --line:#dbe1ea;
  --line-2:#eaeef4;
  --brand:#0078d0;
  --brand-ink:#ffffff;
  --brand-soft:#e3f1fc;
  --danger:#dc2626;
  --bar:#0f172a;
  --bar-ink:#e2e8f0;
  --radius:10px;
  --shadow:0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.08);
  --side-w:340px;
  --strip-h:76px;
  --top-h:56px;
  --safe-b:env(safe-area-inset-bottom,0px);
}

*{box-sizing:border-box}
[hidden]{display:none !important}
html,body{height:100%}
body{
  margin:0; background:var(--bg); color:var(--ink);
  font:15px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  -webkit-text-size-adjust:100%; overscroll-behavior:none;
}
h1,h2,h3{margin:0 0 .5em; line-height:1.25; font-weight:650}
p{margin:0 0 .75em}
input,textarea,button,select{font:inherit; color:inherit}

/* ---------------- buttons ---------------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:7px;
  min-height:38px; padding:0 13px; border:1px solid var(--line);
  background:var(--panel); color:var(--ink); border-radius:var(--radius);
  cursor:pointer; font-size:14px; font-weight:550; white-space:nowrap;
  transition:background .12s, border-color .12s, transform .06s;
  -webkit-tap-highlight-color:transparent; user-select:none;
}
.btn:hover:not(:disabled){background:#f7f9fc; border-color:#c8d1de}
.btn:active:not(:disabled){transform:translateY(1px)}
.btn:disabled{opacity:.42; cursor:not-allowed}
.btn-primary{background:var(--brand); border-color:var(--brand); color:var(--brand-ink)}
.btn-primary:hover:not(:disabled){background:#0069b8; border-color:#0069b8}
.btn-lg{min-height:46px; padding:0 22px; font-size:15.5px}
.btn-icon{min-width:38px; padding:0 9px; font-size:16px}
.btn .ico{font-size:15px; line-height:1}
.btn.danger{color:var(--danger); border-color:#f2c9c9}
.btn.danger:hover:not(:disabled){background:#fef2f2}

/* ---------------- top bar ---------------- */
.topbar{
  position:sticky; top:0; z-index:40; height:var(--top-h);
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:0 12px; background:var(--bar); color:var(--bar-ink);
  box-shadow:0 1px 0 rgba(0,0,0,.2);
}
.brand{
  display:flex; align-items:center; gap:10px; font-weight:700; letter-spacing:.2px;
  color:inherit; text-decoration:none; border-radius:9px; padding:3px 6px 3px 3px;
  -webkit-tap-highlight-color:transparent;
}
.brand:hover{background:#1e293b}
.brand-logo{
  display:grid; place-items:center; background:#fff; border-radius:7px;
  padding:4px 7px; flex:0 0 auto;
}
.brand-logo img{display:block; width:auto; height:19px}
.brand-text{font-size:15.5px; white-space:nowrap}
.topbar-actions{display:flex; align-items:center; gap:8px}
.topbar .btn{
  background:#1e293b; border-color:#334155; color:var(--bar-ink); min-height:34px;
}
.topbar .btn:hover:not(:disabled){background:#293548; border-color:#41506a}
.topbar .btn-primary{background:var(--brand); border-color:var(--brand); color:#fff}
.topbar .btn-primary:hover{background:#0069b8}

/* dropdown menu */
.menu-wrap{position:relative}
.menu{
  position:absolute; right:0; top:calc(100% + 8px); z-index:60; min-width:232px;
  background:var(--panel); color:var(--ink); border:1px solid var(--line);
  border-radius:12px; box-shadow:var(--shadow); padding:6px;
}
.menu button, .menu .menu-file{
  display:block; width:100%; text-align:left; background:none; border:0;
  padding:9px 11px; border-radius:8px; cursor:pointer; font-size:14px;
}
.menu button:hover, .menu .menu-file:hover{background:var(--brand-soft)}
.menu button.danger{color:var(--danger)}
.menu hr{border:0; border-top:1px solid var(--line-2); margin:5px 4px}

/* ---------------- dropzone ---------------- */
.dropzone{display:block}
.dz-hero{
  min-height:calc(100vh - var(--top-h)); display:grid; place-items:center;
  padding:36px 20px 60px; text-align:center;
}
.dz-inner{max-width:660px}

/* ---------------- SEO / landing copy ---------------- */
.seo{background:var(--panel); border-top:1px solid var(--line); padding:52px 20px 60px}
.seo article{max-width:760px; margin:0 auto; color:var(--ink-2); font-size:15.5px; line-height:1.72}
.seo h2{
  font-size:21px; letter-spacing:-.3px; color:var(--ink); margin:38px 0 12px;
  padding-top:22px; border-top:1px solid var(--line-2);
}
.seo article>h2:first-child{margin-top:0; padding-top:0; border-top:0}
.seo h3{font-size:15.5px; color:var(--ink); margin:22px 0 4px}
.seo h3+p{margin-top:0}
.seo p{margin:0 0 14px}
.seo strong,.seo b{color:var(--ink)}
.seo a{color:var(--brand); font-weight:600}
.seo-list,.seo-steps{margin:0 0 16px; padding-left:22px}
.seo-list li,.seo-steps li{margin-bottom:9px}
.seo-steps{counter-reset:step}

.foot-brand{margin:0 0 4px}
.foot-brand a{color:var(--brand); font-weight:700; text-decoration:none; font-size:13.5px}
.foot-brand a:hover{text-decoration:underline}
.dz-icon{
  width:max-content; margin:0 auto 22px; display:grid; place-items:center;
  border-radius:16px; background:var(--panel); padding:12px 18px;
  border:1px solid var(--line); box-shadow:0 8px 24px rgba(0,120,208,.14);
}
.dz-icon img{display:block; width:auto; height:42px}
.dropzone h1{font-size:27px; letter-spacing:-.4px}
.dz-sub{color:var(--ink-2); font-size:15.5px; max-width:560px; margin:0 auto 22px}
.dz-hint{margin-top:14px; color:var(--ink-3); font-size:13px}
.dz-features{
  list-style:none; padding:0; margin:34px 0 0; display:grid; gap:10px;
  grid-template-columns:repeat(auto-fit,minmax(210px,1fr)); text-align:left;
}
.dz-features li{
  background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:13px 15px;
}
.dz-features b{display:block; font-size:14px; margin-bottom:2px}
.dz-features span{color:var(--ink-2); font-size:13px; line-height:1.45}
body.dragging .dz-hero{outline:3px dashed var(--brand); outline-offset:-14px; background:var(--brand-soft)}

/* ---------------- workspace ---------------- */
.workspace{
  display:grid; height:calc(100vh - var(--top-h));
  grid-template-columns:1fr var(--side-w);
  grid-template-rows:var(--strip-h) 1fr;
  grid-template-areas:"strip side" "stage side";
}
.page-strip{
  grid-area:strip; display:flex; align-items:center; gap:9px;
  padding:0 12px; overflow-x:auto; overflow-y:hidden;
  background:var(--panel); border-bottom:1px solid var(--line);
  scrollbar-width:thin;
}
.pg{
  flex:0 0 auto; width:58px; cursor:pointer; text-align:center;
  border:0; background:none; padding:0; -webkit-tap-highlight-color:transparent;
}
.pg canvas{
  display:block; width:58px; height:44px; object-fit:contain;
  border:2px solid var(--line); border-radius:6px; background:#fff;
}
.pg span{display:block; font-size:11px; color:var(--ink-2); margin-top:3px; font-weight:550;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.pg.is-active canvas{border-color:var(--brand); box-shadow:0 0 0 3px var(--brand-soft)}
.pg.is-active span{color:var(--brand)}
.pg .dot{
  display:inline-block; min-width:15px; height:15px; line-height:15px; margin-left:3px;
  background:var(--brand); color:#fff; border-radius:8px; font-size:10px; padding:0 4px;
}

.stage-wrap{grid-area:stage; position:relative; overflow:hidden; background:#dfe4ec}
.stage{
  position:absolute; inset:0; overflow:auto; padding:22px 22px 62px;
  display:grid; justify-items:center; align-content:safe center;
  -webkit-overflow-scrolling:touch; touch-action:pan-x pan-y pinch-zoom;
}
.sheet{
  position:relative; background:#fff; box-shadow:0 4px 22px rgba(15,23,42,.16);
  line-height:0; flex:0 0 auto;
}
.sheet canvas{display:block; max-width:none}
.overlay{position:absolute; inset:0; width:100%; height:100%; overflow:hidden}

.stage-toolbar{
  position:absolute; left:0; right:0; bottom:calc(14px + var(--safe-b)); z-index:20;
  display:flex; align-items:center; justify-content:center; gap:10px; pointer-events:none;
}
.stage-toolbar>*{pointer-events:auto}
.btn-add{box-shadow:0 6px 18px rgba(0,120,208,.36)}
.zoomers{display:flex; gap:0; background:var(--panel); border:1px solid var(--line);
  border-radius:var(--radius); box-shadow:var(--shadow); overflow:hidden}
.zoomers .btn{border:0; border-radius:0; box-shadow:none}
.zoomers .btn+.btn{border-left:1px solid var(--line-2)}
.btn-fit{font-size:13px; font-weight:600}

.hint-bar{
  position:absolute; left:50%; transform:translateX(-50%); top:14px; z-index:25;
  display:flex; align-items:center; gap:12px; padding:9px 10px 9px 15px;
  background:var(--bar); color:#fff; border-radius:999px; font-size:13.5px;
  box-shadow:0 8px 22px rgba(15,23,42,.3); max-width:calc(100% - 28px);
}
.hint-bar button{
  background:#334155; border:0; color:#fff; border-radius:999px;
  padding:5px 12px; cursor:pointer; font-size:12.5px;
}
body.placing .stage{cursor:crosshair}

/* ---------------- side panel ---------------- */
.side{
  grid-area:side; display:flex; flex-direction:column; min-height:0;
  background:var(--panel); border-left:1px solid var(--line);
}
.side-head{display:flex; align-items:center; justify-content:space-between;
  padding:9px 10px; border-bottom:1px solid var(--line-2)}
.side-tabs{display:flex; gap:5px}
.side-tab{
  border:0; background:none; padding:7px 12px; border-radius:8px; cursor:pointer;
  font-size:13.5px; font-weight:600; color:var(--ink-2);
}
.side-tab.is-active{background:var(--brand-soft); color:var(--brand)}
.pill{background:var(--ink-3); color:#fff; border-radius:9px; padding:0 6px; font-size:11px; margin-left:3px}
.side-tab.is-active .pill{background:var(--brand)}
.pane{flex:1; min-height:0; overflow-y:auto; padding:14px}
.empty-note{color:var(--ink-2); font-size:14px; background:#f8fafc;
  border:1px dashed var(--line); border-radius:10px; padding:16px}
.empty-note p:last-child{margin:0}

.cam-form-head{display:flex; align-items:center; gap:10px; margin-bottom:14px}
.cam-badge{
  display:grid; place-items:center; min-width:38px; height:38px; padding:0 8px;
  border-radius:10px; background:var(--ink); color:#fff; font-weight:700; font-size:14px;
}
.swatches{display:flex; gap:6px; flex:1; flex-wrap:wrap}
.sw{width:22px; height:22px; border-radius:50%; border:2px solid #fff;
  box-shadow:0 0 0 1px var(--line); cursor:pointer; padding:0}
.sw.is-active{box-shadow:0 0 0 2px var(--ink)}

.fld{display:block; margin-bottom:12px}
.fld>span{display:block; font-size:12.5px; font-weight:600; color:var(--ink-2); margin-bottom:5px}
.fld input[type=text], .fld input[type=number], .fld input[type=date], .fld textarea{
  width:100%; padding:9px 11px; border:1px solid var(--line); border-radius:9px;
  background:#fcfdff; font-size:15px; /* 15px+ stops iOS zoom-on-focus */
}
.fld textarea{resize:vertical; min-height:64px; line-height:1.45}
.fld input:focus, .fld textarea:focus{
  outline:0; border-color:var(--brand); background:#fff; box-shadow:0 0 0 3px var(--brand-soft);
}
.fld-row{display:grid; grid-template-columns:1fr 1fr; gap:10px}

.fld-group{border:1px solid var(--line); border-radius:11px; padding:13px; background:#fbfcfe; margin-top:4px}
.fld-group-title{font-size:12.5px; font-weight:700; color:var(--ink-2);
  text-transform:uppercase; letter-spacing:.5px; margin-bottom:11px}
.slider{display:block; margin-bottom:12px}
.slider>span{display:flex; justify-content:space-between; font-size:12.5px;
  font-weight:600; color:var(--ink-2); margin-bottom:4px}
.slider em{font-style:normal; color:var(--ink); font-variant-numeric:tabular-nums}
.slider input[type=range]{width:100%; accent-color:var(--brand); height:26px}
.tip{margin:2px 0 0; font-size:12px; color:var(--ink-3); line-height:1.45}

.list-scope{display:flex; gap:6px; margin-bottom:12px}
.chip{border:1px solid var(--line); background:var(--panel); border-radius:999px;
  padding:5px 12px; font-size:12.5px; font-weight:600; cursor:pointer; color:var(--ink-2)}
.chip.is-active{background:var(--brand-soft); border-color:#b3ddf6; color:var(--brand)}
.cam-list{display:flex; flex-direction:column; gap:8px}
.cam-row{
  display:flex; gap:10px; align-items:flex-start; text-align:left; width:100%;
  border:1px solid var(--line); background:var(--panel); border-radius:10px;
  padding:10px 11px; cursor:pointer;
}
.cam-row:hover{border-color:#c1cddf; background:#fafcff}
.cam-row.is-active{border-color:var(--brand); box-shadow:0 0 0 2px var(--brand-soft)}
.cam-row .tag{
  flex:0 0 auto; min-width:30px; height:24px; padding:0 6px; border-radius:7px;
  display:grid; place-items:center; color:#fff; font-size:12px; font-weight:700;
}
.cam-row .meta{min-width:0; flex:1}
.cam-row .m1{font-size:13.5px; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.cam-row .m2{font-size:12px; color:var(--ink-2); overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.cam-row .m3{font-size:11.5px; color:var(--ink-3)}
.list-floor{font-size:11.5px; font-weight:700; color:var(--ink-3);
  text-transform:uppercase; letter-spacing:.6px; margin:10px 0 2px}
.list-floor:first-child{margin-top:0}

/* ---------------- ads ---------------- */
.ad-slot:empty{display:none}
.ad-slot{margin:12px; border-radius:10px; overflow:hidden; text-align:center}
.ad-slot-wide{margin:0 auto 14px; max-width:970px}

/* ---------------- dialogs ---------------- */
.dlg{border:0; border-radius:16px; padding:0; max-width:min(520px,calc(100vw - 28px));
  width:100%; box-shadow:0 24px 60px rgba(15,23,42,.3); color:var(--ink)}
.dlg::backdrop{background:rgba(15,23,42,.5)}
.dlg-body{padding:22px}
.dlg h2{font-size:19px}
.dlg-sub{color:var(--ink-2); font-size:13.5px}
.dlg-actions{display:flex; justify-content:flex-end; gap:9px; margin:18px 0 0; padding:0}
.help-list{margin:0 0 14px; padding-left:20px; color:var(--ink-2); font-size:14px}
.help-list li{margin-bottom:9px}
.help-list b{color:var(--ink)}
code{background:var(--line-2); padding:1px 5px; border-radius:5px; font-size:12.5px}

 /* ---------------- plan preview ---------------- */
.plan-view{
  position:fixed; inset:0; z-index:150; display:flex; flex-direction:column;
  background:var(--bg);
}
.pv-bar{
  flex:0 0 auto; display:flex; align-items:center; justify-content:space-between;
  gap:12px; padding:9px 12px; background:var(--bar); color:var(--bar-ink);
  padding-bottom:9px;
}
.pv-title{font-weight:650; font-size:14.5px; white-space:nowrap}
.pv-actions{display:flex; align-items:center; gap:8px; flex-wrap:wrap; justify-content:flex-end}
.pv-bar .btn{background:#1e293b; border-color:#334155; color:var(--bar-ink); min-height:34px}
.pv-bar .btn:hover{background:#293548; border-color:#41506a}
#pvPrint{background:var(--brand); border-color:var(--brand); color:#fff}
#pvPrint:hover{background:#0069b8; border-color:#0069b8}
#planFrame{flex:1; width:100%; border:0; background:#fff; min-height:0}
body.plan-open{overflow:hidden}

/* ---------------- toast / busy ---------------- */
.toast{
  position:fixed; left:50%; transform:translateX(-50%);
  bottom:calc(84px + var(--safe-b)); z-index:200;
  background:var(--bar); color:#fff; padding:11px 18px; border-radius:999px;
  font-size:13.5px; box-shadow:0 10px 26px rgba(15,23,42,.32); max-width:90vw; text-align:center;
}
.busy{
  position:fixed; inset:0; z-index:300; display:grid; place-items:center; gap:14px;
  align-content:center; background:rgba(238,241,246,.86); color:var(--ink-2); font-size:14px;
}
.spinner{width:34px; height:34px; border:3px solid var(--line); border-top-color:var(--brand);
  border-radius:50%; animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

.footer{padding:26px 16px calc(26px + var(--safe-b)); text-align:center;
  color:var(--ink-3); font-size:12.5px}
.workspace:not([hidden])~.footer{display:none}

/* ---------------- overlay (SVG) ---------------- */
.overlay .cone{cursor:move}
.overlay .cam-hit{cursor:move; fill:transparent}
.overlay .handle{cursor:crosshair}
.overlay text{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;
  font-weight:700; user-select:none; -webkit-user-select:none}

/* ---------------- responsive ---------------- */
.only-mobile{display:none}

@media (max-width:900px){
  :root{--side-w:300px}
}

@media (max-width:760px){
  .pv-title{display:none}
  .pv-bar{padding:8px 10px}
  .pv-actions{gap:6px; width:100%}
  .pv-bar .btn{flex:1; padding:0 8px; font-size:13px}
  #pvClose{flex:0 0 auto}

  .only-mobile{display:inline-flex}
  .topbar .lbl{display:none}
  .topbar .btn{min-width:38px; padding:0 10px}
  .brand-text{font-size:13.5px}
  .dz-hero{padding:28px 16px 44px}
  .dropzone h1{font-size:22px}
  .seo{padding:36px 16px 44px}
  .seo article{font-size:15px}
  .seo h2{font-size:19px}
  .dz-sub{font-size:14.5px}

  .workspace{
    grid-template-columns:1fr;
    grid-template-rows:var(--strip-h) 1fr;
    grid-template-areas:"strip" "stage";
  }
  .side{
    position:fixed; left:0; right:0; bottom:0; z-index:80;
    height:min(76vh,560px); border-left:0; border-top:1px solid var(--line);
    border-radius:18px 18px 0 0; box-shadow:0 -8px 34px rgba(15,23,42,.22);
    transform:translateY(102%); transition:transform .22s ease; padding-bottom:var(--safe-b);
  }
  body.side-open .side{transform:translateY(0)}
  .side-head{padding:11px 12px}
  .pane{padding:12px 14px 22px}
  .stage{padding:12px 12px 72px}
  .btn-add .lbl{display:inline}
  .stage-toolbar{bottom:calc(12px + var(--safe-b))}
  .toast{bottom:calc(76px + var(--safe-b))}
  .fld-row{grid-template-columns:1fr}
  /* bigger touch targets on the plan */
  .overlay .cam-hit{r:26}
}

@media (max-width:400px){
  .btn-add .lbl{display:none}
  .brand-logo img{height:17px}
  .brand-text{font-size:12.5px}
  .brand{gap:7px}
}
@media (max-width:340px){
  .brand-text{display:none}
}

@media (prefers-reduced-motion:reduce){
  *{transition:none !important; animation-duration:.01ms !important}
}

/* markers must not scroll the page while being dragged */
.overlay .cone, .overlay .cam-hit, .overlay .handle{touch-action:none}
.overlay g.cam{ -webkit-tap-highlight-color:transparent }
.btn-add.is-on{background:#0f172a; border-color:#0f172a}
.btn-add.is-on::after{content:'· tap the plan'; font-weight:500; opacity:.75; font-size:12.5px}
@media (max-width:400px){.btn-add.is-on::after{content:none}}

/* privacy / static content pages */
.lastmod{font-size:13px; color:var(--ink-3)}
.footer a{color:var(--brand)}

/* link bar shown by the Android build after a plan is uploaded */
.pv-linkbar{
  flex:0 0 auto; display:flex; align-items:center; gap:8px;
  padding:9px 12px; background:var(--brand-soft); border-bottom:1px solid var(--line);
}
.pv-url{
  flex:1; min-width:0; font-size:13px; font-weight:600; color:var(--brand);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-decoration:none;
}
.pv-linkbar .btn{min-height:34px; padding:0 12px; font-size:13px}
