/* =========================================================================
   RESAEMPLACEMENTS — DESIGN SYSTEM
   A small, documented set of tokens and components shared by every screen.
   Sections: Tokens -> Reset -> Typography -> Layout shell -> Components ->
   Utilities -> Responsive -> Accessibility.
   ========================================================================= */

:root {
    /* ---- Brand (overridable per-environment via inline <style> in <head>) --- */
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-primary-soft: #eef2ff;
    --color-secondary: #0891b2;

    /* ---- Semantic ---- */
    --color-success: #16a34a;
    --color-success-soft: #dcfce7;
    --color-danger: #dc2626;
    --color-danger-soft: #fee2e2;
    --color-warning: #d97706;
    --color-warning-soft: #fef3c7;
    --color-info: #0284c7;
    --color-info-soft: #e0f2fe;

    /* ---- Location status (map legend) ---- */
    --color-available: #16a34a;
    --color-reserved: #dc2626;
    --color-unavailable: #64748b;
    --color-selected: #f97316;

    /* ---- Neutrals / surfaces ---- */
    --color-background: #f6f7fb;
    --color-surface: #ffffff;
    --color-surface-alt: #f1f2f8;
    --color-text: #0f172a;
    --color-text-muted: #64748b;
    --color-text-subtle: #94a3b8;
    --color-border: #e5e7eb;
    --color-border-strong: #d1d5db;

    /* ---- Typography ---- */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text-base: 0.9375rem;
    --text-md: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.75rem;
    --leading-tight: 1.25;
    --leading-normal: 1.5;

    /* ---- Spacing scale ---- */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* ---- Radii ---- */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 999px;

    /* ---- Shadows ---- */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.14);

    /* ---- Motion ---- */
    --transition-fast: 120ms ease;
    --transition-base: 180ms ease;

    /* ---- Layout ---- */
    --sidebar-width: 248px;
    --topbar-height: 64px;
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ========================= Reset ========================= */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--color-text);
    background: var(--color-background);
    -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 var(--space-1); font-weight: 700; letter-spacing: -0.01em; color: var(--color-text); }
h1 { font-size: var(--text-2xl); line-height: var(--leading-tight); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
p { margin: 0 0 var(--space-3); }
ul { margin: 0; padding: 0; }
button { font-family: inherit; }

/* Focus visibility everywhere (keyboard nav) */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

.subtitle { color: var(--color-text-muted); margin: 0 0 var(--space-5); font-size: var(--text-sm); }
.muted { color: var(--color-text-muted); font-size: var(--text-sm); }

/* ========================= Icons ========================= */

.icon {
    width: 1em;
    height: 1em;
    stroke: currentColor;
    fill: none;
    vertical-align: -0.15em;
    flex-shrink: 0;
}
.icon-lg { width: 1.5em; height: 1.5em; }

/* ========================= App shell ========================= */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: #14152b;
    color: #cbd0f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 40;
    transition: transform var(--transition-base);
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-5) var(--space-5);
    color: #fff;
    font-weight: 700;
    font-size: var(--text-lg);
    letter-spacing: -0.01em;
}
.sidebar-brand .icon { color: var(--color-primary); }
.sidebar-env {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0 var(--space-4) var(--space-4);
    padding: var(--space-2) var(--space-3);
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: #fff;
}
.sidebar-env img { width: 24px; height: 24px; border-radius: var(--radius-sm); object-fit: cover; }
.sidebar-env-avatar {
    width: 24px; height: 24px; border-radius: var(--radius-sm);
    background: var(--color-primary); color: #fff; font-size: 0.7rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--space-2) var(--space-3); }
.sidebar-section-label {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7099;
    padding: var(--space-4) var(--space-3) var(--space-2);
    font-weight: 600;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    color: #cbd0f0;
    font-size: var(--text-base);
    font-weight: 500;
    margin-bottom: 2px;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.sidebar-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; text-decoration: none; }
.sidebar-link.active { background: var(--color-primary); color: #fff; }
.sidebar-link .icon { opacity: 0.9; }
.sidebar-footer { padding: var(--space-3); border-top: 1px solid rgba(255, 255, 255, 0.08); }

.main-col { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: var(--topbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    position: sticky;
    top: 0;
    z-index: 30;
    gap: var(--space-4);
}
.topbar-breadcrumb { font-size: var(--text-md); font-weight: 600; color: var(--color-text); display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.topbar-breadcrumb a { color: var(--color-text-muted); font-weight: 500; }
.topbar-breadcrumb .sep { color: var(--color-text-subtle); }
.menu-toggle { display: none; background: none; border: none; padding: var(--space-2); color: var(--color-text); cursor: pointer; border-radius: var(--radius-sm); }

.user-menu { display: flex; align-items: center; gap: var(--space-3); }
.user-menu .avatar {
    width: 34px; height: 34px; border-radius: var(--radius-full);
    background: var(--color-primary-soft); color: var(--color-primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: var(--text-sm);
}
.user-menu-info { display: flex; flex-direction: column; line-height: 1.2; }
.user-menu-info strong { font-size: var(--text-sm); }
.user-menu-info span { font-size: var(--text-xs); color: var(--color-text-muted); }
.user-menu form { margin: 0; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: var(--radius-md);
    background: transparent; border: 1px solid var(--color-border);
    color: var(--color-text-muted); cursor: pointer; transition: all var(--transition-fast);
}
.icon-btn:hover { background: var(--color-surface-alt); color: var(--color-text); }

.content { padding: var(--space-6); flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; }
.content.content-full { max-width: none; }
.sidebar-overlay { display: none; }

/* ========================= Dropdown menu (row actions) ========================= */

.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: var(--space-2);
    z-index: 50;
}
.dropdown-menu.open { display: block; }
.dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    padding: 0.55rem 0.7rem;
    border-radius: var(--radius-sm);
    background: none;
    border: none;
    color: var(--color-text);
    font-size: var(--text-base);
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}
.dropdown-menu .dropdown-item:hover { background: var(--color-surface-alt); text-decoration: none; }
.dropdown-menu .dropdown-item.danger { color: var(--color-danger); }
.dropdown-menu form { margin: 0; }
.dropdown-menu hr { border: none; border-top: 1px solid var(--color-border); margin: var(--space-2) 0; }

/* ========================= Page header ========================= */

.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-4); margin-bottom: var(--space-6); flex-wrap: wrap; }
.page-header h1 { margin-bottom: var(--space-1); }
.page-header .subtitle { margin: 0; }

/* ========================= Buttons ========================= */

.btn, button:not(.icon-btn):not(.tab):not(.sidebar-link) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    font-size: var(--text-base);
    font-weight: 600;
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    background: var(--color-primary);
    color: #fff;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
    line-height: 1.2;
}
.btn:hover, button:not(.icon-btn):not(.tab):not(.sidebar-link):hover { background: var(--color-primary-hover); text-decoration: none; }
.btn:active, button:active { transform: translateY(1px); }
.btn:disabled, button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn.secondary, button.secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border-strong);
}
.btn.secondary:hover, button.secondary:hover { background: var(--color-surface-alt); }

.btn.danger, button.danger { background: var(--color-danger); }
.btn.danger:hover, button.danger:hover { background: #b91c1c; }

.btn.ghost, button.ghost { background: transparent; color: var(--color-text-muted); border-color: transparent; }
.btn.ghost:hover, button.ghost:hover { background: var(--color-surface-alt); color: var(--color-text); }

.btn.small, button.small { padding: 0.4rem 0.75rem; font-size: var(--text-sm); }
.btn.block { width: 100%; }

form.inline { display: inline-block; margin: 0; }

/* ========================= Cards ========================= */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
}
.card.narrow { width: 100%; max-width: 400px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-4); }
.card-header h2 { margin: 0; font-size: var(--text-lg); }

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 20% 20%, #eef0ff 0%, var(--color-background) 55%);
    padding: var(--space-4);
}
.login-brand { display: flex; align-items: center; gap: var(--space-2); justify-content: center; margin-bottom: var(--space-6); font-weight: 700; font-size: var(--text-lg); color: var(--color-text); }
.login-brand .icon { color: var(--color-primary); }

/* ========================= Stat tiles ========================= */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--space-4); margin: 0 0 var(--space-6); }
.stat-tile {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.stat-tile-top { display: flex; align-items: center; justify-content: space-between; }
.stat-tile-icon {
    width: 38px; height: 38px; border-radius: var(--radius-md);
    background: var(--color-primary-soft); color: var(--color-primary);
    display: flex; align-items: center; justify-content: center;
}
.stat-tile .value { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.02em; }
.stat-tile .label { color: var(--color-text-muted); font-size: var(--text-sm); }

.occupancy-card { display: flex; align-items: center; gap: var(--space-6); flex-wrap: wrap; }
.occupancy-ring { flex-shrink: 0; }
.occupancy-legend { display: flex; flex-direction: column; gap: var(--space-2); font-size: var(--text-sm); }
.occupancy-legend .dot { width: 10px; height: 10px; border-radius: var(--radius-full); display: inline-block; margin-right: var(--space-2); }

/* ========================= Section headings ========================= */

.section-heading { display: flex; align-items: center; justify-content: space-between; margin: var(--space-8) 0 var(--space-4); }
.section-heading h2 { margin: 0; }

/* ========================= Tables ========================= */

.table-toolbar { display: flex; gap: var(--space-3); margin-bottom: var(--space-4); flex-wrap: wrap; align-items: center; }
.search-input { position: relative; flex: 1; min-width: 220px; max-width: 340px; }
.search-input .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--color-text-subtle); }
.search-input input { padding-left: 2.25rem; margin-bottom: 0; }

.table-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: var(--space-3) var(--space-5); text-align: left; font-size: var(--text-base); border-bottom: 1px solid var(--color-border); }
th { background: var(--color-surface-alt); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--color-surface-alt); }
.actions-cell { display: flex; gap: var(--space-2); flex-wrap: nowrap; justify-content: flex-end; white-space: nowrap; }
td.actions-cell { justify-content: flex-end; }
th:last-child, td:last-child { text-align: right; }

/* ========================= Badges ========================= */

.badge { display: inline-flex; align-items: center; gap: var(--space-1); padding: 0.2rem 0.6rem; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: 700; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: var(--radius-full); background: currentColor; }
.badge-active, .badge-open { background: var(--color-success-soft); color: #15803d; }
.badge-inactive, .badge-closed { background: var(--color-danger-soft); color: #b91c1c; }
.badge-draft, .badge-archived { background: var(--color-surface-alt); color: var(--color-text-muted); }

/* ========================= Forms ========================= */

label { display: block; font-size: var(--text-sm); font-weight: 600; margin-bottom: var(--space-1); color: var(--color-text); }
.field-hint { font-size: var(--text-xs); color: var(--color-text-muted); margin: -0.5rem 0 var(--space-3); }
.required-mark { color: var(--color-danger); }

input[type="email"], input[type="password"], input[type="text"], input[type="number"],
input[type="date"], input[type="tel"], input[type="file"], textarea, select {
    width: 100%;
    padding: 0.62rem 0.8rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    font-size: var(--text-base);
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}
input.has-error, textarea.has-error, select.has-error { border-color: var(--color-danger); }
textarea { resize: vertical; min-height: 4.5rem; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.7rem center; padding-right: 2.2rem; }

.field-error { color: var(--color-danger); font-size: var(--text-xs); margin: -0.75rem 0 var(--space-3); display: flex; align-items: center; gap: var(--space-1); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space-5); }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: var(--space-3); margin-top: var(--space-2); align-items: center; }

/* ========================= Alerts (page-level, non-toast) ========================= */

.alert { display: flex; align-items: flex-start; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); margin-bottom: var(--space-4); font-size: var(--text-base); }
.alert .icon { margin-top: 0.15em; flex-shrink: 0; }
.alert-error { background: var(--color-danger-soft); color: #991b1b; }
.alert-success { background: var(--color-success-soft); color: #166534; }
.alert-info { background: var(--color-info-soft); color: #075985; }

/* ========================= Empty states ========================= */

.empty-state { text-align: center; padding: var(--space-12) var(--space-6); }
.empty-state .icon-wrap {
    width: 56px; height: 56px; border-radius: var(--radius-full);
    background: var(--color-surface-alt); color: var(--color-text-subtle);
    display: flex; align-items: center; justify-content: center; margin: 0 auto var(--space-4);
}
.empty-state h3 { margin-bottom: var(--space-2); }
.empty-state p { color: var(--color-text-muted); max-width: 380px; margin: 0 auto var(--space-5); }

/* ========================= Toasts ========================= */

.toast-stack { position: fixed; top: var(--space-5); right: var(--space-5); z-index: 1000; display: flex; flex-direction: column; gap: var(--space-2); max-width: min(360px, calc(100vw - 2rem)); }
.toast {
    background: var(--color-text);
    color: #fff;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    font-size: var(--text-base);
    animation: toast-in var(--transition-base);
}
.toast.success { background: #14532d; }
.toast.error { background: #7f1d1d; }
.toast .icon { margin-top: 0.15em; flex-shrink: 0; }
.toast-close { margin-left: auto; background: none; border: none; color: rgba(255, 255, 255, 0.7); cursor: pointer; padding: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* ========================= Tabs (used sparingly) ========================= */

.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-5); }
.tab { background: none; border: none; padding: var(--space-3) var(--space-4); font-weight: 600; color: var(--color-text-muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--color-primary); border-color: var(--color-primary); }

/* ========================= Map picker (map create/edit) ========================= */

.map-picker-wrap { position: relative; height: 420px; border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: var(--space-4); }
.map-picker-wrap .leaflet-container { height: 100%; width: 100%; }
.map-picker-pin {
    position: absolute; top: 50%; left: 50%;
    width: 18px; height: 18px; margin: -9px 0 0 -9px;
    border-radius: 50%; background: var(--color-primary); border: 3px solid white;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 2px 5px rgba(0, 0, 0, 0.4);
    pointer-events: none; z-index: 1000;
}
.map-picker-coords { display: flex; gap: var(--space-4); align-items: flex-end; flex-wrap: wrap; }
.map-picker-coords > div { flex: 1; min-width: 120px; }
.map-picker-coords button { margin-bottom: var(--space-4); }

/* ========================= Location editor ========================= */

.editor-layout { display: flex; gap: var(--space-4); height: calc(100vh - var(--topbar-height) - var(--space-6) * 2 - 3rem); min-height: 1400px; }
.editor-map-col { flex: 1; position: relative; border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
#location-map { height: 100%; width: 100%; }
.editor-side-col { width: 340px; flex-shrink: 0; display: flex; flex-direction: column; gap: var(--space-4); overflow-y: auto; }
.loc-panel-body .form-grid { grid-template-columns: 1fr; }
.editor-toolbar { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.drawing-hint {
    position: absolute; top: var(--space-3); left: 50%; transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.92); color: white; padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md); font-size: var(--text-sm); z-index: 1000; display: none;
    max-width: 90%; text-align: center; box-shadow: var(--shadow-md);
}
#location-list { list-style: none; margin: 0; padding: 0; max-height: 200px; overflow-y: auto; border: 1px solid var(--color-border); border-radius: var(--radius-md); }
#location-list li { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-border); cursor: pointer; font-size: var(--text-base); display: flex; align-items: center; gap: var(--space-2); }
#location-list li:last-child { border-bottom: none; }
#location-list li:hover { background: var(--color-surface-alt); }
#location-list li .status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
#location-list li .location-checkbox { flex-shrink: 0; margin: 0; width: auto; }
#location-list li .location-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-2); }
.list-header-row label { margin: 0; }
.select-all-label { display: flex; align-items: center; gap: var(--space-1); font-size: var(--text-sm); font-weight: 500; color: var(--color-text-muted); cursor: pointer; }
.select-all-label input { width: auto; margin: 0; }
.bulk-actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    background: var(--color-primary-soft);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    margin-top: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-primary-hover);
}
.bulk-actions-bar .bulk-actions-buttons { display: flex; gap: var(--space-2); }
.readonly-metrics { display: flex; gap: var(--space-5); font-size: var(--text-sm); color: var(--color-text-muted); background: var(--color-surface-alt); border-radius: var(--radius-md); padding: var(--space-3); margin: 0 0 var(--space-4); }
.readonly-metrics strong { color: var(--color-text); }

/* Location edit panel: fields on the left, primary actions pinned as an icon
   column on the right so Save/Duplicate/Delete/Cancel stay visible without
   scrolling past a long (rectangle or polygon) form. */
#loc-panel.card { padding: var(--space-4); display: flex; gap: var(--space-3); align-items: flex-start; }
.loc-panel-body { flex: 1; min-width: 0; }
.loc-panel-actions { display: flex; flex-direction: column; gap: var(--space-2); flex-shrink: 0; position: sticky; top: var(--space-4); }
.loc-panel-actions .icon-btn { width: 38px; height: 38px; }
.loc-panel-actions .action-save { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.loc-panel-actions .action-save:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
.loc-panel-actions .action-delete { background: var(--color-danger); border-color: var(--color-danger); color: #fff; }
.loc-panel-actions .action-delete:hover { background: #b91c1c; border-color: #b91c1c; }
.loc-panel-actions .action-duplicate:hover { color: var(--color-primary); border-color: var(--color-primary); }
.loc-panel-actions .action-cancel:hover { color: var(--color-danger); border-color: var(--color-danger); }
.leaflet-tooltip.location-label {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
    font-weight: 700;
    font-size: 0.8rem;
    color: #1f2937;
    text-shadow: 0 0 3px white, 0 0 3px white, 0 0 3px white;
}
.leaflet-tooltip.location-label::before { display: none; }

.edit-handle { border-radius: 3px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); cursor: pointer; }
.handle-corner { width: 12px !important; height: 12px !important; background: white; border: 2px solid var(--color-primary); border-radius: 2px; margin: -6px 0 0 -6px; }
.handle-vertex { width: 12px !important; height: 12px !important; background: white; border: 2px solid var(--color-primary); border-radius: 50%; margin: -6px 0 0 -6px; }
.handle-move { width: 16px !important; height: 16px !important; background: var(--color-selected); border: 2px solid white; border-radius: 50%; margin: -8px 0 0 -8px; cursor: move; }
.handle-rotate { width: 16px !important; height: 16px !important; background: #8b5cf6; border: 2px solid white; border-radius: 50%; margin: -8px 0 0 -8px; cursor: grab; }

.legend { display: flex; gap: var(--space-4); flex-wrap: wrap; font-size: var(--text-sm); color: var(--color-text-muted); }
.legend span { display: inline-flex; align-items: center; gap: var(--space-2); }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; }

/* ========================= Public reservation page ========================= */

.public-page { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.public-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-3) var(--space-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
    z-index: 20;
    row-gap: var(--space-2);
}
.public-header-info { min-width: 0; }
.public-header-assoc { font-size: var(--text-sm); color: var(--color-text-muted); font-weight: 600; display: flex; align-items: center; gap: var(--space-2); }
.public-header-event { font-size: var(--text-lg); font-weight: 700; margin: 0.1rem 0 0; }
.public-header-dates { font-size: var(--text-sm); color: var(--color-text-muted); margin: 0; }
.public-header-right { display: flex; align-items: center; gap: var(--space-5); flex-wrap: wrap; }
.public-header-stats { display: flex; gap: var(--space-4); font-size: var(--text-sm); white-space: nowrap; }
.public-header-stats strong { color: var(--color-text); font-size: var(--text-md); display: block; }
.public-map-wrap { flex: 1; position: relative; min-height: 0; }
#public-map { height: 100%; width: 100%; }
.public-map-wrap .location-label { font-size: 0.85rem; }

@media (max-width: 640px) {
    .public-header { padding: var(--space-3) var(--space-4); }
    .public-header-right { width: 100%; justify-content: space-between; }
}

/* ========================= Modal ========================= */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: var(--space-4);
    animation: modal-fade-in var(--transition-base);
}
.modal-overlay[hidden] { display: none; }
.modal {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    padding: var(--space-6);
    animation: modal-pop-in var(--transition-base);
}
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-1); }
.modal-header h2 { margin: 0; }
.modal-close { background: none; border: none; color: var(--color-text-muted); cursor: pointer; padding: var(--space-1); border-radius: var(--radius-sm); flex-shrink: 0; }
.modal-close:hover { color: var(--color-text); background: var(--color-surface-alt); }
.modal-subtitle { color: var(--color-text-muted); font-size: var(--text-sm); margin: 0 0 var(--space-4); }
.modal-success { text-align: center; padding: var(--space-4) 0; }
.modal-success .icon-wrap { width: 64px; height: 64px; border-radius: 50%; background: var(--color-success-soft); color: var(--color-success); display: flex; align-items: center; justify-content: center; margin: 0 auto var(--space-4); }
.modal-success h2 { margin-bottom: var(--space-2); }
.modal-success p { color: var(--color-text-muted); }
@keyframes modal-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop-in { from { opacity: 0; transform: scale(0.96) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* ========================= Utilities ========================= */

.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.mt-0 { margin-top: 0; }
.text-right { text-align: right; }
.skeleton { background: linear-gradient(90deg, var(--color-surface-alt) 25%, #e9eaf3 37%, var(--color-surface-alt) 63%); background-size: 400% 100%; animation: skeleton-loading 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ========================= Responsive ========================= */

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .main-col { margin-left: 0; }
    .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .sidebar-overlay.open { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 35; }
    .content { padding: var(--space-4); }
    .form-grid { grid-template-columns: 1fr; }
    .editor-layout { flex-direction: column; height: auto; }
    .editor-map-col { flex: 0 0 60vh; height: 60vh; }
    .editor-side-col { width: 100%; }
    .user-menu-info { display: none; }
    .topbar-breadcrumb { overflow: hidden; }
    .topbar-breadcrumb > *:not(:last-child) { display: none; }
    .topbar-breadcrumb > *:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-width: 640px) {
    table, thead, tbody, th, td, tr { display: block; }
    thead { display: none; }
    .table-card table { border: none; }
    tbody tr { border-bottom: 1px solid var(--color-border); padding: var(--space-3) var(--space-4); }
    tbody tr:last-child { border-bottom: none; }
    td { border: none; padding: var(--space-1) 0; display: flex; justify-content: space-between; gap: var(--space-3); text-align: right; }
    td::before { content: attr(data-label); font-weight: 600; color: var(--color-text-muted); font-size: var(--text-sm); text-align: left; }
    td.actions-cell { justify-content: flex-start; padding-top: var(--space-2); }
    td.actions-cell::before { display: none; }
    .page-header { flex-direction: column; }
    .page-header .btn { width: 100%; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
}
