:root {
    --bg: #eef3f5;
    --panel: #ffffff;
    --line: #dce5e9;
    --text: #18252d;
    --muted: #657681;
    --green: #0b6b57;
    --green-dark: #075243;
    --gold: #d49b22;
    --blue: #3178c6;
    --purple: #7664ad;
    --target: #e13d4f;
    --overlap: #e80073;
    --shadow: 0 10px 30px rgba(24, 50, 62, .08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    width: 100%;
    height: 100%;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

button, input { font: inherit; }

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

.topbar {
    height: 70px;
    min-height: 70px;
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    z-index: 1000;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    color: white;
    background: var(--green);
    font-weight: 900;
    letter-spacing: .04em;
}

.brand-title {
    font-weight: 800;
    font-size: 18px;
}

.brand-subtitle {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

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

.workspace {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 350px minmax(0, 1fr);
}

.sidebar {
    overflow-y: auto;
    padding: 14px;
    border-right: 1px solid var(--line);
    background: #f6f9fa;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: 0 4px 18px rgba(25, 51, 63, .035);
}

.panel-title {
    font-size: 12px;
    font-weight: 900;
    color: #52636e;
    text-transform: uppercase;
    letter-spacing: .055em;
    margin-bottom: 12px;
}

.row-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.record-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
}

.field {
    border: 1px solid #e2e9ed;
    background: #f9fbfc;
    border-radius: 10px;
    padding: 9px 10px;
    min-width: 0;
}

.field span,
.field small {
    display: block;
    color: var(--muted);
    font-size: 11px;
}

.field strong {
    display: block;
    margin-top: 3px;
    overflow-wrap: anywhere;
}

.field.target {
    border-color: rgba(225, 61, 79, .35);
    background: rgba(225, 61, 79, .05);
}

.toggle-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.toggle-row strong,
.toggle-row small {
    display: block;
}

.toggle-row small {
    color: var(--muted);
    margin-top: 3px;
    line-height: 1.35;
}

.switch {
    width: 48px;
    height: 27px;
    position: relative;
    flex: 0 0 auto;
}

.switch input { display: none; }

.switch span {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: #bcc9cf;
    transition: .2s;
}

.switch span:after {
    content: "";
    position: absolute;
    width: 21px;
    height: 21px;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    background: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,.18);
    transition: .2s;
}

.switch input:checked + span {
    background: var(--green);
}

.switch input:checked + span:after {
    transform: translateX(21px);
}

.setting-row {
    margin-top: 14px;
}

.setting-row label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 6px;
}

.inline-value {
    display: grid;
    grid-template-columns: 1fr 55px;
    gap: 8px;
    align-items: center;
}

.inline-value span {
    font-size: 12px;
    font-weight: 800;
    text-align: right;
}

.button-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 14px;
}

.btn {
    border: 0;
    border-radius: 10px;
    padding: 10px 13px;
    cursor: pointer;
    font-weight: 800;
    transition: transform .08s ease, opacity .2s ease, background .2s ease;
}

.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn.primary { background: var(--green); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--green-dark); }
.btn.secondary { background: #e8f2ef; color: #075946; }
.btn.ghost { background: #edf2f4; color: #344751; }
.btn.danger-soft { background: #fff0f1; color: #a62433; }

.hint {
    font-size: 12px;
    line-height: 1.45;
    color: var(--muted);
    margin-top: 12px;
    border-left: 3px solid #c7d5db;
    padding-left: 9px;
}

.stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px solid #edf2f4;
    font-size: 13px;
}

.stat-row:last-child { border-bottom: 0; }
.stat-row span { color: var(--muted); }

.badge {
    min-width: 26px;
    height: 24px;
    padding: 0 8px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: #f3e7ee;
    color: #a31256;
}

.overlap-list {
    display: grid;
    gap: 8px;
}

.overlap-card {
    padding: 9px;
    border: 1px solid rgba(232, 0, 115, .22);
    border-radius: 10px;
    background: rgba(232, 0, 115, .045);
    cursor: pointer;
}

.overlap-card strong,
.overlap-card span {
    display: block;
}

.overlap-card span {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.empty {
    color: var(--muted);
    font-size: 12px;
}

.legend > div:not(.panel-title) {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    margin: 7px 0;
}

.swatch {
    width: 23px;
    height: 9px;
    border-radius: 3px;
    display: inline-block;
}

.swatch.mouza { background: rgba(11,107,87,.22); border: 2px dashed var(--green); }
.swatch.khata { background: rgba(212,155,34,.2); border: 2px solid var(--gold); }
.swatch.sibling { background: rgba(49,120,198,.16); border: 2px solid var(--blue); }
.swatch.neighbor { background: rgba(118,100,173,.09); border: 2px dashed var(--purple); }
.swatch.target { background: rgba(225,61,79,.22); border: 2px solid var(--target); }
.swatch.overlap { background: rgba(232,0,115,.48); border: 2px solid var(--overlap); }

.map-area {
    position: relative;
    min-width: 0;
    min-height: 0;
}

#map {
    position: absolute;
    inset: 0;
    background: #dfe8e5;
}

.map-status,
.draw-badge,
.snap-badge {
    position: absolute;
    z-index: 600;
    border-radius: 10px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(7px);
}

.map-status {
    left: 14px;
    bottom: 14px;
    padding: 9px 12px;
    background: rgba(255,255,255,.93);
    color: #41535e;
    font-size: 12px;
}

.draw-badge {
    left: 50%;
    top: 14px;
    transform: translateX(-50%);
    padding: 9px 13px;
    background: rgba(11,107,87,.95);
    color: #fff;
    font-size: 12px;
    font-weight: 900;
}

.snap-badge {
    right: 14px;
    top: 14px;
    padding: 7px 10px;
    background: rgba(212,155,34,.97);
    color: #37270b;
    font-size: 11px;
    font-weight: 950;
    letter-spacing: .08em;
}

.hidden { display: none !important; }

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 9999;
    max-width: 430px;
    padding: 12px 15px;
    border-radius: 11px;
    color: #fff;
    background: #263740;
    box-shadow: 0 12px 35px rgba(0,0,0,.2);
    font-weight: 700;
    font-size: 13px;
}

.leaflet-tooltip.khasra-label {
    background: rgba(255,255,255,.88);
    border: 1px solid rgba(34,57,68,.18);
    color: #20313a;
    box-shadow: none;
    font-weight: 800;
    font-size: 11px;
    padding: 2px 5px;
}

.leaflet-tooltip.khasra-label:before { display: none; }

.vertex-marker {
    width: 13px;
    height: 13px;
    margin-left: -6.5px;
    margin-top: -6.5px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: var(--target);
    box-shadow: 0 1px 5px rgba(0,0,0,.3);
}

.draw-point {
    width: 11px;
    height: 11px;
    margin-left: -5.5px;
    margin-top: -5.5px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: var(--green);
    box-shadow: 0 1px 5px rgba(0,0,0,.25);
}

@media (max-width: 900px) {
    .workspace { grid-template-columns: 300px minmax(0, 1fr); }
    .brand-subtitle { display: none; }
}

@media (max-width: 700px) {
    .topbar { height:auto; min-height:64px; padding:10px; }
    .top-actions .secondary,
    .top-actions .ghost { display:none; }
    .workspace { grid-template-columns: 1fr; grid-template-rows: 45vh 55vh; }
    .sidebar { order: 2; border-right:0; border-top:1px solid var(--line); }
    .map-area { order: 1; }
}
