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

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    color: #1a1a1a;
    background: #f8f8f6;
}

/* ─── Navbar ─── */

.navbar {
    background: #2c5f2e;
    padding: 0 1.5rem;
    height: 52px;
    display: flex;
    align-items: center;
}

.nav-brand {
    color: #fff;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
    margin-left: 2rem;
}

.nav-auth {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    margin-left: auto;
}

.nav-username {
    color: rgba(255,255,255,0.65);
    font-size: 0.82rem;
    padding: 0.25rem 0.5rem;
}

.nav-link--btn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.nav-link--register {
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
    color: #fff !important;
}

.nav-link--register:hover {
    background: rgba(255,255,255,0.25) !important;
}

.nav-link {
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
}

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

.main-content {
    height: calc(100vh - 52px);
}

/* ─── Flash messages ─── */

.flash-messages {
    position: relative;
    z-index: 100;
}

.flash {
    padding: 0.65rem 1.5rem;
    font-size: 0.88rem;
    border-bottom: 1px solid transparent;
}

.flash--success {
    background: #eef5ee;
    color: #2c5f2e;
    border-color: #c3dcc4;
}

.flash--error {
    background: #fff3f3;
    color: #c0392b;
    border-color: #f5c6c6;
}

/* ─── Auth pages (login / register) ─── */

.auth-page {
    display: flex;
    justify-content: center;
    padding: 3rem 1.5rem;
}

.auth-card {
    background: #fff;
    border: 1px solid #e2e2da;
    border-radius: 8px;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}

.auth-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 1.5rem;
    color: #111;
}

.auth-notice {
    background: #eef5ee;
    border: 1px solid #c3dcc4;
    border-radius: 5px;
    color: #2c5f2e;
    font-size: 0.82rem;
    line-height: 1.55;
    padding: 0.6rem 0.8rem;
    margin-bottom: 1.25rem;
}

.auth-error {
    background: #fff3f3;
    border: 1px solid #f5c6c6;
    border-radius: 5px;
    color: #c0392b;
    font-size: 0.82rem;
    padding: 0.6rem 0.8rem;
    margin-bottom: 1rem;
}

.auth-field {
    margin-bottom: 1rem;
}

.auth-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 0.3rem;
}

.auth-field input[type="text"],
.auth-field input[type="email"],
.auth-field input[type="password"] {
    width: 100%;
    padding: 0.48rem 0.65rem;
    border: 1.5px solid #d4d4cc;
    border-radius: 5px;
    font-size: 0.93rem;
    font-family: inherit;
    color: #222;
}

.auth-field input:focus {
    outline: none;
    border-color: #2c5f2e;
}

.field-error {
    color: #c0392b;
    font-size: 0.78rem;
    margin-top: 0.25rem;
}

.field-help {
    color: #aaa;
    font-size: 0.75rem;
    margin-top: 0.2rem;
}

.field-optional {
    font-weight: 400;
    color: #aaa;
    font-size: 0.75rem;
}

.auth-btn {
    width: 100%;
    background: #2c5f2e;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 0.6rem;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    margin-top: 0.25rem;
}

.auth-btn:hover {
    background: #234d24;
}

.auth-switch {
    text-align: center;
    margin: 1.1rem 0 0;
    font-size: 0.85rem;
    color: #666;
}

.auth-switch a {
    color: #2c5f2e;
    font-weight: 600;
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* ─── Map page layout ─── */

.page-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Filter bar */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem 1.25rem;
    padding: 0.65rem 1.25rem;
    background: #fff;
    border-bottom: 1px solid #e0e0d8;
    flex-shrink: 0;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.28rem;
}

.filter-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #999;
}

.filter-divider {
    width: 1px;
    height: 32px;
    background: #e0e0d8;
    align-self: flex-end;
    margin-bottom: 1px;
}

/* Chip toggles */

.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.28rem;
}

.chip {
    cursor: pointer;
}

.chip input {
    display: none;
}

.chip span {
    display: inline-block;
    padding: 0.22rem 0.6rem;
    border: 1.5px solid #d4d4cc;
    border-radius: 100px;
    font-size: 0.78rem;
    font-weight: 500;
    color: #555;
    background: #fff;
    user-select: none;
    transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.chip span:hover {
    border-color: #2c5f2e;
    color: #2c5f2e;
}

.chip input:checked + span {
    background: #2c5f2e;
    color: #fff;
    border-color: #2c5f2e;
}

.chip input:checked + span:hover {
    background: #234d24;
    border-color: #234d24;
}

/* Date / time pair inputs */

.input-pair {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.input-pair input[type="date"],
.input-pair input[type="time"] {
    padding: 0.24rem 0.4rem;
    border: 1.5px solid #d4d4cc;
    border-radius: 5px;
    font-size: 0.82rem;
    font-family: inherit;
    color: #333;
}

.pair-sep {
    color: #bbb;
    font-size: 0.85rem;
}

.filter-bar-actions {
    display: flex;
    align-items: flex-end;
    gap: 0.4rem;
    margin-left: auto;
}

.btn-apply {
    background: #2c5f2e;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 0.38rem 1.1rem;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.btn-apply:hover {
    background: #234d24;
}

.btn-advanced {
    background: #fff;
    color: #555;
    border: 1.5px solid #d4d4cc;
    border-radius: 5px;
    padding: 0.38rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.btn-advanced:hover {
    border-color: #2c5f2e;
    color: #2c5f2e;
}

.btn-advanced.is-active {
    background: #eef5ee;
    border-color: #2c5f2e;
    color: #2c5f2e;
}

.advanced-arrow {
    font-size: 0.65rem;
    transition: transform 0.15s;
    display: inline-block;
}

.btn-advanced.is-active .advanced-arrow {
    transform: rotate(180deg);
}

/* Advanced panel */

.advanced-panel {
    display: none;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem 1.25rem;
    padding: 0.65rem 1.25rem;
    background: #f8f8f4;
    border-bottom: 1px solid #e0e0d8;
    flex-shrink: 0;
}

.advanced-panel.is-open {
    display: flex;
}

.advanced-divider--sources {
    background: #d0d0c8;
}

/* Map */

#map {
    flex: 1;
    min-height: 0;
}

.page-layout.map-hidden #map {
    display: none;
}

.page-layout.map-hidden .event-list-section {
    flex: 1;
    height: auto;
    max-height: none;
}

/* Event list below map */

.event-list-section {
    height: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-top: 2px solid #e0e0d8;
    background: #fff;
}

.list-header {
    padding: 0.42rem 1.25rem;
    background: #f4f4f0;
    border-bottom: 1px solid #e8e8e0;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #777;
    flex-shrink: 0;
}

#event-list {
    overflow-y: auto;
    flex: 1;
}

.event-row {
    display: block;
    padding: 0.52rem 1.25rem;
    border-bottom: 1px solid #f0f0ea;
    text-decoration: none;
    color: inherit;
}

.event-row:hover {
    background: #f8f8f4;
}

.event-row-main {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
}

.event-row-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.event-row-date {
    font-size: 0.78rem;
    color: #555;
    white-space: nowrap;
    flex-shrink: 0;
}

.event-row-sub {
    display: flex;
    gap: 0.6rem;
    margin-top: 0.08rem;
}

.event-row-loc {
    font-size: 0.76rem;
    color: #666;
}

.event-row-meta {
    font-size: 0.76rem;
    color: #999;
}

.list-empty {
    padding: 1rem 1.25rem;
    font-size: 0.85rem;
    color: #999;
    margin: 0;
}

/* ─── Custom map markers ─── */

.marker-dot {
    width: 14px;
    height: 14px;
    background: #2c5f2e;
    border: 2.5px solid #fff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}

.marker-location {
    width: 22px;
    height: 22px;
    background: #1565c0;
    border: 2.5px solid #fff;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}

.marker-count {
    width: 30px;
    height: 30px;
    background: #2c5f2e;
    color: #fff;
    border: 2.5px solid #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}

/* ─── Leaflet popup ─── */

.popup {
    min-width: 190px;
    max-width: 270px;
}

.popup-title {
    display: block;
    font-size: 0.9rem;
    line-height: 1.35;
    margin-bottom: 0.35rem;
}

.popup-meta {
    font-size: 0.8rem;
    color: #444;
    margin: 0.12rem 0;
}

.popup-link {
    display: inline-block;
    margin-top: 0.55rem;
    font-size: 0.82rem;
    color: #2c5f2e;
    font-weight: 600;
    text-decoration: none;
}

.popup-link:hover {
    text-decoration: underline;
}

.popup-link--secondary {
    color: #555;
    font-weight: 500;
}

.popup-links {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-top: 0.55rem;
}

.popup-category {
    color: #1565c0;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Location chip — blue accent when checked */
.chip--location input:checked + span {
    background: #1565c0;
    border-color: #1565c0;
}

.chip--location span:hover {
    border-color: #1565c0;
    color: #1565c0;
}

.chip--location input:checked + span:hover {
    background: #0d47a1;
    border-color: #0d47a1;
}

.popup-event-count {
    font-size: 0.75rem;
    color: #888;
    margin: 0.1rem 0 0.5rem;
}

.popup-event-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.popup-event-link {
    display: flex;
    flex-direction: column;
    padding: 0.32rem 0.45rem;
    border-radius: 4px;
    background: #f6f6f2;
    text-decoration: none;
    color: inherit;
}

.popup-event-link:hover {
    background: #eef5ee;
}

.popup-event-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: #111;
    line-height: 1.3;
}

.popup-event-date {
    font-size: 0.74rem;
    color: #666;
    margin-top: 0.08rem;
}

/* ─── Staff nav link ─── */

.nav-link--staff {
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
    color: #fff !important;
}

.nav-link--staff:hover {
    background: rgba(255,255,255,0.25) !important;
}

/* ─── Scrape / Add Event page ─── */

.scrape-container {
    max-width: 820px;
    margin: 2rem auto;
    padding: 0 1.5rem 3rem;
}

.scrape-container h1 {
    font-size: 1.7rem;
    font-weight: 700;
    margin: 0 0 0.3rem;
    color: #111;
}

.scrape-intro {
    color: #666;
    font-size: 0.93rem;
    margin: 0 0 1.5rem;
}

.scrape-url-form {
    margin-bottom: 1.25rem;
}

.url-input-row {
    display: flex;
    gap: 0.6rem;
}

.url-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1.5px solid #d4d4cc;
    border-radius: 6px;
    font-size: 0.93rem;
    font-family: inherit;
}

.btn-fetch {
    background: #fff;
    border: 1.5px solid #2c5f2e;
    color: #2c5f2e;
    border-radius: 6px;
    padding: 0.5rem 1.1rem;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.btn-fetch:hover {
    background: #eef5ee;
}

.scrape-error {
    background: #fff3f3;
    border: 1px solid #f5c6c6;
    border-radius: 6px;
    color: #c0392b;
    padding: 0.75rem 1rem;
    font-size: 0.88rem;
    margin-bottom: 1.25rem;
}

.event-edit-form {
    border: 1px solid #e2e2da;
    border-radius: 8px;
    overflow: hidden;
}

.form-section {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #f0f0ea;
}

.form-section:last-child {
    border-bottom: none;
}

.form-section h2 {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #999;
    margin: 0 0 1rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.form-field--full {
    grid-column: 1 / -1;
}

.form-field label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #555;
}

.form-field .hint {
    font-weight: 400;
    color: #aaa;
    font-size: 0.75rem;
}

.required {
    color: #c0392b;
}

.form-field input[type="text"],
.form-field input[type="url"],
.form-field input[type="date"],
.form-field input[type="time"],
.form-field input[type="number"],
.form-field select,
.form-field textarea {
    padding: 0.4rem 0.55rem;
    border: 1.5px solid #d4d4cc;
    border-radius: 5px;
    font-size: 0.88rem;
    font-family: inherit;
    color: #222;
}

.form-field textarea {
    resize: vertical;
}

.radio-group {
    display: flex;
    gap: 1rem;
    padding-top: 0.2rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.88rem;
    cursor: pointer;
    color: #444;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.88rem;
    cursor: pointer;
    color: #444;
}

.form-actions {
    padding: 1.25rem 1.5rem;
    background: #f8f8f4;
    border-top: 1px solid #e8e8e0;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-save {
    background: #2c5f2e;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.55rem 1.5rem;
    font-size: 0.93rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

.btn-save:hover {
    background: #234d24;
}

.form-actions-hint {
    font-size: 0.8rem;
    color: #999;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .url-input-row {
        flex-direction: column;
    }
}

/* ─── Sources page ─── */

.sources-container {
    max-width: 760px;
    margin: 2rem auto;
    padding: 0 1.5rem 3rem;
}

.sources-header h1 {
    font-size: 1.7rem;
    font-weight: 700;
    margin: 0 0 0.4rem;
    color: #111;
}

.sources-header p {
    margin: 0 0 2rem;
    color: #666;
    font-size: 0.95rem;
}

.source-card {
    background: #fff;
    border: 1px solid #e2e2da;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.source-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f0f0ea;
}

.source-name {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 0.2rem;
    color: #111;
}

.source-meta {
    font-size: 0.8rem;
    color: #888;
}

.branch-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.branch-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.55rem 1.25rem;
    border-bottom: 1px solid #f4f4f0;
    font-size: 0.9rem;
}

.branch-item:last-child {
    border-bottom: none;
}

.branch-item--location {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.85rem 1.25rem;
}

@media (min-width: 600px) {
    .branch-item--location {
        flex-direction: row;
        align-items: center;
    }
}

.loc-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    flex: 1;
    min-width: 0;
}

.loc-category {
    font-size: 0.72rem;
    font-weight: 600;
    color: #1565c0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.loc-description {
    font-size: 0.82rem;
    color: #666;
}

.loc-links {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    align-items: flex-end;
    flex-shrink: 0;
}

.loc-link {
    font-size: 0.82rem;
    text-decoration: none;
    white-space: nowrap;
}

.loc-link--primary {
    color: #2c5f2e;
    font-weight: 600;
}

.loc-link--primary:hover,
.loc-link:hover {
    text-decoration: underline;
}

.loc-link:not(.loc-link--primary) {
    color: #888;
}

.branch-name {
    font-weight: 600;
    color: #222;
    white-space: nowrap;
}

.branch-address {
    color: #777;
    font-size: 0.82rem;
    text-align: right;
}

.sources-empty {
    color: #888;
    font-size: 0.95rem;
}

/* ─── Event detail page ─── */

.btn-primary {
    display: inline-block;
    background: #2c5f2e;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}

.btn-primary:hover {
    background: #234d24;
}

.detail-container {
    max-width: 860px;
    margin: 2rem auto;
    padding: 0 1.5rem 3rem;
}

.back-link {
    display: inline-block;
    margin-bottom: 1.25rem;
    color: #2c5f2e;
    text-decoration: none;
    font-size: 0.88rem;
}

.back-link:hover {
    text-decoration: underline;
}

.detail-container h1 {
    font-size: 1.7rem;
    font-weight: 700;
    margin: 0 0 1.5rem;
    line-height: 1.25;
    color: #111;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 2rem;
    align-items: start;
}

.event-description {
    font-size: 1rem;
    line-height: 1.65;
    color: #333;
    margin: 0 0 1rem;
}

.event-long-description {
    font-size: 0.93rem;
    line-height: 1.7;
    color: #444;
}

.meta-card {
    background: #fff;
    border: 1px solid #e2e2da;
    border-radius: 6px;
    padding: 0.9rem 1rem;
    margin-bottom: 0.7rem;
}

.meta-card h3 {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #999;
    margin: 0 0 0.4rem;
}

.meta-card p {
    margin: 0;
    font-size: 0.93rem;
    line-height: 1.5;
}

.address {
    color: #555;
    font-size: 0.85rem !important;
    margin-top: 0.3rem !important;
}

.tag-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.tag-list li {
    background: #eef5ee;
    color: #2c5f2e;
    padding: 0.18rem 0.6rem;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 500;
}

.source-link {
    font-size: 0.85rem;
    color: #2c5f2e;
    text-decoration: none;
}

.source-link:hover {
    text-decoration: underline;
}

@media (max-width: 720px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .detail-container {
        margin: 1rem auto;
    }

    .filter-divider {
        display: none;
    }
}
