*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: #1f2933;
    background: #eef2f6;
}

body {
    padding-left: 280px;
}

body.page-index {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
    padding-left: 0;
}

.admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    padding: 20px;
    overflow-y: auto;
    border-right: 1px solid #d8dee8;
    background: #ffffff;
    z-index: 1000;
}

.admin-sidebar h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
}

.sidebar-header h1,
.sidebar-header .brand {
    flex: 1;
    min-width: 0;
}

.sidebar-header .language-switcher {
    margin: 0;
    flex-shrink: 0;
}

.brand {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}

.admin-sidebar .status {
    margin: 0 0 14px;
    color: #52616f;
    font-size: 14px;
}

.avatar {
    display: block;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 12px;
}

.avatar.initial {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #d8dee8;
    color: #52616f;
    font-size: 24px;
    font-weight: 700;
}

.admin-sidebar h2 {
    margin: 18px 0 10px;
    color: #52616f;
    font-size: 12px;
    letter-spacing: 0;
    text-transform: uppercase;
}

.admin-sidebar nav {
    display: grid;
    gap: 8px;
}

.admin-sidebar a {
    display: block;
    border: 1px solid #d8dee8;
    border-radius: 6px;
    padding: 10px 12px;
    color: #1f2933;
    text-decoration: none;
    background: #f8fafc;
}

.admin-sidebar a:hover,
.admin-sidebar a.active {
    background: #eaf0f8;
}

.language-switcher {
    position: relative;
    margin: 0 0 14px;
    font-size: 13px;
}

.lang-current {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    border: 1px solid #d8dee8;
    border-radius: 6px;
    padding: 7px 10px;
    background: #f8fafc;
    color: #1f2933;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    appearance: none;
}

.lang-current::after {
    content: "";
    margin-left: auto;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid #52616f;
}

.language-switcher:hover .lang-current::after {
    border-top-color: #1f2933;
}

.lang-options {
    display: none;
    position: absolute;
    inset: 100% 0 auto;
    z-index: 10;
    border: 1px solid #d8dee8;
    border-radius: 6px;
    background: #ffffff;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.language-switcher:hover .lang-options,
.language-switcher:focus-within .lang-options {
    display: block;
}

.admin-sidebar .lang-option,
.menu .lang-option {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 0;
    border-radius: 0;
    padding: 8px 10px;
    color: #52616f;
    text-decoration: none;
    font-size: 13px;
    background: transparent;
}

.admin-sidebar .lang-option:hover,
.admin-sidebar .lang-option.active,
.menu .lang-option:hover,
.menu .lang-option.active {
    background: #eaf0f8;
    color: #1f2933;
}

.flag {
    font-size: 16px;
    line-height: 1;
}

.admin-sidebar .button {
    width: 100%;
    min-height: 38px;
    border: 0;
    border-radius: 6px;
    padding: 8px 12px;
    background: #e5eaf1;
    color: #1f2933;
    font-weight: 700;
    cursor: pointer;
}

.menu {
    background: #ffffff;
    border-right: 1px solid #d8dee8;
    padding: 20px;
    overflow-y: auto;
    z-index: 10;
}

.status {
    margin: 0 0 16px;
    color: #52616f;
    font-size: 14px;
}

.login-form {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
}

.login-form label {
    font-size: 13px;
    font-weight: 700;
}

.login-form input {
    width: 100%;
    min-height: 38px;
    border: 1px solid #c8d0db;
    border-radius: 6px;
    padding: 8px 10px;
    font: inherit;
}

.button {
    min-height: 38px;
    border: 0;
    border-radius: 6px;
    padding: 8px 12px;
    background: #2563eb;
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

.button.secondary {
    width: 100%;
    background: #e5eaf1;
    color: #1f2933;
}

.message {
    margin: 0 0 14px;
    font-size: 14px;
}

.message.error {
    color: #b00020;
}

.message.info {
    color: #116329;
}

.admin-page-message,
.db-error {
    margin: 24px;
    color: #b00020;
}

.db-error {
    text-align: center;
}

.nav {
    display: grid;
    gap: 8px;
}

.menu-section {
    margin-top: 18px;
}

.menu-section h2 {
    margin: 0 0 10px;
    color: #52616f;
    font-size: 12px;
    letter-spacing: 0;
    text-transform: uppercase;
}

.nav a {
    display: block;
    border: 1px solid #d8dee8;
    border-radius: 6px;
    padding: 10px 12px;
    color: #1f2933;
    text-decoration: none;
    background: #f8fafc;
}

.nav a:hover,
.nav a.active {
    background: #eaf0f8;
}

.map-shell {
    position: relative;
    min-width: 0;
    min-height: 100vh;
}

#map {
    position: absolute;
    inset: 0;
    min-height: 420px;
}

.empty-section {
    margin: 0;
    color: #7b8794;
    font-size: 14px;
}

.debug {
    margin: 12px 0 0;
    color: #52616f;
    font-family: monospace;
    font-size: 12px;
    overflow-wrap: anywhere;
}

.chart-container {
    height: 300px;
    width: 100%;
}


.places-list-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px;
}

.places-list-header {
    margin-bottom: 16px;
}

.places-list-header h1 {
    margin: 0 0 4px;
}

.places-sort-form {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.places-sort-form label {
    font-weight: bold;
}

.places-sort-form select {
    padding: 6px 10px;
    border: 1px solid #cdd0d4;
    border-radius: 4px;
    background: #fff;
    font-size: 14px;
}

.place-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.place-card-link:hover .place-card {
    border-color: #2563eb;
    box-shadow: 0 2px 8px rgba(37,99,235,0.15);
}

.place-card {
    display: flex;
    gap: 16px;
    background: #fff;
    border: 1px solid #dde2e8;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.place-card-photo {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    background: #eef2f6;
}

.place-card-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.place-card-title {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 6px;
    color: #1f2933;
}

.place-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    font-size: 13px;
    color: #5b6775;
}

.pagination {
    margin: 20px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
}

.pagination-btn,
.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    text-decoration: none;
    border: 1px solid #ddd;
    color: #000;
    margin: 0 2px;
    border-radius: 5px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
}

.pagination-btn:hover {
    background: #eee;
}

.pagination-current {
    background-color: #4CAF50;
    color: #fff;
    border-color: #4CAF50;
}

.pagination-current:hover {
    background-color: #4CAF50;
}

.pagination-disabled {
    color: #aaa;
    cursor: not-allowed;
    pointer-events: none;
    background: #fff;
}

.pagination-ellipsis {
    border: none;
    background: none;
    padding: 8px 4px;
    min-width: auto;
    cursor: default;
}

.pagination-pages {
    display: flex;
    align-items: center;
    gap: 2px;
}

.sidebar-toggle {
    display: none;
}

.sidebar-toggle.hidden {
    display: none;
}

.sidebar-close {
    display: none;
    border: none;
    background: none;
    color: #52616f;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    flex-shrink: 0;
}

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

@media (max-width: 768px) {

    .pagination-btn,
    .pagination-ellipsis {
        padding: 4px 8px;
        font-size: 12px;
    }

    .pagination {
        gap: 2px;
    }

    .pagination-pages {
        gap: 1px;
    }

    .pagination > .pagination-btn:first-child {
        font-size: 0;
    }
    .pagination > .pagination-btn:first-child::before {
        content: "<<";
        font-size: 14px;
    }

    .pagination > .pagination-btn:last-child {
        font-size: 0;
    }
    .pagination > .pagination-btn:last-child::before {
        content: ">>";
        font-size: 14px;
    }

    body {
        padding-left: 0;
    }

    body.page-index {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(420px, 1fr);
    }

    body.page-index.logged-in {
        grid-template-rows: 1fr;
    }

    .menu {
        border-right: 0;
        border-bottom: 1px solid #d8dee8;
    }

    body.page-index.logged-in .menu {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100%;
        z-index: 1000;
        transition: left 0.3s ease;
        border-right: 1px solid #d8dee8;
        border-bottom: none;
        overflow-y: auto;
    }

    body.page-index.logged-in .menu.sidebar-open {
        left: 0;
    }

    .map-shell {
        min-height: calc(100vh - 360px);
    }

    .sidebar-toggle {
        display: block;
        position: fixed;
        top: 12px;
        left: 12px;
        z-index: 1200;
        width: 40px;
        height: 40px;
        border: none;
        background: #1f2933;
        color: #fff;
        font-size: 22px;
        border-radius: 6px;
        cursor: pointer;
        line-height: 40px;
        text-align: center;
        padding: 0;
    }

    .places-list-header .sidebar-toggle {
        position: static;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        font-size: 20px;
        line-height: 1;
        flex-shrink: 0;
        background: #1f2933;
        color: #fff;
        border-radius: 6px;
        border: none;
        cursor: pointer;
        padding: 0;
    }

    .places-list-header .sidebar-toggle.hidden {
        display: none;
    }

    .places-list-header {
        display: flex;
        align-items: center;
        gap: 10px;
        flex-wrap: wrap;
    }

    .places-list-header h1 {
        flex: 1;
        min-width: 0;
    }

    .sidebar-close {
        display: inline-block;
    }

    .admin-sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        bottom: 0;
        width: 280px;
        transition: left 0.25s ease;
    }

    .admin-sidebar.sidebar-open {
        left: 0;
    }

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

    .places-list-container {
        padding: 12px;
    }

}

@media (max-width: 600px) {
    .place-card {
        flex-direction: column;
    }
    .place-card-photo {
        width: 100%;
        height: 180px;
    }
}
