/* ===========================================
   Índice Minero — consulta pública
   Colores de la Segunda Notaría de Vallenar
   =========================================== */

.im-wrap {
    --im-green: #2f5e43;
    --im-green-dark: #1a3a2a;
    --im-green-light: #e8f2ec;
    --im-gold: #c9a227;
    --im-border: #d8e0dc;
    --im-muted: #5a6b62;
    max-width: 1180px;
    margin: 24px auto;
    padding: 28px 28px 32px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 14px;
    box-shadow: 0 4px 22px rgba(26, 58, 42, 0.07);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #1f2d25;
    box-sizing: border-box;
}

.im-wrap *,
.im-wrap *::before,
.im-wrap *::after {
    box-sizing: border-box;
}

.im-header {
    text-align: center;
    margin-bottom: 22px;
}

.im-title {
    margin: 0 0 6px;
    color: var(--im-green);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.im-title::after {
    content: "";
    display: block;
    width: 64px;
    height: 3px;
    margin: 10px auto 0;
    border-radius: 3px;
    background: var(--im-gold);
}

.im-subtitle {
    margin: 10px 0 0;
    color: var(--im-muted);
    font-size: 15px;
}

/* --- Botones de índice (tarjetas) --- */
.im-cards {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
}

.im-wrap button.im-card {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 196px;
    margin: 0;
    padding: 22px 14px 20px;
    background: #fff;
    color: var(--im-green-dark);
    border: 1px solid var(--im-border);
    border-radius: 16px;
    box-shadow: 0 2px 6px rgba(26, 58, 42, 0.05);
    font: inherit;
    text-align: center;
    text-transform: none;
    letter-spacing: normal;
    line-height: 1.3;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.im-wrap button.im-card::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 4px;
    background: var(--im-gold);
    transform: scaleX(0);
    transition: transform 0.2s ease;
}

.im-wrap button.im-card:hover,
.im-wrap button.im-card:focus-visible {
    transform: translateY(-4px);
    border-color: var(--im-green);
    box-shadow: 0 10px 24px rgba(26, 58, 42, 0.14);
    outline: none;
    background: #fff;
    color: var(--im-green-dark);
}

.im-wrap button.im-card:hover::after,
.im-wrap button.im-card:focus-visible::after {
    transform: scaleX(1);
}

.im-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: var(--im-green-light);
    color: var(--im-green);
    transition: background 0.18s ease, color 0.18s ease;
}

.im-card-title {
    max-width: 100%;
    font-size: 16px;
    font-weight: 700;
    overflow-wrap: break-word;
    -webkit-hyphens: auto;
    hyphens: auto;
}

.im-card-desc {
    font-size: 12.5px;
    color: var(--im-muted);
}

.im-wrap button.im-card.is-active {
    background: linear-gradient(160deg, var(--im-green) 0%, var(--im-green-dark) 100%);
    border-color: var(--im-green-dark);
    color: #fff;
    box-shadow: 0 12px 26px rgba(26, 58, 42, 0.28);
}

.im-wrap button.im-card.is-active::after {
    transform: scaleX(1);
}

.im-wrap button.im-card.is-active .im-card-icon {
    background: rgba(255, 255, 255, 0.14);
    color: var(--im-gold);
}

.im-wrap button.im-card.is-active .im-card-desc {
    color: #d6e6dc;
}

/* --- Panel de búsqueda --- */
.im-panel {
    margin-top: 24px;
    padding: 20px 22px;
    background: #f7faf8;
    border: 1px solid var(--im-border);
    border-left: 5px solid var(--im-green);
    border-radius: 12px;
    animation: im-fade 0.25s ease;
}

.im-panel[hidden],
.im-loading[hidden] {
    display: none;
}

.im-panel-title {
    margin: 0 0 14px;
    color: var(--im-green-dark);
    font-size: 19px;
    font-weight: 700;
}

.im-filters {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 130px 160px auto;
    gap: 14px;
    align-items: end;
}

.im-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #2b3b32;
}

.im-wrap .im-field input,
.im-wrap .im-field select {
    width: 100%;
    height: 44px;
    margin: 0;
    padding: 8px 12px;
    border: 1px solid #c5cfc9;
    border-radius: 8px;
    background: #fff;
    color: #1f2d25;
    font: inherit;
    font-size: 15px;
}

.im-wrap .im-field input:focus,
.im-wrap .im-field select:focus {
    border-color: var(--im-green);
    outline: none;
    box-shadow: 0 0 0 3px rgba(47, 94, 67, 0.16);
}

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

.im-wrap .im-btn {
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 44px;
    margin: 0;
    padding: 0 26px;
    border: none;
    border-radius: 8px;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.1s ease;
}

.im-wrap .im-btn:active {
    transform: scale(0.98);
}

.im-wrap .im-btn-primary {
    background: var(--im-green);
    color: #fff;
}

.im-wrap .im-btn-primary:hover {
    background: var(--im-green-dark);
    color: #fff;
}

.im-wrap .im-btn-primary:disabled {
    background: #8aa899;
    cursor: wait;
}

.im-wrap .im-btn-light {
    background: #fff;
    color: var(--im-green-dark);
    border: 1px solid var(--im-border);
}

.im-wrap .im-btn-light:hover {
    background: var(--im-green-light);
    color: var(--im-green-dark);
}

/* --- Resultados --- */
.im-loading {
    padding: 30px;
    text-align: center;
    color: var(--im-muted);
}

.im-loading::before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 8px;
    vertical-align: middle;
    border: 3px solid #e0e0e0;
    border-top-color: var(--im-green);
    border-radius: 50%;
    animation: im-spin 0.6s linear infinite;
}

.im-results {
    margin-top: 22px;
}

.im-results-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.im-results-count {
    font-size: 14px;
    color: var(--im-muted);
}

.im-results-count strong {
    color: var(--im-green-dark);
}

.im-results-actions {
    display: flex;
    gap: 8px;
}

.im-doc-header {
    text-align: center;
    margin-bottom: 12px;
}

.im-doc-header h4 {
    margin: 0 0 4px;
    font-size: 18px;
    color: #111;
    text-transform: uppercase;
}

.im-doc-header p {
    margin: 0;
    font-size: 13px;
    color: #444;
}

.im-table-scroll {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--im-border);
    border-radius: 10px;
}

.im-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    margin: 0;
}

.im-table th {
    position: sticky;
    top: 0;
    padding: 11px 12px;
    background: var(--im-green);
    color: #fff;
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
    border: none;
}

.im-table td {
    padding: 9px 12px;
    border: none;
    border-bottom: 1px solid #e8ece9;
    vertical-align: top;
}

.im-table tbody tr:not(.im-letter):nth-child(even) td {
    background: #f9fbfa;
}

.im-table tbody tr:not(.im-letter):hover td {
    background: #eef5f0;
}

.im-table tr.im-letter td {
    padding: 7px 12px;
    background: var(--im-green-light);
    color: var(--im-green);
    font-weight: 800;
    font-size: 14px;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #cfe0d5;
}

.im-table .im-col-personas div + div {
    margin-top: 3px;
    color: #3d4d44;
}

.im-table .im-col-num {
    white-space: nowrap;
    text-align: center;
}

.im-message {
    padding: 14px 16px;
    border-radius: 8px;
    font-size: 14px;
    background: #fff7e6;
    border: 1px solid #f1d9a6;
    color: #6b4f12;
}

.im-message.is-error {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

@keyframes im-spin {
    to { transform: rotate(360deg); }
}

@keyframes im-fade {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .im-cards {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .im-wrap {
        padding: 18px 14px 22px;
    }

    .im-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .im-wrap button.im-card {
        min-height: 150px;
        padding: 16px 10px;
    }

    .im-card-icon {
        width: 58px;
        height: 58px;
    }

    .im-card-icon svg {
        width: 34px;
        height: 34px;
    }

    .im-card-desc {
        display: none;
    }

    .im-filters {
        grid-template-columns: 1fr 1fr;
    }

    .im-field-q,
    .im-field-btn {
        grid-column: 1 / -1;
    }

    .im-field-btn .im-btn {
        width: 100%;
    }

    .im-table {
        min-width: 680px;
    }
}

@media (max-width: 420px) {
    .im-cards {
        grid-template-columns: 1fr;
    }

    .im-wrap button.im-card {
        flex-direction: row;
        min-height: 0;
        padding: 12px 14px;
        text-align: left;
    }

    .im-card-icon {
        flex: 0 0 auto;
        width: 50px;
        height: 50px;
    }

    .im-card-icon svg {
        width: 28px;
        height: 28px;
    }

    .im-filters {
        grid-template-columns: 1fr;
    }
}
