/* ============================================================
   Scoped Styles — Land Area & Plot Measurement (.lp- prefix)
   ============================================================ */

.lp-calc-wrapper {
    --lp-brand:        var(--color-brand, #f97316);
    --lp-brand-d:      #ea580c;
    --lp-bg:           var(--color-bg-main, #f8fafc);
    --lp-surface:      var(--color-bg-card, #ffffff);
    --lp-border:       var(--color-border, #e2e8f0);
    --lp-text:         var(--color-text-primary, #0f172a);
    --lp-muted:        var(--color-text-secondary, #64748b);
    --lp-radius:       10px;
    --lp-shadow:       0 1px 4px rgba(0,0,0,.07);
    --lp-success:      #16a34a;
    --lp-danger:       #dc2626;

    width: 100%;
    box-sizing: border-box;
    color: var(--lp-text);
}

.lp-calc-wrapper *,
.lp-calc-wrapper *::before,
.lp-calc-wrapper *::after { box-sizing: border-box; }

.lp-calc-wrapper .back-btn { margin-bottom: 16px; }

/* ======================================================
   TABS NAV
   ====================================================== */
.lp-tabs-nav {
    display: inline-flex;
    gap: 4px;
    background: var(--lp-bg);
    border: 1px solid var(--lp-border);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 20px;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
}

.lp-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--lp-muted);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background .18s, color .18s, box-shadow .18s;
}
.lp-tab-btn svg { width: 14px; height: 14px; }
.lp-tab-btn.active {
    background: var(--lp-surface);
    color: var(--lp-brand);
    box-shadow: 0 1px 4px rgba(0,0,0,.1);
}

/* ======================================================
   LAYOUT
   ====================================================== */
.lp-calc-wrapper .calc-layout {
    width: 100%;
    min-width: 0;
}
.lp-calc-wrapper .calc-panel {
    min-width: 0;
    overflow: hidden;
}

.lp-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--lp-muted);
    margin: 22px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--lp-border);
}

/* ======================================================
   GRID & FORM
   ====================================================== */
.lp-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.lp-fg {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lp-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--lp-text);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lp-wrap {
    position: relative;
    display: flex;
    align-items: stretch;
}

.lp-input {
    width: 100%;
    padding: 8px 36px 8px 10px;
    background: var(--lp-bg);
    border: 1px solid var(--lp-border);
    color: var(--lp-text);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 7px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
    appearance: none;
}
.lp-input:focus {
    border-color: var(--lp-brand);
    box-shadow: 0 0 0 3px rgba(249,115,22,.12);
}
.lp-input[type="number"] { padding-right: 36px; }
select.lp-input { padding-right: 28px; cursor: pointer; }

.lp-unit {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--lp-muted);
    pointer-events: none;
}

.lp-arrow {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px; height: 14px;
    pointer-events: none;
    stroke: var(--lp-muted);
    flex-shrink: 0;
}

/* ======================================================
   CARDS & COLLAPSE
   ====================================================== */
.lp-card {
    border: 1px solid var(--lp-border);
    border-radius: var(--lp-radius);
    overflow: hidden;
    margin-bottom: 12px;
    box-shadow: var(--lp-shadow);
    background: var(--lp-surface);
}

.lp-card-head {
    width: 100%;
    padding: 12px 16px;
    background: var(--lp-bg);
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--lp-text);
    transition: background .15s;
    text-align: left;
}
.lp-card-head:hover { background: var(--lp-border); }
.lp-card-head svg {
    width: 16px; height: 16px;
    stroke: var(--lp-muted);
    transition: transform .2s;
}
.lp-card.open .lp-card-head svg { transform: rotate(180deg); }

.lp-card-body {
    display: none;
    padding: 14px;
    border-top: 1px solid var(--lp-border);
}
.lp-card.open .lp-card-body { display: block; }

/* ======================================================
   TABLES
   ====================================================== */
.lp-tbl-wrap {
    overflow-x: auto;
    border: 1px solid var(--lp-border);
    border-radius: 8px;
    margin-bottom: 12px;
    -webkit-overflow-scrolling: touch;
}

.lp-tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    white-space: nowrap;
}
.lp-tbl th, .lp-tbl td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--lp-border);
    text-align: left;
}
.lp-tbl th {
    background: var(--lp-bg);
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--lp-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.lp-tbl tbody tr:hover td { background: rgba(249,115,22,.04); }

.lp-tbl input {
    width: 100%;
    min-width: 60px;
    padding: 4px 6px;
    background: var(--lp-bg);
    border: 1px solid transparent;
    color: var(--lp-text);
    font-size: 0.8rem;
    border-radius: 4px;
    outline: none;
}
.lp-tbl input:focus { border-color: var(--lp-brand); }

/* ======================================================
   BUTTONS
   ====================================================== */
.lp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .15s, box-shadow .15s;
    white-space: nowrap;
}
.lp-btn svg { width: 14px; height: 14px; }
.lp-btn-primary { background: var(--lp-brand); color: #fff; }
.lp-btn-primary:hover { background: var(--lp-brand-d); }
.lp-btn-secondary { background: var(--lp-bg); border-color: var(--lp-border); color: var(--lp-text); }
.lp-btn-secondary:hover { background: var(--lp-border); }
.lp-btn-ghost {
    background: transparent;
    border: 1px dashed var(--lp-brand);
    color: var(--lp-brand);
    width: 100%;
    padding: 6px;
    font-size: 0.8rem;
}
.lp-btn-ghost:hover { background: rgba(249,115,22,.04); }
.lp-btn-del {
    background: transparent;
    border: none;
    color: var(--lp-danger);
    cursor: pointer;
    padding: 2px 4px;
}
.lp-btn-del:hover { background: rgba(220,38,38,.08); border-radius: 4px; }

.lp-actions {
    display: flex;
    gap: 8px;
    margin-top: 18px;
    flex-wrap: wrap;
}
.lp-actions .lp-btn { flex: 1; min-width: 100px; }

/* ======================================================
   RESULTS & KPIS
   ====================================================== */
.lp-res-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--lp-border);
}
.lp-res-header h2 { margin: 0; font-size: 1rem; font-weight: 700; }

.lp-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}
.lp-kpi {
    background: var(--lp-surface);
    border: 1px solid var(--lp-border);
    border-radius: var(--lp-radius);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-shadow: var(--lp-shadow);
}
.lp-kpi.accent { border-left: 4px solid var(--lp-brand); }
.lp-kpi-label { font-size: 0.72rem; font-weight: 600; color: var(--lp-muted); }
.lp-kpi-val   { font-size: 1.3rem; font-weight: 700; color: var(--lp-text); }
.lp-kpi-unit  { font-size: 0.7rem; color: var(--lp-muted); }
.lp-kpi.accent .lp-kpi-val { color: var(--lp-brand); }

/* ======================================================
   VISUAL LAND BOUNDARY PLOTTER CANVAS
   ====================================================== */
.lp-visual-container {
    background: var(--lp-bg);
    border: 2px solid var(--lp-border);
    border-radius: var(--lp-radius);
    padding: 10px;
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}
.lp-canvas {
    background: var(--lp-surface);
    border: 1px solid var(--lp-border);
    border-radius: 6px;
    max-width: 100%;
    box-shadow: var(--lp-shadow);
}

.lp-step {
    background: var(--lp-bg);
    border-left: 3px solid var(--lp-brand);
    padding: 8px 12px;
    border-radius: 0 6px 6px 0;
    margin-bottom: 8px;
    font-size: 0.8rem;
}
.lp-step-title { font-weight: 700; }
.lp-step-formula { font-family: monospace; color: var(--lp-brand-d); font-size: 0.82rem; }
.lp-step-result  { font-size: 0.75rem; color: var(--lp-muted); margin-top: 2px; }

.lp-export {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 15px;
    border-top: 1px solid var(--lp-border);
    padding-top: 12px;
}

.lp-empty {
    text-align: center;
    padding: 36px 12px;
    color: var(--lp-muted);
}
.lp-empty svg { width: 36px; height: 36px; margin-bottom: 10px; stroke: var(--lp-border); }

/* ======================================================
   RESPONSIVE
   ====================================================== */
@media (max-width: 900px) {
    .lp-calc-wrapper .calc-layout {
        flex-direction: column !important;
    }
    .lp-calc-wrapper .calc-panel { width: 100% !important; }
}

@media (max-width: 560px) {
    .lp-row { grid-template-columns: 1fr; }
    .lp-kpis { grid-template-columns: 1fr 1fr; }
    .lp-actions { flex-direction: column; }
    
    .lp-tbl, .lp-tbl thead, .lp-tbl tbody,
    .lp-tbl th, .lp-tbl td, .lp-tbl tr { display: block; }
    .lp-tbl thead tr { position: absolute; top:-9999px; left:-9999px; }
    .lp-tbl tbody tr {
        border: 1px solid var(--lp-border);
        border-radius: 8px;
        margin-bottom: 8px;
        background: var(--lp-surface);
        overflow: hidden;
    }
    .lp-tbl td {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        padding: 8px 10px;
        border-bottom: 1px solid var(--lp-border);
    }
    .lp-tbl td:last-child { border-bottom: none; }
    .lp-tbl td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 0.7rem;
        text-transform: uppercase;
        color: var(--lp-muted);
        margin-bottom: 2px;
    }
}
