/* ==========================================================================
   Tehnika CD - design system
   Mobile first. The phone is the primary device: reports are filed on site.
   ========================================================================== */

:root {
  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --line:      #dde5ee;
  --line-2:    #c9d5e3;
  --ink:       #0f172a;
  --ink-2:     #475569;
  --ink-3:     #78889c;
  --accent:    #1d4ed8;
  --accent-ink:#ffffff;
  --accent-sf: #e8efff;

  --high:  #dc2626;
  --mid:   #d97706;
  --low:   #16a34a;
  --info:  #2563eb;
  --watch: #7c3aed;
  --done:  #64748b;

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 18px;
  --shadow:    0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,.08), 0 2px 4px rgba(15,23,42,.04);
  --shadow-lg: 0 18px 40px rgba(15,23,42,.16);

  --nav-w: 250px;
  --top-h: 56px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0b1220;
    --surface:   #131c2c;
    --surface-2: #182335;
    --surface-3: #1f2c42;
    --line:      #263349;
    --line-2:    #33425c;
    --ink:       #e8eef8;
    --ink-2:     #a7b6cb;
    --ink-3:     #7b8ca4;
    --accent:    #6c9bff;
    --accent-ink:#0b1220;
    --accent-sf: #1b2a48;
    --high:  #f87171;
    --mid:   #fbbf24;
    --low:   #4ade80;
    --info:  #7aa5ff;
    --watch: #a78bfa;
    --done:  #94a3b8;
    --shadow-lg: 0 18px 40px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --bg:#0b1220; --surface:#131c2c; --surface-2:#182335; --surface-3:#1f2c42;
  --line:#263349; --line-2:#33425c; --ink:#e8eef8; --ink-2:#a7b6cb; --ink-3:#7b8ca4;
  --accent:#6c9bff; --accent-ink:#0b1220; --accent-sf:#1b2a48;
  --high:#f87171; --mid:#fbbf24; --low:#4ade80; --info:#7aa5ff; --watch:#a78bfa; --done:#94a3b8;
  --shadow-lg:0 18px 40px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.011em; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.08rem; }
h3 { font-size: .95rem; }
p  { margin: 0 0 .7em; }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
img { max-width: 100%; }
[hidden] { display: none !important; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--surface); padding: 10px 16px; border-radius: 0 0 var(--r) 0;
}
.skip:focus { left: 0; }

/* ------------------------------------------------------------------ topbar */
.topbar {
  position: sticky; top: 0; z-index: 60;
  height: var(--top-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  padding-top: env(safe-area-inset-top);
  height: calc(var(--top-h) + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar__burger {
  width: 40px; height: 40px; border: 0; background: none; cursor: pointer;
  display: grid; place-content: center; gap: 4px; border-radius: var(--r-sm);
  flex-shrink: 0;
}
.topbar__burger span { display: block; width: 19px; height: 2px; background: var(--ink-2); border-radius: 2px; transition: .18s; }
.topbar__burger:hover { background: var(--surface-3); }
.topbar__brand { display: flex; align-items: center; gap: 10px; color: var(--ink); min-width: 0; }
.topbar__brand:hover { text-decoration: none; }
.topbar__mark {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: var(--ink); color: var(--surface);
  display: grid; place-content: center;
  font-size: 11.5px; font-weight: 750; letter-spacing: .02em;
}
.topbar__name { font-weight: 650; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__name span { color: var(--ink-3); font-weight: 500; }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.topbar__quick {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: var(--accent-ink);
  padding: 8px 13px; border-radius: 999px;
  font-size: .84rem; font-weight: 600; line-height: 1; white-space: nowrap;
  flex-shrink: 0;
}
.topbar__quick:hover { text-decoration: none; filter: brightness(1.06); }
.topbar__quick svg { width: 16px; height: 16px; stroke-width: 2.4; }

/* On a phone the header has no room for the label; keep just the + target. */
@media (max-width: 560px) {
  .topbar__quick { width: 38px; height: 38px; padding: 0; gap: 0; }
  .topbar__quick span { display: none; }
  .topbar__quick svg { width: 19px; height: 19px; }
}

.usermenu { position: relative; }
.usermenu > summary { list-style: none; cursor: pointer; display: grid; place-content: center; }
.usermenu > summary::-webkit-details-marker { display: none; }
.usermenu__avatar {
  width: 33px; height: 33px; border-radius: 50%;
  background: var(--surface-3); color: var(--ink);
  display: grid; place-content: center; font-weight: 650; font-size: .85rem;
  border: 1px solid var(--line);
}
.usermenu__panel {
  position: absolute; right: 0; top: calc(100% + 8px); width: 250px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 8px; z-index: 70;
}
.usermenu__who { padding: 8px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; display: grid; gap: 2px; }
.usermenu__who span { font-size: .8rem; color: var(--ink-3); word-break: break-all; }
.usermenu__panel > a { display: block; padding: 9px 10px; border-radius: var(--r-sm); color: var(--ink); font-size: .88rem; }
.usermenu__panel > a:hover { background: var(--surface-3); text-decoration: none; }
.usermenu__panel form { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }

/* ----------------------------------------------------------------- sidenav */
.sidenav {
  position: fixed; z-index: 80;
  top: calc(var(--top-h) + env(safe-area-inset-top));
  bottom: 0; left: 0; width: var(--nav-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform .22s cubic-bezier(.4,0,.2,1);
  overscroll-behavior: contain;
}
.sidenav.is-open { transform: none; }
.sidenav__inner { padding: 14px 10px 28px; display: grid; gap: 18px; }
.sidenav__grouplabel {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-3); padding: 0 10px 6px;
}
.sidenav__foot { border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 2px; }

.navitem {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 11px; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: .9rem; font-weight: 500;
  min-height: 42px;
}
.navitem:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.navitem.is-active { background: var(--accent-sf); color: var(--accent); font-weight: 620; }
.navitem__icon { width: 18px; height: 18px; flex-shrink: 0; }
.navitem__label { flex: 1; min-width: 0; }
.navitem__badge {
  background: var(--high); color: #fff; font-size: .7rem; font-weight: 700;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  display: grid; place-content: center;
}
.navitem--sm { font-size: .82rem; min-height: 36px; padding: 7px 11px; color: var(--ink-3); }

.scrim {
  position: fixed; inset: 0; z-index: 75;
  background: rgba(15,23,42,.42); backdrop-filter: blur(2px);
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }

/* -------------------------------------------------------------------- main */
.main {
  padding: 16px 14px 64px;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  max-width: 1180px;
  margin: 0 auto;
}
.main--wide { max-width: none; }
.main--bare { display: grid; place-items: center; min-height: calc(100vh - var(--top-h)); }

@media (min-width: 1024px) {
  .topbar__burger { display: none; }
  .sidenav { transform: none; }
  .scrim { display: none !important; }
  .main { margin-left: var(--nav-w); max-width: calc(1180px + var(--nav-w)); padding: 24px 28px 64px; }
  .main--wide { max-width: none; }
  .main--bare { margin-left: 0; }
}

/* ------------------------------------------------------------------- cards */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.card__head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.card__head h2 { flex: 1; min-width: 0; }
.card__body { padding: 16px; }
.card__body--flush { padding: 0; }

.pagehead { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.pagehead__text { flex: 1; min-width: 220px; }
.pagehead__sub { color: var(--ink-3); font-size: .88rem; margin: 3px 0 0; }
.pagehead__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ blocks */
.grid { display: grid; gap: 14px; }
.grid--2 { grid-template-columns: 1fr; }
.grid--3 { grid-template-columns: 1fr; }
@media (min-width: 700px)  { .grid--2 { grid-template-columns: 1fr 1fr; } .grid--3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .grid--sidebar { grid-template-columns: minmax(0,1fr) 360px; } }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 620px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 13px 14px; box-shadow: var(--shadow);
}
.stat__num { font-size: 1.6rem; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.stat__lbl { font-size: .76rem; color: var(--ink-3); margin-top: 3px; font-weight: 500; }
.stat--high .stat__num { color: var(--high); }
.stat--mid  .stat__num { color: var(--mid); }
.stat--low  .stat__num { color: var(--low); }

/* ------------------------------------------------------------------ badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .73rem; font-weight: 650; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-3); color: var(--ink-2); white-space: nowrap;
  border: 1px solid transparent;
}
.badge--dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--visoka  { background: color-mix(in srgb, var(--high) 14%, transparent);  color: var(--high); }
.badge--srednja { background: color-mix(in srgb, var(--mid) 16%, transparent);   color: var(--mid); }
.badge--nizka   { background: color-mix(in srgb, var(--low) 15%, transparent);   color: var(--low); }
.badge--odprto     { background: color-mix(in srgb, var(--high) 13%, transparent); color: var(--high); }
.badge--v_izvedbi  { background: color-mix(in srgb, var(--info) 15%, transparent); color: var(--info); }
.badge--opazovanje { background: color-mix(in srgb, var(--watch) 15%, transparent);color: var(--watch); }
.badge--zakljuceno { background: var(--surface-3); color: var(--done); }
.badge--role { background: var(--accent-sf); color: var(--accent); align-self: start; margin-top: 4px; }
.badge--code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .72rem; letter-spacing: -.02em; }

/* ----------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px; padding: 9px 16px;
  border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
  transition: background .14s, border-color .14s, filter .14s;
  text-align: center;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { filter: brightness(1.07); background: var(--accent); }
.btn--danger { color: var(--high); border-color: color-mix(in srgb, var(--high) 40%, var(--line-2)); }
.btn--danger:hover { background: color-mix(in srgb, var(--high) 10%, transparent); }
.btn--ghost { border-color: transparent; background: none; }
.btn--ghost:hover { background: var(--surface-3); }
.btn--sm { min-height: 34px; padding: 6px 11px; font-size: .82rem; }
.btn--block { width: 100%; }
.btn svg { width: 17px; height: 17px; }

.btnrow { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------------- forms */
.field { margin-bottom: 14px; }
.field > label, .field__label {
  display: block; font-size: .8rem; font-weight: 600; color: var(--ink-2); margin-bottom: 5px;
}
.field__hint { font-size: .76rem; color: var(--ink-3); margin-top: 4px; }
.field__err  { font-size: .78rem; color: var(--high); margin-top: 4px; font-weight: 500; }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=search], input[type=tel], input[type=url],
textarea, select {
  width: 100%; padding: 10px 12px;
  font: inherit; font-size: 16px;      /* 16px stops iOS zooming the page on focus */
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--r-sm);
  min-height: 44px;
  appearance: none;
}
@media (min-width: 700px) {
  input[type=text], input[type=email], input[type=password], input[type=date],
  input[type=number], input[type=search], input[type=tel], input[type=url],
  textarea, select { font-size: .92rem; }
}
textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2378889c' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 17px;
  padding-right: 34px;
}
input:focus-visible, textarea:focus-visible, select:focus-visible, .btn:focus-visible, a:focus-visible,
.segbtn:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input[aria-invalid=true], textarea[aria-invalid=true] { border-color: var(--high); }
.field--inline { display: flex; align-items: center; gap: 9px; }
.field--inline input[type=checkbox] { width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--accent); }
.field--inline label { margin: 0; font-size: .9rem; font-weight: 500; color: var(--ink); }

.formgrid { display: grid; gap: 0 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .formgrid--2 { grid-template-columns: 1fr 1fr; } }

.fieldset {
  border: 1px solid var(--line); border-radius: var(--r); padding: 14px;
  margin: 0 0 16px; background: var(--surface-2);
}
.fieldset > legend {
  font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); padding: 0 6px;
}

/* segmented control - severity / status pickers, thumb friendly */
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg--fill .segbtn { flex: 1 1 0; min-width: 90px; }
.segbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 12px;
  border: 1.5px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink-2);
  font: inherit; font-size: .87rem; font-weight: 600; cursor: pointer;
}
.segbtn:hover { background: var(--surface-3); }
.segbtn__dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.segbtn.is-on { color: var(--accent); border-color: var(--accent); background: var(--accent-sf); }
.segbtn.is-on[data-tone=visoka]  { color: var(--high);  border-color: var(--high);  background: color-mix(in srgb, var(--high) 12%, transparent); }
.segbtn.is-on[data-tone=srednja] { color: var(--mid);   border-color: var(--mid);   background: color-mix(in srgb, var(--mid) 14%, transparent); }
.segbtn.is-on[data-tone=nizka]   { color: var(--low);   border-color: var(--low);   background: color-mix(in srgb, var(--low) 13%, transparent); }

/* checkbox pills - conditions */
.pills { display: flex; gap: 7px; flex-wrap: wrap; }
.pill { position: relative; }
.pill input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.pill span {
  display: inline-flex; align-items: center; min-height: 38px; padding: 7px 13px;
  border: 1.5px solid var(--line-2); border-radius: 999px;
  font-size: .85rem; font-weight: 550; color: var(--ink-2); background: var(--surface);
}
.pill input:checked + span { border-color: var(--accent); background: var(--accent-sf); color: var(--accent); }
.pill input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* filter chips */
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 6px 13px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink-2); font: inherit; font-size: .84rem; font-weight: 550; cursor: pointer;
}
.chip:hover { background: var(--surface-3); text-decoration: none; }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chip__n { font-size: .75rem; opacity: .7; font-weight: 700; }

/* ----------------------------------------------------------------- flashes */
.flashes { display: grid; gap: 8px; margin-bottom: 16px; }
.flash {
  padding: 11px 14px; border-radius: var(--r); font-size: .89rem; font-weight: 500;
  border: 1px solid; display: flex; gap: 8px;
}
.flash--ok   { background: color-mix(in srgb, var(--low) 12%, var(--surface));  border-color: color-mix(in srgb, var(--low) 35%, transparent); color: color-mix(in srgb, var(--low) 75%, var(--ink)); }
.flash--err  { background: color-mix(in srgb, var(--high) 11%, var(--surface)); border-color: color-mix(in srgb, var(--high) 35%, transparent); color: color-mix(in srgb, var(--high) 78%, var(--ink)); }
.flash--info { background: var(--accent-sf); border-color: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--accent); }

/* ------------------------------------------------------------------ tables */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 560px; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; white-space: nowrap; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.empty { text-align: center; padding: 42px 20px; color: var(--ink-3); }
.empty h3 { color: var(--ink-2); margin-bottom: 6px; }
.empty p { font-size: .88rem; max-width: 30rem; margin: 0 auto .9em; }

.meta { font-size: .8rem; color: var(--ink-3); }
.dl { display: grid; gap: 10px 16px; grid-template-columns: 1fr; margin: 0; }
@media (min-width: 560px) { .dl--2 { grid-template-columns: 1fr 1fr; } }
.dl > div { min-width: 0; }
.dl dt { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; }
.dl dd { margin: 2px 0 0; font-size: .92rem; word-wrap: break-word; }

/* ================================================================= PLAN MAP
   The floor plan viewer: pinch/scroll zoom, drag pan, tap to place a pin.
   ========================================================================= */
.planbar {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding: 8px 10px; background: var(--surface);
  border-bottom: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}
.planbar::-webkit-scrollbar { display: none; }
.planbar__group { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.planbar__group + .planbar__group { border-left: 1px solid var(--line); padding-left: 6px; margin-left: 2px; }
.plantab {
  position: relative; flex-shrink: 0; scroll-snap-align: center;
  min-height: 38px; padding: 7px 12px;
  border: 1px solid var(--line-2); border-radius: 999px;
  background: var(--surface); color: var(--ink-2);
  font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.plantab:hover { background: var(--surface-3); }
.plantab.is-on { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.plantab__n {
  display: inline-grid; place-content: center; margin-left: 6px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--high); color: #fff; font-size: .68rem; font-weight: 700;
}
.plantab.is-on .plantab__n { background: var(--surface); color: var(--ink); }

.planview {
  position: relative;
  background: var(--surface-2);
  overflow: hidden;
  touch-action: none;              /* we handle pan and pinch ourselves */
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  height: 62vh;
  min-height: 320px;
}
.planview.is-picking { cursor: crosshair; }
.planview.is-dragging { cursor: grabbing; }
@media (min-width: 1024px) { .planview { height: 68vh; } }
.planview:fullscreen { height: 100vh; }

.planview__stage {
  position: absolute; top: 0; left: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.planview__img {
  display: block; width: 100%; height: 100%;
  image-rendering: -webkit-optimize-contrast;
  pointer-events: none; -webkit-user-drag: none;
}
/* The full-detail sheet fades in over the preview once decoded. */
.planview__img--hi { position: absolute; inset: 0; opacity: 0; transition: opacity .18s linear; }
.planview__img--hi.is-ready { opacity: 1; }

.planview__pins { position: absolute; inset: 0; pointer-events: none; }

.pin {
  position: absolute; width: 0; height: 0;
  pointer-events: auto; cursor: pointer;
}
.pin__shape {
  position: absolute; left: 50%; top: 50%;
  width: 26px; height: 26px; margin: -13px 0 0 -13px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.4), 0 0 0 1px rgba(0,0,0,.15);
  display: grid; place-content: center;
  font-size: 10.5px; font-weight: 800; color: #fff;
  transition: transform .12s;
}
.pin:hover .pin__shape, .pin.is-sel .pin__shape { transform: scale(1.22); z-index: 2; }
.pin.is-sel .pin__shape { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 45%, transparent), 0 1px 4px rgba(0,0,0,.4); }
.pin--visoka  .pin__shape { background: var(--high); }
.pin--srednja .pin__shape { background: var(--mid); }
.pin--nizka   .pin__shape { background: var(--low); }
.pin.is-done .pin__shape { background: var(--done); opacity: .75; }
.pin--draft .pin__shape {
  background: var(--accent);
  animation: pinpulse 1.5s ease-out infinite;
}
@keyframes pinpulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent), 0 1px 4px rgba(0,0,0,.4); }
  70%  { box-shadow: 0 0 0 14px transparent, 0 1px 4px rgba(0,0,0,.4); }
  100% { box-shadow: 0 0 0 0 transparent, 0 1px 4px rgba(0,0,0,.4); }
}
.pin__tip {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--ink); color: var(--surface);
  font-size: 11px; font-weight: 600; line-height: 1.35;
  padding: 5px 9px; border-radius: 7px; white-space: nowrap;
  opacity: 0; transition: opacity .14s; pointer-events: none;
  box-shadow: var(--shadow-md); max-width: 60vw; overflow: hidden; text-overflow: ellipsis;
}
.pin:hover .pin__tip, .pin.is-sel .pin__tip { opacity: 1; }

/* floating controls over the map */
.planctl {
  position: absolute; z-index: 5; display: flex; gap: 6px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 5px; box-shadow: var(--shadow-md);
  backdrop-filter: blur(8px);
}
.planctl--zoom { right: 10px; bottom: 10px; }
.planctl--tools { left: 10px; bottom: 10px; }
.planctl button {
  width: 38px; height: 38px; border: 0; border-radius: 50%;
  background: none; color: var(--ink-2); cursor: pointer;
  display: grid; place-content: center; font: inherit; font-weight: 700;
}
.planctl button:hover { background: var(--surface-3); color: var(--ink); }
.planctl button.is-on { background: var(--accent); color: var(--accent-ink); }
.planctl svg { width: 19px; height: 19px; }

.planhint {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
  z-index: 5; max-width: calc(100% - 24px);
  background: var(--ink); color: var(--surface);
  font-size: .8rem; font-weight: 600; padding: 8px 14px; border-radius: 999px;
  box-shadow: var(--shadow-md); text-align: center;
  animation: dropin .2s ease;
}
.planhint--ok { background: var(--low); color: #fff; }
@keyframes dropin { from { opacity: 0; transform: translate(-50%, -8px); } }

.planzoomlabel {
  position: absolute; right: 10px; top: 10px; z-index: 5;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 10px; font-size: .74rem; font-weight: 700; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------ photo upload */
/* Wrapper around the drop area + the dedicated camera button. */
.photopick { display: grid; gap: 10px; }
.photopick__cam { justify-content: center; }

.dropzone {
  position: relative;
  border: 1.5px dashed var(--line-2); border-radius: var(--r);
  background: var(--surface-2); padding: 18px 16px; text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone.is-over { border-color: var(--accent); background: var(--accent-sf); }
.dropzone input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone__icon { width: 30px; height: 30px; color: var(--ink-3); margin: 0 auto 6px; display: block; }
.dropzone__main { font-size: .92rem; font-weight: 620; }
.dropzone__sub { font-size: .78rem; color: var(--ink-3); margin-top: 3px; }

.photogrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; margin-top: 12px; }
@media (min-width: 700px) { .photogrid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); } }
.photo {
  position: relative; aspect-ratio: 1; border-radius: var(--r-sm);
  overflow: hidden; border: 1px solid var(--line); background: var(--surface-3);
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo__rm {
  position: absolute; top: 4px; right: 4px;
  width: 26px; height: 26px; border: 0; border-radius: 50%;
  background: rgba(15,23,42,.72); color: #fff; cursor: pointer;
  display: grid; place-content: center; font-size: 15px; line-height: 1; padding: 0;
}
.photo__rm:hover { background: var(--high); }
.photo__busy {
  position: absolute; inset: 0; background: rgba(15,23,42,.45);
  display: grid; place-content: center; color: #fff; font-size: .72rem; font-weight: 700;
}
.photo--add {
  display: grid; place-content: center; border-style: dashed; cursor: pointer;
  color: var(--ink-3); background: var(--surface-2);
}

/* lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(8,12,22,.94);
  display: grid; grid-template-rows: auto 1fr auto; gap: 8px;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.lightbox__bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: #e8eef8; }
.lightbox__bar button { background: none; border: 0; color: #e8eef8; cursor: pointer; padding: 8px; border-radius: 50%; display: grid; place-content: center; }
.lightbox__bar button:hover { background: rgba(255,255,255,.14); }
.lightbox__bar span { font-size: .85rem; }
.lightbox__stage { display: grid; place-items: center; overflow: auto; padding: 0 12px; }
.lightbox__stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--r-sm); }
.lightbox__cap { padding: 10px 16px 16px; color: #a7b6cb; font-size: .85rem; text-align: center; }

/* ------------------------------------------------------------- leak list */
.leaklist { display: grid; }
.leakrow {
  display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 12px;
  align-items: start; padding: 13px 16px;
  border-bottom: 1px solid var(--line); color: var(--ink);
}
.leakrow:last-child { border-bottom: 0; }
.leakrow:hover { background: var(--surface-2); text-decoration: none; }
.leakrow.is-sel { background: var(--accent-sf); }
.leakrow__thumb {
  width: 54px; height: 54px; border-radius: var(--r-sm); object-fit: cover;
  border: 1px solid var(--line); background: var(--surface-3); flex-shrink: 0;
}
.leakrow__ph {
  width: 54px; height: 54px; border-radius: var(--r-sm); flex-shrink: 0;
  background: var(--surface-3); display: grid; place-content: center; color: var(--ink-3);
  border: 1px solid var(--line);
}
.leakrow__ph svg { width: 20px; height: 20px; }
.leakrow__title { font-weight: 640; font-size: .95rem; }
.leakrow__meta { font-size: .79rem; color: var(--ink-3); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.leakrow__desc {
  font-size: .84rem; color: var(--ink-2); margin-top: 5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.leakrow__tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 7px; }
.leakrow__right { display: grid; gap: 5px; justify-items: end; }
.leakrow__sev { width: 10px; height: 10px; border-radius: 50%; }

.sevbar { width: 4px; border-radius: 4px; align-self: stretch; min-height: 54px; }
.sevbar--visoka  { background: var(--high); }
.sevbar--srednja { background: var(--mid); }
.sevbar--nizka   { background: var(--low); }

/* timeline of observations */
.timeline { display: grid; gap: 0; position: relative; }
.tlitem { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding-bottom: 14px; position: relative; }
.tlitem:not(:last-child)::before {
  content: ""; position: absolute; left: 10px; top: 18px; bottom: 0; width: 2px; background: var(--line);
}
.tlitem__dot {
  width: 11px; height: 11px; border-radius: 50%; margin: 5px auto 0;
  background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 0 2px var(--line);
  position: relative; z-index: 1;
}
.tlitem__when { font-size: .78rem; font-weight: 700; color: var(--ink-2); }
.tlitem__body { font-size: .87rem; color: var(--ink-2); }

/* login */
.authcard { width: 100%; max-width: 400px; }
.authcard .card__body { padding: 26px 22px; }
.authbrand { text-align: center; margin-bottom: 20px; }
.authbrand__mark {
  width: 46px; height: 46px; border-radius: 13px; margin: 0 auto 12px;
  background: var(--ink); color: var(--surface);
  display: grid; place-content: center; font-weight: 750; font-size: 15px;
}
.authbrand h1 { font-size: 1.15rem; }
.authbrand p { color: var(--ink-3); font-size: .87rem; margin: 4px 0 0; }

/* code / install blocks */
pre.code {
  background: var(--surface-3); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 13px 14px; overflow-x: auto;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .78rem; line-height: 1.55; margin: 0 0 12px;
  -webkit-overflow-scrolling: touch;
}
.checklist { display: grid; gap: 8px; margin: 0 0 14px; padding: 0; list-style: none; }
.checklist li { display: grid; grid-template-columns: 20px 1fr; gap: 9px; font-size: .89rem; align-items: start; }
.checklist__mark { font-weight: 800; line-height: 1.5; }
.checklist li.ok  .checklist__mark { color: var(--low); }
.checklist li.bad .checklist__mark { color: var(--high); }
.checklist li.warn .checklist__mark { color: var(--mid); }

.steps { counter-reset: s; display: grid; gap: 14px; }
.step { counter-increment: s; display: grid; grid-template-columns: 28px 1fr; gap: 12px; }
.step::before {
  content: counter(s); width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-sf); color: var(--accent);
  display: grid; place-content: center; font-size: .8rem; font-weight: 750;
}
.step h3 { margin-bottom: 4px; }
.step p { font-size: .88rem; color: var(--ink-2); }

/* sticky action bar on long forms (phone) */
.stickybar {
  position: sticky; bottom: 0; z-index: 20;
  margin: 18px -14px -64px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex; gap: 8px;
}
.stickybar .btn { flex: 1; }
@media (min-width: 1024px) {
  .stickybar { position: static; margin: 18px 0 0; padding: 0; background: none; border: 0; backdrop-filter: none; }
  .stickybar .btn { flex: 0 1 auto; min-width: 150px; }
}

.sronly {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

@media print {
  .topbar, .sidenav, .scrim, .planctl, .stickybar, .pagehead__actions { display: none !important; }
  .main { margin: 0; max-width: none; padding: 0; }
  .card { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
}
