:root {
    --sidebar-width: 240px;
    --app-bg: #f0f3f8;
    --panel-bg: #ffffff;
    --sidebar-bg: #0f1c2e;
    --sidebar-text: #c5d0de;
    --brand: #1f6feb;
    --brand-soft: #dbe8ff;
    --ink: #152033;
    --muted: #6b7a90;
    --border: #dde3ee;
    --login-grad-a: #0b1a2e;
    --login-grad-b: #1a3a5c;
    --login-accent: #3d8bfd;
}

[data-bs-theme="dark"] {
    --app-bg: #0b1220;
    --panel-bg: #121a2a;
    --sidebar-bg: #070d18;
    --sidebar-text: #a9b7cb;
    --brand: #4c9aff;
    --brand-soft: #163057;
    --ink: #e8eef8;
    --muted: #8b9bb3;
    --border: #243247;
}

* { box-sizing: border-box; }

body.app-body {
    background: var(--app-bg);
    color: var(--ink);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    min-height: 100vh;
}

#wrapper { min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: sticky;
    top: 0;
    flex-shrink: 0;
    z-index: 1040;
}

.sidebar-brand a { color: #fff; }
.brand-icon { color: var(--login-accent); font-size: 1.25rem; }

.sidebar .nav-link {
    color: var(--sidebar-text);
    border-radius: .5rem;
    padding: .65rem .85rem;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.sidebar .nav-link.active {
    background: linear-gradient(90deg, rgba(61, 139, 253, .28), transparent);
    border-left: 3px solid var(--login-accent);
}

.topbar {
    background: var(--panel-bg);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.stat-card,
.panel,
.filter-panel,
.visits-table,
.login-card {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: .85rem;
}

.stat-card {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 1.1rem 1.25rem;
}

.stat-icon {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: .7rem;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
}

.stat-label {
    color: var(--muted);
    font-size: .85rem;
}

.stat-value {
    font-size: 1.55rem;
    font-weight: 700;
    line-height: 1.2;
}

.filter-panel,
.panel-body,
.panel-header {
    padding: 1rem 1.15rem;
}

.panel-header {
    border-bottom: 1px solid var(--border);
}

.visits-table {
    overflow: hidden;
}

.visits-table table { --bs-table-bg: transparent; }
.visits-table thead th {
    background: color-mix(in srgb, var(--panel-bg) 90%, var(--brand) 10%);
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--muted);
    border-bottom-width: 1px;
}

.rank-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: .85rem;
}

.day-chart {
    display: flex;
    align-items: flex-end;
    gap: .35rem;
    min-height: 150px;
    overflow-x: auto;
    padding-bottom: .25rem;
}

.day-bar {
    flex: 0 0 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}

.day-bar-fill {
    width: 100%;
    border-radius: .35rem .35rem 0 0;
    background: linear-gradient(180deg, var(--brand), color-mix(in srgb, var(--brand) 40%, #0b1a2e));
}

.day-bar-label {
    font-size: .65rem;
    color: var(--muted);
    margin-top: .35rem;
    writing-mode: horizontal-tb;
}

.login-page {
    min-height: 100vh;
    margin: 0;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at 20% 20%, rgba(61, 139, 253, .25), transparent 40%),
        radial-gradient(circle at 80% 0%, rgba(20, 184, 166, .18), transparent 35%),
        linear-gradient(145deg, var(--login-grad-a), var(--login-grad-b));
    color: #fff;
}

.login-wrap { width: min(420px, calc(100% - 2rem)); }

.login-card {
    padding: 2rem 1.75rem;
    color: var(--ink);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
}

.login-icon {
    width: 3.5rem;
    height: 3.5rem;
    margin-inline: auto;
    border-radius: 1rem;
    display: grid;
    place-items: center;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 1.6rem;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 1035;
    display: none;
}

.sidebar-overlay.show { display: block; }

@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
    }
    .sidebar.show { transform: translateX(0); }
}

.home-hero {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
    background:
        radial-gradient(circle at top left, rgba(61, 139, 253, .2), transparent 45%),
        linear-gradient(160deg, #0b1a2e, #16324f 55%, #0f2438);
    color: #e8eef8;
}

.home-card {
    width: min(720px, 100%);
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .12);
    backdrop-filter: blur(10px);
    border-radius: 1.25rem;
    padding: 2.5rem;
}

.home-card h1 {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 700;
}

.home-meta {
    display: grid;
    gap: .5rem;
    margin-top: 1.5rem;
    font-size: .95rem;
    color: #b7c6db;
}

.install-page {
    min-height: 100vh;
    background: var(--app-bg);
    padding: 2rem 1rem;
}

.install-card {
    width: min(640px, 100%);
    margin: 0 auto;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 2rem;
}

/* —— Panel fácil —— */
.easy-admin {
    font-family: "DM Sans", system-ui, sans-serif;
    --brand: #e86945;
    --brand-soft: #ffe4da;
}

.easy-header {
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.easy-brand {
    font-family: "Fredoka", "DM Sans", sans-serif;
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}

.easy-brand-mark { font-size: 1.35rem; line-height: 1; }

.easy-nav {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}

.easy-nav a {
    text-decoration: none;
    color: var(--muted);
    font-weight: 500;
    padding: .4rem .75rem;
    border-radius: 999px;
}

.easy-nav a:hover { color: var(--ink); background: color-mix(in srgb, var(--brand) 12%, transparent); }
.easy-nav a.active {
    color: #fff;
    background: var(--brand);
}

.easy-title {
    font-family: "Fredoka", "DM Sans", sans-serif;
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 600;
}

.easy-stat {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1rem 1.15rem;
    height: 100%;
}

.easy-stat-num {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--brand);
}

.easy-stat-label {
    color: var(--muted);
    font-size: .9rem;
    margin-top: .2rem;
}

.easy-search .input-group-lg > .form-control,
.easy-search .input-group-lg > .input-group-text,
.easy-search .input-group-lg > .btn {
    border-radius: .85rem;
}

.easy-search .input-group-text {
    background: var(--panel-bg);
}

.easy-filters {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1rem;
}

.easy-list {
    display: grid;
    gap: .75rem;
}

.easy-visit {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: .85rem;
    align-items: center;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1rem 1.1rem;
}

.easy-check { margin: 0; }

.easy-visit-top {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1rem;
    align-items: baseline;
}

.easy-ip {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.05rem;
}

.easy-when {
    color: var(--muted);
    font-size: .85rem;
}

.easy-where { margin-top: .15rem; }
.easy-meta {
    margin-top: .2rem;
    color: var(--muted);
    font-size: .85rem;
}

.easy-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    justify-content: flex-end;
}

.easy-empty {
    background: var(--panel-bg);
    border: 1px dashed var(--border);
    border-radius: 1rem;
}

.login-page {
    background:
        radial-gradient(circle at 15% 20%, rgba(255, 143, 107, .35), transparent 40%),
        radial-gradient(circle at 85% 10%, rgba(126, 200, 163, .25), transparent 35%),
        linear-gradient(145deg, #2a1f1a, #4a3228);
}

.login-icon {
    background: #ffe4da;
    font-size: 2rem;
    border: 0;
}

@media (max-width: 767.98px) {
    .easy-visit {
        grid-template-columns: auto 1fr;
    }
    .easy-actions {
        grid-column: 1 / -1;
        justify-content: stretch;
    }
    .easy-actions .btn { flex: 1; }
}

/* Mapa */
.map-layout {
    display: grid;
    gap: 1rem;
}

.map-layout-triple {
    grid-template-columns: 1fr;
}

@media (min-width: 1100px) {
    .map-layout-triple {
        grid-template-columns: 280px 1fr;
        align-items: start;
    }
}

.map-main { min-width: 0; }

.map-panel {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 1rem;
    overflow: hidden;
}

.map-panel-head {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1rem;
    justify-content: space-between;
    align-items: center;
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--border);
}

.gmaps-frame-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    min-height: 320px;
    background: #dfe8e4;
}

.gmaps-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.visits-map {
    height: min(48vh, 420px);
    min-height: 280px;
    border: 0;
    border-radius: 0;
    overflow: hidden;
    background: #dfe8e4;
    z-index: 1;
}

.map-side {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1rem;
    max-height: min(85vh, 760px);
    overflow: auto;
}

.map-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: .5rem;
}

.map-list-item {
    width: 100%;
    text-align: left;
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--panel-bg) 90%, var(--brand) 8%);
    border-radius: .75rem;
    padding: .65rem .75rem;
    display: grid;
    gap: .15rem;
    cursor: pointer;
}

.map-list-item.is-precise {
    border-color: #0d9488;
}
.map-list-item.is-approx {
    border-color: color-mix(in srgb, #ea580c 45%, var(--border));
}

.map-list-item:hover,
.map-list-item.is-active {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 25%, transparent);
}

.map-list-item strong {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .92rem;
}

.map-list-item span {
    font-size: .82rem;
    color: var(--muted);
}

.map-list-when { font-size: .75rem !important; }

.map-popup {
    font-size: .9rem;
    line-height: 1.4;
}

.map-popup a {
    color: var(--brand);
    font-weight: 600;
}
