:root {
    --bg: #eef4ef;
    --bg-accent: #d8eadf;
    --panel: rgba(250, 252, 250, 0.9);
    --panel-strong: rgba(255, 255, 255, 0.96);
    --border: rgba(23, 40, 32, 0.12);
    --text: #172820;
    --muted: #5d6e67;
    --accent: #0c8f63;
    --accent-deep: #0a6c4d;
    --danger: #ba3f3f;
    --shadow: 0 24px 60px rgba(18, 35, 28, 0.12);
    --mobile-browser-offset: 0px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: "DM Sans", "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(12, 143, 99, 0.18), transparent 35%),
        radial-gradient(circle at bottom right, rgba(255, 107, 53, 0.18), transparent 28%),
        linear-gradient(180deg, #f7fbf8 0%, var(--bg) 55%, var(--bg-accent) 100%);
}

button,
input {
    font: inherit;
}

.app-shell {
    position: relative;
    height: 100vh;
}

.topbar {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 420;
    pointer-events: auto;
}

h2,
h3,
strong {
    font-family: "Space Grotesk", sans-serif;
}

.topbar-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px;
    border-radius: 22px;
    border: 1px solid var(--border);
    background: rgba(250, 252, 250, 0.84);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.ghost-button,
.primary-button {
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    cursor: pointer;
    transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

.ghost-button:hover,
.primary-button:hover {
    transform: translateY(-1px);
}

.ghost-button {
    background: rgba(255, 255, 255, 0.75);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: 0 10px 24px rgba(18, 35, 28, 0.08);
}

.ghost-button-danger {
    color: var(--danger);
}

.primary-button {
    background: linear-gradient(135deg, var(--accent) 0%, #1d5cff 100%);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 18px 36px rgba(12, 143, 99, 0.26);
}

.map-panel,
.panel-card {
    position: relative;
}

.map-panel {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.map {
    width: 100%;
    height: 100vh;
}

.map-overlay {
    position: absolute;
    top: 16px;
    left: 16px;
    display: flex;
    gap: 12px;
    z-index: 410;
    pointer-events: none;
    display: none;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(23, 40, 32, 0.08);
    box-shadow: 0 12px 30px rgba(18, 35, 28, 0.1);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #c7cfd1;
}

.status-dot.is-live {
    background: #18b46a;
    box-shadow: 0 0 0 8px rgba(24, 180, 106, 0.14);
}

.status-title {
    color: var(--muted);
}

.panel-card {
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 28px;
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.panel-card-muted {
    background: rgba(238, 244, 239, 0.92);
}

.panel-card-embedded {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.panel-heading h2,
.panel-card h2 {
    margin: 0;
    font-size: 1.15rem;
}

.small-badge {
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(12, 143, 99, 0.12);
    color: var(--accent-deep);
    font-size: 0.82rem;
    font-weight: 700;
}

.identity-preview {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border-radius: 20px;
    background: var(--panel-strong);
    border: 1px solid rgba(23, 40, 32, 0.07);
}

.identity-preview p {
    margin: 6px 0 0;
    color: var(--muted);
}

.identity-swatch,
.member-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ff6b35;
    box-shadow: 0 0 0 6px rgba(255, 107, 53, 0.16);
    flex-shrink: 0;
}

.identity-swatch {
    width: 24px;
    height: 24px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 16px 0 0;
}

.stat-grid div {
    padding: 14px;
    border-radius: 18px;
    background: var(--panel-strong);
    border: 1px solid rgba(23, 40, 32, 0.07);
}

.stat-grid dt {
    color: var(--muted);
    font-size: 0.82rem;
}

.stat-grid dd {
    margin: 8px 0 0;
    font-family: "Space Grotesk", sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
}

.member-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.member-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 18px;
    background: var(--panel-strong);
    border: 1px solid rgba(23, 40, 32, 0.07);
}

.member-main {
    display: flex;
    gap: 12px;
    align-items: center;
}

.member-name {
    margin: 0;
    font-size: 1rem;
}

.member-meta,
.member-status,
.panel-card p {
    margin: 4px 0 0;
    color: var(--muted);
}

.member-status {
    margin: 0;
    font-size: 0.84rem;
    text-align: right;
}

.panel-modal {
    z-index: 950;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(13, 24, 19, 0.55);
    backdrop-filter: blur(10px);
    z-index: 999;
}

.modal-backdrop.is-visible {
    display: flex;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-card {
    width: min(480px, 100%);
    padding: 28px;
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.24);
}

.panel-modal-card {
    width: min(760px, calc(100vw - 32px));
    max-height: min(78dvh, 860px);
    overflow: auto;
}

.panel-modal-card-wide {
    width: min(920px, calc(100vw - 32px));
}

.panel-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.modal-close-button {
    border: 1px solid rgba(23, 40, 32, 0.12);
    border-radius: 999px;
    padding: 11px 16px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
}

.modal-card h2 {
    margin: 0;
    font-size: 1.8rem;
}

.modal-copy {
    margin: 10px 0 20px;
    color: var(--muted);
}

.setup-form {
    display: grid;
    gap: 14px;
}

.setup-form label {
    display: grid;
    gap: 8px;
}

.setup-form span {
    font-size: 0.92rem;
    font-weight: 600;
}

.setup-form input {
    width: 100%;
    border: 1px solid rgba(23, 40, 32, 0.12);
    border-radius: 14px;
    padding: 13px 14px;
    background: #fff;
    color: var(--text);
}

.setup-form input[type="color"] {
    min-height: 52px;
    padding: 6px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 6px;
}

.form-error {
    margin: 0;
    color: var(--danger);
    font-weight: 600;
}

.empty-state {
    padding: 16px;
    border-radius: 18px;
    background: var(--panel-strong);
    border: 1px dashed rgba(23, 40, 32, 0.14);
    color: var(--muted);
}

.walker-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 0 0 8px rgba(23, 40, 32, 0.12);
}

.leaflet-popup-content-wrapper {
    border-radius: 16px;
}

@media (max-width: 980px) {
    .topbar-actions {
        max-width: calc(100vw - 32px);
    }
}

@media (max-width: 720px) {
    .topbar {
        position: fixed;
        top: auto;
        bottom: max(calc(env(safe-area-inset-bottom, 0px) + var(--mobile-browser-offset, 0px) + 8px));
        left: calc(env(safe-area-inset-left, 0px) + 12px);
        right: calc(env(safe-area-inset-right, 0px) + 12px);
    }

    .topbar-actions {
        width: 100%;
        padding: 10px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px) * 0.25);
        border-radius: 20px;
        gap: 8px;
        flex-wrap: nowrap;
    }

    .topbar-actions .ghost-button {
        flex: 1 1 0;
        min-width: 0;
        padding: 10px 8px;
        font-size: 0.9rem;
        white-space: nowrap;
    }

    .topbar-actions,
    .map-overlay {
        flex-direction: row;
        align-items: stretch;
    }

    .map-overlay {
        left: 12px;
        right: auto;
        top: 12px;
    }

    .status-pill {
        justify-content: center;
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }

    .panel-modal-card,
    .panel-modal-card-wide {
        width: min(100vw - 16px, 100%);
        max-height: calc(100dvh - 24px);
        padding: 22px;
        border-radius: 24px;
    }
}