:root {
    --bg: #0f1115;
    --fg: #e8e8e8;
    --muted: #a0a4ad;
    --card: #161a22;
    --accent: #4da3ff;
    --ok: #22c55e;
    --warn: #f59e0b;
    --br: 12px;
    --shadow: 0 8px 24px rgba(0, 0, 0, .35);
    --sheet-collapsed: 56px;
    --sheet-desktop-collapsed: 360px;
}

* {
    box-sizing: border-box
}

html,
body,
#map {
    height: 100%;
    margin: 0
}

html,
body {
    overscroll-behavior-y: contain;
}

body {
    font-family: system-ui, Segoe UI, Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--fg)
}

/* TOPBAR */

.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(180deg, #0f1115, rgba(15, 17, 21, .85));
    z-index: 500;
    backdrop-filter: blur(6px);
    border-bottom: 1px solid rgba(255, 255, 255, .06)
}

.topbar input {
    width: 100%;
    height: 40px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: #0b0e13;
    color: var(--fg);
    padding: 0 12px;
    font-size: 14px;
    outline: none
}

.count {
    min-width: 36px;
    text-align: center;
    background: #0b0e13;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 10px;
    padding: 8px 10px;
    color: var(--muted)
}

.logout {
    height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: #0b0e13;
    color: #fff;
    cursor: pointer
}

.filter-btn {
    height: 32px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: #0b0e13;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px
}

.filter-badge {
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    border-radius: 9px;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, .2);
    font-size: 11px;
    text-align: center;
    display: inline-block
}

/* MAPA */

.leaflet-container {
    background: #0b0e13
}

#map {
    position: absolute;
    inset: 0;
    top: 56px;
    touch-action: pan-x pan-y;
}

/* BACKDROP */

.backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .35);
    backdrop-filter: blur(2px);
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}

.backdrop.show {
    opacity: 1;
    pointer-events: auto
}

/* SHEET (detalji) */

.sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--card);
    color: var(--fg);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: var(--shadow);
    z-index: 1200;
    transition: transform .25s ease, height .25s ease;
    height: 0;
    transform: translateY(100%);
    display: flex;
    flex-direction: column;
}

.sheet.open {
    transform: translateY(0);
}

.sheet.expanded {
    overflow-y: auto;
}

/* u proširenom modu sakrij prvi redak (sheet-bar) */
.sheet.expanded .sheet-bar {
    display: none;
}

.sheet.collapsed {
    height: var(--sheet-collapsed);
    overflow: hidden;
}

.sheet-bar {
    position: relative;
    padding: 0;
    /* nema dodatnog vertikalnog razdvajanja */
}

/* cijeli header detalja = jedan red */

.detail-min {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid rgba(255, 255, 255, .06);
    background: #0f131a
}

/* naslov + GMaps pin */

.detail-min .t {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    /* ne raste, ne gura ikone */
}

/* skupina ikona (↕ i X) odmah iza pina */

.sheet-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* veći gumbi ↕ i X */

.sheet-mode,
.sheet-close {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    padding: 0 10px;
    border: 1px solid rgba(255, 255, 255, .16);
    background: #0b0e13;
    color: #eaeaea;
    cursor: pointer;
}

.sheet-close:hover,
.sheet-mode:hover {
    border-color: rgba(255, 255, 255, .28);
    background: #111824
}

/* TOOLBAR unutar detalja */

.detail-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 2px 8px 2px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    margin-bottom: 8px
}

.detail-toolbar h3 {
    margin: 0;
    font-size: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.detail-select {
    height: 30px;
    padding: 0 34px 0 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: #0b0e13;
    color: #fff;
    font-size: 13px;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='white'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px
}

#detail {
    padding: 8px 14px 14px;
    /* overflow: auto;  više ne treba, scrolla se cijeli sheet */
}

#detail .grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px
}

#detail .item {
    background: #0f131a;
    border: 1px solid rgba(255, 255, 255, .06);
    border-radius: 10px;
    padding: 8px
}

#detail .k {
    display: block;
    font-size: 11px;
    color: var(--muted)
}

#detail .v {
    font-size: 13px;
    word-break: break-word
}

/* BADGE */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .18);
    font-size: 12px;
    margin-right: 6px
}

.badge.ok {
    border-color: #2dd47c;
    color: #2dd47c
}

.badge.warn {
    border-color: #f59e0b;
    color: #f59e0b
}

.cardlink {
    display: inline-block;
    margin-top: 10px;
    text-decoration: none;
    color: var(--accent)
}

/* MODAL / FILTER */

.modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(0, 0, 0, .45);
    backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 14px
}

.modal.show {
    display: flex
}

.modal-card {
    width: min(92vw, 720px);
    max-height: 86vh;
    background: #121620;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 14px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .08)
}

.modal-close {
    height: 30px;
    min-width: 30px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: #0b0e13;
    color: #fff;
    cursor: pointer
}

.modal-body {
    padding: 12px 14px;
    overflow: auto
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px
}

@media(min-width:700px) {
    .form-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.form-field label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid rgba(255, 255, 255, .08)
}

.btn {
    height: 36px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .22);
    background: #1a2230;
    color: #fff;
    cursor: pointer
}

.btn.ghost {
    background: #0b0e13;
    border-color: rgba(255, 255, 255, .18)
}

.spacer {
    flex: 1
}

/* Dropdown (checkbox) */

.dd {
    position: relative
}

.dd-btn {
    width: 100%;
    height: 38px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: #0b0e13;
    color: #fff;
    padding: 0 36px 0 10px;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.dd-btn::after {
    content: "▾";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    opacity: .8
}

.dd-menu {
    position: absolute;
    z-index: 10;
    left: 0;
    right: 0;
    top: 42px;
    background: #0f131a;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 10px;
    box-shadow: var(--shadow);
    display: none;
    max-height: 260px;
    overflow: auto
}

.dd.open .dd-menu {
    display: block
}

.dd-head {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: #0f131a;
    border-bottom: 1px solid rgba(255, 255, 255, .12)
}

.dd-head .dd-title {
    font-size: 12px;
    color: #94a3b8
}

.dd-head .dd-close {
    height: 24px;
    min-width: 24px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: #0b0e13;
    color: #fff;
    cursor: pointer
}

.dd-search {
    padding: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, .12)
}

.dd-search input {
    width: 100%;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: #0b0e13;
    color: #fff;
    padding: 0 8px
}

.dd-list {
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px
}

.dd-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px
}

.dd-item input {
    width: 16px;
    height: 16px
}

/* RESPONSIVE SHEET */

@media (min-width:900px) {
    .sheet {
        left: auto;
        right: 12px;
        width: 380px;
        bottom: 12px;
        border-radius: 16px;
    }

    .sheet.expanded {
        height: 80vh;
    }

    .sheet.collapsed {
        height: var(--sheet-desktop-collapsed);
    }

    .fab {
        bottom: 20px
    }
}

/* LOGIN OVERLAY */

.auth {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: linear-gradient(180deg, #0f1115, #0b0e13);
    z-index: 1000
}

.auth-card {
    width: min(92vw, 380px);
    border-radius: 16px;
    background: #121620;
    border: 1px solid rgba(255, 255, 255, .12);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
    padding: 22px 18px
}

.auth-card h1 {
    margin: 0 0 8px;
    font-size: 20px
}

.auth-card p {
    margin: 0 0 12px;
    color: #a0a4ad
}

.auth-card input {
    width: 100%;
    height: 46px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: #0b0e13;
    color: #fff;
    padding: 0 12px;
    font-size: 18px;
    letter-spacing: 6px;
    text-align: center;
    outline: none
}

.auth-card input:focus {
    border-color: #4da3ff;
    box-shadow: 0 0 0 3px rgba(77, 163, 255, .2)
}

.auth-card button {
    margin-top: 10px;
    width: 100%;
    height: 44px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .2);
    background: #1a2230;
    color: #fff;
    cursor: pointer
}

.auth-card button:hover {
    filter: brightness(1.08)
}

.auth-msg {
    margin-top: 10px;
    min-height: 1.2em;
    font-size: 13px;
    color: #f87171
}

/* LABELI NA MAPI */

.ts-label {
    background: rgba(15, 23, 42, 0.9);
    color: #e5e7eb;
    border: 1px solid rgba(148, 163, 184, 0.5);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
}

/* GUMB ZA PONIŠTI FILTER */

.filter-clear-btn {
    margin-left: 4px;
    padding: 4px 10px;
    font-size: 0.8rem;
    border-radius: 999px;
    border: 1px solid #4b5563;
    background: #0f172a;
    color: #e5e7eb;
}

.filter-clear-btn:hover:not(:disabled) {
    background: #1f2937;
    border-color: #9ca3af;
}

.filter-clear-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

/* GMaps PIN u naslovu */

.title-map {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: #0f172a;
    border: 1px solid #4b5563;
    text-decoration: none;
}

.title-map:hover {
    background: #1f2937;
    border-color: #9ca3af;
}

.gmaps-pin {
    width: 20px;
    height: 20px;
}

.gmaps-pin-body {
    fill: #22c55e;
    /* zelena kap */
}

.gmaps-pin-dot {
    fill: #facc15;
    /* žuti krug unutra */
    stroke: #0f172a;
    stroke-width: 1;
}

.gmaps-pin-shadow {
    fill: rgba(15, 23, 42, 0.45);
    /* mala sjena ispod pina */
}

/* pozicija switchera karte – ispod topbara, skroz lijevo */
.leaflet-top.leaflet-left .leaflet-control-layers {
    margin-top: 5px;
    margin-left: 8px;
}

/* makni ružni kvadratasti okvir oko kontrole */
.leaflet-control,
.leaflet-control-layers {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
}

/* gumb (zatvoreno stanje) */
.leaflet-control-layers-toggle {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: #0f172a;
    border: 1px solid #4b5563;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    background-image: none !important;
    position: relative;
}

/* dvije “ploče” u obliku dijamanta – centrirane u krug */
.leaflet-control-layers-toggle::before,
.leaflet-control-layers-toggle::after {
    content: "";
    position: absolute;
    left: 50%;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 2px solid #e5e7eb;
    box-sizing: border-box;
    transform: translateX(-50%) rotate(45deg);
}

/* gornji dijamant (blago iznad centra) */
.leaflet-control-layers-toggle::before {
    top: 50%;
    transform: translate(-50%, -60%) rotate(45deg);
}

/* donji dijamant (blago ispod centra) */
.leaflet-control-layers-toggle::after {
    top: 50%;
    transform: translate(-50%, -20%) rotate(45deg);
    opacity: 0.9;
}

.leaflet-control-layers-toggle:hover {
    background: #1f2937;
    border-color: #9ca3af;
}

/* otvoreni panel za izbor Karta / Satelit */
.leaflet-control-layers.leaflet-control-layers-expanded {
    background: #0f131a !important;
    border-radius: 12px;
    border: 1px solid #4b5563;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    padding: 6px 8px;
}

.leaflet-control-layers-list {
    margin: 0;
    padding: 2px 0 0 0;
    color: #e5e7eb;
    font-size: 13px;
}

.leaflet-control-layers-base label,
.leaflet-control-layers-overlays label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 2px;
    cursor: pointer;
}

.leaflet-control-layers-base input,
.leaflet-control-layers-overlays input {
    accent-color: #22c55e;
}


/* MOBITEL (ispod 900px) – sheet proširen preko cijelog ekrana ispod topbara */
@media (max-width: 899px) {
    .sheet.expanded {
        top: 56px;
        /* visina topbara */
        bottom: 0;
        height: auto;
        max-height: none;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }
}

.btn-report {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 16px;
    padding: 8px 18px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.6);
    background: #1a2230;
    color: #e5e7eb;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
}

.btn-report:hover {
    background: #111827;
    border-color: #e5e7eb;
}

/* MOBITEL + COLLAPSED: veće ikone dolje */
@media (max-width: 899px) {

    .sheet.collapsed .sheet-mode,
    .sheet.collapsed .sheet-close {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .sheet.collapsed .title-map {
        width: 40px;
        height: 40px;
    }

    .sheet.collapsed .gmaps-pin {
        width: 24px;
        height: 24px;
    }
}

.leaflet-control-container {
    z-index: 500;
}

/* kad je proširen sheet, gornje ikone (uz naslov) sakrij */
.sheet.expanded .sheet-actions {
    display: none;
}

/* gumb Prijavi problem + ikone desno */
.detail-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
}

.detail-footer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* prilagodba buttona za prijavu problema u footeru */
.btn-report {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 18px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.6);
    background: #1a2230;
    color: #e5e7eb;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
    margin-top: 0;
    /* više ne treba vertikalni razmak */
}

.btn-report:hover {
    background: #111827;
    border-color: #e5e7eb;
}

/* veće ikone u proširenom modu (footer) */
.sheet.expanded .detail-footer-actions .sheet-mode,
.sheet.expanded .detail-footer-actions .sheet-close,
.sheet.expanded .detail-footer-actions .title-map {
    width: 48px;
    height: 48px;
    font-size: 22px;
}

/* veći pin unutra */
.sheet.expanded .detail-footer-actions .gmaps-pin {
    width: 28px;
    height: 28px;
}


#detail .k-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

#detail .k-row .k {
    flex: 1;
}

/* gumb za kopiranje */
.copy-btn {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.6);
    background: #0b0e13;
    color: #e5e7eb;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
}

.copy-btn:hover {
    background: #111827;
    border-color: #e5e7eb;
}

.copy-btn.copied {
    border-color: #22c55e;
    color: #22c55e;
}