:root {
    --bg: #0f172a;
    --card: #1e293b;
    --accent: #38bdf8;
    --text: #e2e8f0;
    --danger: #f87171;
    --success: #4ade80;
    font-family: 'Segoe UI', system-ui, sans-serif;
}

body {
    margin: 0;
    background: radial-gradient(circle at top, rgba(59,130,246,0.15), transparent 50%), var(--bg);
    color: var(--text);
}

a {
    color: var(--accent);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 30px rgba(15,23,42,0.4);
    position: sticky;
    top: 0;
    z-index: 10;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.brand {
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.main-nav a {
    color: rgba(226, 232, 240, 0.85);
    text-decoration: none;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    transition: background 0.2s ease, color 0.2s ease;
}

.main-nav a:hover,
.main-nav a:focus {
    background: rgba(56, 189, 248, 0.2);
    color: rgba(226, 232, 240, 1);
    outline: none;
}

.main-nav a.active {
    background: rgba(56, 189, 248, 0.35);
    color: rgba(226, 232, 240, 1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.95rem;
}

.user-info span {
    color: rgba(226, 232, 240, 0.8);
}

.user-info .button {
    padding: 0.4rem 0.9rem;
    font-size: 0.9rem;
}

.button {
    background: var(--accent);
    color: #0f172a;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
}

.layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2rem;
    padding: 2rem;
}

.dashboard-main {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.content-section {
    padding: 2rem;
    display: flex;
    justify-content: center;
}

.content-section > .panel,
.content-section > .photo-list {
    width: 100%;
    max-width: 1200px;
}

#dashboard,
#upload,
#map-section,
#photos,
#share,
#categories,
#approvals {
    scroll-margin-top: 96px;
}

.panel {
    background: rgba(30, 41, 59, 0.85);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.4);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.panel form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.panel input,
.panel textarea,
.panel button {
    border: none;
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.8);
    color: var(--text);
}

.panel button {
    background: linear-gradient(135deg, var(--accent), #6366f1);
    cursor: pointer;
    font-weight: 600;
}

.panel .hint,
.photo-list .hint,
.shared-hint {
    font-size: 0.9rem;
    color: rgba(226, 232, 240, 0.7);
    background: rgba(15, 23, 42, 0.4);
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
}

.category-select {
    border: 1px dashed rgba(56, 189, 248, 0.4);
    border-radius: 0.75rem;
    padding: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}

.upload-advanced {
    margin-top: 0.5rem;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
}

.upload-advanced summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--accent);
    list-style: none;
}

.upload-advanced summary::-webkit-details-marker {
    display: none;
}

.upload-advanced[open] summary {
    margin-bottom: 0.75rem;
}

.upload-advanced-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.upload-advanced-grid input {
    width: 100%;
}

.geocode-search {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.geocode-row {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.geocode-row input[type="text"] {
    flex: 1;
}

.geocode-results {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 0.5rem;
    overflow: hidden;
    max-height: 12rem;
    overflow-y: auto;
}

.geocode-results li + li {
    border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.geocode-results button {
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    background: rgba(15, 23, 42, 0.4);
    color: inherit;
    border: none;
    cursor: pointer;
    font: inherit;
    transition: background 0.2s ease;
}

.geocode-results button:hover,
.geocode-results button:focus {
    background: rgba(59, 130, 246, 0.2);
    outline: none;
}

.geocode-feedback {
    font-size: 0.9rem;
    margin: 0;
}

.geocode-feedback.error {
    color: #f87171;
}

.geocode-feedback.success {
    color: #34d399;
}

.geocode-feedback.hidden {
    display: none;
}

.category-select legend {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(226, 232, 240, 0.7);
    padding: 0 0.5rem;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.checkbox input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
}

.color-dot {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    background: var(--dot-color, #3388FF);
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.45);
    flex-shrink: 0;
}

.photo-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.popup-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.35rem;
}

.category-pill {
    --category-color: #3388FF;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    border: 1px solid var(--category-color);
    background: rgba(148, 163, 184, 0.12);
    color: #e2e8f0;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.category-pill::before {
    content: '';
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 999px;
    background: var(--category-color);
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.4);
}

.category-form,
.share-form {
    gap: 0.5rem;
}

.share {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.share .category-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 160px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.share-form.inline {
    display: inline-flex;
    gap: 0.5rem;
    margin-top: -0.5rem;
}

.share-form.inline button {
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.share-form .danger {
    background: rgba(248, 113, 113, 0.2);
    border: 1px solid rgba(248, 113, 113, 0.5);
    color: var(--danger);
}

.category-color-list {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.category-color-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.category-color-form .category-name {
    flex: 1;
    font-weight: 500;
}

.category-color-form input[type="color"] {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
}

.category-color-form button {
    padding: 0.45rem 0.9rem;
}

.categories-section,
.admin-approval,
.category-manager,
.share {
    background: rgba(15, 23, 42, 0.4);
    border-radius: 1rem;
    padding: 1rem;
}

.pending-users {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.pending-users li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    background: rgba(15, 23, 42, 0.5);
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
}

.pending-users form button {
    background: linear-gradient(135deg, #4ade80, #22c55e);
}

.popup-image {
    width: 180px;
    height: 120px;
    object-fit: cover;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.5);
}

.popup-categories {
    font-size: 0.85rem;
    color: rgba(226, 232, 240, 0.8);
    margin-bottom: 0.35rem;
}

.popup-date {
    font-size: 0.8rem;
    color: rgba(226, 232, 240, 0.7);
}

.home-control button {
    width: 100%;
    height: 32px;
    border: none;
    background: rgba(56, 189, 248, 0.9);
    color: #0f172a;
    font-weight: 600;
    cursor: pointer;
}

.home-control button:hover {
    background: rgba(56, 189, 248, 1);
}

.distance-tooltip {
    background: rgba(15, 23, 42, 0.95);
    color: #f8fafc;
    border-radius: 999px;
    border: none;
    padding: 0.25rem 0.6rem;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.45);
    font-weight: 600;
}

.distance-tooltip::before {
    display: none;
}

.leaflet-interactive.home-marker {
    stroke: #0f172a;
    stroke-width: 2;
    fill: #f59e0b;
    fill-opacity: 1;
}

.home-tooltip {
    background: rgba(15, 23, 42, 0.9);
    color: #f8fafc;
    border-radius: 999px;
    border: none;
    padding: 0.2rem 0.6rem;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.4);
    font-weight: 600;
}

.home-tooltip::before {
    display: none;
}

.map-controls {
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(56, 189, 248, 0.15);
    border-radius: 1rem;
    padding: 1rem 1.25rem;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.5);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.map-controls-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.map-controls-header p {
    margin: 0;
    font-size: 0.85rem;
    color: rgba(226, 232, 240, 0.7);
}

.category-filter-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.5rem 1rem;
}

.category-filter-item {
    background: rgba(15, 23, 42, 0.55);
    border-radius: 0.75rem;
    border: 1px solid rgba(56, 189, 248, 0.2);
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.45);
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
    width: 100%;
}

.category-filter-item:hover {
    border-color: rgba(56, 189, 248, 0.45);
    background: rgba(15, 23, 42, 0.7);
}

.category-filter-item input[type="checkbox"] {
    accent-color: var(--accent);
    flex-shrink: 0;
}

.category-filter-item input:not(:checked) ~ span {
    opacity: 0.55;
}

.category-filter-item span:last-child {
    font-weight: 600;
}

.button-ghost {
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.4);
    color: rgba(226, 232, 240, 0.85);
    border-radius: 999px;
    padding: 0.45rem 1rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
    align-self: flex-start;
}

.button-ghost:hover,
.button-ghost:focus {
    background: rgba(56, 189, 248, 0.18);
    border-color: rgba(56, 189, 248, 0.65);
    color: rgba(226, 232, 240, 1);
    outline: none;
}

#map {
    width: 100%;
    height: 480px;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.5);
}

.map-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.map-panel h2 {
    margin: 0;
    font-size: 1.5rem;
}

.photo-detail {
    position: relative;
    background: rgba(30, 41, 59, 0.85);
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.55);
    color: var(--text);
    overflow: hidden;
}

.photo-detail .detail-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.photo-detail img {
    width: 100%;
    max-height: 360px;
    object-fit: contain;
    border-radius: 0.75rem;
    background: rgba(15, 23, 42, 0.8);
    margin-bottom: 1rem;
}

.photo-detail .detail-meta {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.photo-detail .detail-distance {
    margin: 0.5rem 0 0;
    font-weight: 600;
    color: #f8fafc;
}

.photo-detail .detail-distance.hidden {
    display: none;
}

.photo-detail .detail-hint {
    margin: 0;
    color: rgba(226, 232, 240, 0.7);
    font-size: 0.9rem;
}

.detail-feedback {
    margin: 0;
}

.detail-edit-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.detail-edit-form label {
    font-weight: 600;
    color: rgba(148, 163, 184, 0.9);
}

.detail-edit-form input[type="text"],
.detail-edit-form input[type="datetime-local"],
.detail-edit-form textarea {
    width: 100%;
    border-radius: 0.6rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.8);
    color: var(--text);
    padding: 0.6rem 0.75rem;
    font-family: inherit;
    font-size: 1rem;
}

.detail-edit-form textarea {
    resize: vertical;
}

.detail-coordinates {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}

.detail-note {
    margin: -0.35rem 0 0;
    font-size: 0.8rem;
    color: rgba(226, 232, 240, 0.6);
}

.detail-categories {
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 0.75rem;
    padding: 0.75rem;
    display: grid;
    gap: 0.5rem;
}

.detail-categories legend {
    font-weight: 600;
    color: rgba(148, 163, 184, 0.9);
    padding: 0 0.25rem;
}

.detail-categories .checkbox {
    align-items: center;
}

.detail-categories .hint {
    margin: 0;
}

.detail-edit-form .form-actions {
    display: flex;
    justify-content: flex-end;
}

.photo-detail .detail-close {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    background: transparent;
    border: none;
    color: rgba(226, 232, 240, 0.8);
    font-size: 1.5rem;
    cursor: pointer;
}

.photo-detail .detail-close:hover {
    color: rgba(226, 232, 240, 1);
}

.detail-empty {
    text-align: center;
    color: rgba(226, 232, 240, 0.7);
}

.hidden {
    display: none !important;
}

.detail-button {
    margin-top: 0.5rem;
    align-self: flex-start;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    border: none;
    background: rgba(56, 189, 248, 0.9);
    color: #0f172a;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.detail-button:hover {
    background: rgba(56, 189, 248, 1);
}

.photo-actions .detail-button {
    margin-top: 0;
    padding: 0.35rem 0.85rem;
}

.photo-list {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.photo-list-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.photo-list-messages {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 200px;
}

.table-wrapper {
    overflow-x: auto;
    background: rgba(15, 23, 42, 0.35);
    border-radius: 1rem;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.45);
}

.photo-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 680px;
}

.photo-table thead {
    background: rgba(30, 41, 59, 0.85);
}

.photo-table th {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(226, 232, 240, 0.7);
}

.photo-table th,
.photo-table td {
    padding: 1rem;
    text-align: left;
    vertical-align: top;
}

.photo-table tbody tr:nth-child(even) {
    background: rgba(15, 23, 42, 0.45);
}

.photo-table tbody tr:nth-child(odd) {
    background: rgba(15, 23, 42, 0.35);
}

.photo-row {
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.photo-row:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.4);
}

.photo-row:focus {
    outline: 2px solid rgba(56, 189, 248, 0.8);
    outline-offset: 2px;
}

.photo-row.active {
    box-shadow: 0 18px 32px rgba(56, 189, 248, 0.4);
    position: relative;
}

.photo-thumb img {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: 0.75rem;
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.4);
}

.photo-info {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.photo-info strong {
    font-size: 1.05rem;
}

.photo-description {
    color: rgba(226, 232, 240, 0.85);
}

.photo-meta-line {
    font-size: 0.9rem;
    color: rgba(226, 232, 240, 0.7);
}

.photo-meta-line.warning {
    color: rgba(248, 250, 252, 0.85);
    background: rgba(248, 113, 113, 0.15);
    padding: 0.35rem 0.6rem;
    border-radius: 0.5rem;
    display: inline-block;
}

.photo-categories-cell {
    min-width: 180px;
}

.photo-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
}

.photo-actions form {
    margin: 0;
}

.location-editor {
    width: 100%;
}

.location-editor summary {
    cursor: pointer;
    color: var(--accent);
    font-weight: 600;
    outline: none;
}

.location-form {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: rgba(15, 23, 42, 0.65);
    padding: 0.75rem;
    border-radius: 0.75rem;
}

.location-form input,
.location-form button {
    width: 100%;
    border-radius: 0.65rem;
    border: none;
    padding: 0.6rem 0.85rem;
}

.location-form button {
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: #0f172a;
    font-weight: 600;
    cursor: pointer;
}

.danger-link {
    background: transparent;
    border: none;
    color: var(--danger);
    font-weight: 600;
    cursor: pointer;
    padding: 0.35rem 0;
}

.danger-link:hover,
.danger-link:focus {
    text-decoration: underline;
}

.error,
.success {
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
}

.error {
    background: rgba(248, 113, 113, 0.2);
    color: var(--danger);
}

.success {
    background: rgba(74, 222, 128, 0.2);
    color: var(--success);
}

.auth-container {
    max-width: 360px;
    margin: 6rem auto;
    background: rgba(30, 41, 59, 0.9);
    padding: 2rem;
    border-radius: 1.25rem;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.6);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-container form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.auth-container input,
.auth-container button {
    border: none;
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.8);
    color: var(--text);
}

.auth-container button {
    background: linear-gradient(135deg, var(--accent), #6366f1);
    cursor: pointer;
    font-weight: 600;
}

.share-link {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.share-link input {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.shared-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 2rem;
    padding: 2rem;
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }
    .shared-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .topbar {
        padding: 0.75rem 1rem;
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        flex-wrap: nowrap;
    }
    .brand {
        font-size: 1.05rem;
    }
    .main-nav {
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0.75rem;
        padding-bottom: 0.25rem;
    }
    .main-nav::-webkit-scrollbar {
        display: none;
    }
    .main-nav a {
        flex: 0 0 auto;
        font-size: 0.9rem;
    }
    .user-info {
        width: 100%;
        justify-content: space-between;
    }
    .dashboard-main {
        padding: 1.5rem 1rem;
    }
    .content-section {
        padding: 1.5rem 1rem;
    }
    .panel {
        padding: 1.25rem;
    }
    .photo-list {
        padding: 1.5rem 1rem;
    }
    .photo-list-header {
        flex-direction: column;
        align-items: stretch;
    }
    #map {
        height: 360px;
    }
    .map-controls {
        padding: 0.85rem 1rem;
    }
    .category-filter-list {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
    .photo-detail {
        padding: 1rem;
    }
    .photo-detail img {
        max-height: 260px;
    }
    .detail-coordinates {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 540px) {
    .topbar {
        padding: 0.75rem;
    }
    .brand {
        font-size: 1rem;
    }
    .main-nav {
        gap: 0.5rem;
    }
    .main-nav a {
        font-size: 0.85rem;
        padding: 0.3rem 0.65rem;
    }
    .user-info span {
        font-size: 0.85rem;
    }
    .panel {
        padding: 1rem;
    }
    .photo-list {
        padding: 1rem;
    }
    .map-controls-header h3 {
        font-size: 1rem;
    }
    .map-controls-header p {
        font-size: 0.8rem;
    }
    .category-filter-list {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    #map {
        height: 320px;
    }
    .photo-detail img {
        max-height: 220px;
    }
    .button-ghost {
        width: 100%;
    }
}
