:root {
    --azul: #2563eb;
    --azul-oscuro: #1d4ed8;
    --gris-100: #f3f4f6;
    --gris-200: #e5e7eb;
    --gris-500: #6b7280;
    --gris-800: #1f2937;
    --rojo: #dc2626;
    --verde: #16a34a;
    --radio: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--gris-100);
    color: var(--gris-800);
}

/* ---------- LOGIN ---------- */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
}

.login-box {
    background: #fff;
    padding: 2.5rem 2rem;
    border-radius: var(--radio);
    box-shadow: 0 10px 30px rgba(0,0,0,.2);
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.login-box h1 { margin: 0 0 .25rem; }
.subtitulo { color: var(--gris-500); margin-bottom: 1.5rem; font-size: .9rem; }

.login-box form { display: flex; flex-direction: column; gap: .75rem; text-align: left; }
.login-box label { font-size: .85rem; font-weight: 600; }

input[type="password"], input[type="text"], input[type="email"], textarea {
    width: 100%;
    padding: .6rem .75rem;
    border: 1px solid var(--gris-200);
    border-radius: 8px;
    font-size: .95rem;
    font-family: inherit;
}

button { cursor: pointer; font-family: inherit; }

.btn {
    display: inline-block;
    padding: .55rem 1rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    font-size: .9rem;
    text-decoration: none;
    text-align: center;
}
.btn-primario { background: var(--azul); color: #fff; }
.btn-primario:hover { background: var(--azul-oscuro); }
.btn-secundario { background: var(--gris-200); color: var(--gris-800); }
.btn-secundario:hover { background: #d1d5db; }
.btn-texto { background: none; color: var(--gris-500); padding: .55rem .25rem; }
.btn-mini { padding: .3rem .6rem; font-size: .8rem; }
.btn-peligro { background: var(--rojo); color: #fff; }
.btn-peligro:hover { background: #b91c1c; }

/* ---------- APP ---------- */
.topbar {
    background: #fff;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.topbar h1 { margin: 0; font-size: 1.25rem; }

.contenedor {
    max-width: 900px;
    margin: 1.5rem auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.panel {
    background: #fff;
    border-radius: var(--radio);
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.panel h2 { margin-top: 0; font-size: 1.1rem; }

.form-contacto .fila {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.campo { flex: 1 1 220px; display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.campo label { font-size: .8rem; font-weight: 600; color: var(--gris-500); }

.acciones-form { display: flex; gap: .6rem; }

.cabecera-lista {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 1rem;
}
.form-busqueda { display: flex; gap: .5rem; }
.form-busqueda input { min-width: 220px; }

.vacio { color: var(--gris-500); text-align: center; padding: 1.5rem 0; }

.tabla-wrap { overflow-x: auto; }
.tabla-contactos { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabla-contactos th, .tabla-contactos td {
    text-align: left;
    padding: .6rem .5rem;
    border-bottom: 1px solid var(--gris-200);
    vertical-align: top;
}
.tabla-contactos th { color: var(--gris-500); font-size: .78rem; text-transform: uppercase; }
.col-acciones { white-space: nowrap; display: flex; gap: .4rem; }
.form-inline { display: inline; }

.alerta { padding: .75rem 1rem; border-radius: 8px; font-size: .9rem; margin-bottom: 1rem; }
.alerta-exito { background: #dcfce7; color: #166534; }
.alerta-error { background: #fee2e2; color: #991b1b; }

/* ---------- RESPONSIVE TABLA ---------- */
@media (max-width: 640px) {
    .tabla-contactos thead { display: none; }
    .tabla-contactos, .tabla-contactos tbody, .tabla-contactos tr, .tabla-contactos td { display: block; width: 100%; }
    .tabla-contactos tr { margin-bottom: 1rem; border: 1px solid var(--gris-200); border-radius: 8px; padding: .5rem; }
    .tabla-contactos td { border: none; padding: .3rem .25rem; }
    .tabla-contactos td::before {
        content: attr(data-label);
        display: block;
        font-size: .72rem;
        color: var(--gris-500);
        text-transform: uppercase;
        font-weight: 600;
    }
    .col-acciones { flex-wrap: wrap; }
}
