:root {
    color-scheme: dark;
    --pulse-bg: #07131d;
    --pulse-panel: rgba(18, 34, 47, 0.78);
    --pulse-panel-strong: rgba(24, 43, 58, 0.9);
    --pulse-line: rgba(169, 199, 224, 0.16);
    --pulse-text: #f5f8fb;
    --pulse-muted: rgba(229, 238, 246, 0.68);
    --pulse-soft: rgba(229, 238, 246, 0.1);
    --pulse-blue: #62b4ff;
    --pulse-green: #30d158;
    --pulse-yellow: #ffd60a;
    --pulse-red: #ff453a;
    font-family: Inter, "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html,
body {
    min-height: 100%;
    margin: 0;
}

body.pulse-page {
    min-height: 100vh;
    overflow: hidden;
    background:
        radial-gradient(circle at 18% 0%, rgba(98, 180, 255, 0.22), transparent 30rem),
        radial-gradient(circle at 82% 10%, rgba(48, 209, 88, 0.12), transparent 30rem),
        linear-gradient(135deg, #06111a, #0a1a25 46%, #051018);
    color: var(--pulse-text);
}

.pulse-auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
}

.pulse-auth-card {
    width: min(28rem, 100%);
    display: grid;
    gap: 1rem;
    padding: 2rem;
    border: 1px solid var(--pulse-line);
    border-radius: 2rem;
    background: var(--pulse-panel);
    box-shadow: 0 2rem 5rem rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(24px);
}

.pulse-auth-card img {
    width: 5rem;
}

.pulse-auth-card p,
.pulse-auth-card span {
    margin: 0;
    color: var(--pulse-muted);
}

.pulse-auth-card h1 {
    margin: 0;
    font-size: clamp(2.6rem, 10vw, 4.8rem);
    letter-spacing: -0.08em;
}

.pulse-auth-card a {
    display: inline-flex;
    justify-content: center;
    padding: 0.9rem 1.2rem;
    border-radius: 999px;
    color: #04101a;
    background: #fff;
    font-weight: 900;
    text-decoration: none;
}

.pulse-auth-card form {
    display: grid;
    gap: 0.75rem;
}

.pulse-auth-card label {
    display: grid;
    gap: 0.45rem;
    color: var(--pulse-muted);
    font-size: 0.76rem;
    font-weight: 950;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.pulse-auth-card input {
    width: 100%;
    min-height: 3.25rem;
    border: 1px solid var(--pulse-line);
    border-radius: 1rem;
    padding: 0 1rem;
    color: var(--pulse-text);
    background: rgba(255, 255, 255, 0.08);
    outline: 0;
    font: inherit;
    font-weight: 850;
    letter-spacing: 0;
    text-transform: none;
}

.pulse-auth-card input:focus {
    border-color: rgba(98, 180, 255, 0.7);
    box-shadow: 0 0 0 0.25rem rgba(98, 180, 255, 0.14);
}

.pulse-auth-card button {
    min-height: 3.1rem;
    border: 0;
    border-radius: 999px;
    padding: 0.8rem 1rem;
    color: #07131d;
    background: #fff;
    font: inherit;
    font-weight: 950;
    cursor: pointer;
}

.pulse-auth-card button[type="button"] {
    color: var(--pulse-text);
    background: rgba(255, 255, 255, 0.1);
}

.pulse-auth-card .pulse-passkey-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    color: #07131d;
    background: linear-gradient(135deg, #ffffff, #dceeff);
}

.pulse-auth-alert {
    border: 1px solid rgba(255, 69, 58, 0.35);
    border-radius: 1rem;
    padding: 0.85rem 1rem;
    color: #ffd8d6;
    background: rgba(255, 69, 58, 0.12);
    font-weight: 850;
}

.pulse-shell {
    height: 100vh;
    padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 0.9rem;
}

.pulse-topbar,
.pulse-kpi,
.pulse-map-panel,
.pulse-panel,
.pulse-bottom-sheet {
    border: 1px solid var(--pulse-line);
    background: var(--pulse-panel);
    box-shadow: 0 1.4rem 4rem rgba(0, 0, 0, 0.24);
    backdrop-filter: blur(24px);
}

.pulse-topbar {
    min-height: 5.3rem;
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 1.5rem;
}

.pulse-topbar p,
.pulse-map-head p,
.pulse-panel header p {
    margin: 0 0 0.22rem;
    color: #9fdaff;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.pulse-topbar h1 {
    margin: 0;
    font-size: clamp(2rem, 5vw, 3.6rem);
    line-height: 0.9;
    letter-spacing: -0.08em;
}

.pulse-topbar span,
.pulse-live span {
    color: var(--pulse-muted);
}

.pulse-live,
.pulse-user {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 2.8rem;
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--pulse-line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
}

.pulse-live i {
    width: 0.62rem;
    height: 0.62rem;
    border-radius: 999px;
    background: var(--pulse-green);
    box-shadow: 0 0 0 0.45rem rgba(48, 209, 88, 0.12);
}

.pulse-user img {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    object-fit: cover;
}

.pulse-user button,
.pulse-user a {
    width: 2.15rem;
    height: 2.15rem;
    border: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #07131d;
    background: #fff;
    cursor: pointer;
    text-decoration: none;
}

.pulse-passkey-status {
    border: 1px solid rgba(98, 180, 255, 0.28);
    border-radius: 1rem;
    padding: 0.72rem 0.9rem;
    color: #d9efff;
    background: rgba(98, 180, 255, 0.11);
    font-size: 0.86rem;
    font-weight: 850;
    box-shadow: 0 1rem 2.2rem rgba(0, 0, 0, 0.16);
}

.pulse-passkey-status.is-error {
    border-color: rgba(255, 69, 58, 0.38);
    color: #ffd8d6;
    background: rgba(255, 69, 58, 0.12);
}

.pulse-passkey-status.is-success {
    border-color: rgba(48, 209, 88, 0.34);
    color: #d8ffe2;
    background: rgba(48, 209, 88, 0.12);
}

.pulse-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.9rem;
}

.pulse-kpi {
    min-height: 8rem;
    border-radius: 1.35rem;
    padding: 1rem;
    display: grid;
    align-content: space-between;
}

.pulse-kpi i {
    color: var(--pulse-blue);
    font-size: 1.35rem;
}

.pulse-kpi span {
    color: var(--pulse-muted);
    font-weight: 800;
}

.pulse-kpi strong {
    font-size: clamp(2.1rem, 5vw, 4rem);
    letter-spacing: -0.08em;
}

.pulse-kpi small {
    color: var(--pulse-muted);
    font-weight: 800;
}

.pulse-command {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(22rem, 27vw);
    gap: 0.9rem;
}

.pulse-map-panel {
    position: relative;
    min-height: 0;
    overflow: hidden;
    border-radius: 1.65rem;
}

.pulse-map-head {
    position: absolute;
    z-index: 500;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    pointer-events: none;
}

.pulse-map-head > div,
.pulse-map-head label,
.pulse-filter-bar {
    pointer-events: auto;
    border: 1px solid var(--pulse-line);
    border-radius: 1.1rem;
    background: rgba(7, 19, 29, 0.72);
    backdrop-filter: blur(20px);
}

.pulse-map-head > div {
    min-width: min(25rem, 54vw);
    padding: 0.85rem 1rem;
}

.pulse-map-head strong {
    font-size: 1.2rem;
}

.pulse-map-head label {
    width: min(28rem, 42vw);
    min-height: 3.1rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0 0.9rem;
}

.pulse-map-head input {
    width: 100%;
    border: 0;
    outline: 0;
    color: var(--pulse-text);
    background: transparent;
    font: inherit;
    font-weight: 800;
}

.pulse-map {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 52% 42%, rgba(98, 180, 255, 0.12), transparent 28rem),
        #dfe8ee;
    background-size: auto;
}

.pulse-map .leaflet-control-attribution {
    border-radius: 999px 0 0 0;
    background: rgba(7, 19, 29, 0.62);
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.62rem;
    backdrop-filter: blur(10px);
}

.pulse-map .leaflet-control-attribution a {
    color: rgba(255, 255, 255, 0.9);
}

.pulse-marker {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    border: 3px solid var(--status-color, #30d158);
    background: rgba(7, 19, 29, 0.82);
    color: #fff;
    font-weight: 950;
    box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.pulse-marker img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pulse-marker span {
    font-size: 0.82rem;
}

.pulse-filter-bar {
    position: absolute;
    z-index: 500;
    left: 1rem;
    bottom: 1rem;
    display: flex;
    gap: 0.45rem;
    padding: 0.45rem;
}

.pulse-filter-bar button {
    border: 0;
    border-radius: 999px;
    padding: 0.65rem 0.85rem;
    color: var(--pulse-muted);
    background: transparent;
    font-weight: 900;
    cursor: pointer;
}

.pulse-filter-bar button.is-active {
    color: #07131d;
    background: #fff;
}

.pulse-side {
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) minmax(14rem, 40%);
    gap: 0.9rem;
}

.pulse-panel {
    min-height: 0;
    border-radius: 1.35rem;
    overflow: hidden;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.pulse-panel header {
    padding: 1rem 1rem 0.7rem;
}

.pulse-panel header strong {
    font-size: 1.1rem;
}

.pulse-operators,
.pulse-timeline {
    min-height: 0;
    overflow: auto;
    padding: 0 0.75rem 0.85rem;
}

.pulse-operator,
.pulse-event {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 1rem;
    margin-bottom: 0.55rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.055);
    color: inherit;
    text-align: left;
}

.pulse-operator {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.65rem;
    cursor: pointer;
}

.pulse-operator:hover,
.pulse-operator.is-active {
    border-color: rgba(98, 180, 255, 0.55);
    background: rgba(98, 180, 255, 0.12);
}

.pulse-avatar {
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid var(--status-color, #30d158);
    overflow: hidden;
    font-weight: 950;
}

.pulse-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pulse-operator strong,
.pulse-event strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pulse-operator span,
.pulse-event span,
.pulse-operator small,
.pulse-event small {
    color: var(--pulse-muted);
    font-weight: 800;
}

.pulse-status-dot {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 999px;
    margin-top: 0.35rem;
    background: var(--status-color, #30d158);
}

.pulse-event {
    display: grid;
    gap: 0.18rem;
}

.pulse-bottom-sheet {
    position: fixed;
    z-index: 1200;
    left: 50%;
    bottom: max(1rem, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: min(42rem, calc(100vw - 2rem));
    border-radius: 1.6rem;
    padding: 1rem;
}

.pulse-sheet-close {
    position: absolute;
    right: 0.8rem;
    top: 0.8rem;
    width: 2.4rem;
    height: 2.4rem;
    border: 0;
    border-radius: 50%;
    color: var(--pulse-text);
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
}

.pulse-sheet-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.65rem;
    margin-top: 1rem;
}

.pulse-sheet-metric {
    padding: 0.75rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.07);
}

.pulse-sheet-metric span {
    display: block;
    color: var(--pulse-muted);
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
}

.pulse-sheet-metric strong {
    display: block;
    margin-top: 0.25rem;
    font-size: 1.15rem;
}

.pulse-sheet-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-top: 0.9rem;
}

.pulse-sheet-actions a,
.pulse-sheet-actions button {
    border: 0;
    border-radius: 999px;
    padding: 0.75rem 1rem;
    color: #07131d;
    background: #fff;
    font-weight: 950;
    text-decoration: none;
}

@media (max-width: 1020px) {
    body.pulse-page {
        overflow: auto;
    }

    .pulse-shell {
        min-height: 100vh;
        height: auto;
    }

    .pulse-topbar,
    .pulse-command {
        grid-template-columns: 1fr;
    }

    .pulse-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pulse-command {
        min-height: 54rem;
    }

    .pulse-map-panel {
        min-height: 34rem;
    }

    .pulse-side {
        grid-template-rows: auto auto;
    }
}

@media (max-width: 680px) {
    .pulse-shell {
        padding: max(0.7rem, env(safe-area-inset-top)) max(0.7rem, env(safe-area-inset-right)) max(0.7rem, env(safe-area-inset-bottom)) max(0.7rem, env(safe-area-inset-left));
    }

    .pulse-topbar {
        min-height: auto;
    }

    .pulse-live,
    .pulse-user {
        justify-content: center;
    }

    .pulse-kpis {
        grid-template-columns: 1fr 1fr;
        gap: 0.65rem;
    }

    .pulse-kpi {
        min-height: 6.7rem;
        padding: 0.82rem;
    }

    .pulse-map-head {
        display: grid;
    }

    .pulse-map-head > div,
    .pulse-map-head label {
        width: 100%;
        min-width: 0;
    }

    .pulse-filter-bar {
        max-width: calc(100% - 2rem);
        overflow-x: auto;
    }

    .pulse-sheet-grid {
        grid-template-columns: 1fr 1fr;
    }
}
