:root {
    --bg: #050608;
    --bg2: #0a0d10;
    --panel: rgba(12, 15, 18, .92);
    --panel2: rgba(18, 22, 26, .94);
    --gold: #d7a73a;
    --gold2: #f1d27a;
    --text: #ffffff;
    --muted: #aeb6bf;
    --red: #ef3b35;
    --green: #34c759;
    --yellow: #f6a21a;
    --blue: #2f7bff;
    --purple: #9b5cff;
    --border: rgba(215, 167, 58, .28);
    --soft-border: rgba(255, 255, 255, .09);
    --shadow: 0 20px 50px rgba(0, 0, 0, .45);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(215, 167, 58, .14) 0, transparent 28%),
        linear-gradient(135deg, #060708 0%, #0b0d10 45%, #020303 100%);
    color: var(--text);
    overflow: hidden;
}

.main-header {
    height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    background: rgba(0, 0, 0, .88);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 12px 35px rgba(0, 0, 0, .35);
    position: relative;
    z-index: 1000;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-pin {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: #0b0b0b;
    background: linear-gradient(135deg, var(--gold), var(--gold2));
    font-size: 20px;
    box-shadow: 0 0 22px rgba(215, 167, 58, .28);
}

.header-brand strong {
    display: block;
    font-size: 32px;
    letter-spacing: 4px;
    line-height: 1;
}

.header-brand span {
    display: block;
    color: var(--gold2);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 1.8px;
    margin-top: 5px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-nav a {
    color: #e8e8e8;
    text-decoration: none;
    padding: 13px 16px;
    border-radius: 12px;
    font-weight: 700;
    transition: .18s ease;
}

.header-nav a:hover,
.header-nav a.active {
    background: rgba(215, 167, 58, .12);
    color: var(--gold2);
}

.header-nav .admin-link {
    color: #050505;
    background: linear-gradient(135deg, var(--gold), var(--gold2));
    margin-left: 8px;
}

.page {
    height: calc(100vh - 78px);
    display: grid;
    grid-template-columns: 370px 1fr;
    gap: 14px;
    padding: 14px;
}

.sidebar {
    height: 100%;
    overflow-y: auto;
    padding-right: 3px;
}

.sidebar::-webkit-scrollbar,
.city-list::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-thumb,
.city-list::-webkit-scrollbar-thumb {
    background: rgba(215, 167, 58, .35);
    border-radius: 20px;
}

.brand {
    padding: 8px 8px 16px;
}

.brand .seal-logo {
    display: block;
    width: auto !important;
    max-width: 220px !important;
    max-height: 100px !important;
    height: auto !important;
    object-fit: contain;
    margin: 0 auto 18px auto;
}

h1 {
    margin: 0 0 8px;
    font-size: 28px;
    color: var(--gold2);
    letter-spacing: -.5px;
}

p {
    color: #d5d5d5;
    line-height: 1.45;
    margin: 0;
}

.panel {
    background: linear-gradient(180deg, rgba(18, 21, 24, .96), rgba(8, 10, 12, .96));
    border: 1px solid var(--soft-border);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 13px;
    box-shadow: var(--shadow);
}

.panel h2 {
    margin: 0 0 14px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .7px;
    color: #fff;
}

.stats {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.stat-card {
    min-height: 78px;
    border-radius: 14px;
    padding: 15px;
    display: grid;
    grid-template-columns: 54px 1fr;
    align-items: center;
    column-gap: 12px;
    border: 1px solid rgba(255, 255, 255, .08);
    overflow: hidden;
    position: relative;
}

.stat-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(255,255,255,.13), transparent 45%);
    pointer-events: none;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    font-size: 27px;
    font-weight: 900;
}

.stat-card strong {
    display: block;
    font-size: 30px;
    line-height: 1;
}

.stat-card small {
    display: block;
    color: #f1f1f1;
    margin-top: 5px;
    font-size: 13px;
}

.stat-total {
    background: linear-gradient(135deg, rgba(18, 103, 180, .48), rgba(15, 33, 52, .75));
}

.stat-total .stat-icon {
    color: #48b8ff;
    background: rgba(72, 184, 255, .14);
}

.stat-total strong {
    color: #48b8ff;
}

.stat-operando {
    background: linear-gradient(135deg, rgba(21, 145, 73, .46), rgba(14, 45, 28, .76));
}

.stat-operando .stat-icon {
    color: #9ef3aa;
    background: rgba(52, 199, 89, .18);
}

.stat-operando strong {
    color: #9ef3aa;
}

.stat-instalando {
    background: linear-gradient(135deg, rgba(180, 36, 36, .52), rgba(55, 13, 18, .78));
}

.stat-instalando .stat-icon {
    color: #ff7770;
    background: rgba(239, 59, 53, .18);
}

.stat-instalando strong {
    color: #ff7770;
}

.search-box label {
    display: block;
    color: #fff;
    font-weight: 900;
    font-size: 13px;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.search-wrap {
    display: flex;
    align-items: center;
    border: 1px solid rgba(215, 167, 58, .28);
    border-radius: 12px;
    background: rgba(255, 255, 255, .035);
    overflow: hidden;
}

.search-wrap input {
    width: 100%;
    padding: 14px;
    border: 0;
    background: transparent;
    color: white;
    outline: none;
    font-size: 14px;
}

.search-wrap span {
    color: var(--gold2);
    font-size: 24px;
    padding: 0 13px;
}

.legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
    color: #e7e7e7;
    font-size: 14px;
}

.dot,
.marker-dot {
    display: inline-block;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}

.dot {
    width: 11px;
    height: 11px;
}

.marker-dot {
    width: 14px;
    height: 14px;
    box-shadow: 0 0 0 4px rgba(255,255,255,.08);
}

.operando { background: var(--green); }
.implantacao { background: var(--blue); }
.expansao { background: var(--yellow); }
.instalando { background: var(--red); }
.franquia { background: var(--purple); }

.city-panel {
    padding-bottom: 10px;
}

.panel-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.city-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 382px;
    overflow-y: auto;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,.06);
}

.city-card {
    background: rgba(255, 255, 255, .035);
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    border-left: 0;
    border-radius: 0;
    padding: 15px;
    cursor: pointer;
    transition: .18s ease;
}

.city-card:hover {
    background: rgba(215, 167, 58, .08);
}

.city-card h3 {
    margin: 0 0 7px;
    font-size: 16px;
}

.city-card p {
    margin: 0 0 8px;
    font-size: 13px;
    color: #d4d4d4;
}

.badge {
    display: inline-block;
    padding: 5px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    background: rgba(255,255,255,.08);
    color: white;
}

.city-card a {
    display: inline-block;
    margin-top: 12px;
    color: #050505;
    background: linear-gradient(135deg, var(--gold), var(--gold2));
    text-decoration: none;
    font-weight: 900;
    padding: 10px 13px;
    border-radius: 10px;
}

.map-area {
    min-width: 0;
    height: 100%;
}

.map-card {
    position: relative;
    height: 100%;
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
    background: #101418;
    box-shadow: var(--shadow);
}

#map {
    height: 100%;
    width: 100%;
    background: #101418;
    filter: saturate(.82) contrast(1.05) brightness(.82);
}

.leaflet-container {
    background: #101418;
}

.topbar {
    position: absolute;
    top: 18px;
    left: 78px;
    right: 18px;
    z-index: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    background: rgba(5, 6, 7, .86);
    border: 1px solid rgba(215, 167, 58, .25);
    border-radius: 18px;
    padding: 14px 16px;
    backdrop-filter: blur(10px);
    box-shadow: 0 12px 32px rgba(0,0,0,.36);
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    color: var(--gold2);
    background: rgba(215,167,58,.12);
    font-size: 23px;
}

.topbar strong {
    color: #fff;
    display: block;
    text-transform: uppercase;
    letter-spacing: .2px;
}

.topbar span {
    color: #d7d7d7;
    font-size: 13px;
}

.topbar a {
    color: #050505;
    background: linear-gradient(135deg, var(--gold), var(--gold2));
    text-decoration: none;
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.floating-legend {
    position: absolute;
    right: 18px;
    bottom: 72px;
    z-index: 500;
    display: grid;
    gap: 13px;
    background: rgba(8, 9, 10, .88);
    border: 1px solid rgba(215, 167, 58, .24);
    border-radius: 16px;
    padding: 17px 18px;
    backdrop-filter: blur(8px);
    box-shadow: 0 14px 34px rgba(0,0,0,.42);
}

.floating-legend span {
    color: #fff;
    font-size: 14px;
    white-space: nowrap;
}

.map-footer-note {
    position: absolute;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    z-index: 500;
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 13px 18px;
    border-radius: 16px;
    background: rgba(8, 9, 10, .86);
    border: 1px solid rgba(215, 167, 58, .22);
    color: #d8d8d8;
    box-shadow: 0 14px 34px rgba(0,0,0,.32);
}

.map-footer-note strong {
    color: var(--gold2);
}

.leaflet-control-zoom {
    border: 0 !important;
    box-shadow: 0 8px 24px rgba(0,0,0,.35) !important;
}

.leaflet-control-zoom a {
    background: rgba(5, 6, 7, .88) !important;
    color: #fff !important;
    border-color: rgba(255,255,255,.08) !important;
}

.leaflet-popup-content-wrapper {
    background: rgba(12, 13, 14, .96);
    color: white;
    border: 1px solid rgba(215, 167, 58, .28);
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(0,0,0,.45);
}

.leaflet-popup-tip {
    background: rgba(12, 13, 14, .96);
}

.popup-title {
    color: #fff;
    font-weight: 900;
    font-size: 16px;
    margin-bottom: 8px;
}

.popup-btn {
    display: inline-block;
    margin-top: 12px;
    color: #050505 !important;
    background: linear-gradient(135deg, var(--gold), var(--gold2));
    padding: 10px 12px;
    border-radius: 9px;
    text-decoration: none;
    font-weight: 900;
}

.marker-pin {
    width: 28px;
    height: 28px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 3px solid white;
    box-shadow: 0 0 0 3px rgba(0,0,0,.22), 0 8px 20px rgba(0,0,0,.55);
    position: relative;
}

.marker-pin::after {
    content: "";
    width: 8px;
    height: 8px;
    background: white;
    position: absolute;
    border-radius: 50%;
    left: 7px;
    top: 7px;
}

.marker-operando { background: var(--green); }
.marker-implantacao { background: var(--blue); }
.marker-expansao { background: var(--yellow); }
.marker-franquia { background: var(--purple); }
.marker-instalando { background: var(--red); }

.notice {
    display: block;
    margin-top: 12px;
    color: #f7d676;
    font-size: 12px;
    line-height: 1.35;
    background: rgba(247,214,118,.08);
    border: 1px solid rgba(247,214,118,.22);
    padding: 8px 10px;
    border-radius: 10px;
}

@media (max-width: 1100px) {
    .page {
        grid-template-columns: 330px 1fr;
    }

    .header-brand strong {
        font-size: 25px;
    }

    .header-nav a:not(.admin-link) {
        display: none;
    }
}

@media (max-width: 900px) {
    body {
        overflow: auto;
    }

    .main-header {
        height: auto;
        padding: 14px;
        gap: 12px;
        align-items: flex-start;
    }

    .header-brand strong {
        font-size: 22px;
    }

    .header-brand span {
        font-size: 10px;
    }

    .page {
        height: auto;
        grid-template-columns: 1fr;
        padding: 10px;
    }

    .sidebar {
        height: auto;
        max-height: none;
        overflow: visible;
    }

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

    .map-area {
        height: 620px;
    }

    .topbar {
        left: 12px;
        right: 12px;
        top: 12px;
        padding: 12px;
    }

    .topbar a {
        display: none;
    }

    .floating-legend {
        right: 12px;
        bottom: 12px;
        padding: 12px;
    }

    .map-footer-note {
        display: none;
    }

    .desktop-legend {
        display: none;
    }
}
