.ifm-app {
    --ifm-ink: #17211b;
    --ifm-muted: #617064;
    --ifm-line: #d9e1d8;
    --ifm-panel: #ffffff;
    --ifm-soft: #f4f7f2;
    --ifm-accent: #2f7d52;
    --ifm-accent-2: #246b8f;
    color: var(--ifm-ink);
    font-family: inherit;
}

.ifm-btn,
.ifm-filter-group button {
    border: 1px solid var(--ifm-line);
    background: var(--ifm-panel);
    color: var(--ifm-ink);
    border-radius: 6px;
    padding: 9px 12px;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
}

.ifm-filter-group button.is-active,
.ifm-primary {
    background: var(--ifm-accent);
    border-color: var(--ifm-accent);
    color: #fff;
}

.ifm-section-head {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.ifm-section-head h2 {
    margin: 0 0 6px;
    line-height: 1.2;
}

.ifm-section-head p {
    margin: 0;
    color: var(--ifm-muted);
}

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

.ifm-form {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--ifm-line);
    border-radius: 8px;
    background: var(--ifm-soft);
    margin-bottom: 18px;
}

.ifm-form label {
    display: grid;
    gap: 5px;
    font-size: 14px;
}

.ifm-form input,
.ifm-form select,
.ifm-form textarea {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--ifm-line);
    border-radius: 6px;
    padding: 8px 10px;
    background: #fff;
    color: var(--ifm-ink);
}

.ifm-primary {
    justify-self: start;
    border: 0;
    border-radius: 6px;
    padding: 11px 15px;
    cursor: pointer;
}

.ifm-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.ifm-summary > div {
    background: #fff;
    border: 1px solid var(--ifm-line);
    border-radius: 8px;
    padding: 11px;
    color: var(--ifm-muted);
}

.ifm-summary strong {
    display: block;
    margin-top: 4px;
    color: var(--ifm-ink);
    font-size: 18px;
}

.ifm-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--ifm-line);
    border-radius: 8px;
    background: #fff;
}

.ifm-table-wrap table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

.ifm-table-wrap th,
.ifm-table-wrap td {
    border-bottom: 1px solid var(--ifm-line);
    padding: 10px;
    text-align: left;
    vertical-align: top;
}

.ifm-table-wrap th {
    background: var(--ifm-soft);
    font-weight: 700;
}

.ifm-link {
    border: 0;
    background: transparent;
    color: #a33b35;
    cursor: pointer;
    padding: 0;
}

.ifm-map-layout {
    display: grid;
    grid-template-columns: minmax(260px, 340px) 1fr;
    gap: 16px;
    margin: 18px 0;
}

.ifm-map-layout aside {
    display: grid;
    gap: 14px;
    align-content: start;
}

.ifm-map {
    /* Fixed height + sticky: the sidebar (now with the draw panel) can be taller than the map, and the map must
       not stretch with it. It stays in view while the sidebar is scrolled. */
    height: 640px;
    min-height: 620px;
    align-self: start;
    position: sticky;
    top: 20px;
    border: 1px solid var(--ifm-line);
    border-radius: 8px;
    overflow: hidden;
    background: #eef3eb;
}

.ifm-filter-group,
.ifm-legend {
    display: grid;
    gap: 8px;
}

.ifm-legend {
    border: 1px solid var(--ifm-line);
    border-radius: 8px;
    padding: 12px;
    background: #fff;
}

.ifm-legend span {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ifm-legend i,
.ifm-marker-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .18);
}

.ifm-legend .grazing,
.ifm-marker-grazing { background: #2f7d52; }
.ifm-legend .water,
.ifm-marker-water { background: #2477b3; }
.ifm-legend .feeding,
.ifm-marker-feeding { background: #c18b1f; }
.ifm-legend .shelter,
.ifm-marker-shelter { background: #7e5aa7; }
.ifm-legend .infrastructure,
.ifm-marker-infrastructure { background: #677078; }

.ifm-map-hint {
    margin: 0;
    color: var(--ifm-muted);
    font-size: 13px;
}

.ifm-login-required {
    border: 1px solid #e5d4a8;
    border-radius: 8px;
    background: #fff7df;
    padding: 14px;
}

@media (max-width: 800px) {
    .ifm-section-head,
    .ifm-map-layout {
        grid-template-columns: 1fr;
        display: grid;
    }

    .ifm-actions {
        justify-content: flex-start;
    }

    .ifm-map {
        height: 440px;
        min-height: 440px;
        position: relative;
        top: auto;
    }
}

/* ------------------------------------------------------------------
   Draw & measure panel, zones and saved shapes (added in 1.1.0)
   ------------------------------------------------------------------ */

/* Elements toggled with the HTML "hidden" attribute must really disappear, even when a rule sets display. */
.ifm-draw-panel [hidden] {
    display: none !important;
}

.ifm-draw-panel {
    display: grid;
    gap: 10px;
    border: 1px solid var(--ifm-line);
    border-radius: 8px;
    padding: 12px;
    background: #fff;
}

.ifm-draw-panel h3 {
    margin: 0;
    font-size: 16px;
}

.ifm-tool-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ifm-tool-row button {
    border: 1px solid var(--ifm-line);
    background: var(--ifm-panel);
    color: var(--ifm-ink);
    border-radius: 6px;
    padding: 8px 11px;
    cursor: pointer;
    line-height: 1.2;
}

.ifm-tool-row button.is-active {
    background: var(--ifm-accent-2);
    border-color: var(--ifm-accent-2);
    color: #fff;
}

/* The save form inside the panel does not need its own outer margin. */
.ifm-draw-panel .ifm-form {
    margin-bottom: 0;
}

.ifm-readout {
    border-left: 4px solid #0b84ff;
    background: var(--ifm-soft);
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 14px;
    line-height: 1.5;
}

.ifm-check {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 14px;
}

/* While drawing: crosshair cursor, and existing markers/shapes let the click through to the map. */
.ifm-map.is-drawing,
.ifm-map.is-drawing.leaflet-grab,
.ifm-map.is-drawing.leaflet-dragging .leaflet-grab {
    cursor: crosshair;
}

.ifm-map.is-drawing .leaflet-interactive {
    pointer-events: none;
}

/* Label that follows the mouse while measuring (e.g. "3.27 km"). */
.leaflet-tooltip.ifm-draw-tip {
    background: rgba(40, 40, 40, .88);
    border: 0;
    border-radius: 4px;
    color: #fff;
    padding: 6px 9px;
    font-size: 14px;
    line-height: 1.35;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}

.leaflet-tooltip.ifm-draw-tip::before {
    display: none;
}

.ifm-draw-tip-hint {
    font-size: 12px;
    opacity: .85;
}

/* Name + size label shown on a saved zone / line. */
.leaflet-tooltip.ifm-shape-label {
    background: rgba(255, 255, 255, .88);
    border: 0;
    border-radius: 4px;
    color: var(--ifm-ink, #17211b);
    text-align: center;
    font-size: 12px;
    line-height: 1.3;
    padding: 3px 7px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

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

/* Saved lines & zones list in the sidebar. */
.ifm-shape-list {
    display: grid;
    gap: 6px;
}

.ifm-shape-item {
    display: grid;
    grid-template-columns: 14px 1fr;
    gap: 4px 8px;
    align-items: start;
    border-top: 1px solid var(--ifm-line);
    padding-top: 8px;
    font-size: 14px;
}

.ifm-shape-item > i {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    margin-top: 3px;
}

.ifm-shape-item span {
    display: block;
    color: var(--ifm-muted);
    font-size: 13px;
}

.ifm-shape-actions {
    grid-column: 2;
    display: flex;
    gap: 12px;
}

.ifm-link-plain {
    color: var(--ifm-accent-2);
}
