:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --panel-border: #d9e2ef;
    --text: #172033;
    --muted: #65758b;
    --primary: #1d4ed8;
    --primary-dark: #1e3a8a;
    --danger: #b42318;
    --success: #167647;
    --warning: #b54708;
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.45;
}

a {
    color: var(--primary);
    text-decoration: none;
}

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

.sidebar {
    width: 270px;
    min-height: 100vh;
    background: #111827;
    color: #e5edf8;
    display: flex;
    flex-direction: column;
    padding: 20px;
    position: fixed;
    inset: 0 auto 0 0;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding-bottom: 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #2563eb;
    color: #fff;
    font-weight: 700;
}

.brand strong,
.brand small {
    display: block;
}

.brand small,
.user-box small,
.nav-title {
    color: #a9b7ca;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 22px;
}

.nav a,
.user-box a {
    color: #e5edf8;
    border-radius: 8px;
    padding: 10px 12px;
}

.nav a:hover,
.nav a.active {
    background: rgba(59, 130, 246, 0.22);
    color: #fff;
}

.nav-title {
    margin: 14px 12px 4px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0;
}

.user-box {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.user-box span,
.user-box small {
    display: block;
}

.user-box a {
    display: inline-block;
    margin-top: 10px;
    padding-left: 0;
}

.content {
    width: 100%;
    margin-left: 270px;
    padding: 28px;
}

.content-centered {
    margin-left: 0;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 18px;
}

.auth-panel {
    width: min(460px, 100%);
}

.panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.panel + .panel {
    margin-top: 18px;
}

.subsection {
    border-top: 1px solid var(--panel-border);
    padding-top: 18px;
    margin-top: 18px;
}

.page-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.page-title h1,
.panel h1,
.panel h2 {
    margin: 0;
    line-height: 1.15;
}

.page-title p,
.panel .muted {
    color: var(--muted);
    margin: 6px 0 0;
}

.page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 18px;
}

.metric strong {
    display: block;
    font-size: 32px;
}

.metric span {
    color: var(--muted);
}

label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
}

.field {
    margin-bottom: 14px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    background: #fff;
    font: inherit;
}

input[type="checkbox"] {
    width: auto;
}

input[type="color"] {
    height: 42px;
    padding: 4px;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

select[multiple] {
    min-height: 150px;
}

.help {
    margin-top: 5px;
    color: var(--muted);
    font-size: 13px;
}

.checkbox-line {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    margin-top: 10px;
}

.inline-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.btn,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 9px 14px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.btn:hover,
button:hover {
    background: var(--primary-dark);
    color: #fff;
}

.btn-secondary {
    background: #fff;
    color: var(--primary);
    border-color: #b6c8e6;
}

.btn-secondary:hover {
    background: #eff6ff;
    color: var(--primary-dark);
}

.btn-danger {
    background: var(--danger);
}

.btn-danger:hover {
    background: #7a271a;
}

.btn-small {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 14px;
}

.actions-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    vertical-align: top;
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
}

th {
    color: #475569;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0;
}

.table-wrap {
    overflow-x: auto;
}

.alert {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid;
}

.alert-success {
    background: #ecfdf3;
    color: var(--success);
    border-color: #abefc6;
}

.alert-error {
    background: #fef3f2;
    color: var(--danger);
    border-color: #fecdca;
}

.alert-warning {
    background: #fffaeb;
    color: var(--warning);
    border-color: #fedf89;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 3px 9px;
    background: #e0edff;
    color: #164995;
    font-size: 13px;
    font-weight: 700;
}

.badge-muted {
    background: #eef2f7;
    color: #526071;
}

.photo-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #d7dee8;
    background: #edf2f7;
}

.map {
    width: 100%;
    height: 620px;
    min-height: 420px;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.map-small {
    height: 320px;
}

.leaflet-popup-content {
    min-width: 230px;
}

.popup-photo {
    width: 100%;
    max-height: 180px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 8px;
}

.custom-marker {
    width: 34px;
    height: 34px;
    border-radius: 50% 50% 50% 8px;
    transform: rotate(-45deg);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 800;
    border: 2px solid #fff;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.28);
}

.custom-marker span {
    transform: rotate(45deg);
    display: inline-block;
}

.address-row {
    border: 1px solid #d9e2ef;
    border-radius: 8px;
    padding: 14px;
    background: #fbfdff;
    margin-bottom: 12px;
}

.address-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.empty-state {
    padding: 24px;
    text-align: center;
    color: var(--muted);
}

.search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
}

@media (max-width: 900px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        position: static;
        width: 100%;
        min-height: auto;
    }

    .content {
        margin-left: 0;
        padding: 18px;
    }

    .grid-2,
    .grid-3,
    .inline-fields,
    .search-row {
        grid-template-columns: 1fr;
    }

    .page-title {
        display: block;
    }

    .page-actions {
        justify-content: flex-start;
        margin-top: 12px;
    }

    .map {
        height: 520px;
    }
}
