:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --text: #1f2933;
    --muted: #64748b;
    --line: #e5e7eb;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --shadow: 0 10px 28px rgba(15, 23, 42, .10);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
button, input, select { font: inherit; }
button, .button { border: 1px solid var(--line); background: #fff; color: var(--text); padding: 9px 10px; border-radius: 10px; cursor: pointer; text-decoration: none; text-align: center; transition: .12s ease; }
button:hover, .button:hover { background: #f8fafc; transform: translateY(-1px); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
button.primary { background: var(--primary); color: white; border-color: var(--primary); font-weight: 700; }
button.primary:hover { background: var(--primary-dark); }
button.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
button.danger-soft { background: var(--danger-soft); color: #991b1b; border-color: #fecaca; }
.app-shell { display: flex; height: 100%; overflow: hidden; }
.sidebar { width: 380px; min-width: 320px; max-width: 430px; height: 100%; overflow: auto; padding: 14px; background: #eef2f7; border-right: 1px solid var(--line); }
.brand { padding: 15px 14px 12px; margin-bottom: 12px; background: linear-gradient(135deg, #172554, #1d4ed8); color: white; border-radius: 18px; box-shadow: var(--shadow); }
.brand-title { font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.brand-sub { margin-top: 3px; font-size: 12px; opacity: .85; }
.panel { background: var(--panel); padding: 14px; border: 1px solid var(--line); border-radius: 18px; margin-bottom: 12px; box-shadow: 0 4px 16px rgba(15, 23, 42, .05); }
.panel h2 { margin: 0 0 12px; font-size: 16px; }
.upload-form { display: grid; gap: 9px; }
input[type="file"], input[type="number"], input[type="color"], select { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fff; }
input[type="number"] { padding: 6px 8px; }
.row { display: flex; align-items: center; }
.gap { gap: 10px; }
.radio, .checks label { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.layer-checks { grid-template-columns: repeat(3, 1fr); }
.field-label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.button-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.button-grid.two { grid-template-columns: repeat(2, 1fr); }
.summary { color: var(--muted); font-size: 12px; line-height: 1.45; margin-top: 10px; white-space: pre-line; }
.hint { color: var(--muted); font-size: 12px; margin-top: 10px; }
.small-controls label { flex: 1; color: var(--muted); font-size: 12px; }
.grade-controls { display: grid; gap: 8px; margin-bottom: 10px; }
.grade-row { display: grid; grid-template-columns: 36px 48px 1fr; align-items: center; gap: 8px; font-size: 13px; }
.grade-row .badge { display: inline-flex; width: 28px; height: 28px; border-radius: 50%; align-items: center; justify-content: center; color: #fff; font-weight: 800; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.progress-wrap { margin-top: 10px; }
.progress { height: 10px; border-radius: 999px; background: #e5e7eb; overflow: hidden; }
.progress > div { height: 100%; width: 0%; background: linear-gradient(90deg, #2563eb, #22c55e); transition: width .2s ease; }
.map-wrap { flex: 1; position: relative; min-width: 0; height: 100%; }
#map { position: absolute; inset: 46px 0 0 0; background: #dbeafe; cursor: default; }
.topbar { position: absolute; top: 0; left: 0; right: 0; height: 46px; background: rgba(255,255,255,.92); backdrop-filter: blur(10px); z-index: 500; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 12px; }
#statusText { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; gap: 8px; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px); background: #111827; color: white; padding: 11px 14px; border-radius: 12px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; z-index: 2000; transition: .18s ease; max-width: min(680px, calc(100vw - 28px)); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.point-label {
    pointer-events: none;
    width: 220px !important;
    height: auto !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
}
.point-label .name {
    display: inline-block;
    max-width: 212px;
    min-width: 28px;
    background: rgba(255, 255, 255, .86);
    border: 1px solid rgba(15, 23, 42, .16);
    border-radius: 8px;
    padding: 3px 7px 4px;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: keep-all;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.25;
    color: #111827;
    overflow: hidden;
    max-height: calc(1.25em * 3 + 7px);
    box-shadow: 0 2px 7px rgba(15, 23, 42, .18);
}
.point-label .grade {
    display: inline-block;
    position: static;
    transform: none;
    color: #fff;
    border-radius: 999px;
    padding: 1px 7px 2px;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
    width: auto;
    height: auto;
    box-shadow: 0 2px 5px rgba(0,0,0,.24);
}
.leaflet-container { font-family: inherit; }
.leaflet-control-attribution { font-size: 10px; }
/* 공통 패널 토글: PC/태블릿/모바일 모두 같은 버튼 로직 사용 */
.sidebar { transition: width .2s ease, min-width .2s ease, max-width .2s ease, padding .2s ease, transform .2s ease; }
body.sidebar-closed .sidebar {
    width: 0;
    min-width: 0;
    max-width: 0;
    padding-left: 0;
    padding-right: 0;
    border-right: 0;
    overflow: hidden;
}
body.sidebar-closed .sidebar > * {
    visibility: hidden;
    pointer-events: none;
}
.sidebar-close {
    display: block;
    position: sticky;
    top: 8px;
    margin-left: auto;
    z-index: 1600;
    background: #111827;
    color: #fff;
    border-color: #111827;
    box-shadow: var(--shadow);
}
.mobile-panel-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: max(14px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 1800;
    padding: 11px 14px;
    border-radius: 999px;
    background: #111827;
    color: #fff;
    border: 0;
    box-shadow: var(--shadow);
    font-weight: 800;
}
body.sidebar-open .mobile-panel-toggle { background: #dc2626; }
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .32);
    z-index: 900;
}
#map { cursor: grab; touch-action: none; }
#map.leaflet-drag-target { cursor: grabbing; }
@media (max-width: 900px) {
    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 1000;
        transform: translateX(-100%);
        width: min(92vw, 390px);
        min-width: 0;
        max-width: none;
        padding-top: 10px;
        padding-bottom: calc(86px + env(safe-area-inset-bottom));
        box-shadow: var(--shadow);
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-closed .sidebar {
        width: min(92vw, 390px);
        max-width: none;
        padding-left: 14px;
        padding-right: 14px;
        border-right: 1px solid var(--line);
        transform: translateX(-100%);
    }
    body.sidebar-closed .sidebar > * { visibility: visible; pointer-events: auto; }
    body.sidebar-open .sidebar-backdrop { display: block; }
    .button-grid { grid-template-columns: repeat(2, 1fr); }
    .brand { margin-top: 6px; }
    #map { inset: 46px 0 0 0; }
}


/* v1.4 point list/manual management */
input[type="text"], input[type="search"] {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px;
    background: #fff;
}
.manual-form { display: grid; gap: 9px; }
.manual-form .field-label input { margin-top: 5px; }
.compact-buttons { gap: 6px; }
.compact-buttons button { padding: 8px 7px; font-size: 12px; }
.list-search { margin-bottom: 8px; }
.list-head {
    display: grid;
    grid-template-columns: 64px 70px 82px;
    gap: 6px;
    align-items: center;
    padding: 7px 6px;
    color: var(--muted);
    font-size: 12px;
    border-bottom: 1px solid var(--line);
}
.point-list {
    max-height: 430px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}
.point-row {
    display: grid;
    grid-template-columns: 32px 48px 58px 1fr 42px 42px;
    gap: 6px;
    align-items: center;
    padding: 9px 7px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 12px;
}
.point-row:last-child { border-bottom: 0; }
.point-row.is-hidden { opacity: .52; background: #f8fafc; }
.point-row .point-main { min-width: 0; }
.point-row .point-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.point-row .point-name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.point-row .point-address { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.point-row .mini-grade {
    display: inline-flex;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    text-shadow: 0 1px 2px rgba(0,0,0,.35);
    flex: 0 0 auto;
}
.point-row button { padding: 6px 7px; border-radius: 8px; font-size: 12px; }
.point-row input[type="checkbox"] { width: 18px; height: 18px; }
@media (max-width: 900px) {
    .point-list { max-height: 48vh; }
    .point-row { grid-template-columns: 28px 42px 48px 1fr 38px 38px; gap: 4px; padding: 8px 5px; }
    .point-row button { padding: 6px 4px; font-size: 11px; }
}
